Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Checking the Memory regions

Reply
Thread Tools

Checking the Memory regions

 
 
new
Guest
Posts: n/a
 
      05-28-2009
Hi Experts,
How can I check the memory regions occupied by the c program in gcc
compiler?
Any commands?
My intention is to check for the variables defined in the
program,whether it is in text,data,stack or heap regions.

Thanks for the help.

 
Reply With Quote
 
 
 
 
Kenny McCormack
Guest
Posts: n/a
 
      05-28-2009
In article <(E-Mail Removed)>,
new <(E-Mail Removed)> wrote:
>Hi Experts,
>How can I check the memory regions occupied by the c program in gcc
>compiler?
>Any commands?
>My intention is to check for the variables defined in the
>program,whether it is in text,data,stack or heap regions.
>
>Thanks for the help.
>


Beavis/Butthead: He said the "S" word. Har har har.

 
Reply With Quote
 
 
 
 
Ben Bacarisse
Guest
Posts: n/a
 
      05-28-2009
new <(E-Mail Removed)> writes:

> Hi Experts,
> How can I check the memory regions occupied by the c program in gcc
> compiler?
> Any commands?
> My intention is to check for the variables defined in the
> program,whether it is in text,data,stack or heap regions.


....or nowhere.

This is a system-specific question and you will get better help is
group discusses the tools you use. For example, if you use a
unix-like system, comp.unix.programmer can tell you all about programs
like nm that let you see what the compiler has done with your
program. There are similar active groups for Windows programming.

--
Ben.
 
Reply With Quote
 
new
Guest
Posts: n/a
 
      05-28-2009
On May 28, 5:27*pm, Ben Bacarisse <(E-Mail Removed)> wrote:
> new <(E-Mail Removed)> writes:
> > Hi Experts,
> > How can I check the memory regions occupied by the c program in gcc
> > compiler?
> > Any commands?
> > My intention is to check for the variables defined in the
> > program,whether it is in text,data,stack or heap regions.

>
> ...or nowhere.
>
> This is a system-specific question and you will get better help is
> group discusses the tools you use. *For example, if you use a
> unix-like system, comp.unix.programmer can tell you all about programs
> like nm that let you see what the compiler has done with your
> program. *There are similar active groups for Windows programming.
>
> --
> Ben.


Am trying to find out in Linux machine
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      05-28-2009
new <(E-Mail Removed)> writes:
> On May 28, 5:27*pm, Ben Bacarisse <(E-Mail Removed)> wrote:
>> new <(E-Mail Removed)> writes:
>> > Hi Experts,
>> > How can I check the memory regions occupied by the c program in gcc
>> > compiler?
>> > Any commands?
>> > My intention is to check for the variables defined in the
>> > program,whether it is in text,data,stack or heap regions.

>>
>> ...or nowhere.
>>
>> This is a system-specific question and you will get better help is
>> group discusses the tools you use. *For example, if you use a
>> unix-like system, comp.unix.programmer can tell you all about programs
>> like nm that let you see what the compiler has done with your
>> program. *There are similar active groups for Windows programming.

>
> Am trying to find out in Linux machine


Then try comp.unix.programmer. If your question turns out to be
Linux-specific, they can direct you to a Linux newsgroup.

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
kid joe
Guest
Posts: n/a
 
      05-28-2009
On Thu, 28 May 2009 08:01:11 -0700, new wrote:
> On May 28, 5:27*pm, Ben Bacarisse <(E-Mail Removed)> wrote:
>> new <(E-Mail Removed)> writes:
>> > Hi Experts,
>> > How can I check the memory regions occupied by the c program in gcc
>> > compiler?
>> > Any commands?
>> > My intention is to check for the variables defined in the
>> > program,whether it is in text,data,stack or heap regions.

>>
>> ...or nowhere.
>>
>> This is a system-specific question and you will get better help is
>> group discusses the tools you use. *For example, if you use a
>> unix-like system, comp.unix.programmer can tell you all about programs
>> like nm that let you see what the compiler has done with your
>> program. *There are similar active groups for Windows programming.
>>
>> --
>> Ben.

>
> Am trying to find out in Linux machine


Hi new,

You can use nm to find out about variables compiled into your object file
(static/global variables) as Ben said.

At runtime, of course malloc()d variables will be on the heap, local
variables on the stack. One way is to use gdb and set a breakpoint. You
can then type "info frame" to find out the current program counter and
where the locals start. The stack grows down, so look at the address
of the variable youre interested in. If its just below the "locals at"
address from "info frame", its on the stack. If its a much much lower
memory address then its on the heap.

Cheers,
Joe

--
...................... o _______________ _,
` Good Evening! , /\_ _| | .-'_|
`................, _\__`[_______________| _| (_|
] [ \, ][ ][ (_|


 
Reply With Quote
 
Flash Gordon
Guest
Posts: n/a
 
      05-28-2009
kid joe wrote:
> On Thu, 28 May 2009 08:01:11 -0700, new wrote:
>> On May 28, 5:27 pm, Ben Bacarisse <(E-Mail Removed)> wrote:
>>> new <(E-Mail Removed)> writes:
>>>> Hi Experts,
>>>> How can I check the memory regions occupied by the c program in gcc
>>>> compiler?
>>>> Any commands?
>>>> My intention is to check for the variables defined in the
>>>> program,whether it is in text,data,stack or heap regions.
>>> ...or nowhere.
>>>
>>> This is a system-specific question and you will get better help is
>>> group discusses the tools you use. For example, if you use a
>>> unix-like system, comp.unix.programmer can tell you all about programs
>>> like nm that let you see what the compiler has done with your
>>> program. There are similar active groups for Windows programming.
>>>
>>> --
>>> Ben.

>> Am trying to find out in Linux machine

>
> Hi new,
>
> You can use nm to find out about variables compiled into your object file
> (static/global variables) as Ben said.
>
> At runtime, of course malloc()d variables will be on the heap, local
> variables on the stack.


That is inaccurate. Often local variables are only in a register on some
processors.

> One way is to use gdb and set a breakpoint. You
> can then type "info frame" to find out the current program counter and
> where the locals start. The stack grows down, so look at the address
> of the variable youre interested in. If its just below the "locals at"
> address from "info frame", its on the stack. If its a much much lower
> memory address then its on the heap.


Have you checked on all of the processors Linux have been ported to? No,
I thought not.

As Ben said, finding a system specific news group (either one of the gnu
ones, a linux one, or comp.unix.programmer would be better.
--
Flash Gordon
 
Reply With Quote
 
cr88192
Guest
Posts: n/a
 
      05-29-2009

"Flash Gordon" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)-gordon.me.uk...
> kid joe wrote:
>> On Thu, 28 May 2009 08:01:11 -0700, new wrote:
>>> On May 28, 5:27 pm, Ben Bacarisse <(E-Mail Removed)> wrote:
>>>> new <(E-Mail Removed)> writes:
>>>>> Hi Experts,
>>>>> How can I check the memory regions occupied by the c program in gcc
>>>>> compiler?
>>>>> Any commands?
>>>>> My intention is to check for the variables defined in the
>>>>> program,whether it is in text,data,stack or heap regions.
>>>> ...or nowhere.
>>>>
>>>> This is a system-specific question and you will get better help is
>>>> group discusses the tools you use. For example, if you use a
>>>> unix-like system, comp.unix.programmer can tell you all about programs
>>>> like nm that let you see what the compiler has done with your
>>>> program. There are similar active groups for Windows programming.
>>>>
>>>> --
>>>> Ben.
>>> Am trying to find out in Linux machine

>>
>> Hi new,
>>
>> You can use nm to find out about variables compiled into your object file
>> (static/global variables) as Ben said.
>>
>> At runtime, of course malloc()d variables will be on the heap, local
>> variables on the stack.

>
> That is inaccurate. Often local variables are only in a register on some
> processors.
>
>> One way is to use gdb and set a breakpoint. You
>> can then type "info frame" to find out the current program counter and
>> where the locals start. The stack grows down, so look at the address
>> of the variable youre interested in. If its just below the "locals at"
>> address from "info frame", its on the stack. If its a much much lower
>> memory address then its on the heap.

>
> Have you checked on all of the processors Linux have been ported to? No, I
> thought not.
>
> As Ben said, finding a system specific news group (either one of the gnu
> ones, a linux one, or comp.unix.programmer would be better.



FWIW, it is almost assured that whatever the OP is using is probably x86, or
maybe x86-64...
other possibilities are sufficiently unlikely as to be assumed, by default,
not to be the case.

(or... maybe... one can start making a fuss that these groups are not easily
accessible to non-English speakers... and the illiterate...).


thus, there is no need to use that sort of attitude when responding...


> --
> Flash Gordon



 
Reply With Quote
 
James Dow Allen
Guest
Posts: n/a
 
      05-29-2009
On May 29, 8:13*am, "cr88192" <(E-Mail Removed)> wrote:
> "Flash Gordon" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)-gordon.me.uk...
> > kid joe wrote:
> >> On Thu, 28 May 2009 08:01:11 -0700, new wrote:
> >>> On May 28, 5:27 pm, Ben Bacarisse <(E-Mail Removed)> wrote:
> >>>> new <(E-Mail Removed)> writes:
> >>>>> Hi Experts,
> >>> Am trying to find out in Linux machine
> >> Hi new,
> >> You can use nm ...

> > That is inaccurate. ... on some
> > processors.
> > Have you checked on all of the processors Linux
> > have[sic] been ported to? No, I
> > thought not.

>
> FWIW, it is almost assured that whatever the OP is
> using is probably x86, or maybe x86-64...
> other possibilities are sufficiently unlikely as to be
> assumed, by default, not to be the case.


Note moreover, that the chance OP is not using
x86 is even smaller than the (small) a priori chance.
This is because even a relatively naive user would
be aware any non-x86 machine is somewhat "unusual"
and therefore would have mentioned it.

In the (unlikely) event that further evidence were
needed of excessive pedantry in c.l.c, these continual
topicality debates would prove it!

Although in this case c.u.p might be a good bet,
some of the ng recommendations here are often absurd,
of a ng with a name that makes it appear topical
but which is actually devoted to discussions about
sodomizing pigs, or some such.

James
 
Reply With Quote
 
Flash Gordon
Guest
Posts: n/a
 
      05-29-2009
cr88192 wrote:
> "Flash Gordon" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)-gordon.me.uk...
>> kid joe wrote:
>>> On Thu, 28 May 2009 08:01:11 -0700, new wrote:
>>>> On May 28, 5:27 pm, Ben Bacarisse <(E-Mail Removed)> wrote:
>>>>> new <(E-Mail Removed)> writes:
>>>>>> Hi Experts,
>>>>>> How can I check the memory regions occupied by the c program in gcc
>>>>>> compiler?
>>>>>> Any commands?
>>>>>> My intention is to check for the variables defined in the
>>>>>> program,whether it is in text,data,stack or heap regions.
>>>>> ...or nowhere.
>>>>>
>>>>> This is a system-specific question and you will get better help is
>>>>> group discusses the tools you use. For example, if you use a
>>>>> unix-like system, comp.unix.programmer can tell you all about programs
>>>>> like nm that let you see what the compiler has done with your
>>>>> program. There are similar active groups for Windows programming.
>>>>>
>>>>> --
>>>>> Ben.
>>>> Am trying to find out in Linux machine
>>> Hi new,
>>>
>>> You can use nm to find out about variables compiled into your object file
>>> (static/global variables) as Ben said.
>>>
>>> At runtime, of course malloc()d variables will be on the heap, local
>>> variables on the stack.

>> That is inaccurate. Often local variables are only in a register on some
>> processors.
>>
>>> One way is to use gdb and set a breakpoint. You
>>> can then type "info frame" to find out the current program counter and
>>> where the locals start. The stack grows down, so look at the address
>>> of the variable youre interested in. If its just below the "locals at"
>>> address from "info frame", its on the stack. If its a much much lower
>>> memory address then its on the heap.

>> Have you checked on all of the processors Linux have been ported to? No, I
>> thought not.
>>
>> As Ben said, finding a system specific news group (either one of the gnu
>> ones, a linux one, or comp.unix.programmer would be better.

>
> FWIW, it is almost assured that whatever the OP is using is probably x86, or
> maybe x86-64...
> other possibilities are sufficiently unlikely as to be assumed, by default,
> not to be the case.


I agree that it is the most likely, but it is by no means the only
processor hobiest are using Linux on. It is also used in the old non-x86
Macs and the last time I checked the TiVo (for which there certainly
used to be a large hacking community).

> (or... maybe... one can start making a fuss that these groups are not easily
> accessible to non-English speakers... and the illiterate...).


I do not see what that has got to do with it.

> thus, there is no need to use that sort of attitude when responding...


The post did not says something like, "on the x86 which you are probably
using..." and was also in direct response to a post which suggested a
more appropriate group for the discussion. So I do think that pointing
out that not all the world is an x86 and that more appropriate groups
had been suggested was appropriate.
--
Flash Gordon
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bitwise OR on large memory regions oswald.kluge@web.de C++ 20 08-14-2006 06:12 PM
Click multiple regions on a map Jerry Manner HTML 3 06-29-2005 01:11 AM
Config of a web app for multiple regions. Bliss ASP .Net 0 10-26-2004 03:21 AM
Hiding Regions - Alternatives Doug ASP .Net 1 08-03-2004 11:47 AM
Paste from Excel into predefined regions in HTML Humvee HTML 1 07-22-2003 02:01 PM



Advertisments