Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2008-01

RTL StackTrace patch

13 messages · 6 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Fabio Dell'Aria

Hi to all,

I'm writing a patch to can use an external .dbg file during the debugging process.

All works fine but when an unhandled exception is raised the RTL show stacktrace without debug info (no sources line).

How I can instruct the RTL to search the debug symbols in a project.dbg file (if not found in the executable)?

Best regards... Fabio Dell'Aria.

Reply by email

Vincent Snijders
to Fabio Dell'Aria
Fabio Dell'Aria wrote 11 lines
Hi to all, I'm writing a patch to can use an external .dbg file during the debugging process. All works fine but when an unhandled exception is raised the RTL show stacktrace without debug info (no sources line). How I can instruct the RTL to search the debug symbols in a project.dbg file (if not found in the executable)?

Write support for it in the lineinfo and lnfodwrf units. You can find those units in fpc\rtl\inc.

Vincent

Reply by email

Peter Vreman
Show quoted text 15 lines
Fabio Dell'Aria schreef: > Hi to all, > > I'm writing a patch to can use an external .dbg file during the > debugging process. > > All works fine but when an unhandled exception is raised the RTL show > stacktrace without debug info (no sources line). > > How I can instruct the RTL to search the debug symbols in a > project.dbg file (if not found in the executable)? > Write support for it in the lineinfo and lnfodwrf units. You can find those units in fpc\rtl\inc.

See http://sourceware.org/gdb/download/onlinedocs/gdb_16.html#SEC154 how to find the external .dbg file from the .gnu_debuglink section.

Note that the build-id support still needs to be added to fpc and thus the crc checksum verification needs to be implemented to verify that the correct .dbg is found. In the final situation both options shall be implemented.

If you are going to implement something first refactor the part that handles the opening and reading of the executable file and can find the position of sections. Most of these routines are already available in lineinfo.pp for multiple platforms. Both lineinfo and lnfodwrf shall use the new unit. Keep also in mind that only routines from the system unit can be used, so no streams from classes unit.

Peter

Reply by email

Fabio Dell'Aria
to Vincent Snijders: Write support for it in the lineinfo and lnfodwrf units. You can find those units in…

Hi,

2008/1/17, Vincent Snijders :

Show quoted text 17 lines
Fabio Dell'Aria schreef: > Hi to all, > > I'm writing a patch to can use an external .dbg file during the > debugging process. > > All works fine but when an unhandled exception is raised the RTL show > stacktrace without debug info (no sources line). > > How I can instruct the RTL to search the debug symbols in a > project.dbg file (if not found in the executable)? > Write support for it in the lineinfo and lnfodwrf units. You can find those units in fpc\rtl\inc. Vincent

These 2 units uses the "f" and "infile" files to read the debug data, but I cannot find the unit that assign these files. Where can I looking for?

Best regards... Fabio Dell'Aria.

Reply by email

Michael Van Canneyt
to Fabio Dell'Aria: I'm writing a patch to can use an external .dbg file during the debugging process. All…
Fabio Dell'Aria wrote 10 lines
Hi to all, I'm writing a patch to can use an external .dbg file during the debugging process. All works fine but when an unhandled exception is raised the RTL show stacktrace without debug info (no sources line). How I can instruct the RTL to search the debug symbols in a project.dbg file (if not found in the executable)?

See function openstabs in lineinfo:

function OpenStabs:boolean;
var
  ofm : word;
begin
  OpenStabs:=false;
  assign(f,paramstr(0));

and for dwarf in lnfodwarf there is OpenDwarf:

function OpenDwarf() : Boolean;
var
  oldfilemode : Word;
begin
  OpenDwarf := false;
  { open input file }
  assign(infile, paramstr(0));
  {$I-}

Michael.

Reply by email

Fabio Dell'Aria
to Michael Van Canneyt

Hi,

2008/1/17, Michael Van Canneyt :

Show quoted text 34 lines
On Thu, 17 Jan 2008, Fabio Dell'Aria wrote: > Hi to all, > > I'm writing a patch to can use an external .dbg file during the > debugging process. > > All works fine but when an unhandled exception is raised the RTL show > stacktrace without debug info (no sources line). > > How I can instruct the RTL to search the debug symbols in a > project.dbg file (if not found in the executable)? See function openstabs in lineinfo: function OpenStabs:boolean; var ofm : word; begin OpenStabs:=false; assign(f,paramstr(0)); and for dwarf in lnfodwarf there is OpenDwarf: function OpenDwarf() : Boolean; var oldfilemode : Word; begin OpenDwarf := false; { open input file } assign(infile, paramstr(0)); {$I-}

Thank you very much! :)

I'm working on. ;)

Best regards... Fabio Dell'Aria.

Reply by email

Bogusław Brandys
to Fabio Dell'Aria: 2008/1/17, Michael Van Canneyt : Thank you very much! :) I'm working on. ;) Best…
Fabio Dell'Aria wrote 40 lines
Hi, 2008/1/17, Michael Van Canneyt : > > On Thu, 17 Jan 2008, Fabio Dell'Aria wrote: > >> Hi to all, >> >> I'm writing a patch to can use an external .dbg file during the >> debugging process. >> >> All works fine but when an unhandled exception is raised the RTL show >> stacktrace without debug info (no sources line). >> >> How I can instruct the RTL to search the debug symbols in a >> project.dbg file (if not found in the executable)? > See function openstabs in lineinfo: > > function OpenStabs:boolean; > var > ofm : word; > begin > OpenStabs:=false; > assign(f,paramstr(0)); > > and for dwarf in lnfodwarf there is OpenDwarf: > > function OpenDwarf() : Boolean; > var > oldfilemode : Word; > begin > OpenDwarf := false; > { open input file } > assign(infile, paramstr(0)); > {$I-} Thank you very much! :) I'm working on. ;)

I think it should by default look for program.dbg file , and then if not exists for paramstr(0). Is that enough ? If so,please explain how to check if file exists , which function could be used here.

Regards
Boguslaw

Reply by email

Tomas Hajny
to Vincent Snijders: No, as Peter described, you should look in the executable for a link to the file with…
Vincent Snijders wrote 9 lines
Bogusław Brandys schreef: > > I think it should by default look for program.dbg file , and then if not > exists for paramstr(0). Is that enough ? If so,please explain how to > check if file exists , which function could be used here. No, as Peter described, you should look in the executable for a link to the file with debug info.

Moreover, if the debug information is included within the executable file directly, there's probably no need to look for an external file, IMHO, so if the proper link isn't available and we would want to support external files anyway, the preference should be probably the other way round (first paramstr(0), then paramstr(0) with extension changed to .dbg or something like that).

Tomas

Reply by email

Peter Vreman
Show quoted text 14 lines
>> I think it should by default look for program.dbg file , and then if not >> exists for paramstr(0). Is that enough ? If so,please explain how to >> check if file exists , which function could be used here. > > No, as Peter described, you should look in the executable for a link to > the file > with debug info. Moreover, if the debug information is included within the executable file directly, there's probably no need to look for an external file, IMHO, so if the proper link isn't available and we would want to support external files anyway, the preference should be probably the other way round (first paramstr(0), then paramstr(0) with extension changed to .dbg or something like that).

I don't agree. We should not support looking implicitly for a .dbg without a gnu_debuglink section. Because there is no garauntee that the .dbg and the .exe will match. The gnu_debuglink is the only reliable way, because it uses a build-id or a checksum verification.

Peter

Reply by email

Bogusław Brandys
to Vincent Snijders: No, as Peter described, you should look in the executable for a link to the file with…
Vincent Snijders wrote 10 lines
Bogusław Brandys schreef: > > I think it should by default look for program.dbg file , and then if > not exists for paramstr(0). Is that enough ? If so,please explain how > to check if file exists , which function could be used here. No, as Peter described, you should look in the executable for a link to the file with debug info. Vincent

I see - this is the perfect situation.I thought about fast hack ;-)

Reply by email

Fabio Dell'Aria
to Peter Vreman: I don't agree. We should not support looking implicitly for a .dbg without a gnu_debuglink

Hi,

2008/1/17, Peter Vreman :

Show quoted text 20 lines
>>> I think it should by default look for program.dbg file , and then if not >>> exists for paramstr(0). Is that enough ? If so,please explain how to >>> check if file exists , which function could be used here. >> >> No, as Peter described, you should look in the executable for a link to >> the file >> with debug info. > > Moreover, if the debug information is included within the executable file > directly, there's probably no need to look for an external file, IMHO, so > if the proper link isn't available and we would want to support external > files anyway, the preference should be probably the other way round (first > paramstr(0), then paramstr(0) with extension changed to .dbg or something > like that). I don't agree. We should not support looking implicitly for a .dbg without a gnu_debuglink section. Because there is no garauntee that the .dbg and the .exe will match. The gnu_debuglink is the only reliable way, because it uses a build-id or a checksum verification. Peter

I'm sorry but I'm NOT ABLE to create a patch to read and verify the gnu_debuglink section.
I'm ONLY able to search for an external .dbg file (the same of the .exe but simply renamed).

So I think others must write this path, I'm really sorry to cannot help! :(

A voluntary? ;)

Best regards... Fabio Dell'Aria.

Reply by email

Tomas Hajny
to Peter Vreman: I don't agree. We should not support looking implicitly for a .dbg without a gnu_debuglink
Peter Vreman wrote 26 lines
>>> I think it should by default look for program.dbg file , and then if >>> not >>> exists for paramstr(0). Is that enough ? If so,please explain how to >>> check if file exists , which function could be used here. >> >> No, as Peter described, you should look in the executable for a link to >> the file >> with debug info. > > Moreover, if the debug information is included within the executable > file > directly, there's probably no need to look for an external file, IMHO, > so > if the proper link isn't available and we would want to support external > files anyway, the preference should be probably the other way round > (first > paramstr(0), then paramstr(0) with extension changed to .dbg or > something > like that). I don't agree. We should not support looking implicitly for a .dbg without a gnu_debuglink section. Because there is no garauntee that the .dbg and the .exe will match. The gnu_debuglink is the only reliable way, because it uses a build-id or a checksum verification.

I don't think there's a contradiction - I wrote "if ... we would want to support external files". I understand very well that we might not want to support that for reasons you just mentioned.

Tomas

Reply by email