Difference between revisions of "Debugger Setup"

From Lazarus wiki
Jump to navigationJump to search
(14 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 +
{{Debugger Setup}}
 
__TOC__  
 
__TOC__  
= Configure the IDE =
 
  
 +
From Lazarus 2.0 onwards the IDE has an [https://forum.lazarus.freepascal.org/index.php/topic,42869.0.html LLDB based debugger for MacOS]. Many of the captions in the IDE still refer explicitly to [[GDB]], but the options apply to [[LLDB]] too.
 +
 +
== Configure the IDE ==
 
In order to be able to debug your projects, you need to make sure the IDE is correctly configured.
 
In order to be able to debug your projects, you need to make sure the IDE is correctly configured.
  
 
These settings do not usually change. You need to make them only once after you installed Lazarus, or if you changed/updated your installation
 
These settings do not usually change. You need to make them only once after you installed Lazarus, or if you changed/updated your installation
  
;Open the Lazarus option dialog:
+
;Open the Lazarus option dialog: [[image:Dbg_setup_options1.png]]
[[image:Dbg_setup_options1.png]]
 
  
 
The image shows where to find the option dialog in Lazarus 0.9.31 and up. In previous versions the entry is in the "Environment" menu.
 
The image shows where to find the option dialog in Lazarus 0.9.31 and up. In previous versions the entry is in the "Environment" menu.
  
 +
{{Note|In Lazarus Version 2.1 and up the setting below moved to Debugger > Backend}}
  
 
[[image:Dbg_setup_options2.png]]
 
[[image:Dbg_setup_options2.png]]
  
* Make sure that the option "Gnu debugger ([[GDB]])" is selected.
+
* Make sure that the option "GNU debugger ([[GDB]])" is selected.
 
* The path to gdb.exe may differ:
 
* The path to gdb.exe may differ:
 
** On Linux/Unix based systems it may be something like "/usr/bin/gdb"
 
** On Linux/Unix based systems it may be something like "/usr/bin/gdb"
 
** On Windows it should be in a folder called "mingw\bin\" under the directory in which Lazarus is installed.
 
** On Windows it should be in a folder called "mingw\bin\" under the directory in which Lazarus is installed.
  
= Project Options =
+
Lazarus 2.0 and up:
 +
On Windows 64 find the option "FixIncorrectStepOver" in the property grid and set it to enabled (true).
 +
 
 +
 
 +
* On MacOS, with Lazarus 2.0 or higher
 +
** Select "LLDB (with fpdebug)"
 +
** Set the path to: /usr/bin/lldb
  
 +
== Project Options ==
 
In order to debug your project, you need to tell the IDE to compile it in a special way, which provides additional information required by the debugger.
 
In order to debug your project, you need to tell the IDE to compile it in a special way, which provides additional information required by the debugger.
  
Please note: This will considerably increase the size of your executable ([[Lazarus_Faq#Why_are_the_generated_binaries_so_big.3F |See FAQ]]). If you want to build a release version of your software you should switch those settings off (see also [[IDE_Window:_Compiler_Options/de#Build_modes |Build Modes]])
+
Please note: This will considerably increase the size of your executable ([[Lazarus_Faq#Why_are_the_generated_binaries_so_big.3F |See FAQ]]). If you want to build a release version of your software you should switch those settings off (see also [[IDE_Window:_Compiler_Options#Build_modes |Build Modes]])
  
 
The required settings are made in the "Project Options" dialog:
 
The required settings are made in the "Project Options" dialog:
<table><tr><td> [[image:Dbg_setup_project1.png]] </td><td> [[image:Dbg_setup_project2.png]] </td></tr></table>
+
{|
 +
|-
 +
| [[image:Dbg_setup_project1.png]]  
 +
| [[image:Dbg_setup_project2.png]]  
 +
|}
  
 
* You must enable the "Generate Debug Info for GDB"
 
* You must enable the "Generate Debug Info for GDB"
** On Windows/Linux 32 bit it is highly recommended to use "Dwarf" <br>[[image:Dbg_setup_project3.png]]
+
** On Windows/Linux 32 bit it is highly recommended to use "Dwarf"  
 +
* If using the LLDB based debugger, you are not allowed to use "Stabs". You can choose any of the Dwarf settings. Best to set this explicitly, as "automatic" depends on your fpc version.
 +
<br>[[image:Dbg_setup_project3.png]]
 
* You must <b>not</b> use any of the following
 
* You must <b>not</b> use any of the following
 
** "Strip Symbols"
 
** "Strip Symbols"
 
** "Link Smart"
 
** "Link Smart"
** Any optimization other than "Level 1" (or "Level 0") <br>[[image:Dbg_setup_project4.png]]
+
** Any optimization other than "Level 0" ("Level 1" may be used, but in some cases may cause issues) <br>[[image:Dbg_setup_project4.png]]
  
= GDB Version =
+
== GDB Version ==
  
GDB 7.5 is not supported by Lazarus 1.0. It can be used with trunk only.
+
GDB 7.5 requires Lazarus 1.4 or higher.
  
 
GDB 7.7.1 seems to work well with Lazarus 1.2.4.
 
GDB 7.7.1 seems to work well with Lazarus 1.2.4.
  
= See also =
+
On macOS: '''lldb''' is part of the Apple developer tools
* [[IDE Window: Debugger Options]]
+
 
* [[IDE Window: Run parameters]] This menu also covers some debugging-related options.
+
== See also ==
* [[GDB Debugger Tips]]
+
* IDE Options / Configuration
 +
*;Lazarus 2.0.x (and before): [[IDE Window: Debugger Options]]
 +
*;Lazarus 2.2 (and up): [[IDE_Window:_DebuggerGeneralOptionsFrame|Debugger General Options]] and [[IDE_Window:_DebuggerClassOptionsFrame|Debugger Backend Options]
 +
* Project Option / Command line args, Environment, and launcher app: [[IDE Window: Run parameters|Run -> Run Parameters]]  
 +
* The FAQ for the default "GNU Debugger" in Lazarus: [[GDB Debugger Tips]]
 +
* Alternative debuggers in Lazarus: [[Debugger Status]] Includes a feature map and default-key-strokes
  
=External links=
+
==External links==
 
* [http://www.youtube.com/watch?v=cf4G06k2YL8 Setup Video Tutorial]
 
* [http://www.youtube.com/watch?v=cf4G06k2YL8 Setup Video Tutorial]
  
 
[[Category:Debugging]]
 
[[Category:Debugging]]
 
[[Category:Lazarus]]
 
[[Category:Lazarus]]

Revision as of 11:52, 27 July 2020

English (en) español (es) français (fr) русский (ru)

From Lazarus 2.0 onwards the IDE has an LLDB based debugger for MacOS. Many of the captions in the IDE still refer explicitly to GDB, but the options apply to LLDB too.

Configure the IDE

In order to be able to debug your projects, you need to make sure the IDE is correctly configured.

These settings do not usually change. You need to make them only once after you installed Lazarus, or if you changed/updated your installation

Open the Lazarus option dialog
Dbg setup options1.png

The image shows where to find the option dialog in Lazarus 0.9.31 and up. In previous versions the entry is in the "Environment" menu.

Light bulb  Note: In Lazarus Version 2.1 and up the setting below moved to Debugger > Backend

Dbg setup options2.png

  • Make sure that the option "GNU debugger (GDB)" is selected.
  • The path to gdb.exe may differ:
    • On Linux/Unix based systems it may be something like "/usr/bin/gdb"
    • On Windows it should be in a folder called "mingw\bin\" under the directory in which Lazarus is installed.

Lazarus 2.0 and up: On Windows 64 find the option "FixIncorrectStepOver" in the property grid and set it to enabled (true).


  • On MacOS, with Lazarus 2.0 or higher
    • Select "LLDB (with fpdebug)"
    • Set the path to: /usr/bin/lldb

Project Options

In order to debug your project, you need to tell the IDE to compile it in a special way, which provides additional information required by the debugger.

Please note: This will considerably increase the size of your executable (See FAQ). If you want to build a release version of your software you should switch those settings off (see also Build Modes)

The required settings are made in the "Project Options" dialog:

Dbg setup project1.png Dbg setup project2.png
  • You must enable the "Generate Debug Info for GDB"
    • On Windows/Linux 32 bit it is highly recommended to use "Dwarf"
  • If using the LLDB based debugger, you are not allowed to use "Stabs". You can choose any of the Dwarf settings. Best to set this explicitly, as "automatic" depends on your fpc version.


Dbg setup project3.png

  • You must not use any of the following
    • "Strip Symbols"
    • "Link Smart"
    • Any optimization other than "Level 0" ("Level 1" may be used, but in some cases may cause issues)
      Dbg setup project4.png

GDB Version

GDB 7.5 requires Lazarus 1.4 or higher.

GDB 7.7.1 seems to work well with Lazarus 1.2.4.

On macOS: lldb is part of the Apple developer tools

See also

External links