|
@@ -22,7 +22,7 @@ interface
|
|
{$S-}
|
|
{$S-}
|
|
{$Q-}
|
|
{$Q-}
|
|
|
|
|
|
-procedure GetLineInfo(addr:ptruint;var func,source:string;var line:longint);
|
|
|
|
|
|
+function GetLineInfo(addr:ptruint;var func,source:string;var line:longint) : boolean;
|
|
|
|
|
|
|
|
|
|
implementation
|
|
implementation
|
|
@@ -71,16 +71,26 @@ var
|
|
linestab, { stab with current line info }
|
|
linestab, { stab with current line info }
|
|
dirstab, { stab with current directory info }
|
|
dirstab, { stab with current directory info }
|
|
filestab : tstab; { stab with current file info }
|
|
filestab : tstab; { stab with current file info }
|
|
|
|
+ filename,
|
|
|
|
+ dbgfn : string;
|
|
|
|
|
|
|
|
|
|
-function OpenStabs:boolean;
|
|
|
|
-var
|
|
|
|
- dbgfn : string;
|
|
|
|
|
|
+function OpenStabs(addr : pointer) : boolean;
|
|
|
|
+ var
|
|
|
|
+ baseaddr : pointer;
|
|
begin
|
|
begin
|
|
OpenStabs:=false;
|
|
OpenStabs:=false;
|
|
if staberr then
|
|
if staberr then
|
|
exit;
|
|
exit;
|
|
- if not OpenExeFile(e,paramstr(0)) then
|
|
|
|
|
|
+
|
|
|
|
+ GetModuleByAddr(addr,baseaddr,filename);
|
|
|
|
+{$ifdef DEBUG_LINEINFO}
|
|
|
|
+ writeln(stderr,filename);
|
|
|
|
+{$endif DEBUG_LINEINFO}
|
|
|
|
+
|
|
|
|
+ e.processaddress:=e.processaddress-dword(baseaddr);
|
|
|
|
+
|
|
|
|
+ if not OpenExeFile(e,filename) then
|
|
exit;
|
|
exit;
|
|
if ReadDebugLink(e,dbgfn) then
|
|
if ReadDebugLink(e,dbgfn) then
|
|
begin
|
|
begin
|
|
@@ -109,7 +119,7 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
-procedure GetLineInfo(addr:ptruint;var func,source:string;var line:longint);
|
|
|
|
|
|
+function GetLineInfo(addr:ptruint;var func,source:string;var line:longint) : boolean;
|
|
var
|
|
var
|
|
res,
|
|
res,
|
|
stabsleft,
|
|
stabsleft,
|
|
@@ -117,6 +127,10 @@ var
|
|
found : boolean;
|
|
found : boolean;
|
|
lastfunc : tstab;
|
|
lastfunc : tstab;
|
|
begin
|
|
begin
|
|
|
|
+ GetLineInfo:=false;
|
|
|
|
+{$ifdef DEBUG_LINEINFO}
|
|
|
|
+ writeln(stderr,'GetLineInfo called');
|
|
|
|
+{$endif DEBUG_LINEINFO}
|
|
fillchar(func,high(func)+1,0);
|
|
fillchar(func,high(func)+1,0);
|
|
fillchar(source,high(source)+1,0);
|
|
fillchar(source,high(source)+1,0);
|
|
line:=0;
|
|
line:=0;
|
|
@@ -124,7 +138,7 @@ begin
|
|
exit;
|
|
exit;
|
|
if not e.isopen then
|
|
if not e.isopen then
|
|
begin
|
|
begin
|
|
- if not OpenStabs then
|
|
|
|
|
|
+ if not OpenStabs(pointer(addr)) then
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -230,6 +244,9 @@ begin
|
|
if i>0 then
|
|
if i>0 then
|
|
Delete(func,i,255);
|
|
Delete(func,i,255);
|
|
end;
|
|
end;
|
|
|
|
+ if e.isopen then
|
|
|
|
+ CloseStabs;
|
|
|
|
+ GetLineInfo:=true;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -240,11 +257,16 @@ var
|
|
hs : string[32];
|
|
hs : string[32];
|
|
line : longint;
|
|
line : longint;
|
|
Store : TBackTraceStrFunc;
|
|
Store : TBackTraceStrFunc;
|
|
|
|
+ Success : boolean;
|
|
begin
|
|
begin
|
|
|
|
+{$ifdef DEBUG_LINEINFO}
|
|
|
|
+ writeln(stderr,'StabBackTraceStr called');
|
|
|
|
+{$endif DEBUG_LINEINFO}
|
|
{ reset to prevent infinite recursion if problems inside the code PM }
|
|
{ reset to prevent infinite recursion if problems inside the code PM }
|
|
|
|
+ Success:=false;
|
|
Store:=BackTraceStrFunc;
|
|
Store:=BackTraceStrFunc;
|
|
BackTraceStrFunc:=@SysBackTraceStr;
|
|
BackTraceStrFunc:=@SysBackTraceStr;
|
|
- GetLineInfo(ptruint(addr),func,source,line);
|
|
|
|
|
|
+ Success:=GetLineInfo(ptruint(addr),func,source,line);
|
|
{ create string }
|
|
{ create string }
|
|
{$ifdef netware}
|
|
{$ifdef netware}
|
|
{ we need addr relative to code start on netware }
|
|
{ we need addr relative to code start on netware }
|
|
@@ -254,7 +276,7 @@ begin
|
|
StabBackTraceStr:=' $'+HexStr(ptruint(addr),sizeof(ptruint)*2);
|
|
StabBackTraceStr:=' $'+HexStr(ptruint(addr),sizeof(ptruint)*2);
|
|
{$endif}
|
|
{$endif}
|
|
if func<>'' then
|
|
if func<>'' then
|
|
- StabBackTraceStr:=StabBackTraceStr+' '+func;
|
|
|
|
|
|
+ StabBackTraceStr:=StabBackTraceStr+' '+func;
|
|
if source<>'' then
|
|
if source<>'' then
|
|
begin
|
|
begin
|
|
if func<>'' then
|
|
if func<>'' then
|
|
@@ -266,7 +288,7 @@ begin
|
|
end;
|
|
end;
|
|
StabBackTraceStr:=StabBackTraceStr+' of '+source;
|
|
StabBackTraceStr:=StabBackTraceStr+' of '+source;
|
|
end;
|
|
end;
|
|
- if e.IsOpen then
|
|
|
|
|
|
+ if Success then
|
|
BackTraceStrFunc:=Store;
|
|
BackTraceStrFunc:=Store;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -277,5 +299,4 @@ initialization
|
|
finalization
|
|
finalization
|
|
if e.isopen then
|
|
if e.isopen then
|
|
CloseStabs;
|
|
CloseStabs;
|
|
-
|
|
|
|
end.
|
|
end.
|