read gdb symbols in a program - Unix

This is a discussion on read gdb symbols in a program - Unix ; i have a binary compiled with gdb symbols in it. If it crashes, i want to print the callstack just like what i get when i do a "bt" by loading the core and binary in to gdb and at ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: read gdb symbols in a program

  1. read gdb symbols in a program

    i have a binary compiled with gdb symbols in it. If it crashes, i want
    to print the callstack
    just like what i get when i do a "bt" by loading the core and binary
    in to gdb and at the same time after printing the callstack i should
    be able to generate the core as well.
    how can i do this.

    thanks
    sinbad

  2. Re: read gdb symbols in a program



    sinbad wrote:
    > i have a binary compiled with gdb symbols in it. If it crashes, i want
    > to print the callstack
    > just like what i get when i do a "bt" by loading the core and binary
    > in to gdb and at the same time after printing the callstack i should
    > be able to generate the core as well.
    > how can i do this.
    >


    Use glibc backtrace()

    http://www.kernel.org/doc/man-pages/...cktrace.3.html

    But I am not sure if it exists in all UNIX variants.

    Bin

  3. Re: read gdb symbols in a program

    sinbad writes:

    > i have a binary compiled with gdb symbols in it.


    I think you mean that the program is compiled with debug info.
    [This has nothing to do with "gdb symbols".]

    > If it crashes, i want to print the callstack
    > just like what i get when i do a "bt" by loading the core and binary
    > in to gdb and at the same time after printing the callstack i should
    > be able to generate the core as well.
    > how can i do this.


    Use gdb to generate that call stack.
    Some examples can be found in this message (and thread):
    http://groups.google.com/group/comp....6026cfcb32b01b

    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.

  4. Re: read gdb symbols in a program

    Bin Chen writes:

    > Use glibc backtrace()
    > http://www.kernel.org/doc/man-pages/...cktrace.3.html


    It doesn't provide "symbolized" stack trace, only raw addresses,
    and so doesn't fit OP's requirements [1]. It also doesn't work with
    optimized code [2].

    > But I am not sure if it exists in all UNIX variants.


    It does *not* exist on most UNIX variants.

    [1] There is a backtrace_symbols(), but that calls malloc, and is
    unsafe to call from a signal handler.

    [2] At least on some platforms, such as x86_64.
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.

+ Reply to Thread