From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,91c5b958fecf5eff X-Google-Attributes: gid103376,public From: Spam Hater Subject: Re: GNAT exception traceback Date: 1997/06/17 Message-ID: <33A6A725.3BD0@no.such.com>#1/1 X-Deja-AN: 249087018 Sender: usenet@most.fw.hac.com (News Administration) X-Nntp-Posting-Host: sparc02 References: <199706131810.OAA07239@seahunt.ctron.com> <01bc7a82$c57186a0$2a208b82@wd> Organization: See Warning Below! Newsgroups: comp.lang.ada Date: 1997-06-17T00:00:00+00:00 List-Id: > Or, as Wiljan notes, you can hack a-raise.c. > The idea of using GDB to determine the program location, given a hex > location, is certainly a reasonable one, though in general you really > want the traceback which GDB can give you. gcc C has a builtin function (macro?) for the return address. Someone sent me C that uses this in a loop to get a stack trace. Note the parameter to __builtin_frame_address - if I remember right, this allows you to say how high up the stack you want to go. If that's right, and if it's not required to be static (using Ada's definition of static) then you could increment the parameter in a loop. The return_addr= part of the following is not portable, but I'm not sure that's needed. Anyway, for what it's worth (maybe nothing) this might be a starting point: void stack_trace() { char *current_frame int return_addr; /* obtain current frame address somehow, e.g. inline assembler or use gcc __builtin_frame_address. */ current_frame=__builtin_frame_address(0); do { return_addr=*(int*)(current_frame+4); /* obtain return addr */ /* do whatever you want with the return addr here */ current_frame=*(char*)current_frame; /* get frame of next upper function */ } while( stack_valid() ); } -- ---------------------------------------------------------------------- Wes Groleau, Hughes Defense Communications, Fort Wayne, IN USA Senior Software Engineer - AFATDS Tool-smith Wanna-be Don't send advertisements to this domain unless asked! All disk space on fw.hac.com hosts belongs to either Hughes Defense Communications or the United States government. Using email to store YOUR advertising on them is trespassing! ----------------------------------------------------------------------