Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 May 1996 19:09:56 -0700 (PDT)
From:      Archie Cobbs <archie@whistle.com>
To:        freebsd-questions@freebsd.org
Subject:   stack trace library?
Message-ID:  <199605230209.TAA10682@bubba.whistle.com>

next in thread | raw e-mail | index | archive | help

Does there exist a library with routines that a program (linked with -g)
can use for doing stack crawls?

For example, suppose you

    signal(SIGSEGV, CatchBug);

Then when CatchBug() is called, you want the program to display a
stack trace from the point at which the signal occurred, a la gdb's
"where" command. Then we could have self debugging programs! :-)

CatchBug() might look something like this:

    extern void StabsSignalTrace(FILE *fp, struct sigcontext *ctx);

    void
    CatchBug(int sig, struct sigcontext *ctx)
    {
      warnx("caught fatal signal %s", sys_signame[sig]);
      warnx("please email bug report to xxx@foo.com with this trace:");
      StabsSignalTrace(stderr, ctx);
      exit(1);
    }

If there's no such library, is this possible and/or do-able?

-Archie

___________________________________________________________________________
Archie L. Cobbs, archie@whistle.com  *  Whistle Communications Corporation



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199605230209.TAA10682>