Recent

Author Topic: [CLOSED] Disable debugger  (Read 2440 times)

pcurtis

  • Hero Member
  • *****
  • Posts: 739
[CLOSED] Disable debugger
« on: October 21, 2021, 12:21:09 pm »
Is there a way to disable the debugger for a section of code?
« Last Edit: October 21, 2021, 08:13:54 pm by pcurtis »
Windows 10
Laz 2.0.10
FPC 3.2.0

ccrause

  • Sr. Member
  • ****
  • Posts: 480
Re: Disable debugger
« Reply #1 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.

josh

  • Hero Member
  • *****
  • Posts: 833
Re: Disable debugger
« Reply #2 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
Development Installation Lazarus 1.3, FPC 2.7.1,Windows 7/8 32/64, OSX, *nix

Test Environment Lazarus & FPC Trunk on Windows and OSX (Cocoa Mainly on OSX). Testing also Crosscompile windows to OSX.. 
Any posts made from 2015 will be based on Lazarus Trunk.

MarkMLl

  • Hero Member
  • *****
  • Posts: 3459
Re: Disable debugger
« Reply #3 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
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

ccrause

  • Sr. Member
  • ****
  • Posts: 480
Re: Disable debugger
« Reply #4 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

MarkMLl

  • Hero Member
  • *****
  • Posts: 3459
Re: Disable debugger
« Reply #5 on: October 21, 2021, 03:13:12 pm »
Thanks for checking and correcting me :-)

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7508
  • Debugger - SynEdit - and more
    • wiki
Re: Disable debugger
« Reply #6 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.

MarkMLl

  • Hero Member
  • *****
  • Posts: 3459
Re: Disable debugger
« Reply #7 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
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7508
  • Debugger - SynEdit - and more
    • wiki
Re: Disable debugger
« Reply #8 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