The project page with the download link:
http://www.chebmaster.narod.ru/soft/...helinfo_e.html
Test:
Code:
{$ifdef windows}
{$apptype gui}
{$endif}
program chelinfo_test;
{note: DON'T FORGET to compile your program with the -gw key
Lazarus: you must type it in
Project -> Compiler Options -> Other -> User parameters
}
uses
Classes, SysUtils, un_lineinfo;
begin
InitLineInfo(nil);
byte(nil^):= 0; // go BOOM!
end.
[cheb@localhost]$ ./chelinfo_test
An unhandled exception occurred at $080481E2 :
EAccessViolation : Access violation
$080481E2, line 16 of chelinfo_test.pp in ./chelinfo_test
Details:
Code:
unit un_lineinfo;
interface
uses
SysUtils, Classes;
procedure GetLineInfo
(addr: pointer; var exe, src: ansistring; var line, column: integer);
{
The format of returned information:
"exe" *always* receives the full name of the executable file
(the main exe or one of dlls it uses) the addr belongs to.
In Linux, it returns the real file name, with all symlinks
resolved.
"line" can be negative, which means no line info has been found
for this address. See LineInfoError (below) for details.
"src" returns the source file name. It either doesn't or does
contain a full path. If the source was in the same directory
as the program itself, there will be no path. If the source
was in the different directory, there will be a full path
(for the moment when the program was compiled, NOT for the
current location of that source).
"column" is positive ONLY when there is more than one address
stored for the same source line. FreePascal generates this
on VERY rare occasions, mostly for the arithmetic formulas
spanning several lines. So most of the time column will
receive -1.
}
function InitLineInfo(someaddr: pointer): longbool;
{
This function is called by GetLineInfo() anyway if it doesnt't
fid a loaded line info for the executable to which the
requested addres belongs.
Also installs the custom BackTraceStr handler.
Input:
someaddr is adress of any function that belongs to the executable
you want to pre-load the line info for. For example, a function
exported from a dll.
If you pass NIL, it will load loads the line info for the
executable it belongs to.
Output:
Returns false if it failed to load the line info for the particular
executable. In this case look LineInfoError for explanation
Returns true if the line info for the particular executable is loaded ok.
Returns true and does nothing if line info for that executable is
already loaded.
}
procedure GetModuleByAddr
(addr: pointer; var baseaddr: pointer; var filename: string);
{
This function allows you to know which executable (i.e. the main exe
or one of the dlls loaded by it) owns this part of the virtual
addres space.
baseaddr receives the exe/dll base address
(always NIL for the main exe in Linux).
The mechnaism is made with possibility of a DLL relocation
in mind, but that particular feature is untested.
This function is used by GetLineInfo() to determine which executable
to load line the info from.
}
var
LineInfoError: WideString = '';
implementation
....
Bookmarks