Question about Using -Xg compile option lazarus / 12-Debugger ---------------------------------------------------------------------- garlar27 · 2011-10-04 15:34 When I set this compile option generates an external file with .dbg extension. How do I use it? ---------------------------------------------------------------------- typo · 2011-10-04 15:47 Project Options > Compiler Options > Linking ---------------------------------------------------------------------- garlar27 · 2011-10-04 19:08 Sorry I didn't mentioned that I already did it and have my dbg file but I can't use it to get the unit and line number where the exception occurred. It's a file to be used with Lazarus only? when I run the app from the linux terminal it wont show the line numbers where the exception occurred, only the memory address where the exception was caused. ---------------------------------------------------------------------- Leledumbo · 2011-10-05 04:44 QuoteIt's a file to be used with Lazarus only?More precisely, with GDB. Quotewhen I run the app from the linux terminal it wont show the line numbers where the exception occurred, only the memory address where the exception was caused.Yep, for that, you need -gl where the line numbers are included in your executable. ---------------------------------------------------------------------- garlar27 · 2011-10-05 12:03 Thank you!! One more question: Is there a tool to search the file with a specific memory address to get the unit, line and method that caused the exception? ---------------------------------------------------------------------- Chronos · 2011-10-05 14:57 See http://wiki.freepascal.org/Logging_exceptions for detailed information. You can also take http://svn.zdechov.net/PascalClassLibrary/ExceptionLogger/ as inspiration for custom exception handling. ---------------------------------------------------------------------- Leledumbo · 2011-10-05 16:08 QuoteOne more question: Is there a tool to search the file with a specific memory address to get the unit, line and method that caused the exception?Err... GDB? ---------------------------------------------------------------------- felipemdc · 2011-10-05 16:42 Quote from: garlar27 on October 05, 2011, 02:03:10 pmOne more question: Is there a tool to search the file with a specific memory address to get the unit, line and method that caused the exception? In lazarus-ccr/applications/lazstacktrace there is an application which can read a memory address and find to which method it corresponds in a binary. It uses GDB for doing that. I created it to convert Android stacktraces from memory addresses to method names. ---------------------------------------------------------------------- garlar27 · 2011-10-06 21:03 Quote from: chronos on October 05, 2011, 04:57:18 pmSee http://wiki.freepascal.org/Logging_exceptions for detailed information. This is a great article which I already applied to my project but I can't do much with the memory stacktrace in the log... Quote from: chronos on October 05, 2011, 04:57:18 pmYou can also take http://svn.zdechov.net/svn/PascalClassLibrary/ExceptionLogger/ as inspiration for custom exception handling. I still didn't have time to look at this link. Quote from: felipemdc on October 05, 2011, 06:42:07 pmQuote from: garlar27 on October 05, 2011, 02:03:10 pmOne more question: Is there a tool to search the file with a specific memory address to get the unit, line and method that caused the exception? In lazarus-ccr/applications/lazstacktrace there is an application which can read a memory address and find to which method it corresponds in a binary. It uses GDB for doing that. I created it to convert Android stacktraces from memory addresses to method names. I didn't have time to check this too, but it looks like this is what I need. Thank you very much!!! I will post if I could make it. ---------------------------------------------------------------------- Martin_fr · 2011-10-06 21:52 Btw, if you have stacktraces with files and lines in it (e.g. compile without -Xg, but with -gl) then you may want to look at the package "Leak View". It was originally designed to open the output of the leak trc unit, but you can copy and paste the stacktraces from exception etc too. You can then double click the lines, to navigate to the unit in the IDE. ---------------------------------------------------------------------- Martin_fr · 2011-10-06 22:28 in the fpc bin folder should be an application called objdump.exe It can read the file. If you generated dwarf, the use    objdump.exe -WL  file.dbg The address is the first for the line, so it may not be the exact one you have in the trace. You need to find the nearest address before. For stabs, I don't know if there is a simple way. You can view stabs, but get the line numbers... EDIT: gdb.exe --batch  -ex "info line *0x413290" lib\foo.dbg Line 196 of "../inc/sysres.inc" starts at address 0x413290 and ends at 0x413298 . ---------------------------------------------------------------------- garlar27 · 2011-10-07 12:23 Thank you Martin_fr. I will take a look at that.