Bläddra i källkod

* replaced fpcunit custom code to obtaining a caller site with a call to
CaptureBacktrace (prevents crashes when compiled with LLVM backend,
and is generally more robust)

git-svn-id: trunk@42093 -

Jonas Maebe 6 år sedan
förälder
incheckning
c330f5080c
1 ändrade filer med 7 tillägg och 9 borttagningar
  1. 7 9
      packages/fcl-fpcunit/src/fpcunit.pp

+ 7 - 9
packages/fcl-fpcunit/src/fpcunit.pp

@@ -376,16 +376,14 @@ Const
 function CallerAddr: Pointer;
 function CallerAddr: Pointer;
 
 
 Var
 Var
-  bp,pcaddr : pointer;
-  
+  address: CodePointer;
+  nframes: sizeint;
 begin
 begin
-  Result:=Nil;
-  bp:=get_frame;
-  pcaddr:=get_pc_addr;
-  get_caller_stackinfo(bp,pcaddr);
-  if bp<>Nil then
-    get_caller_stackinfo(bp,pcaddr);
-  result:=pcaddr;
+  nframes:=CaptureBacktrace(2,1,@address);
+  if nframes=1 then
+    result:=address
+  else
+    result:=nil;
 end;
 end;
 
 
 function AddrsToStr(Addrs: Pointer): string;
 function AddrsToStr(Addrs: Pointer): string;