From owner-freebsd-hackers Sun Jul 18 3:45:38 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by hub.freebsd.org (Postfix) with ESMTP id D82C41500F for ; Sun, 18 Jul 1999 03:45:31 -0700 (PDT) (envelope-from des@flood.ping.uio.no) Received: (from des@localhost) by flood.ping.uio.no (8.9.3/8.9.1) id MAA43785; Sun, 18 Jul 1999 12:45:28 +0200 (CEST) (envelope-from des) To: Alfred Perlstein Cc: Dag-Erling Smorgrav , hackers@FreeBSD.ORG Subject: Re: Determining the return address References: From: Dag-Erling Smorgrav Date: 18 Jul 1999 12:45:27 +0200 In-Reply-To: Alfred Perlstein's message of "Sat, 17 Jul 1999 16:01:50 -0500 (EST)" Message-ID: Lines: 30 X-Mailer: Gnus v5.5/Emacs 19.34 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Alfred Perlstein writes: > This looks like what you are doing is trying to grab the data on the > stack before "log" which is the return address. Yes. It actually works :) > I doubt this is > at all portable and may fail because of optimizations and ABI, such > as archs that store the return address in a register... I know - I don't expect it to be portable. > gdb and glibc have some functions to assist in runtime backtraces, > perhaps a look there may help? I found out about __builtin_return_address(0). > > BTW, is dladdr() signal-safe? > not according to the sigaction man page. OK, is there any way I can find out that I am being called from a signal handler, other than using a global variable? I want my logging functions to be signal-safe - that's why I use writev(), and I've gone to great lengths to ensure that log_makedate() (which uses localtime_r() and strftime() to build a date string) and lvformat() (a printf() clone with some additional goodies) are signal-safe. DES -- Dag-Erling Smorgrav - des@flood.ping.uio.no To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message