Find the answer to your Linux question:
Results 1 to 4 of 4
hi all: i meet a problem . i wanna backtrace my program whiling asserting fail. but the backtrace info from GNU c library do not cantain the function name and ...
  1. #1
    Just Joined!
    Join Date
    Apr 2007
    Posts
    4

    backtrace your program?

    hi all:

    i meet a problem . i wanna backtrace my program whiling asserting fail. but the backtrace info from GNU c library do not cantain the function name and the line number in soure file.

    void WxcBackTrace()
    {
    int i;
    void * array[25];
    int nSize = backtrace(array, 25);
    char ** symbols = backtrace_symbols(array, nSize);

    for (i = 0; i < nSize; i++)
    {
    printf("%s \n" , symbols[i]);
    }
    free(symbols);
    }


    how can i let the backtrace function to give the detail info like gdb.


    (gdb) bt
    #0 sprintf_bcd (
    pBcdBuff=0xbfe92ee0 "\001\002\003\004\005\006\a\b\t\n\v\f\r\016\017\02 0\021\022\023\024\025\026\027\030\031\032\033\034\ 035\036\037 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOP`^\\ZXVTRPNLJHFDB @><:86420.,*(&$\" \036\034\032\030\026\024\022\020\016\f\n\b\006\004 \002", nBcdLen=30, pStrBuff=0xbfe92de0 "-0", nStrBuffSize=256) at prt_bcd.c:56
    #1 0x08048b0e in main () at prt_bcd.c:102

  2. #2
    Just Joined!
    Join Date
    Apr 2007
    Posts
    4
    Is there any body can give me any ideas?

  3. #3
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Smile

    i not sure this is perfect solution for you...
    I don't much about gdb,but i often use strace command to debug ..
    try,
    strace -e trace=all your_binary_name
    thanks
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  4. #4
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    When you compile your program with gcc, give it the '-g' option. Then gdb will give you function name, line number, etc.
    DISTRO=Arch
    Registered Linux User #388732

Posting Permissions

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