Recent

Author Topic: Testers wanted: FpDebug on Linux and Windows  (Read 9323 times)

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 370
Re: Testers wanted: FpDebug on Linux and Windows
« Reply #15 on: July 28, 2020, 10:03:54 am »
Martin,

Thanks for FpDebug!

Will FpDebug support external symbols (-Xg)?

We use -Xg in our app to link statically some GCC .o libraries.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Testers wanted: FpDebug on Linux and Windows
« Reply #16 on: July 28, 2020, 11:17:43 am »
Will FpDebug support external symbols (-Xg)?

We use -Xg in our app to link statically some GCC .o libraries.

It should already do (at least in basic cases). I tested on Windows, but IIRC should be Linux too.

Note that debugging in libraries (dll/so) files is still work in progress. You have to test and see what works.

wp

  • Hero Member
  • *****
  • Posts: 11856
Re: Testers wanted: FpDebug on Linux and Windows
« Reply #17 on: July 28, 2020, 12:13:13 pm »
With my current gdb issues with console applications I finally decided to give fpdebug a try. And I must say I am extraordinarily surprised. It's almost like working with Delphi finally! Fly-over hints of properties? No problem (well, mostly...). 10 to 20 seconds waiting before the FileDialog opens in the debugger? No problem. I think i can do 90% of my debug work with it.

For those who like myself are confused by the many debugger packages available in the standard installation here are the steps that I took to make it work

- Go to "Package" > "Install/Uninstall packages". Make sure that LazDebuggerFp is installed (if not, install the package).
- Go to "Tools" > "Options" > "Debugger". In the gray combobox "Debugger type and paths" which usually displays "GNU debugger (gdb)", select "FpDebug standard Dwarf debugger (beta)".
- After compilation of a project you will be prompted to select which kind of dwarf debugging informations is too be used. The selection is written to the project file. (I hope permanent selection here is not a problem when the project is passed to others, like in my forum posts)

@Martin: There is also a package fpdebug. It is not installed on my systems. Is it needed?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Testers wanted: FpDebug on Linux and Windows
« Reply #18 on: July 28, 2020, 12:20:36 pm »
With my current gdb issues with console applications I finally decided to give fpdebug a try. And I must say I am extraordinarily surprised. It's almost like working with Delphi finally! Fly-over hints of properties? No problem (well, mostly...). 10 to 20 seconds waiting before the FileDialog opens in the debugger? No problem. I think i can do 90% of my debug work with it.
Properties (or the working subset of them) are actually not fpdebug specific.

They are stabs vs dwarf. However fpdebug only supports dwarf, so you were forced to select that.

With dwarf, fpc writes info for properties that read the field directly (that is there is no getter proc).
When using dwarf, gdb will show the same set of properties.
https://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Properties

However, with FpDebug you can use "Dwarf 3" and get the names in stack/locals/... in normal case as declared (instead of all uppercase).

Gdb does dwarf-3, but  dwarf3 increases the risk of gdb crashing.

Quote
@Martin: There is also a package fpdebug. It is not installed on my systems. Is it needed?
Its used by LazDebuggerFp. So its compiled in.

But it does not need to be installed.

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 370
Re: Testers wanted: FpDebug on Linux and Windows
« Reply #19 on: July 28, 2020, 01:34:56 pm »
Martin,

I found a reason of the problem.

FpDebugger doesn't work on Windows 10 when Project Options use an option "Use external debug symbols file (-Xg)".

I see a warning, that FpDebugger doesn't work in this mode.

I prefer this option to reduce EXE file size. Of course, I perform strip command for a release version.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Testers wanted: FpDebug on Linux and Windows
« Reply #20 on: July 28, 2020, 02:25:42 pm »
FpDebugger doesn't work on Windows 10 when Project Options use an option "Use external debug symbols file (-Xg)".

Ouch, my fault. I recently had to fix something on the gdb debugger. So my debugger was set to gdb.

Indeed, FpDebug does not yet support that.


It should not be too much work to implement. But I do not know when I will have time for it

It needs to be done in unit FpImgReaderWinPE (package FpDebug)

For the "how to" see unit LNfoDwarf (part of fpc), and exeinfo.
Code: Pascal  [Select][+][-]
  1. function OpenDwarf(addr : codepointer) : boolean;
  2.   if ReadDebugLink(e,dbgfn) then
  3.  
and the code in ReadDebugLink.

---
The warning prompt can be configured in
class function TFpDebugDebugger.RequiredCompilerOpts(ATargetCPU, ATargetOS: String): TDebugCompilerRequirements;
"dcrNoExternalDbgInfo"
« Last Edit: July 28, 2020, 02:29:26 pm by Martin_fr »

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 370
Re: Testers wanted: FpDebug on Linux and Windows
« Reply #21 on: July 28, 2020, 07:29:00 pm »
Martin,

Thanks! It's not critical problem and it can wait.

calebs

  • Full Member
  • ***
  • Posts: 190
Re: Testers wanted: FpDebug on Linux and Windows
« Reply #22 on: August 11, 2020, 09:45:31 pm »
Hello all
i've followed all these steps and enabled fpdebugger but sometimes when i press f7 instead of f8 to enter a function or procedure it gives me protection fault.
Im using lazarus 2.0.10 rev 63526 x86 with windows 10x64 compiling in x86 mode (not x64).
Also, f7 doesn't get inside the code in control.inc for example when i press f7 on labeledit.caption:='hi'; (which is very anoying to me because i don't want to debug the master work of lazarus devs, only my mess lol) but i don't know if its normal.
When asked about debug info type  i've selected dwarf3-beta.
With dwarf2 also fails with f7 on some lines.

Is this normal because i'm not using trunk? thanks!


With my current gdb issues with console applications I finally decided to give fpdebug a try. And I must say I am extraordinarily surprised. It's almost like working with Delphi finally! Fly-over hints of properties? No problem (well, mostly...). 10 to 20 seconds waiting before the FileDialog opens in the debugger? No problem. I think i can do 90% of my debug work with it.

For those who like myself are confused by the many debugger packages available in the standard installation here are the steps that I took to make it work

- Go to "Package" > "Install/Uninstall packages". Make sure that LazDebuggerFp is installed (if not, install the package).
- Go to "Tools" > "Options" > "Debugger". In the gray combobox "Debugger type and paths" which usually displays "GNU debugger (gdb)", select "FpDebug standard Dwarf debugger (beta)".
- After compilation of a project you will be prompted to select which kind of dwarf debugging informations is too be used. The selection is written to the project file. (I hope permanent selection here is not a problem when the project is passed to others, like in my forum posts)

@Martin: There is also a package fpdebug. It is not installed on my systems. Is it needed?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Testers wanted: FpDebug on Linux and Windows
« Reply #23 on: August 11, 2020, 10:31:09 pm »
First of all: Dwarf2 vs Dwarf3 etc only matters for inspecting variables.
Line info (for stepping) should be the same for all of them.

First question is, if you have debug info (dwarf) for the LCL / LCLBase?
Does "procedure TControl.SetText(const Value: TCaption);" have the blue dots.

It may work under gdb, because if "debug info type" is "default -g", that may (on 32bit win) generate stabs. And fpdebug does not read stabs.
The dialog that pops up, requiring dwarf, only affect project files.

You can
- edit the Package options. LclBase
- tools > configure build lazarus. Add  -gw   or -gw3 to options, and save (no need to rebuild the IDE, packages will be rebuild on next run)
- Use "additions and overrides"

With debug info, it works for me. 32 bit 2.0.10 IDE on a Win64 PC.


Stepping had a major overhaul in trunk. There was no known fix for anything matching the above. But if the issue is not due to missing line info, then there still is a chance that it works in trunk.


calebs

  • Full Member
  • ***
  • Posts: 190
Re: Testers wanted: FpDebug on Linux and Windows
« Reply #24 on: September 02, 2020, 11:11:46 pm »
i've encountered a problem with fpdebug and posted here

https://forum.lazarus.freepascal.org/index.php/topic,51310.0.html

i forgot to add i'm using windows 10x64 and lazarus 2.0.10 r63526 x86

ccrause

  • Hero Member
  • *****
  • Posts: 845
Re: Testers wanted: FpDebug on Linux and Windows
« Reply #25 on: December 04, 2020, 09:10:38 am »
On Windows 10-64 and Lazarus 2.0.10 I noticed that debugging 32 bit applications from 32 bit Lazarus/fpdebug and 64 bit applications from 64 bit Lazarus/fpdebug works, but the cross bitness combinations fail.

When attempting to debug a 32 bit application with fpdebug (64 bit Lazarus) an error is displayed: "External exception 80000003".
When attempting to debug a 64 bit application with fpdebug (32 bit Lazarus) the executable fails to run and no error is displayed.

According to this Microsoft guide a debugger extension is required to debug 32 bit applications using a 64 bit debugger.  I'm not sure if other work-arounds exist, but this suggests that cross 32/64 bit debugging on Windows is more complicated than on Linux.

If this is true (I stopped poking around for Windows workarounds a long time ago), an information message to tell the user why debugging is not going to work seem appropriate.

Edit: I just noticed the following work-around for gdb. I guess in principle if fpdebug is compiled as a stand-alone executable that matches the bitness of the target executable it should also work, although I prefer to have fpdebug compiled into Lazarus.
« Last Edit: December 04, 2020, 09:21:52 am by ccrause »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Testers wanted: FpDebug on Linux and Windows
« Reply #26 on: December 04, 2020, 12:53:19 pm »
In trunk, a 64bit IDE can debug a 32bit target.

The other way round is not possible yet.
And indeed it gives no error, so that part should be reported on mantis.

wp

  • Hero Member
  • *****
  • Posts: 11856
Re: Testers wanted: FpDebug on Linux and Windows
« Reply #27 on: December 04, 2020, 01:07:40 pm »
As I wrote above I am an enthusiastic user of FPDebug now. There is one little annoyance, though: When I compile one of the Lazarus demos for example I am asked to switch to dwarf debug info. That's fine, but the problem is that this is now part of the project settings. When I commit this program back to svn (or git) the project settings are changed, and every subsequent user of this demo will have to use dwarf debug info. I think this should not happen. Is there a way to avoid changing the project settings when FPDebug is used, or to write the changed settings to the session file rather than to the lpi file?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Testers wanted: FpDebug on Linux and Windows
« Reply #28 on: December 04, 2020, 01:26:09 pm »
Is there a way to avoid changing the project settings when FPDebug is used, or to write the changed settings to the session file rather than to the lpi file?

Afaik, debug info is stored in session.

I opened one of the examples to check, and
  Project options > Session
showed
  "Save in lpi file"

IMHO, that should be set to "save in lps" for all examples.
That would then need to be committed once to svn.

I prefer lps in project dir, but if you want clean svn checkouts, then it needs to be in config dir (which afaik can lead to name clashes)

wp

  • Hero Member
  • *****
  • Posts: 11856
Re: Testers wanted: FpDebug on Linux and Windows
« Reply #29 on: December 04, 2020, 02:00:06 pm »
Oh, you are right. I was mislead by what is shown in the IDE - I thought that the debugger settings are always taken from the lpi.

I think that none of the examples uses build modes. But what if there were a sample with a buildmode in which the box "In Session" is not checked?

 

TinyPortal © 2005-2018