Skip to content

Commit

Permalink
Add support for DW_FORM_line_strp
Browse files Browse the repository at this point in the history
  • Loading branch information
jld01 committed Jan 16, 2023
1 parent 781646e commit 1c7aa96
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 4 deletions.
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions core/org.eclipse.cdt.core/.settings/.api_filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.cdt.core" version="2">
<resource path="utils/org/eclipse/cdt/utils/debug/dwarf/DwarfConstants.java" type="org.eclipse.cdt.utils.debug.dwarf.DwarfConstants">
<filter id="336658481">
<message_arguments>
<message_argument value="org.eclipse.cdt.utils.debug.dwarf.DwarfConstants"/>
<message_argument value="DW_FORM_line_strp"/>
</message_arguments>
</filter>
</resource>
</component>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2019 QNX Software Systems and others.
* Copyright (c) 2000, 2023 QNX Software Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -12,6 +12,7 @@
* QNX Software Systems - Initial API and implementation
* Salvatore Culcasi - Bug 322475
* Serge Beauchamp - Bug 409916
* John Dallaway - Support DW_FORM_line_strp (#198)
*******************************************************************************/

package org.eclipse.cdt.utils.debug.dwarf;
Expand Down Expand Up @@ -56,6 +57,7 @@ public class Dwarf implements AutoCloseable {
final static String DWARF_DEBUG_MACINFO = ".debug_macinfo"; //$NON-NLS-1$
final static String DWARF_DEBUG_MACRO = ".debug_macro"; //$NON-NLS-1$
final static String DWARF_DEBUG_TYPES = ".debug_types"; //$NON-NLS-1$
final static String DWARF_DEBUG_LINE_STR = ".debug_line_str"; //$NON-NLS-1$
final static String DWARF_GNU_DEBUGLINK = ".gnu_debuglink"; //$NON-NLS-1$
final static String DWARF_GNU_DEBUGALTLINK = ".gnu_debugaltlink"; //$NON-NLS-1$

Expand Down Expand Up @@ -724,6 +726,33 @@ Object readAttribute(int form, ByteBuffer in, CompilationUnitHeader header) thro
}
break;

case DwarfConstants.DW_FORM_line_strp: {
long offset;
if (header.offsetSize == 8)
offset = read_8_bytes(in);
else
offset = read_4_bytes(in) & 0xffffffffL;

ByteBuffer data = dwarfSections.get(DWARF_DEBUG_LINE_STR);
if (data == null) {
obj = ""; //$NON-NLS-1$
} else if (offset < 0 || offset > data.capacity()) {
obj = ""; //$NON-NLS-1$
} else {
StringBuilder sb = new StringBuilder();
data.position((int) offset);
while (data.hasRemaining()) {
byte c = data.get();
if (c == 0) {
break;
}
sb.append((char) c);
}
obj = sb.toString();
}
}
break;

case DwarfConstants.DW_FORM_GNU_strp_alt: {
long offset;
if (header.offsetSize == 8)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2014 QNX Software Systems and others.
* Copyright (c) 2000, 2023 QNX Software Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -10,6 +10,7 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
* John Dallaway - Add DW_FORM_line_strp (#198)
*******************************************************************************/

package org.eclipse.cdt.utils.debug.dwarf;
Expand Down Expand Up @@ -207,6 +208,10 @@ public class DwarfConstants {
* @since 5.7
*/
public final static int DW_FORM_flag_present = 0x19;
/**
* @since 8.0
*/
public final static int DW_FORM_line_strp = 0x1f;
/**
* @since 5.7
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2019 Nokia and others.
* Copyright (c) 2007, 2023 Nokia and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -49,7 +49,7 @@ public class DwarfReader extends Dwarf implements ISymbolReader, ICompileOptions
// These are sections that need be parsed to get the source file list.
final static String[] DWARF_SectionsToParse = { DWARF_DEBUG_INFO, DWARF_DEBUG_LINE, DWARF_DEBUG_ABBREV,
DWARF_DEBUG_STR, // this is optional. Some compilers don't generate it.
DWARF_DEBUG_MACRO, };
DWARF_DEBUG_MACRO, DWARF_DEBUG_LINE_STR };

final static String[] DWARF_ALT_SectionsToParse = { DWARF_DEBUG_STR, DWARF_DEBUG_MACRO };

Expand Down Expand Up @@ -335,6 +335,9 @@ void parseSourceInCULineInfo(String cuCompDir, // compilation directory of the C
short version = read_2_bytes(data);
// Skip the following till "opcode_base"
short skip_bytes = 8;
if (version >= 5) {
skip_bytes += 2; // see address_size and segment_selector_size
}
if (version >= 4)
skip_bytes += 1; // see maximum_operations_per_instruction
if (dwarf64Bit)
Expand Down

0 comments on commit 1c7aa96

Please sign in to comment.