Re: Finding the callstack programmatically

From: Ashutosh (ashusharma1980_at_yahoo.co.uk)
Date: 07/16/04


Date: Fri, 16 Jul 2004 06:34:08 GMT

Thanks. That seems to work very well with STANDALONE defined. However, if I
try to compile it (with gcc -c) and link it with my program and if I call
StackTrace() from within my program, it says "No debugger found".

On debugging this, I found that 'status' after the line "rc = waitpid(pid,
&status, 0)" is 512. 'pid' was non-zero (and on doing a 'ps', it
corresponded to 'sh <defunct>'.

If I define USE_BUILTIN, it has a Segmentation fault.

Ashutosh

"Bjorn Reese" <breese@see.signature> wrote in message
news:pan.2004.07.15.17.19.43.292263@see.signature...
> On Thu, 15 Jul 2004 13:45:55 +0000, Ashutosh wrote:
>
> > Is there a way to find the call stack at any point of time inside a
(C/C++)
> > program?
> > Whenever my program raises a SIGSEGV, is it possible for me to print the
> > function call stack in the SIGSEGV handler?
>
> See stacktrace.c in http://home1.stofanet.dk/breese/debug/debug.tar.gz
>
> --
> mail1dotstofanetdotdk
>



Relevant Pages

  • Re: one simple question
    ... but if you use gcc -S something.s something.c ... >> I compile a test C file. ... >> beginning of the assembly code. ... > the stack pointer... ...
    (freebsd-questions)
  • -mregparm on gcc doesnt work correctly?
    ... I have some expermentals with -mregparm option of gcc. ... I compile my ... So I expect that the first 2 param of a function is transferred in EAX ... and from the 3rd params onward the params are put in stack. ...
    (comp.lang.asm.x86)
  • Re: Why is so much space allocated on the stack?
    ... I have some c code that I compile with gcc in cygwin and the stack for ... Why does the stack increase by 40? ... gcc tries to ...
    (comp.lang.asm.x86)
  • Re: -mregparm on gcc doesnt work correctly?
    ... I have some expermentals with -mregparm option of gcc. ... I compile my ... So I expect that the first 2 param of a function is transferred in EAX ... and from the 3rd params onward the params are put in stack. ...
    (comp.lang.asm.x86)
  • Re: An Observation
    ... first character on the stack. ... parse a word and compile the value as a literal to use ... need to execute at compile-time for. ...
    (comp.lang.forth)