Find the answer to your Linux question:
Results 1 to 3 of 3
Hello. I need your help. I made simple program with class and a couple of functions and a variable. and i compiled it with gcc command. Now i have to ...
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Posts
    19

    Objdump help

    Hello.

    I need your help.
    I made simple program with class and a couple of functions and a variable.
    and i compiled it with gcc command.

    Now i have to get all functions and variables listed. How should i do this?
    I used objdump -S a.out >> some.txt and in some.txt i did find class constructor destructor and functions, but no variables.
    What command should i use? what is simmular to objdump?
    I also used nm -s a.out | grep ZN2
    and i got
    0804853e W _ZN2CA4GetAEv
    08048548 W _ZN2CA4SetAEi
    08048522 W _ZN2CAC1Ev
    08048530 W _ZN2CAD1Ev

    Which would be great if there would be my m_nA variable listed to.

    here is the code of the simple program:

    #include <stdio.h>
    class CA
    {
    public:
    CA() {m_nA = 0; }
    ~CA() {m_nA = -1; }
    int GetA() { return m_nA; }
    void SetA(const int nA) { m_nA = nA; }
    int m_nA;
    };
    int main()
    {
    CA A;
    A.SetA(10);
    printf("A = %d\n", A.GetA());
    return 0;
    }
    As you see all that objdump or nm dont give me is m_nA.

    Someone told me to use gcb and then ptype but i dont know how...
    Can i work out my problem with ptype?

    Thank you for your help.

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    To get any mention of m_nA in your objdump output, you need to go back and compile with the -g option.

    Hope this helps.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  3. #3
    Just Joined!
    Join Date
    Feb 2008
    Posts
    19
    Thank you wje_lf. objdump did find m_nA but only because it was in getA function.
    I am looking for it to stand alone so even if it is not used it will still be shown.

    But if i wont find any other way to get m_nA that will just have to do.

    Thank you for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...