Difference between revisions of "DWARF"
(2 intermediate revisions by the same user not shown) | |||
Line 19: | Line 19: | ||
* -gw4 Generate DWARFv4 debug information | * -gw4 Generate DWARFv4 debug information | ||
+ | |||
+ | = Choosing a DWARF version for Debugging = | ||
+ | |||
+ | <div style="line-height: 2em; font-size: 1.5em; border-style: solid; border-width:2px; border-color:blue"><center>See [[Debugger_Setup]] for information which setting to use.</center></div> | ||
Missing dwarf-style debugging-data-format will result in a message: | Missing dwarf-style debugging-data-format will result in a message: | ||
[[File:Enable Dwarf 2 prompt.png|none|left]] | [[File:Enable Dwarf 2 prompt.png|none|left]] | ||
− | + | ||
The Debugger Status page has as overview which versions are supported and recommended: [[Debugger_Status#Debug_Info_Support]] | The Debugger Status page has as overview which versions are supported and recommended: [[Debugger_Status#Debug_Info_Support]] | ||
Line 31: | Line 35: | ||
Fpc encodes some data types differently depending on the version of DWARF used. This comprises: | Fpc encodes some data types differently depending on the version of DWARF used. This comprises: | ||
− | + | * dynamic arrays | |
− | + | * short and long strings | |
− | + | * TObjects | |
− | + | * variants | |
Especially the info for Long/ShortString may affect how different debugger backends display those types. | Especially the info for Long/ShortString may affect how different debugger backends display those types. | ||
Line 42: | Line 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. | 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. | ||
+ | |||
+ | * debugger may not be able to distinguish between PChar and AnsiString | ||
+ | * All identifiers (e.g. field-names) returned by the debugger are upper-cased | ||
+ | * ... other diffs | ||
+ | |||
+ | DWARF 2 (the one **without** "with sets") does not display sets "type TMySet = set of (v1,v2,v3)" correctly. | ||
== DWARFv3 == | == DWARFv3 == | ||
Line 47: | Line 57: | ||
DWARFv3 and up, encodes identifiers keeping their case. Instead of "TMYFOOCLASS" the debugger can display "TMyFooClass". | DWARFv3 and up, encodes identifiers keeping their case. Instead of "TMYFOOCLASS" the debugger can display "TMyFooClass". | ||
+ | * debugger should be able to distinguish between PChar and AnsiString | ||
+ | * Identifiers (e.g. field-names) returned by the debugger are kept as declared (not upper-cased) | ||
+ | * ... other diffs | ||
Latest revision as of 13:30, 21 August 2023
│
English (en) │
suomi (fi) │
About
DWARF (Debugging With Attributed Record Formats) is a debugging data format. Dwarf is needed when debugging with FpDebug.
Debugging information is generated by the compiler together with the machine code. Debugging information is read by the debugger. Debugging information is a representation of the relationship between the executable program and the original source code. This information is encoded into a pre-defined format and stored alongside the machine code.
The FPC provides the following DWARF-compatible debugging information with command line parameters:
- -gw Generate DWARFv2 debug information (same as -gw2)
- -gw2 Generate DWARFv2 debug information
- -gw2 -godwarfsets Generate DWARFv2 debug information, but include DWARFv3 description for sets ("set of SomeEnum").
- -gw3 Generate DWARFv3 debug information
- -gw4 Generate DWARFv4 debug information
Choosing a DWARF version for Debugging
Missing dwarf-style debugging-data-format will result in a message:
The Debugger Status page has as overview which versions are supported and recommended: Debugger_Status#Debug_Info_Support
If a project switches between several Debugger Backends, settings should either be adapted or the lowest recommended version should be used.
Differences between versions
Fpc encodes some data types differently depending on the version of DWARF used. This comprises:
- dynamic arrays
- short and long strings
- TObjects
- variants
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.
DWARFv2 (with/without sets)
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.
- debugger may not be able to distinguish between PChar and AnsiString
- All identifiers (e.g. field-names) returned by the debugger are upper-cased
- ... other diffs
DWARF 2 (the one **without** "with sets") does not display sets "type TMySet = set of (v1,v2,v3)" correctly.
DWARFv3
DWARFv3 and up, encodes identifiers keeping their case. Instead of "TMYFOOCLASS" the debugger can display "TMyFooClass".
- debugger should be able to distinguish between PChar and AnsiString
- Identifiers (e.g. field-names) returned by the debugger are kept as declared (not upper-cased)
- ... other diffs