[fpc-devel] CaptureBacktrace

Adriaan van Os adriaan at adriaan.biz
Mon Oct 7 08:49:24 CEST 2024


Karoly Balogh via fpc-devel wrote:
> Hi,
> 
> On Fri, 4 Oct 2024, Adriaan van Os via fpc-devel wrote:
> 
>> My question now is if there is a reason why FPC doesn't call backtrace (see
>> man backtrace) on Linux and Unix (including MacOS) platforms ?
> 
> It seems this is a relatively recent addition to libc, which means, after
> 2000. :)

program TestBacktrace;

procedure StackMe
         ( theDepth : integer);
begin
   writeln
     ( 'theDepth = ', theDepth);
   Dump_Stack
     ( stdout, 0);
   writeln;
   if theDepth > 1
     then StackMe
        ( theDepth - 1)
end;

begin
   writeln
     ( 'main program');
   writeln;
   StackMe
     ( 6)
end.


prints


main program

theDepth = 6

theDepth = 5

theDepth = 4
   $00011680

theDepth = 3
   $00011680
   $000116C5

theDepth = 2
   $00011680
   $000116C5
   $000116C5

theDepth = 1
   $00011680
   $000116C5
   $000116C5
   $000116C5


So, how should I call Dump_Stack ?

Also, there is no symbol information (on MacOS). Is this because of the separate .dSYM file ?

Regards,

Adriaan van Os


More information about the fpc-devel mailing list