public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* How Can I Get See A Memory Map For An Executable
@ 2005-11-14 14:19 Steven Woody
  2005-11-14 21:57 ` Ian Lance Taylor
  0 siblings, 1 reply; 8+ messages in thread
From: Steven Woody @ 2005-11-14 14:19 UTC (permalink / raw)
  To: gcc-help


i want to check in my C++ program, what variable is allocated in where. is
there such a tool?

another relative question is, where the 'new' operator get memory from? the
global heap? does it same with what 'malloc' get from?

thanks.

-- 
steven woody (id: narke)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How Can I Get See A Memory Map For An Executable
  2005-11-14 14:19 How Can I Get See A Memory Map For An Executable Steven Woody
@ 2005-11-14 21:57 ` Ian Lance Taylor
  2005-11-15 13:12   ` Steven Woody
  0 siblings, 1 reply; 8+ messages in thread
From: Ian Lance Taylor @ 2005-11-14 21:57 UTC (permalink / raw)
  To: Steven Woody; +Cc: gcc-help

Steven Woody <narkewoody@gmail.com> writes:

> i want to check in my C++ program, what variable is allocated in where. is
> there such a tool?

I don't know if it will much, but the GNU linker supports a -Map
option.  See the documentation.  You can also use nm or objdump -t or
readelf -s to see where symbols are in the fully linked executable.

> another relative question is, where the 'new' operator get memory from? the
> global heap? does it same with what 'malloc' get from?

In general, the answers are yes and yes.

Ian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How Can I Get See A Memory Map For An Executable
  2005-11-14 21:57 ` Ian Lance Taylor
@ 2005-11-15 13:12   ` Steven Woody
  2005-11-15 15:35     ` Ian Lance Taylor
  0 siblings, 1 reply; 8+ messages in thread
From: Steven Woody @ 2005-11-15 13:12 UTC (permalink / raw)
  To: gcc-help; +Cc: narkewoody

Ian Lance Taylor <ian@airs.com> writes:

> Steven Woody <narkewoody@gmail.com> writes:
>
>> i want to check in my C++ program, what variable is allocated in where. is
>> there such a tool?
>
> I don't know if it will much, but the GNU linker supports a -Map
> option.  See the documentation.  You can also use nm or objdump -t or
> readelf -s to see where symbols are in the fully linked executable.

thank you, but neither of these commands can clearly print size of each segment
( such as heap, bss, text). but, thanks anyway.

>
>> another relative question is, where the 'new' operator get memory from? the
>> global heap? does it same with what 'malloc' get from?
>
> In general, the answers are yes and yes.

thanks.  could you also tell me what's the difference between local heap and
global heap, i can not recall where i heard the the terms.


>
> Ian
>

-- 
steven woody (id: narke)

John McFarland: Hey, what are you guys doing?
Alex: Get the fuck out and don't come back! Some heavy shit's going down! 

	- Elephant (2003)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How Can I Get See A Memory Map For An Executable
  2005-11-15 13:12   ` Steven Woody
@ 2005-11-15 15:35     ` Ian Lance Taylor
  2005-11-15 16:36       ` Steven Woody
  0 siblings, 1 reply; 8+ messages in thread
From: Ian Lance Taylor @ 2005-11-15 15:35 UTC (permalink / raw)
  To: Steven Woody; +Cc: gcc-help

Steven Woody <narkewoody@gmail.com> writes:

> thank you, but neither of these commands can clearly print size of each segment
> ( such as heap, bss, text). but, thanks anyway.

The size program will print the size of the text and bss sections.

The size of the heap program is determined at runtime.  I do not know
of any program which can determine it statically.

> >> another relative question is, where the 'new' operator get memory from? the
> >> global heap? does it same with what 'malloc' get from?
> >
> > In general, the answers are yes and yes.
> 
> thanks.  could you also tell me what's the difference between local heap and
> global heap, i can not recall where i heard the the terms.

I don't know where you heard the terms either.  On a typical Unix (or
GNU/Linux) system, programs have only one heap.

Ian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How Can I Get See A Memory Map For An Executable
  2005-11-15 15:35     ` Ian Lance Taylor
@ 2005-11-15 16:36       ` Steven Woody
  2005-11-15 23:37         ` Ian Lance Taylor
  0 siblings, 1 reply; 8+ messages in thread
From: Steven Woody @ 2005-11-15 16:36 UTC (permalink / raw)
  To: gcc-help; +Cc: narkewoody

Ian Lance Taylor <ian@airs.com> writes:

> Steven Woody <narkewoody@gmail.com> writes:
>
>> thank you, but neither of these commands can clearly print size of each segment
>> ( such as heap, bss, text). but, thanks anyway.
>
> The size program will print the size of the text and bss sections.
>
> The size of the heap program is determined at runtime.  I do not know
> of any program which can determine it statically.

if the heap is not determined statically, how much in size at startup the
program get the big pool to allocate for each 'new' or 'malloc' calling?

>
>> >> another relative question is, where the 'new' operator get memory from? the
>> >> global heap? does it same with what 'malloc' get from?
>> >
>> > In general, the answers are yes and yes.
>> 
>> thanks.  could you also tell me what's the difference between local heap and
>> global heap, i can not recall where i heard the the terms.
>
> I don't know where you heard the terms either.  On a typical Unix (or
> GNU/Linux) system, programs have only one heap.

at least, for embedded system, the programmer has to specify how much size for
each kind of heap, NEAR heap, FAR heap, etc.  for Linux, i've not got the
picture. 

>
> Ian
>

-- 
steven woody (id: narke)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How Can I Get See A Memory Map For An Executable
  2005-11-15 16:36       ` Steven Woody
@ 2005-11-15 23:37         ` Ian Lance Taylor
  2005-11-16 15:22           ` Steven Woody
  0 siblings, 1 reply; 8+ messages in thread
From: Ian Lance Taylor @ 2005-11-15 23:37 UTC (permalink / raw)
  To: Steven Woody; +Cc: gcc-help

Steven Woody <narkewoody@gmail.com> writes:

> >> thank you, but neither of these commands can clearly print size of each segment
> >> ( such as heap, bss, text). but, thanks anyway.
> >
> > The size program will print the size of the text and bss sections.
> >
> > The size of the heap program is determined at runtime.  I do not know
> > of any program which can determine it statically.
> 
> if the heap is not determined statically, how much in size at startup the
> program get the big pool to allocate for each 'new' or 'malloc' calling?

These questions are no longer about gcc, if indeed they ever were.
They are basic Unix questions.  Please take further questions along
these lines to some other mailing list or news group.  Thanks.

Unix systems use virtual memory.  A large chunk of the address space
is available for the heap--all the address space between the end of
the program and the stack.  Any program can theoretically use all of
that space.

Unix programs do not request a certain amount of space when they
start.  They simply request more space as they need it, using the
brk() and sbrk() functions.

> > I don't know where you heard the terms either.  On a typical Unix (or
> > GNU/Linux) system, programs have only one heap.
> 
> at least, for embedded system, the programmer has to specify how much size for
> each kind of heap, NEAR heap, FAR heap, etc.  for Linux, i've not got the
> picture. 

On GNU/Linux there is only one heap, and it is limited primarily by
the size of the address space.

Ian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How Can I Get See A Memory Map For An Executable
  2005-11-15 23:37         ` Ian Lance Taylor
@ 2005-11-16 15:22           ` Steven Woody
  0 siblings, 0 replies; 8+ messages in thread
From: Steven Woody @ 2005-11-16 15:22 UTC (permalink / raw)
  To: gcc-help; +Cc: narkewoody

Ian Lance Taylor <ian@airs.com> writes:

> Steven Woody <narkewoody@gmail.com> writes:
>
>> >> thank you, but neither of these commands can clearly print size of each segment
>> >> ( such as heap, bss, text). but, thanks anyway.
>> >
>> > The size program will print the size of the text and bss sections.
>> >
>> > The size of the heap program is determined at runtime.  I do not know
>> > of any program which can determine it statically.
>> 
>> if the heap is not determined statically, how much in size at startup the
>> program get the big pool to allocate for each 'new' or 'malloc' calling?
>
> These questions are no longer about gcc, if indeed they ever were.
> They are basic Unix questions.  Please take further questions along
> these lines to some other mailing list or news group.  Thanks.
>
> Unix systems use virtual memory.  A large chunk of the address space
> is available for the heap--all the address space between the end of
> the program and the stack.  Any program can theoretically use all of
> that space.
>
> Unix programs do not request a certain amount of space when they
> start.  They simply request more space as they need it, using the
> brk() and sbrk() functions.
>
>> > I don't know where you heard the terms either.  On a typical Unix (or
>> > GNU/Linux) system, programs have only one heap.
>> 
>> at least, for embedded system, the programmer has to specify how much size for
>> each kind of heap, NEAR heap, FAR heap, etc.  for Linux, i've not got the
>> picture. 
>
> On GNU/Linux there is only one heap, and it is limited primarily by
> the size of the address space.

thanks for the answer.

>
> Ian
>

-- 
steven woody (id: narke)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How Can I Get See A Memory Map For An Executable
       [not found] <873bm1dmku.fsf@narke.yellow.line>
@ 2005-11-13 22:50 ` Mike Stump
  0 siblings, 0 replies; 8+ messages in thread
From: Mike Stump @ 2005-11-13 22:50 UTC (permalink / raw)
  To: Steven Woody; +Cc: gcc-help

On Nov 12, 2005, at 11:38 PM, Steven Woody wrote:
> i want to check in my C++ program, what variable is allocated in  
> where. is
> there such a tool?

gdb is useful for debugging.

> another relative question is, where the 'new' operator get memory  
> from?

malloc.

> the global heap? does it same with what 'malloc' get from?

Yes.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-11-16 15:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-14 14:19 How Can I Get See A Memory Map For An Executable Steven Woody
2005-11-14 21:57 ` Ian Lance Taylor
2005-11-15 13:12   ` Steven Woody
2005-11-15 15:35     ` Ian Lance Taylor
2005-11-15 16:36       ` Steven Woody
2005-11-15 23:37         ` Ian Lance Taylor
2005-11-16 15:22           ` Steven Woody
     [not found] <873bm1dmku.fsf@narke.yellow.line>
2005-11-13 22:50 ` Mike Stump

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).