Sign in Join
Wiki copytemporary

DWARF: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11# About
22
33**DWARF** (**D**ebugging **W**ith **A**ttributed **R**ecord **F**ormats) is a debugging data format. Dwarf is needed when debugging with [[FpDebug]].
44
55Debugging 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.
66
77The FPC provides the following DWARF-compatible debugging information with [[Command-line interface|command line]] [[Command line parameters and environment variables|parameters]]:
88
99- -gw Generate DWARFv2 debug information (same as -gw2)
1010- -gw2 Generate DWARFv2 debug information
1111- -gw2 -godwarfsets Generate DWARFv2 debug information, but include DWARFv3 description for **sets** ("set of SomeEnum").
1212- -gw3 Generate DWARFv3 debug information
1313- -gw4 Generate DWARFv4 debug information
1414
1515# Choosing a DWARF version for Debugging
1616
17-<div style="line-height: 2em; font-size: 1.5em; border-style: solid; border-width:2px; border-color:blue">
18-
19-<center>
20-
2117See [[Debugger Setup]] for information which setting to use.
22-
23-</center>
24-
25-</div>
2618
2719Missing dwarf-style debugging-data-format will result in a message: ![](/wiki-images/c/c2/Enable_Dwarf_2_prompt.png)
2820
2921The Debugger Status page has as overview which versions are supported and recommended: [[Debugger Status|Debugger_Status#Debug_Info_Support]]
3022
3123If a project switches between several Debugger Backends, settings should either be adapted or the lowest recommended version should be used.
3224
3325# Differences between versions
3426
3527Fpc encodes some data types differently depending on the version of DWARF used. This comprises:
3628
3729- dynamic arrays
3830- short and long strings
3931- TObjects
4032- variants
4133
4234Especially 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.
4335
4436## DWARFv2 (with/without sets)
4537
4638For 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.
4739
4840- debugger may not be able to distinguish between PChar and AnsiString
4941- All identifiers (e.g. field-names) returned by the debugger are upper-cased
5042- ... other diffs
5143
5244DWARF 2 (the one **without** "with sets") does not display sets "type TMySet = set of (v1,v2,v3)" correctly.
5345
5446## DWARFv3
5547
5648DWARFv3 and up, encodes identifiers keeping their case. Instead of "TMYFOOCLASS" the debugger can display "TMyFooClass".
5749
5850- debugger should be able to distinguish between PChar and AnsiString
5951- Identifiers (e.g. field-names) returned by the debugger are kept as declared (not upper-cased)
6052- ... other diffs
6153
6254---
6355*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).*
6456Category: Debugging
6557Category: FPC

Back to history