mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Add support for DW_FORM_line_strp
This commit is contained in:
parent
781646e0ef
commit
1c7aa967a0
6 changed files with 52 additions and 4 deletions
0
core/org.eclipse.cdt.core.tests/resources/elf/unit_test/simple-dwarf4.elf
Executable file → Normal file
0
core/org.eclipse.cdt.core.tests/resources/elf/unit_test/simple-dwarf4.elf
Executable file → Normal file
0
core/org.eclipse.cdt.core.tests/resources/elf/unit_test/simple-dwarf5.elf
Executable file → Normal file
0
core/org.eclipse.cdt.core.tests/resources/elf/unit_test/simple-dwarf5.elf
Executable file → Normal file
11
core/org.eclipse.cdt.core/.settings/.api_filters
Normal file
11
core/org.eclipse.cdt.core/.settings/.api_filters
Normal file
|
@ -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>
|
|
@ -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
|
* This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License 2.0
|
* are made available under the terms of the Eclipse Public License 2.0
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Salvatore Culcasi - Bug 322475
|
* Salvatore Culcasi - Bug 322475
|
||||||
* Serge Beauchamp - Bug 409916
|
* Serge Beauchamp - Bug 409916
|
||||||
|
* John Dallaway - Support DW_FORM_line_strp (#198)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.utils.debug.dwarf;
|
package org.eclipse.cdt.utils.debug.dwarf;
|
||||||
|
@ -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_MACINFO = ".debug_macinfo"; //$NON-NLS-1$
|
||||||
final static String DWARF_DEBUG_MACRO = ".debug_macro"; //$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_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_DEBUGLINK = ".gnu_debuglink"; //$NON-NLS-1$
|
||||||
final static String DWARF_GNU_DEBUGALTLINK = ".gnu_debugaltlink"; //$NON-NLS-1$
|
final static String DWARF_GNU_DEBUGALTLINK = ".gnu_debugaltlink"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -724,6 +726,33 @@ public class Dwarf implements AutoCloseable {
|
||||||
}
|
}
|
||||||
break;
|
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: {
|
case DwarfConstants.DW_FORM_GNU_strp_alt: {
|
||||||
long offset;
|
long offset;
|
||||||
if (header.offsetSize == 8)
|
if (header.offsetSize == 8)
|
||||||
|
|
|
@ -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
|
* This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License 2.0
|
* are made available under the terms of the Eclipse Public License 2.0
|
||||||
|
@ -10,6 +10,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* John Dallaway - Add DW_FORM_line_strp (#198)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.utils.debug.dwarf;
|
package org.eclipse.cdt.utils.debug.dwarf;
|
||||||
|
@ -207,6 +208,10 @@ public class DwarfConstants {
|
||||||
* @since 5.7
|
* @since 5.7
|
||||||
*/
|
*/
|
||||||
public final static int DW_FORM_flag_present = 0x19;
|
public final static int DW_FORM_flag_present = 0x19;
|
||||||
|
/**
|
||||||
|
* @since 8.0
|
||||||
|
*/
|
||||||
|
public final static int DW_FORM_line_strp = 0x1f;
|
||||||
/**
|
/**
|
||||||
* @since 5.7
|
* @since 5.7
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2019 Nokia and others.
|
* Copyright (c) 2007, 2023 Nokia and others.
|
||||||
*
|
*
|
||||||
* This program and the accompanying materials
|
* This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License 2.0
|
* are made available under the terms of the Eclipse Public License 2.0
|
||||||
|
@ -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.
|
// 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,
|
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_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 };
|
final static String[] DWARF_ALT_SectionsToParse = { DWARF_DEBUG_STR, DWARF_DEBUG_MACRO };
|
||||||
|
|
||||||
|
@ -335,6 +335,9 @@ public class DwarfReader extends Dwarf implements ISymbolReader, ICompileOptions
|
||||||
short version = read_2_bytes(data);
|
short version = read_2_bytes(data);
|
||||||
// Skip the following till "opcode_base"
|
// Skip the following till "opcode_base"
|
||||||
short skip_bytes = 8;
|
short skip_bytes = 8;
|
||||||
|
if (version >= 5) {
|
||||||
|
skip_bytes += 2; // see address_size and segment_selector_size
|
||||||
|
}
|
||||||
if (version >= 4)
|
if (version >= 4)
|
||||||
skip_bytes += 1; // see maximum_operations_per_instruction
|
skip_bytes += 1; // see maximum_operations_per_instruction
|
||||||
if (dwarf64Bit)
|
if (dwarf64Bit)
|
||||||
|
|
Loading…
Add table
Reference in a new issue