Sign in Join
Wiki copytemporary

DWARF: what changed

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

Title: DWARF

OldNewLine
1+# About
2+
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+
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+
7+The FPC provides the following DWARF-compatible debugging information with [[Command-line interface|command line]] [[Command line parameters and environment variables|parameters]]:
8+
9+- -gw Generate DWARFv2 debug information (same as -gw2)
10+- -gw2 Generate DWARFv2 debug information
11+- -gw2 -godwarfsets Generate DWARFv2 debug information, but include DWARFv3 description for **sets** ("set of SomeEnum").
12+- -gw3 Generate DWARFv3 debug information
13+- -gw4 Generate DWARFv4 debug information
14+
15+# Choosing a DWARF version for Debugging
16+
17+<div style="line-height: 2em; font-size: 1.5em; border-style: solid; border-width:2px; border-color:blue">
18+
19+<center>
20+
21+See [[Debugger Setup]] for information which setting to use.
22+
23+</center>
24+
25+</div>
26+
27+Missing dwarf-style debugging-data-format will result in a message: ![](/wiki-images/c/c2/Enable_Dwarf_2_prompt.png)
28+
29+The Debugger Status page has as overview which versions are supported and recommended: [[Debugger Status|Debugger_Status#Debug_Info_Support]]
30+
31+If a project switches between several Debugger Backends, settings should either be adapted or the lowest recommended version should be used.
32+
33+# Differences between versions
34+
35+Fpc encodes some data types differently depending on the version of DWARF used. This comprises:
36+
37+- dynamic arrays
38+- short and long strings
39+- TObjects
40+- variants
41+
42+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+
44+## DWARFv2 (with/without sets)
45+
46+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+
48+- debugger may not be able to distinguish between PChar and AnsiString
49+- All identifiers (e.g. field-names) returned by the debugger are upper-cased
50+- ... other diffs
51+
52+DWARF 2 (the one **without** "with sets") does not display sets "type TMySet = set of (v1,v2,v3)" correctly.
53+
54+## DWARFv3
55+
56+DWARFv3 and up, encodes identifiers keeping their case. Instead of "TMYFOOCLASS" the debugger can display "TMyFooClass".
57+
58+- debugger should be able to distinguish between PChar and AnsiString
59+- Identifiers (e.g. field-names) returned by the debugger are kept as declared (not upper-cased)
60+- ... other diffs
61+
62+---
63+*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+Category: Debugging
65+Category: FPC

Back to history