[Lazarus] Christmas present for Windows lazarus developers : Memproof instaler 2.2MB
Sven Barth
pascaldragon at googlemail.com
Sat Dec 25 12:49:16 CET 2010
On 24.12.2010 17:25, Peter E Williams wrote:
> Is there a tutorial on how to use this? My application which I am
> currently developing are for Lazarus not Free Pascal so I would need
> something which has a GUI interface ?!? Or am I wrong?
>
"-gl" allows you to e.g. dump an exception back trace from within your
program. This happens normally if an exception isn't caught and raises
through the main Pascal block (the "begin ... end." block in the
"program" file).
On the command line FPC will then print something like this:
An unhandled exception occurred at $080480BD :
Exception : Some evil exception
$080480BD TMYOBJECT__METHOD1, line 15 of backtrace.pp
$08048110 PROC3, line 22 of backtrace.pp
$08048148 PROC2, line 30 of backtrace.pp
$08048158 PROC1, line 35 of backtrace.pp
$0804816D main, line 39 of backtrace.pp
You can even print that yourself if you don't have a StdOut available:
The procdure DumpExceptionBackTrace which is available through the
system unit allows you to print such a stack trace to a custom file
(Pascal style file).
E.g. (untested, but correct code should be at least similar):
var
f: Text;
begin
Assign(f, '/tmp/mybacktrace.txt');
Rewrite(f);
try
SomeExceptionRaisingCode;
except
on e: Exception do begin
Writeln(f, e.ClassName, ' : ', e.Message);
DumpExceptionBackTrace(f);
end;
end;
Close(f);
end;
This will print the output from above to the file
'/tmp/mybacktrace.txt'. If you assign a stream to a text file (using the
unit streamio) you can even write to a TStream descendant of your choice
and do some nice things. Or you could wrap the dbugintf unit like
streamio wraps TStream to dump such an exception back trace to a running
debugserver. The possibilities are near endless :)
>
> Afaik memproof (which is like AQTime-lite) needs explicitely debug
> format
> support, and that's why it doesn't work after D7. For decent traces
> it also
> required the TD32 debuginfo to be turned on, and I doubt it understands
> stabs or dwarf.
>
>
> Yes, correct. You need to [ ] Optimization (uncheck) and [x] TD32 debug
> info (check it) and there is probably another option also. Please
> install it and read the help file.
>
> stabs or dwarf are new technologies to me. I know nothing about these
> things.
> :(
>
Stabs and DWARF are the debug formats supported by Free Pascal. They are
used in other Open Source software as well (e.g. gcc) unlike the
proprietary TD32 debug format. Take a look at the units
rtl/inc/lineinfo.pp and rtl/inc/lnfodwrf.pp. Using the public function
GetLineInfo you can retrieve the function/procedure/method name, the
unit name and the source line of a given address within your program (if
it was compiled with "-gl" at least).
Regards,
Sven
More information about the Lazarus
mailing list