Sign in Join

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

Mailing lists / fpc-devel / 2010-08

Which unit does -gl parameter use?

9 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

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

Graeme Geldenhuys

Hi,

When you add the -gl (debug line info added to compiled executable) parameter to a project, which unit does it use to gather the debug information?

LineInfo (via stab information) or LnfoDwrf (via dwarf information)?

How do you toggle between the two? How do I know which one of the two is being used?

At the moment, when I compile with -gl, then the GetLineInfo doesn't return any function name information. I then removed the -gl and explicitly added LnfoDwrf into my project uses clause (thinking that Stab info might be old and outdated), and still the function name information return by GetLineInfo was blank. I'm testing on a 64-bit Linux system.

Regards,   - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Sven Barth
to Graeme Geldenhuys
Graeme Geldenhuys wrote 20 lines
Hi, When you add the -gl (debug line info added to compiled executable) parameter to a project, which unit does it use to gather the debug information? LineInfo (via stab information) or LnfoDwrf (via dwarf information)? How do you toggle between the two? How do I know which one of the two is being used? At the moment, when I compile with -gl, then the GetLineInfo doesn't return any function name information. I then removed the -gl and explicitly added LnfoDwrf into my project uses clause (thinking that Stab info might be old and outdated), and still the function name information return by GetLineInfo was blank. I'm testing on a 64-bit Linux system.

According to the code in compiler\pmodules.pas (~659) (see below) the compiler decides this depending on the used debug format. I might be wrong, but for Linux this should be dwarf.

{ Lineinfo unit }
if (cs_use_lineinfo in current_settings.globalswitches) then begin
   if (paratargetdbg = dbg_stabs) then
     AddUnit('lineinfo')
   else
     AddUnit('lnfodwrf');
end;

Regards,
Sven

Reply by email

Jonas Maebe
to Sven Barth
Sven Barth wrote
According to the code in compiler\pmodules.pas (~659) (see below) the compiler decides this depending on the used debug format. I might be wrong, but for Linux this should be dwarf.

As a rule of the thumb, the default debug informat for 32 bit platforms (except for iPhoneOS/iOS) is stabs and that for 64 bit platforms is DWARF. You can force one or the other using -gw/-gs (although stabs generally doesn't work very well on 64 bit platforms).

Jonas

Reply by email

Thomas Schatzl
to Graeme Geldenhuys: When you add the -gl (debug line info added to compiled executable) parameter to a…

Hi,

Graeme Geldenhuys wrote 10 lines
Hi, When you add the -gl (debug line info added to compiled executable) parameter to a project, which unit does it use to gather the debug information? LineInfo (via stab information) or LnfoDwrf (via dwarf information)? How do you toggle between the two? How do I know which one of the two is being used?

You toggle using the -gX options. -gs forces stabs, and -gw forces dwarf. The default selects according to the platform. I remember the logic is something like this:

32 bit systems (except on OSX iirc?): stabs
64 bit systems: dwarf

Do not bother forcing stabs on 64 bit systems. It will not work correctly and is not supported.

At the moment, when I compile with -gl, then the GetLineInfo doesn't return any function name information. I then removed the -gl and explicitly added LnfoDwrf into my project uses clause (thinking that Stab info might be old and outdated), and still the function name

Stabs is old and outdated, but it has the advantage that it can print the function information. See below too.

information return by GetLineInfo was blank. I'm testing on a 64-bit Linux system.

A limitation of the current dwarf reader is that it only parses the so-called "debug_line" section of the DWARF debug info containing a mapping from instruction address to a line number. There is no information about the function (or "compilation unit") which is currently being processed there.

The mapping from address to a function name is stored in a different section of the DWARF debug info, called "debug_aranges" which provides a mapping of instruction addresses to function names. The compiler does not generate a "debug_aranges" section as far as I know. If it were available, adding this feature would be straigthforward.

The other option would be to parse the whole DWARF debug info to associate an instruction address to a function name.

If the line number output of the lnfodwrf unit does not match the actual source line, you found a bug in the compiler or RTL.

Hth,
Thomas

Reply by email

Sven Barth
to Jonas Maebe: As a rule of the thumb, the default debug informat for 32 bit platforms (except for…
Jonas Maebe wrote 11 lines
On 23 Aug 2010, at 11:03, Sven Barth wrote: > According to the code in compiler\pmodules.pas (~659) (see below) the > compiler decides this depending on the used debug format. I might be > wrong, but for Linux this should be dwarf. As a rule of the thumb, the default debug informat for 32 bit platforms (except for iPhoneOS/iOS) is stabs and that for 64 bit platforms is DWARF. You can force one or the other using -gw/-gs (although stabs generally doesn't work very well on 64 bit platforms).

I should remember this ^^

Is there any comment about the function name restrictions mentioned in Thomas' mail? In what regards is DWARF better suited than stabs (besides 64-bit support)? Or is there even a FPC wiki page about the pros and cons of the two debug formats?

Regards,
Sven

Reply by email

Graeme Geldenhuys
to Sven Barth

Op 2010-08-23 11:55, Sven Barth het geskryf:

Is there any comment about the function name restrictions mentioned in Thomas' mail?

That is rather crucial information that is missing, especially in my current case where I am trying to do profiling of our projects.

I'm much rather use fpprofiler than valgrind. The latter is soooo sloooow while profiling, that it makes it impossible for us to run our applications. On the flip side, fpprofiler is fast, but relies on information retrieved by -gl compiler parameter.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Graeme Geldenhuys
to Thomas Schatzl: On Mon, 23 Aug 2010 10:23:52 +0200, Graeme Geldenhuys You toggle using the -gX options.…

Op 2010-08-23 11:24, Thomas Schatzl het geskryf:

Show quoted text 6 lines
A limitation of the current dwarf reader is that it only parses the so-called "debug_line" section of the DWARF debug info containing a mapping from instruction address to a line number. There is no information about the function (or "compilation unit") which is currently being processed there.

Thanks for the information Thomas.

Is here anybody with DWARF knowledge that could contribute to the crucial part of line information - the missing function names under 64-bit platforms?

This limitation makes FPCUnit, DUnit2 and fpprofiler under 64-bit platforms pretty useless. :-(

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Sergei Gorelkin
to Graeme Geldenhuys

Graeme Geldenhuys пишет:

This limitation makes FPCUnit, DUnit2 and fpprofiler under 64-bit platforms pretty useless. :-(

Well, I don't know about DUnit2 and fpprofiler, but FPCUnit is currently hardcoded to use LineInfo - so it won't display anything if actual type of debug information is DWARF.

Regards,
Sergei

Reply by email

Graeme Geldenhuys
to Sergei Gorelkin

Op 2010-08-23 14:02, Sergei Gorelkin het geskryf:

> Well, I don't know about DUnit2 and fpprofiler, but FPCUnit is currently hardcoded to use LineInfo - so it won't display anything if actual type of debug information is DWARF.

While I did my testing I custom compiled it, and changed the uses clause to use LnfoDwrf.

Either way, under a 64-bit platform FPCUnit never returned function/procedure/method name information. Stabs or Dwarf.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email