Recent

Author Topic: Question about Using -Xg compile option  (Read 10510 times)

garlar27

  • Hero Member
  • *****
  • Posts: 652
Question about Using -Xg compile option
« on: October 04, 2011, 05:34:31 pm »
When I set this compile option generates an external file with .dbg extension.

How do I use it?

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Question about Using -Xg compile option
« Reply #1 on: October 04, 2011, 05:47:58 pm »
Project Options > Compiler Options > Linking

garlar27

  • Hero Member
  • *****
  • Posts: 652
Re: Question about Using -Xg compile option
« Reply #2 on: October 04, 2011, 09:08:44 pm »
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

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Question about Using -Xg compile option
« Reply #3 on: October 05, 2011, 06:44:05 am »
Quote
It's a file to be used with Lazarus only?
More precisely, with GDB.
Quote
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.
Yep, for that, you need -gl where the line numbers are included in your executable.

garlar27

  • Hero Member
  • *****
  • Posts: 652
Re: Question about Using -Xg compile option
« Reply #4 on: October 05, 2011, 02:03:10 pm »
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

  • Sr. Member
  • ****
  • Posts: 253
    • PascalClassLibrary
Re: Question about Using -Xg compile option
« Reply #5 on: October 05, 2011, 04:57:18 pm »
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.
« Last Edit: December 21, 2018, 09:25:04 pm by Chronos »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Question about Using -Xg compile option
« Reply #6 on: October 05, 2011, 06:08:40 pm »
Quote
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?
Err... GDB?

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Question about Using -Xg compile option
« Reply #7 on: October 05, 2011, 06:42:07 pm »
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?

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

  • Hero Member
  • *****
  • Posts: 652
Re: Question about Using -Xg compile option
« Reply #8 on: October 06, 2011, 11:03:24 pm »
See 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...

You 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.

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?

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

  • Administrator
  • Hero Member
  • *
  • Posts: 12011
  • Debugger - SynEdit - and more
    • wiki
Re: Question about Using -Xg compile option
« Reply #9 on: October 06, 2011, 11:52:03 pm »
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

  • Administrator
  • Hero Member
  • *
  • Posts: 12011
  • Debugger - SynEdit - and more
    • wiki
Re: Question about Using -Xg compile option
« Reply #10 on: October 07, 2011, 12:28:09 am »
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 <FREERESOURCE> and ends at 0x413298 <FREERESOURCE+8>.
« Last Edit: October 07, 2011, 12:37:27 am by Martin_fr »

garlar27

  • Hero Member
  • *****
  • Posts: 652
Re: Question about Using -Xg compile option
« Reply #11 on: October 07, 2011, 02:23:01 pm »
Thank you Martin_fr.

I will take a look at that.

 

TinyPortal © 2005-2018