Board index » kylix » Debugging Kylix apps

Debugging Kylix apps


2004-11-09 06:21:11 PM
kylix2
I really need to be able to release debug builds of my app so that users can
mai lme back an address of a runtime error etc in the event of something
going wrong (obviously, I can't really ask end users to run apps inside the
IDE ;-)).
Is there any way that I can get the mapping info out of the Kylix debug
DCU's and my own compiled units so that I can map a memory pointer to a
function/procedure in a unit?
Presumably there must be a map somewhere, and there must be a way to lookup
the info?
Many thanks,
Dean
 
 

Re:Debugging Kylix apps

Added:-
One of the things that is meant to do this, that I never got to work, is the
"-F" switch in the DCC.
Anyone here actually managed to get that to work?
 

Re:Debugging Kylix apps

Added Part 2:-
I managed to build a map file - is it possible to manually correlate this to
error addresses?
Thanks,
Dean
 

{smallsort}

Re:Debugging Kylix apps

Dean,
Quote
I managed to build a map file - is it possible to manually correlate this to
error addresses?
Yes, that's of course possible.
I suggest having a look at the Kylix Leak Finder Project by Johannes Berg at
klf.sourceforge.net/phpwiki/
Sources are at:
cvs.sourceforge.net/viewcvs.py/klf/klf/src/
This project has everything to read stabS debug info from Kylix executables.
Hope this helps,
Simon
 

Re:Debugging Kylix apps

Quote
This project has everything to read stabS debug info from Kylix executables.
....and also is able to read map-files. See udebug.pas.
Simon
 

Re:Debugging Kylix apps

Thanks Simon - another very interesting Kylix project.
I have downloaded the Source, but there is no easy way for me to find out
how to use it......
All I really need to do is read the map file. The problem is the addresses
supplied to me at STDIO do not correlate with the addresses in the map file.
I've had a look through the procedures/functions in uDebug.pas, but still
can't seem to find a solution.
Is there some kind of offset in the map files?
I would prefer to simply lookup line numbers etc manually in the .map file I
think.
Thanks,
Dean
 

Re:Debugging Kylix apps

Quote
Thanks Simon - another very interesting Kylix project.
Yes indeed, I also need to have a closer look at it.
Probably will come in handy while writing the CrossKylix remote de{*word*81}.
Quote
Is there some kind of offset in the map files?
Yes, as your executable image isn't mapped at $0 in memory.
The following should work inside your exceptions:
MapAddress := ExceptAddr - Cardinal(@TextStart);
Simon
 

Re:Debugging Kylix apps

Thanks, so do I just put:-
MapAddress := ExceptAddr - Cardinal(@TextStart);
.... inside my try....except block like this:-
try
do something
except
MapAddress := ExceptAddr - Cardinal(@TextStart);
end;
And put uDebug in my uses clause?
Thanks,
Dean
 

Re:Debugging Kylix apps

Quote
And put uDebug in my uses clause?
No, this was my reply to
"I would prefer to simply lookup line numbers etc manually in the .map file I
think."
This gives you the information you need to look it up manually.
Simon
 

Re:Debugging Kylix apps

Ah, perfect - thanks.
Where do I find the "textstart" offset though?
Dean
"Simon Kissel" < XXXX@XXXXX.COM >wrote in message
Quote
And put uDebug in my uses clause?
No, this was my reply to
"I would prefer to simply lookup line numbers etc manually in the .map file
I
think."
This gives you the information you need to look it up manually.
Simon
 

Re:Debugging Kylix apps

Quote
Ah, perfect - thanks.

Where do I find the "textstart" offset though?
No need to hunt for it, it's part of the Delphi system unit.
It's simply a dummy function that always is the first one in
the text segment.
Simon
 

Re:Debugging Kylix apps

Thanks Simon.
Strange results are ensuing.
The addresses come out of Linux in hex, so I do a calculation something
like:-
MapAddress := Cardinal(ExceptionAddress) - Cardinal(@TextStart)
..... then convert MapAddress to a HEX value and it gives me an address
whcih I can't find anywhere in the map file.
Something obvious that I have wrong here?
Thanks,
Dean
 

Re:Debugging Kylix apps

Quote
Something obvious that I have wrong here?
Hm sorry, no clue. This should work...
Simon
 

Re:Debugging Kylix apps

OK, thanks for trying.
It's a shame there is not a simple way to map this data. One of the big
disadvantages of Kylix..... debugging is very difficult.
Dean
"Simon Kissel" < XXXX@XXXXX.COM >wrote in message
Quote
Something obvious that I have wrong here?
Hm sorry, no clue. This should work...
Simon