DWARF: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | # About | |
| 2 | 2 | ||
| 3 | 3 | **DWARF** (**D**ebugging **W**ith **A**ttributed **R**ecord **F**ormats) is a debugging data format. Dwarf is needed when debugging with [[FpDebug]]. | |
| 4 | 4 | ||
| 5 | 5 | Debugging information is generated by the [[Compiler|compiler]] together with the machine code. Debugging information is read by the [[Debugger|debugger]]. Debugging information is a representation of the relationship between the [[Executable program|executable program]] and the original [[Source code|source code]]. This information is encoded into a pre-defined format and stored alongside the machine code. | |
| 6 | 6 | ||
| 7 | 7 | The FPC provides the following DWARF-compatible debugging information with [[Command-line interface|command line]] [[Command line parameters and environment variables|parameters]]: | |
| 8 | 8 | ||
| 9 | 9 | - -gw Generate DWARFv2 debug information (same as -gw2) | |
| 10 | 10 | - -gw2 Generate DWARFv2 debug information | |
| 11 | 11 | - -gw2 -godwarfsets Generate DWARFv2 debug information, but include DWARFv3 description for **sets** ("set of SomeEnum"). | |
| 12 | 12 | - -gw3 Generate DWARFv3 debug information | |
| 13 | 13 | - -gw4 Generate DWARFv4 debug information | |
| 14 | 14 | ||
| 15 | 15 | # Choosing a DWARF version for Debugging | |
| 16 | 16 | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | 17 | See [[Debugger Setup]] for information which setting to use. | |
| 22 | - | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - | ||
| 26 | 18 | ||
| 27 | 19 | Missing dwarf-style debugging-data-format will result in a message:  | |
| 28 | 20 | ||
| 29 | 21 | The Debugger Status page has as overview which versions are supported and recommended: [[Debugger Status|Debugger_Status#Debug_Info_Support]] | |
| 30 | 22 | ||
| 31 | 23 | If a project switches between several Debugger Backends, settings should either be adapted or the lowest recommended version should be used. | |
| 32 | 24 | ||
| 33 | 25 | # Differences between versions | |
| 34 | 26 | ||
| 35 | 27 | Fpc encodes some data types differently depending on the version of DWARF used. This comprises: | |
| 36 | 28 | ||
| 37 | 29 | - dynamic arrays | |
| 38 | 30 | - short and long strings | |
| 39 | 31 | - TObjects | |
| 40 | 32 | - variants | |
| 41 | 33 | ||
| 42 | 34 | Especially the info for Long/ShortString may affect how different debugger backends display those types. Long/ShortString do not have their own encoding, they are described as either record, array of char or pchar. | |
| 43 | 35 | ||
| 44 | 36 | ## DWARFv2 (with/without sets) | |
| 45 | 37 | ||
| 46 | 38 | For GDB "DWARFv2 with sets" is the best option. Testing shows that, if using other (v3 and up) DWARF (**as generated by FPC**) then GDB is more likely to crash. | |
| 47 | 39 | ||
| 48 | 40 | - debugger may not be able to distinguish between PChar and AnsiString | |
| 49 | 41 | - All identifiers (e.g. field-names) returned by the debugger are upper-cased | |
| 50 | 42 | - ... other diffs | |
| 51 | 43 | ||
| 52 | 44 | DWARF 2 (the one **without** "with sets") does not display sets "type TMySet = set of (v1,v2,v3)" correctly. | |
| 53 | 45 | ||
| 54 | 46 | ## DWARFv3 | |
| 55 | 47 | ||
| 56 | 48 | DWARFv3 and up, encodes identifiers keeping their case. Instead of "TMYFOOCLASS" the debugger can display "TMyFooClass". | |
| 57 | 49 | ||
| 58 | 50 | - debugger should be able to distinguish between PChar and AnsiString | |
| 59 | 51 | - Identifiers (e.g. field-names) returned by the debugger are kept as declared (not upper-cased) | |
| 60 | 52 | - ... other diffs | |
| 61 | 53 | ||
| 62 | 54 | --- | |
| 63 | 55 | *From the Free Pascal wiki, page "DWARF", as it stood on 2023-08-21 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).* | |
| 64 | 56 | Category: Debugging | |
| 65 | 57 | Category: FPC |
