mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 09:28:19 +02:00
* PushExceptObject and dump_stack: use get_caller_stackinfo instead of get_caller_addr and get_caller_frame.
git-svn-id: trunk@27094 -
This commit is contained in:
parent
abc1468a7a
commit
2f05e8b389
@ -113,10 +113,8 @@ var
|
||||
framecount : longint;
|
||||
frames : PCodePointer;
|
||||
prev_frame,
|
||||
curr_frame,
|
||||
caller_frame : Pointer;
|
||||
curr_addr,
|
||||
caller_addr : CodePointer;
|
||||
curr_frame : Pointer;
|
||||
curr_addr : CodePointer;
|
||||
begin
|
||||
{$ifdef excdebug}
|
||||
writeln ('In PushExceptObject');
|
||||
@ -141,21 +139,18 @@ begin
|
||||
while (framecount<RaiseMaxFrameCount) and (curr_frame > prev_frame) and
|
||||
(curr_frame<(StackBottom + StackLength)) do
|
||||
Begin
|
||||
caller_addr := get_caller_addr(curr_frame, curr_addr);
|
||||
caller_frame := get_caller_frame(curr_frame, curr_addr);
|
||||
if (caller_addr=nil) or
|
||||
(caller_frame=nil) then
|
||||
prev_frame:=curr_frame;
|
||||
get_caller_stackinfo(curr_frame,curr_addr);
|
||||
if (curr_addr=nil) or
|
||||
(curr_frame=nil) then
|
||||
break;
|
||||
if (framecount>=framebufsize) then
|
||||
begin
|
||||
inc(framebufsize,16);
|
||||
reallocmem(frames,framebufsize*sizeof(codepointer));
|
||||
end;
|
||||
frames[framecount]:=caller_addr;
|
||||
frames[framecount]:=curr_addr;
|
||||
inc(framecount);
|
||||
prev_frame:=curr_frame;
|
||||
curr_addr:=caller_addr;
|
||||
curr_frame:=caller_frame;
|
||||
End;
|
||||
NewObj^.framecount:=framecount;
|
||||
NewObj^.frames:=frames;
|
||||
|
@ -1139,36 +1139,29 @@ Procedure dump_stack(var f : text;fp : Pointer; addr : CodePointer);
|
||||
var
|
||||
i : Longint;
|
||||
prevfp : Pointer;
|
||||
prevaddr : CodePointer;
|
||||
is_dev : boolean;
|
||||
caller_frame : Pointer;
|
||||
caller_addr : CodePointer;
|
||||
Begin
|
||||
{$ifdef FPC_HAS_FEATURE_EXCEPTIONS}
|
||||
try
|
||||
{$endif FPC_HAS_FEATURE_EXCEPTIONS}
|
||||
prevfp:=fp-1;
|
||||
prevaddr:=nil;
|
||||
{ Frame of this procedure acts as StackBottom, fp values below that are invalid. }
|
||||
prevfp:=get_frame;
|
||||
i:=0;
|
||||
is_dev:=do_isdevice(textrec(f).Handle);
|
||||
{ sanity checks, new frame pointer must be always greater than the old one, further
|
||||
it must point into the stack area, else something went wrong }
|
||||
while (fp>prevfp) and (fp<StackTop) and (fp>StackBottom) Do
|
||||
while (fp>prevfp) and (fp<StackTop) do
|
||||
Begin
|
||||
caller_addr := get_caller_addr(fp,addr);
|
||||
caller_frame := get_caller_frame(fp,addr);
|
||||
if (caller_addr=nil) then
|
||||
prevfp:=fp;
|
||||
get_caller_stackinfo(fp,addr);
|
||||
if (addr=nil) then
|
||||
break;
|
||||
Writeln(f,BackTraceStrFunc(caller_addr));
|
||||
if (caller_frame=nil) then
|
||||
Writeln(f,BackTraceStrFunc(addr));
|
||||
if (fp=nil) then
|
||||
break;
|
||||
Inc(i);
|
||||
If ((i>max_frame_dump) and is_dev) or (i>256) Then
|
||||
break;
|
||||
prevfp:=fp;
|
||||
prevaddr:=addr;
|
||||
fp:=caller_frame;
|
||||
addr:=caller_addr;
|
||||
End;
|
||||
{$ifdef FPC_HAS_FEATURE_EXCEPTIONS}
|
||||
except
|
||||
|
Loading…
Reference in New Issue
Block a user