Lazarus

Using the Lazarus IDE => Debugger => Topic started by: pcurtis on October 21, 2021, 12:21:09 pm

Title: [CLOSED] Disable debugger
Post by: pcurtis on October 21, 2021, 12:21:09 pm
Is there a way to disable the debugger for a section of code?
Title: Re: Disable debugger
Post by: ccrause on October 21, 2021, 02:09:50 pm
In a roundabout way, perhaps.  Move the code you don't want to debug into a unit (or units), disable all debug info, then compile with -Ur option.  Then move unit source and compiled unit (.o and .ppu) to a separate folder (this may not be necessary, but in my case it avoids confusion), add this folder to the project (or compiler command line using -Fu).

Now a debugger will not find debug info for the compiled unit, and Lazarus will not try to recompile the unit to add back the debug info (which you obviously want to add to your project).

This way you can still "step into instruction" when in assembler view, but normal F7 should step over a function call into this unit.
Title: Re: Disable debugger
Post by: josh on October 21, 2021, 02:13:19 pm
If i remeber correctly, delphi you could do

Code: Pascal  [Select][+][-]
  1. {$IFDEF DEBUG}
  2. {$D-}
  3. {$ENDIF}
  4.  
  5. ....  your code
  6.  
  7. {$IFDEF DEBUG}
  8. {$D+}
  9. {$ENDIF}
  10.  

never tried it laz/fpc + i could be totally wrong

Josh
Title: Re: Disable debugger
Post by: MarkMLl on October 21, 2021, 03:01:11 pm
never tried it laz/fpc + i could be totally wrong

Documentation at https://www.freepascal.org/docs-html/current/prog/progsu89.html#x97-960001.3.6 suggests that it's supported, so is worth trying.

MarkMLl
Title: Re: Disable debugger
Post by: ccrause on October 21, 2021, 03:10:19 pm
never tried it laz/fpc + i could be totally wrong

Documentation at https://www.freepascal.org/docs-html/current/prog/progsu89.html#x97-960001.3.6 suggests that it's supported, so is worth trying.

MarkMLl
It is a global directive, so would not give local control over debug info.  I've tested this with FPC 3.2.0 and Lazarus 2.0.10 (win64), where the directive did not appear to have any effect at all  :o
Title: Re: Disable debugger
Post by: MarkMLl on October 21, 2021, 03:13:12 pm
Thanks for checking and correcting me :-)

MarkMLl
Title: Re: Disable debugger
Post by: Martin_fr on October 21, 2021, 03:36:38 pm
If you do not want to "step in" => disable debug info for that code (that is per package only // well you may be able to do per unit, but not sure)

If it is exception handling => no, because that happens in the code of the "raise" procedure, and therefore is not bound to any section of code.
Title: Re: Disable debugger
Post by: MarkMLl on October 21, 2021, 07:19:47 pm
If you do not want to "step in" => disable debug info for that code (that is per package only // well you may be able to do per unit, but not sure)

If I might ask a stupid question: what is a package in this context? If it's to do with Lazarus rather than FPC, what would happen if a program were built with a makefile?

MarkMLl
Title: Re: Disable debugger
Post by: Martin_fr on October 22, 2021, 01:54:15 pm
If you do not want to "step in" => disable debug info for that code (that is per package only // well you may be able to do per unit, but not sure)

If I might ask a stupid question: what is a package in this context? If it's to do with Lazarus rather than FPC, what would happen if a program were built with a makefile?

MarkMLl
Lazarus Package.

In Lazarus you have compiler options for the project, and each package.
So if you want to compile a single unit without debug info ....
TinyPortal © 2005-2018