Checking the Memory regions

Discussion in 'C Programming' started by new, May 28, 2009.

  1. new

    new Guest

    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.
     
    new, May 28, 2009
    #1
    1. Advertising

  2. In article <>,
    new <> 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.
     
    Kenny McCormack, May 28, 2009
    #2
    1. Advertising

  3. new <> 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.
     
    Ben Bacarisse, May 28, 2009
    #3
  4. new

    new Guest

    On May 28, 5:27 pm, Ben Bacarisse <> wrote:
    > new <> 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
     
    new, May 28, 2009
    #4
  5. new <> writes:
    > On May 28, 5:27 pm, Ben Bacarisse <> wrote:
    >> new <> 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.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, May 28, 2009
    #5
  6. new

    kid joe Guest

    On Thu, 28 May 2009 08:01:11 -0700, new wrote:
    > On May 28, 5:27 pm, Ben Bacarisse <> wrote:
    >> new <> 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! , /\_ _| | .-'_|
    `................, _\__`[_______________| _| (_|
    ] [ \, ][ ][ (_|
     
    kid joe, May 28, 2009
    #6
  7. new

    Flash Gordon Guest

    kid joe wrote:
    > On Thu, 28 May 2009 08:01:11 -0700, new wrote:
    >> On May 28, 5:27 pm, Ben Bacarisse <> wrote:
    >>> new <> 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
     
    Flash Gordon, May 29, 2009
    #7
  8. new

    cr88192 Guest

    "Flash Gordon" <> wrote in message
    news:-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 <> wrote:
    >>>> new <> 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
     
    cr88192, May 29, 2009
    #8
  9. On May 29, 8:13 am, "cr88192" <> wrote:
    > "Flash Gordon" <> wrote in message
    > news:-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 <> wrote:
    > >>>> new <> 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
     
    James Dow Allen, May 29, 2009
    #9
  10. new

    Flash Gordon Guest

    cr88192 wrote:
    > "Flash Gordon" <> wrote in message
    > news:-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 <> wrote:
    >>>>> new <> 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
     
    Flash Gordon, May 29, 2009
    #10
  11. In article <>,
    James Dow Allen <> wrote:
    ....
    >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.


    Kewl!

    Note that this is true of CLC itself, as well.

    I.e., although a superficial analysis might conclude that this is
    a newsgroup for dicussion of C programming, in fact, nothing could be
    further from the truth. Any discussion of real C programming is, of
    course, off-topic - and will draw a quick rebuke from those in control.
    But discussions of just about everything and anything else, such as
    Fortran compilers, PL/1 compilers, Shakespeare, English history, the
    correct and proper term to use to refer to residents of the United
    States of America, dirty underwear, data structures (Just make sure to
    avoid using the "S word" when doing so!), the histories (and relative
    market shares over time) of computer companies, and so on, is all OK and
    will get nary a comment from the "mods".
     
    Kenny McCormack, May 29, 2009
    #11
  12. In article <gvncr3$pf4$>,
    cr88192 <> wrote:
    ....
    >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.


    Indeed. Quite.

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


    Not quite sure what you mean by this.

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


    It's what they live for. For many of them, it is quite literally, their
    only reason to get out of bed each day.
     
    Kenny McCormack, May 29, 2009
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Doug

    Hiding Regions - Alternatives

    Doug, Aug 3, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    345
    Dave Fancher
    Aug 3, 2004
  2. Bliss
    Replies:
    0
    Views:
    312
    Bliss
    Oct 26, 2004
  3. Humvee
    Replies:
    1
    Views:
    409
    Mr. Clean
    Jul 22, 2003
  4. Jerry Manner

    Click multiple regions on a map

    Jerry Manner, Jun 27, 2005, in forum: HTML
    Replies:
    3
    Views:
    436
  5. Replies:
    20
    Views:
    685
    Default User
    Aug 14, 2006
Loading...

Share This Page