NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Stack trace from C program
> Hi, is there a sane way of generating a stack trace from withink a C
> program on *BSD?
>
> For example, Solaris has walkcontext() and printstack() functions. It
> doesn't look like there is anything similar on NetBSD.
>
> Is there a portable way of implementing those functions, or does it
> heavily depend on machine architecture and operating system?
You may want to look at the recent BIND 9 source:
lib/isc/backtrace.c
lib/isc/include/isc/backtrace.h
(even in NetBSD src/external/bsd/bind/dist/)
It has comments and embedded docs explaining it. It provides examples
using backtrace() and gcc's Unwind_Backtrace() (on x86_64 or IA64). So
yes it is machine dependent.
Home |
Main Index |
Thread Index |
Old Index