Skip to content

Commit

Permalink
Account for new header layout in DWARF v5
Browse files Browse the repository at this point in the history
Fixes #198
  • Loading branch information
jonahgraham committed Dec 9, 2022
1 parent 04eb054 commit ac135aa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.core; singleton:=true
Bundle-Version: 8.0.0.qualifier
Bundle-Version: 8.0.100.qualifier
Bundle-Activator: org.eclipse.cdt.core.CCorePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,11 +460,22 @@ void parseDebugInfo(IDebugEntryRequestor requestor) {
header.offsetSize = sectionLength.offsetSize;

header.version = read_2_bytes(data);
if (header.offsetSize == 8)
header.abbreviationOffset = (int) read_8_bytes(data);
else
header.abbreviationOffset = read_4_bytes(data);
header.addressSize = data.get();
if (header.version >= 5) {
// XXX: We don't use this new field in DWARF v5 yet
var unit_type = data.get();
header.addressSize = data.get();

if (header.offsetSize == 8)
header.abbreviationOffset = (int) read_8_bytes(data);
else
header.abbreviationOffset = read_4_bytes(data);
} else {
if (header.offsetSize == 8)
header.abbreviationOffset = (int) read_8_bytes(data);
else
header.abbreviationOffset = read_4_bytes(data);
header.addressSize = data.get();
}

if (printEnabled) {
System.out.println("Compilation Unit @ " + Long.toHexString(data.position())); //$NON-NLS-1$
Expand All @@ -476,10 +487,20 @@ void parseDebugInfo(IDebugEntryRequestor requestor) {
// A 4-byte or 12-byte unsigned integer representing the length of the .debug_info
// contribution for that compilation unit, not including the length field itself.
ByteBuffer entryBuffer = data.slice();
entryBuffer.limit(((int) header.length) - (header.offsetSize == 8 ? 11 : 7));
int newLimit = ((int) header.length) - (header.offsetSize == 8 ? 11 : 7);
if (header.version >= 5) {
// account for new field in DWARF v5
newLimit -= 1;
}
entryBuffer.limit(newLimit);
parseDebugInfoEntry(requestor, entryBuffer, abbrevs, header);

data.position(data.position() + ((int) header.length) - (header.offsetSize == 8 ? 11 : 7));
int newLimit2 = ((int) header.length) - (header.offsetSize == 8 ? 11 : 7);
if (header.version >= 5) {
// account for new field in DWARF v5
newLimit2 -= 1;
}
data.position(data.position() + newLimit2);

if (printEnabled)
System.out.println();
Expand Down

0 comments on commit ac135aa

Please sign in to comment.