Displaying of the Stack Trace

Discussion in 'C Programming' started by Guenther Sohler, Jun 24, 2003.

  1. I have written a program, which is very compicated
    and so it happens quite often, that it has to exit itself,
    because its handling an invalid index of an array.
    (It never crashes, it always nicely exits).
    Nevertheless - in that case, It would be very nice
    if my program could display the function hierarchy,
    how my program reached that exit.
    I have already seen programs doing that, before they crashed.
    How can I do this on a unix/linux system ?
    Are there special functions to read the symbols contained within the ELF
    File ?

    rds
     
    Guenther Sohler, Jun 24, 2003
    #1
    1. Advertisements

  2. Guenther Sohler

    Zoran Cutura Guest

    The way you asked your question already should have suggested to you
    that you want to ask it in a newsgroup related to your system rather
    than a language group.
    comp.unix.programmer
    comp.os.linux.development.apps
     
    Zoran Cutura, Jun 24, 2003
    #2
    1. Advertisements

  3. Guenther Sohler

    Ira Baxter Guest

    You either have to depend on some specific compiler feature that does this
    (your compiler mileage will vary significantly) or you will have to
    ensure this yourself.

    A compiler-independent way to do it is to decorate each
    function entry/exit with instrumentation that keeps track
    of this information on your own private stack. You can
    do this by hand, with a few macros and lot of editing.

    Or, you can use a tool that could automatically place such
    probes in all your source files. A white paper on inserting
    probes using automated tools can be found on the web page,
    http://www.semanticdesigns.com/Products/TestCoverage/index.html.
     
    Ira Baxter, Jun 25, 2003
    #3
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.