Debugger Setup: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | ## Configure the IDE | |
| 2 | 2 | ||
| 3 | 3 | ### Updating from an older IDE | |
| 4 | 4 | ||
| 5 | 5 | 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. | |
| 6 | 6 | ||
| 7 | 7 | Please note that many other wiki pages may be outdated and still refer only to GDB. | |
| 8 | 8 | ||
| 9 | 9 | ### Choosing the correct debugger backend | |
| 10 | 10 | ||
| 11 | 11 | The Lazarus IDE provides several debuggers (backends). The page [[Debugger Status|Status of the debugger backends]] provides an overview. | |
| 12 | 12 | ||
| 13 | 13 | The list below indicates which backend is recommended for your environment. | |
| 14 | 14 | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - | ||
| 26 | - | ||
| 27 | - | ||
| 28 | - | ||
| 29 | - | ||
| 30 | - | ||
| 31 | - | ||
| 32 | - | ||
| 33 | - | ||
| 34 | - | ||
| 35 | - | ||
| 36 | - | ||
| 37 | - | ||
| 38 | - | ||
| 39 | - | ||
| 40 | - | ||
| 41 | - | ||
| 42 | - | ||
| 43 | - | ||
| 44 | - | ||
| 45 | - | ||
| 46 | - | ||
| 47 | - | ||
| 48 | - | ||
| 49 | - | ||
| 50 | - | ||
| 51 | - | ||
| 52 | - | ||
| 53 | - | ||
| 54 | - | ||
| 55 | - | ||
| 56 | - | ||
| 57 | - | ||
| 58 | - | ||
| 59 | - | ||
| 60 | - | ||
| 61 | - | ||
| 62 | - | ||
| 63 | - | ||
| 64 | - | ||
| 65 | - | ||
| 66 | - | ||
| 67 | - | ||
| 68 | - | ||
| 69 | - | ||
| 70 | - | ||
| 71 | - | ||
| 72 | - | ||
| 73 | - | ||
| 74 | - | ||
| 75 | - | ||
| 76 | - | ||
| 77 | - | ||
| 78 | - | ||
| 79 | - | ||
| 80 | - | ||
| 81 | - | ||
| 82 | - | ||
| 83 | - | ||
| 84 | - | ||
| 85 | - | ||
| 86 | - | ||
| 87 | - | ||
| 88 | - | ||
| 89 | - | ||
| 90 | - | ||
| 91 | - | ||
| 92 | - | ||
| 93 | - | ||
| 94 | - | ||
| 95 | - | ||
| 96 | - | ||
| 97 | - | ||
| 98 | - | ||
| 99 | - | ||
| 100 | - | ||
| 101 | - | ||
| 102 | - | ||
| 103 | - | ||
| 104 | - | ||
| 105 | - | ||
| 106 | - | ||
| 107 | - | ||
| 108 | - | ||
| 109 | - | ||
| 110 | - | ||
| 111 | - | ||
| 112 | - | ||
| 15 | + | **Operating System** | |
| 113 | 16 | ||
| 114 | - | ||
| 17 | + | **Hardware** | |
| 115 | 18 | ||
| 116 | - | ||
| 19 | + | **Recommended\ | |
| 20 | + | debugger backend** | |
| 117 | 21 | ||
| 118 | - | ||
| 22 | + | **Recommended\ | |
| 23 | + | debug info** | |
| 119 | 24 | ||
| 120 | - | ||
| 25 | + | **Notes** | |
| 121 | 26 | ||
| 122 | - | ||
| 27 | + | Windows 32/64bit | |
| 123 | 28 | ||
| 124 | - | ||
| 29 | + | Intel/AMD\ | |
| 30 | + | i386 or x86_64 | |
| 125 | 31 | ||
| 126 | - | ||
| 32 | + | Fp-Debugger | |
| 127 | 33 | ||
| 128 | - | ||
| 34 | + | DWARF-3 | |
| 129 | 35 | ||
| 130 | - | ||
| 36 | + | Includes cross debugging of a 32bit app on a 64bit system | |
| 131 | 37 | ||
| 132 | - | ||
| 133 | - | ||
| 38 | + | Windows 32bit\ | |
| 134 | 39 | ||
| 135 | - | ||
| 40 | + | Cross 64bit | |
| 136 | 41 | ||
| 42 | + | Intel/AMD\ | |
| 43 | + | x86_64 | |
| 44 | + | ||
| 45 | + | GdbMi | |
| 46 | + | ||
| 47 | + | DWARF-2 with sets | |
| 48 | + | ||
| 49 | + | **Only** **cross debugging** of a 64bit app on a 32bit system | |
| 50 | + | ||
| 51 | + | Windows | |
| 52 | + | ||
| 53 | + | ARM / AArch64 / other | |
| 54 | + | ||
| 55 | + | GdbMi | |
| 56 | + | ||
| 57 | + | DWARF-2 with sets | |
| 58 | + | ||
| 59 | + | You may also try "GdbMI+FpDebug" | |
| 60 | + | ||
| 61 | + | Linux | |
| 62 | + | ||
| 63 | + | Intel/AMD\ | |
| 64 | + | i386 or x86_64 | |
| 65 | + | ||
| 66 | + | Fp-Debugger | |
| 67 | + | ||
| 68 | + | DWARF-3 | |
| 69 | + | ||
| 70 | + | If RTL or packages have debug info, ensure it is the exact same type as for the project | |
| 71 | + | ||
| 72 | + | Linux | |
| 73 | + | ||
| 74 | + | ARM / AArch64 / other | |
| 75 | + | ||
| 76 | + | GdbMi | |
| 77 | + | ||
| 78 | + | DWARF-2 with sets | |
| 79 | + | ||
| 80 | + | You may also try "GdbMI+FpDebug" | |
| 81 | + | ||
| 82 | + | Mac | |
| 83 | + | ||
| 84 | + | Intel/AMD x86_64\ | |
| 85 | + | AArch64 (e.g. M1) | |
| 86 | + | ||
| 87 | + | LLDB+FpDebug | |
| 88 | + | ||
| 89 | + | DWARF-3 | |
| 90 | + | ||
| 91 | + | Embedded AVR | |
| 92 | + | ||
| 93 | + | FpDebug-avr package | |
| 94 | + | ||
| 95 | + | DWARF-2 or 3 | |
| 96 | + | ||
| 97 | + | Requires gdb server | |
| 98 | + | ||
| 99 | + | Remote | |
| 100 | + | ||
| 101 | + | Any supported by GDB | |
| 102 | + | ||
| 103 | + | Gdb-Server | |
| 104 | + | ||
| 105 | + | DWARF-2 with sets | |
| 106 | + | ||
| 107 | + | Debugging on a different PC or VM | |
| 108 | + | ||
| 109 | + | Other | |
| 110 | + | ||
| 111 | + | Any supported by GDB | |
| 112 | + | ||
| 113 | + | GdbMi | |
| 114 | + | ||
| 115 | + | DWARF-2 with sets | |
| 116 | + | ||
| 117 | + | Any OS\ | |
| 118 | + | Debug with STDIN/STDOUT redirect\ | |
| 119 | + | ||
| 120 | + | (via "Run Parameters" command line: \>file \< file) | |
| 121 | + | ||
| 122 | + | Any supported by GDB | |
| 123 | + | ||
| 124 | + | GdbMi | |
| 125 | + | ||
| 126 | + | DWARF-2 with sets | |
| 127 | + | ||
| 128 | + | ### Setting up the debugger backend for the IDE | |
| 129 | + | ||
| 130 | + | The following settings should be made once, after you installed Lazarus. They are often already set by default. | |
| 131 | + | ||
| 132 | + | The settings can be found under | |
| 133 | + | ||
| 134 | + | Tools \> Options \> Debugger \> Debugger Backend | |
| 135 | + | ||
| 136 | + |  The image shows where to find the option dialog. On Mac the dialog is under "Preferences" | |
| 137 | + | ||
| 138 | + |  | |
| 139 | + | ||
| 137 | 140 | - Select the correct backend on top of the page | |
| 138 | 141 | - The Fp-Debugger does not require a path. | |
| 139 | 142 | - If you have an LLDB or Gdb(MI) based debugger you must set the path to the gdb or lldb exe under "Debugger type and path" | |
| 140 | 143 | - On Linux/Unix/Mac systems it may be something like "/usr/bin/gdb" or "/usr/bin/lldb" | |
| 141 | 144 | - On Windows it should be in a folder called "mingw\bin\\" under the directory in which Lazarus is installed. | |
| 142 | 145 | ||
| 143 | 146 | - On [[Debugger Status|Status of the debugger backends]] you find a list of all backends with details on further settings. | |
| 144 | 147 | - For the GdbMI debugger under Lazarus 2.0 and up, enable the option "FixIncorrectStepOver" in the property grid. | |
| 145 | 148 | ||
| 146 | - | ||
| 147 | - | ||
| 148 | - | ||
| 149 | 149 | The backend can also be set on a per project config. For details see [[IDE Window: Project Options - Debugger Backend]] | |
| 150 | 150 | ||
| 151 | 151 | ## Project Options | |
| 152 | 152 | ||
| 153 | - | ||
| 154 | - | ||
| 155 | - | ||
| 156 | - | ||
| 157 | - | ||
| 158 | - | ||
| 153 | + |  | |
| 159 | 154 | ||
| 160 | 155 | 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. | |
| 161 | 156 | ||
| 162 | 157 | The required settings are made in the "Project Options" dialog: | |
| 163 | 158 | ||
| 164 | 159 | - Please note: This will considerably increase the size of your executable ([[Lazarus Faq|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]]) | |
| 165 | 160 | ||
| 166 | - | ||
| 167 | - | ||
| 168 | - | ||
| 169 | - | ||
| 170 | - | ||
| 171 | - | ||
| 172 | - | ||
| 173 | - | ||
| 174 | - | ||
| 175 | - | ||
| 161 | + |  | |
| 176 | 162 | ||
| 177 | 163 | - You must enable "Generate Debug Info for GDB" | |
| 178 | 164 | - You must enable "Run uses the debugger (disable for release mode)" | |
| 179 | 165 | - You should set "Type of debug info" as recommended for your PC. | |
| 180 | 166 | - If you set this to a non supported type, the IDE will prompt you for a correct setting when you try to start the debugger. | |
| 181 | 167 | - **Automatic**: Lets fpc choose. Can not be used with all backends. | |
| 182 | 168 | - **Stabs**: Old and outdated. Supported by GDB only (maybe LLDB **without** FpDebug). Should not be used | |
| 183 | 169 | - **Dwarf 2**: Minimal setting. Can not display watches for "set of". Issues with detecting PChar vs AnsiString. Should not be used | |
| 184 | 170 | - **Dwarf 2 with sets**: GDB friendly. Issues with detecting PChar vs AnsiString | |
| 185 | 171 | - **Dwarf 3**: Best setting for FpDebug. | |
| 186 | 172 | - None of them can currently display "property" with getter function. | |
| 187 | 173 | ||
| 188 | 174 | ------------------------------------------------------------------------ | |
| 189 | 175 | ||
| 190 | 176 | - You should **not** enable "Use external debug symbols"\ | |
| 191 | 177 | (It is a recommendation not to use this) | |
| 192 | 178 | - You **must** **not** enable "Strip symbols from executable" | |
| 193 | 179 | ||
| 194 | 180 | ------------------------------------------------------------------------ | |
| 195 | 181 | ||
| 196 | 182 | 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". | |
| 197 | 183 | ||
| 198 | - | ||
| 199 | - | ||
| 200 | - | ||
| 201 | - | ||
| 202 | - | ||
| 203 | - | ||
| 204 | - | ||
| 205 | - | ||
| 206 | - | ||
| 207 | - | ||
| 184 | + |  | |
| 208 | 185 | ||
| 209 | 186 | - - Use optimization "Level 0" ("Level 1" may be used, but in some cases may cause issues)\ | |
| 210 | 187 | - Do **not** use "Link Smart" | |
| 211 | - | ||
| 212 | - | ||
| 213 | - | ||
| 214 | - | ||
| 215 | 188 | ||
| 216 | 189 | ## GDB / LLDB Version | |
| 217 | 190 | ||
| 218 | 191 | GDB 7.5 requires Lazarus 1.4 or higher. | |
| 219 | 192 | ||
| 220 | 193 | GDB 7.7.1 seems to work well with Lazarus 1.2.4. | |
| 221 | 194 | ||
| 222 | 195 | On macOS: **lldb** is part of the Apple developer tools | |
| 223 | 196 | ||
| 224 | 197 | ## See also | |
| 225 | 198 | ||
| 226 | 199 | - IDE Options / Configuration | |
| 227 | 200 | Lazarus 2.0.x (and before) | |
| 228 | 201 | [[IDE Window: Debugger Options]] | |
| 229 | 202 | ||
| 230 | 203 | Lazarus 2.2 (and up) | |
| 231 | 204 | [[IDE Window: DebuggerGeneralOptionsFrame|Debugger General Options]] and [[IDE Window: DebuggerClassOptionsFrame|Debugger Backend Options]] | |
| 232 | 205 | - Project Option / Command line args, Environment, and launcher app: [[IDE Window: Run parameters|Run -> Run Parameters]] | |
| 233 | 206 | - The FAQ for the default "GNU Debugger" in Lazarus: [[GDB Debugger Tips]] | |
| 234 | 207 | - Alternative debuggers in Lazarus: [[Debugger Status]] Includes a feature map and default-key-strokes | |
| 235 | 208 | ||
| 236 | 209 | --- | |
| 237 | 210 | *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](/wiki-contact).* | |
| 238 | 211 | Category: Debugging | |
| 239 | 212 | Category: Lazarus |
