By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,759 Members | 959 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,759 IT Pros & Developers. It's quick & easy.

Good ways to analyze a running c-program?

P: n/a
I would like to analyze my running c-program.

What I would like to know for example is the range of the entire
address space of my running c-program (memory reserved for/by the
running program), starting address and sizes of text (code), stack,
heap, bss, constant data, linked in libraries, etc.

What are some good ways to extract this kind of information?

What (free) tools are the most common ones for displaying this kind of
information?

The main reason for this analysis is that I want to understand exactly
how my c-source code transforms to a running program and what memory
regions the program uses and for what the memory regions are used. An
example could be for example that I wanted to display all the constant
data (variables declared with the const modifier) of the running
program, is that possible?

BR!

Dec 30 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
dspfun a écrit :
I would like to analyze my running c-program.

What I would like to know for example is the range of the entire
address space of my running c-program (memory reserved for/by the
running program), starting address and sizes of text (code), stack,
heap, bss, constant data, linked in libraries, etc.

What are some good ways to extract this kind of information?

What (free) tools are the most common ones for displaying this kind of
information?

The main reason for this analysis is that I want to understand exactly
how my c-source code transforms to a running program and what memory
regions the program uses and for what the memory regions are used. An
example could be for example that I wanted to display all the constant
data (variables declared with the const modifier) of the running
program, is that possible?

BR!
So, you want to invest zero in software and get highly sophisticated
results...

This depends on your OS. If you run under linux you can try
the GNU profiler but last time I looked at it I do not remember
that it gave this kind of information. Other tools like "top",
can give you more info, but they are not really reliable. The man
page of top says for instance
TSIZE
The code size of the task. This gives strange values
for kernel processes and is broken for ELF processes.

Since all processes are ELF processes... this will not go very far.
But maybe this has improved in later versions, I really do not know.

Another possibility is tha you call yourself routines that give
this kind of info in your program and you call them at some
specific time, etc.

Under windows you can have several tools for doing that, but the only
really free one is the task manager, that will display the
memory/handles/paged/non paged memory/memory usage delta/
page faults/ and many other information.

Better tools are Intel's profiler, that is an excellent one
and will give you more detailed info. It costs around 500 US$.

If (under windows) you use the lcc-win32 debugger it will show you the stack
size of each thread but not when the process is running...
MMM... you give an idea. An oscilloscope-like display of memory usage
would be nice actually.
Dec 31 '06 #2

P: n/a
jacob navia wrote:
dspfun a écrit :
>I would like to analyze my running c-program.

What I would like to know for example is the range of the entire
address space of my running c-program (memory reserved for/by the
running program), starting address and sizes of text (code), stack,
heap, bss, constant data, linked in libraries, etc.
.... snip ...
>
Under windows you can have several tools for doing that, but the
only really free one is the task manager, that will display the
memory/handles/paged/non paged memory/memory usage delta/
page faults/ and many other information.
Look up prcview. <http://www.teamcti.com/pview/prcview.htm>
--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee.
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>

Dec 31 '06 #3

P: n/a
CBFalconer a écrit :
jacob navia wrote:
>>dspfun a écrit :

>>>I would like to analyze my running c-program.

What I would like to know for example is the range of the entire
address space of my running c-program (memory reserved for/by the
running program), starting address and sizes of text (code), stack,
heap, bss, constant data, linked in libraries, etc.

... snip ...
>>Under windows you can have several tools for doing that, but the
only really free one is the task manager, that will display the
memory/handles/paged/non paged memory/memory usage delta/
page faults/ and many other information.


Look up prcview. <http://www.teamcti.com/pview/prcview.htm>

I downloaded that, it is a nice utility but it doesn't
display (as far as I see) any memory information...

Dec 31 '06 #4

P: n/a
On Sun, 31 Dec 2006 01:37:33 +0100, in comp.lang.c , jacob navia
<ja***@jacob.remcomp.frwrote:
>dspfun a écrit :
>I would like to analyze my running c-program.

What I would like to know for example is the range of the entire
address space of my running c-program (memory reserved for/by the
running program), starting address and sizes of text (code), stack,
heap, bss, constant data, linked in libraries, etc.

What are some good ways to extract this kind of information?

What (free) tools are the most common ones for displaying this kind of
information?

So, you want to invest zero in software and get highly sophisticated
results...
No, he wants to use some free tools. You imply by the above that no
free software can be sophisticated, which is untrue as I'm sure you
know. There's even a compiler which is reputed to be fairly
sophisticated which is free.
>This depends on your OS.
Agreed. The OP wold be better advised to ask in a group specialising
in his OS, as such tools will be highly OS-dependent.
>can give you more info, but they are not really reliable. The man
page of top says for instance
(man pages are notorious for getting out of date mind you)
>Under windows you can have several tools for doing that, but the only
really free one is the task manager, that will display the
memory/handles/paged/non paged memory/memory usage delta/
page faults/ and many other information.
FWIW there /are/ various free profiling and analysis tools for
Windows, eg at winternals.com
>MMM... you give an idea. An oscilloscope-like display of memory usage
would be nice actually.
procexp.exe

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Dec 31 '06 #5

P: n/a
jacob navia wrote:
CBFalconer a écrit :
.... snip ...
>>
Look up prcview. <http://www.teamcti.com/pview/prcview.htm>

I downloaded that, it is a nice utility but it doesn't
display (as far as I see) any memory information...
Select the process. Then: Process | Memory.

--
Some informative links:
<http://members.fortunecity.com/nnqweb/ (newusers)
<http://www.catb.org/~esr/faqs/smart-questions.html>
<http://www.caliburn.nl/topposting.html>
<http://www.netmeister.org/news/learn2quote.html>
<http://cfaj.freeshell.org/google/ (taming google)
Dec 31 '06 #6

P: n/a
look at this program
http://www.microsoft.com/technet/sys...sExplorer.mspx
and other of sysinternals

Dec 31 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.