Sign in Join
Wiki copytemporary

Revision 1 of 2, by Martin on 12-13-2023. The page as it is now.

Debugger Setup

Configure the IDE

Updating from an older IDE

Older versions of Lazarus were only providing the GdbMI backend. It is highly recommended to update to Fp-Debugger or LLDB+FpDebug as indicated for your OS below.

Please note that many other wiki pages may be outdated and still refer only to GDB.

Choosing the correct debugger backend

The Lazarus IDE provides several debuggers (backends). The page Status of the debugger backends provides an overview.

The list below indicates which backend is recommended for your environment.

<table> <thead> <tr> <th class="partial"><p>Operating System</p></th> <th class="unknown"><p>Hardware</p></th> <th class="working"><p>Recommended<br /> debugger backend</p></th> <th class="working"><p>Recommended<br /> debug info</p></th> <th class="unknown"><p>Notes</p></th> </tr> </thead> <tbody> <tr> <td class="partial" style="text-align:left"><p>Windows 32/64bit</p></td> <td class="unknown"><p>Intel/AMD<br /> i386 or x86_64</p></td> <td class="working"><p>Fp-Debugger</p></td> <td class="working"><p>DWARF-3</p></td> <td class="unknown"><p>Includes cross debugging of a 32bit app on a 64bit system</p></td> </tr> <tr> <td class="partial" style="text-align:left"><p>Windows 32bit<br /> </p> <div style="font-size:0.7em"> <p>Cross 64bit</p> </div></td> <td class="unknown"><p>Intel/AMD<br /> x86_64</p></td> <td class="working"><p>GdbMi</p></td> <td class="working"><p>DWARF-2 with sets</p></td> <td class="unknown"><p><u><strong>Only</strong></u> <strong>cross debugging</strong> of a 64bit app on a 32bit system</p></td> </tr> <tr> <td class="partial" style="text-align:left"><p>Windows</p></td> <td class="unknown"><p>ARM / AArch64 / other</p></td> <td class="working"><p>GdbMi</p></td> <td class="working"><p>DWARF-2 with sets</p></td> <td class="unknown"><p>You may also try "GdbMI+FpDebug"</p></td> </tr> <tr> <td class="partial" style="text-align:left"><p>Linux</p></td> <td class="unknown"><p>Intel/AMD<br /> i386 or x86_64</p></td> <td class="working"><p>Fp-Debugger</p></td> <td class="working"><p>DWARF-3</p></td> <td class="unknown"><p>If RTL or packages have debug info, ensure it is the exact same type as for the project</p></td> </tr> <tr> <td class="partial" style="text-align:left"><p>Linux</p></td> <td class="unknown"><p>ARM / AArch64 / other</p></td> <td class="working"><p>GdbMi</p></td> <td class="working"><p>DWARF-2 with sets</p></td> <td class="unknown"><p>You may also try "GdbMI+FpDebug"</p></td> </tr> <tr> <td class="partial" style="text-align:left"><p>Mac</p></td> <td class="unknown"><p>Intel/AMD x86_64<br /> AArch64 (e.g. M1)</p></td> <td class="working"><p>LLDB+FpDebug</p></td> <td class="working"><p>DWARF-3</p></td> <td class="unknown"></td> </tr> <tr> <td class="partial" style="text-align:left"><p>Embedded AVR</p></td> <td class="unknown"></td> <td class="working"><p>FpDebug-avr package</p></td> <td class="working"><p>DWARF-2 or 3</p></td> <td class="unknown"><p>Requires gdb server</p></td> </tr> <tr> <td class="partial" style="text-align:left"><p>Remote</p></td> <td class="unknown"><p>Any supported by GDB</p></td> <td class="working"><p>Gdb-Server</p></td> <td class="working"><p>DWARF-2 with sets</p></td> <td class="unknown"><p>Debugging on a different PC or VM</p></td> </tr> <tr> <td class="partial" style="text-align:left"><p>Other</p></td> <td class="unknown"><p>Any supported by GDB</p></td> <td class="working"><p>GdbMi</p></td> <td class="working"><p>DWARF-2 with sets</p></td> <td class="unknown"></td> </tr> <tr> <td class="partial" style="text-align:left"><p>Any OS<br /> Debug with <b>STDIN/STDOUT redirect</b><br /> </p> <div style="font-size:0.7em"> <p>(via "Run Parameters" command line: >file < file)</p> </div></td> <td class="unknown"><p>Any supported by GDB</p></td> <td class="working"><p>GdbMi</p></td> <td class="working"><p>DWARF-2 with sets</p></td> <td class="unknown"></td> </tr> </tbody> </table>

Setting up the debugger backend for the IDE

The following settings should be made once, after you installed Lazarus. They are often already set by default.

The settings can be found under

<center>

<u>Tools > Options > Debugger > Debugger Backend</u>

</center>

<center>

The image shows where to find the option dialog. On Mac the dialog is under "Preferences"

</center>


<div style="min-width:20%; display:table;">

</div>


The backend can also be set on a per project config. For details see IDE Window: Project Options - Debugger Backend

Project Options

<figure> <img src="Dbg_setup_project1.png" title="Dbg_setup_project1.png" /> <figcaption>Dbg_setup_project1.png</figcaption> </figure>

<div style="min-width:20%; display:table;">

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.

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

</div>

\

<figure> <img src="lazarus_projectopts_dbg.png" title="lazarus_projectopts_dbg.png" /> <figcaption>lazarus_projectopts_dbg.png</figcaption> </figure>

<div style="min-width:20%; display:table;">



You can use the "Build modes". The "..." button brings of a dialog to create "release and debug mode". In this case you should still check the "Type of debug info".

</div>

\

<figure> <img src="Dbg_setup_project4.png" title="Dbg_setup_project4.png" /> <figcaption>Dbg_setup_project4.png</figcaption> </figure>

<div style="min-width:20%; display:table;">

</div>

\

GDB / LLDB 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


From the Free Pascal wiki, page "Debugger Setup", as it stood on 2023-12-13 after a change by Martin, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.