Recent

Author Topic: How to prevent Lazarus debugger GDB from branching into library units?  (Read 9915 times)

Michael Diegelmann

  • New member
  • *
  • Posts: 7
    • MichaelGraphics Software Tools
When running a Lazarus Object Pascal program in debug mode, the debugger opens up a dozen LCL library units in the IDE editor and branches to all of these units after finishing any of my event handler routines with the F4 key. Due to the countless Windows messages coming in all the time, it is often hard or even impossible to make the debugger branch back to my own source code. How can I prevent this from happening and instead restrict the debugger to my own source code units only?

I assume (or at least I hope) that the solution of my problem will simply be finding the right IDE / compiler / debugger option (however deeply hidden somewhere in the Lazarus menu labyrinth) to be set to the appropriate value. Unfortunately, setting the debugger option DisableLoadSymbolsForLibraries didn't do the job.
« Last Edit: November 09, 2015, 09:18:26 am by Michael Diegelmann »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12710
  • FPC developer.
Re: How to prevent Lazarus debugger GDB from branching into library units?
« Reply #1 on: November 09, 2015, 12:01:02 pm »
See comments at http://stackoverflow.com/questions/33573822/prevent-lazarus-debugger-branching-into-library-units
 
     
That option (DisableLoadSymbolsForLibraries) is about loading symbols from DLLs, not for units in the EXE. Probably it is something like tools-> configure lazarus followed by tools->build lazarus to generate a new set of units without debug info.


Lazarus doesn't have two sets of units preinstalled like Delphi.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12195
  • Debugger - SynEdit - and more
    • wiki
Re: How to prevent Lazarus debugger GDB from branching into library units?
« Reply #2 on: November 09, 2015, 01:13:13 pm »
You need to recompile the LCL (and any other affected package) without debug info.
Each package has its own settings, reachable from the package dialog.

You can also disable it by using "overrides and additions" in the project (search wiki).


I noted you wrote "F4". Just a quick explanation:

F4 works only within the current function.

You can not use F4 to step into another function. If you do so F4 will stop when you leave the current function.

Well it can be used to go to functions called by the current function, because then the current function is still active.

http://bugs.freepascal.org/view.php?id=21958#c59370
« Last Edit: November 09, 2015, 01:15:16 pm by Martin_fr »

Michael Diegelmann

  • New member
  • *
  • Posts: 7
    • MichaelGraphics Software Tools
Re: How to prevent Lazarus debugger GDB from branching into library units?
« Reply #3 on: November 09, 2015, 02:27:08 pm »
Thank you for your attempt to solve my problem! However, being a newcomer to Lazarus, I did not understand your following suggestion:

You can also disable it by using "overrides and additions" in the project

I cannot find anything like or similar to "overrides and additions" in the project menu. Which menu item should I look for?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12710
  • FPC developer.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12195
  • Debugger - SynEdit - and more
    • wiki
Re: How to prevent Lazarus debugger GDB from branching into library units?
« Reply #5 on: November 09, 2015, 02:47:34 pm »
It is easier to open the packages and edit it there (more work, but easier)

Not sure what you want to archive, but if it is something like:

step through Button1Click, and after stepping out of it, run your app, until for example Edit1Changed is triggered, then you need to set a breakpoint.

There is no stepping function (neither F4, F7 nor F8) that will find the next triggered event automatically.

Also as I said, if you are in Button1Click then you can not use F4 to get to Edit1Changed.

If you remove debug info, they will either Run (F9), or open the assembler view.

Michael Diegelmann

  • New member
  • *
  • Posts: 7
    • MichaelGraphics Software Tools
Re: How to prevent Lazarus debugger GDB from branching into library units?
« Reply #6 on: November 09, 2015, 05:31:37 pm »
To marcov:
My Lazarus IDE v1.4.0 does not provide any such thing as IDE_Window:_Compiler_Options#Additions_and_Overrides - or I am simply too stupid to find it (see the following screen shot, unfortunately in German)
http://www2.fh-rosenheim.de/diegelmann/Download/MyCloud/Lazarus_v1.4.0 IDE_Menu_Project-Project_Options_plus_Form_Project_Options.png

To Martin_fr:
Quote
It is easier to open the packages and edit it there (more work, but easier)
a) Which package(s)?
b) What do you mean by 'opening a package'?
c) What exactly would I have to edit there?

Quote
Not sure what you want to archive
I do not want to save anything at all to whatever archive. What should that be good for? All I want to do is the following:
Assume you have some event handler routine Botton1Click which causes some sort of exception and I suspect this to arise from a particular statement. I will then place a breakpoint a few lines of code before the suspected location in order to see in debug mode why, say, a certain variable gets a value that finally causes the exception (e.g. division by zero). After having traced through these statements of interest, I would then like the program to proceed to the next breakpoint (however, not in single step mode F7 or F8 but all at once) or I want it to finish Botton1Click and to continue its normal flow of operations. In order to do this, I used to press F4. At least in Delphi 5,7,XE5,XE8 this works fine. Why not in Lazarus?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12195
  • Debugger - SynEdit - and more
    • wiki
Re: How to prevent Lazarus debugger GDB from branching into library units?
« Reply #7 on: November 09, 2015, 06:16:16 pm »
F9 is run to next breakpoint.

F4 is run to either (whatever comes first)
- the line in which the caret is
- the exit/end of the current procedure (that is what you encounter)
- a breakpoint

IIRC F4 differs from setting a (temp) breakpoint in that line, because it will not stop at the line, if it is reached in a recursive call.

-----------------------------

Open the project inspector. Packages are at the bottom of the list.
Double click to open, then in the package window choose options, and disable debug (this is for the package, and affects the package for ALL projects that use it).

Also in the package window there will be more packages listed. Recursively follow the steps.

Zoran

  • Hero Member
  • *****
  • Posts: 1988
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: How to prevent Lazarus debugger GDB from branching into library units?
« Reply #8 on: November 09, 2015, 07:03:31 pm »
When running a Lazarus Object Pascal program in debug mode, the debugger opens up a dozen LCL library units in the IDE editor and branches to all of these units after finishing any of my event handler routines with the F4 key. Due to the countless Windows messages coming in all the time, it is often hard or even impossible to make the debugger branch back to my own source code. How can I prevent this from happening and instead restrict the debugger to my own source code units only?

I assume (or at least I hope) that the solution of my problem will simply be finding the right IDE / compiler / debugger option (however deeply hidden somewhere in the Lazarus menu labyrinth) to be set to the appropriate value. Unfortunately, setting the debugger option DisableLoadSymbolsForLibraries didn't do the job.

The simplest solution would be to rebuild lazarus with predefined "optimized ide" -- in main menu go to: tools->configure "Build Lazarus"... then in combo box chose profile to build -- it's probably set to "Normal IDE", you change to "Optimized IDE". Then check "Clean All" radio button and click on "Build" button. Lazarus will start recompiling itself. After it is done, you should have LCL recompiled without debug simbols and GDB will not jump into LCL units.
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

Michael Diegelmann

  • New member
  • *
  • Posts: 7
    • MichaelGraphics Software Tools
Re: How to prevent Lazarus debugger GDB from branching into library units?
« Reply #9 on: November 10, 2015, 12:07:31 am »
To Martin_fr:
Thanx for your detailed recipe! It worked perfectly and my problem has been solved this way.  :D  See the following screen shot (unfortunately in German):
http://www2.fh-rosenheim.de/diegelmann/Download/MyCloud/Lazarus_v1.4.0 IDE_Menu_Project-Project_Inspector.png

To Zoran:
Thanx for your suggestion! You Linux guys may be used to recompile giant programs such as Lazarus. But me, being a Windows user, I would never ever dare to do this kind of thing, because most likely this will screw up your entire system leaving you with a couple of patched DLLs in your WINDOWS\system32 directory and your registry being corrupted forever. In other words, total disaster! Never change a running system (as long as it's based on Windows). For that reason I have preferred Martin_fr's approach. Sorry for that. But don't worry, that's not your fault.  >:D
« Last Edit: November 10, 2015, 12:37:57 am by Michael Diegelmann »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4693
  • I like bugs.
Re: How to prevent Lazarus debugger GDB from branching into library units?
« Reply #10 on: November 10, 2015, 12:33:27 am »
Thanx for your suggestion! You Linux guys may be used to recompile giant programs such as Lazarus. But me, being a Windows user, I would never ever dare to do this kind of thing, because most likely this will screw up your entire system leaving you with a couple of patched DLLs in your WINDOWS\system32 directory and your registry being corrupted forever. In other words, total disaster! Never change a running system (as long as it's based on Windows).

No. You must rebuild Lazarus every time you install an IDE package. Dynamic packages are not supported yet.
Your bad memories are from big C++ applications but this is different. Rebuilding is easy. There are minimal dependencies. It does not use neither registry nor Windows system dir.
You better get used to it, you will install some IDE package someday for sure.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12195
  • Debugger - SynEdit - and more
    • wiki
Re: How to prevent Lazarus debugger GDB from branching into library units?
« Reply #11 on: November 10, 2015, 04:10:30 am »
Glad it works.

About recompiling: No worry there. Lazarus itself does not touch the registry at all. Only the installer for windows creates entries to associate files, and register the uninstaller. that is all the registry there is.

Same for dll. The only dll that is installed (in system) is for Qt (if you set the checkbox in the installer.
There are a few dll in the lazarus folder itself.

Recompiling happens in the Lazarus folder only. It creates a backup of the old Lazarus.exe too, so you can roll back.

Settings are either in the project folder or in C:\Users\USERNAME\AppData\Local\lazarus

Zoran

  • Hero Member
  • *****
  • Posts: 1988
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: How to prevent Lazarus debugger GDB from branching into library units?
« Reply #12 on: November 10, 2015, 11:14:53 am »
To Martin_fr:
Thanx for your detailed recipe! It worked perfectly and my problem has been solved this way.  :D  See the following screen shot (unfortunately in German):
http://www2.fh-rosenheim.de/diegelmann/Download/MyCloud/Lazarus_v1.4.0 IDE_Menu_Project-Project_Inspector.png

To Zoran:
Thanx for your suggestion! You Linux guys may be used to recompile giant programs such as Lazarus. But me, being a Windows user, I would never ever dare to do this kind of thing, because most likely this will screw up your entire system leaving you with a couple of patched DLLs in your WINDOWS\system32 directory and your registry being corrupted forever. In other words, total disaster! Never change a running system (as long as it's based on Windows). For that reason I have preferred Martin_fr's approach. Sorry for that. But don't worry, that's not your fault.  >:D

Actually I do it on Windows all the time :). Okay, yes, I do it on Linux too.
Normal usage of Lazarus includes recompiling the IDE. As Juha and Martin say, there is nothing dangerous in it, Lazarus does not touch registry or Windows system directory.
I am glad you solved this particular problem, but I am sorry you are afraid of rebuild Lazarus. That means that you will not be able to use any package that is not installed by default.
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

 

TinyPortal © 2005-2018