[llvm-commits] [llvm] r160365 - in /llvm/trunk: lib/DebugInfo/DWARFContext.cpp lib/DebugInfo/DWARFDebugInfoEntry.cpp lib/DebugInfo/DWARFDebugInfoEntry.h test/DebugInfo/Inputs/dwarfdump-test3.elf-x86-64 test/DebugInfo/dwarfdump-test.test test/DebugInfo/lit.local.cfg
Alexey Samsonov
samsonov at google.com
Tue Jul 17 08:28:35 PDT 2012
Author: samsonov
Date: Tue Jul 17 10:28:35 2012
New Revision: 160365
URL: http://llvm.org/viewvc/llvm-project?rev=160365&view=rev
Log:
Improve behavior of DebugInfoEntryMinimal::getSubprogramName() introduced in r159512.
To fetch a subprogram name we should not only inspect the DIE for this subprogram, but optionally inspect
its specification, or its abstract origin (even if there is no inlining), or even specification of an abstract origin.
Reviewed by Benjamin Kramer.
Added:
llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test3.elf-x86-64 (with props)
Modified:
llvm/trunk/lib/DebugInfo/DWARFContext.cpp
llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp
llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.h
llvm/trunk/test/DebugInfo/dwarfdump-test.test
llvm/trunk/test/DebugInfo/lit.local.cfg
Modified: llvm/trunk/lib/DebugInfo/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.cpp?rev=160365&r1=160364&r2=160365&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFContext.cpp Tue Jul 17 10:28:35 2012
@@ -155,8 +155,10 @@
if (specifier.needs(DILineInfoSpecifier::FunctionName)) {
const DWARFDebugInfoEntryMinimal *function_die =
cu->getFunctionDIEForAddress(address);
- if (function_die)
- functionName = function_die->getSubprogramName(cu);
+ if (function_die) {
+ if (const char *name = function_die->getSubprogramName(cu))
+ functionName = name;
+ }
}
if (specifier.needs(DILineInfoSpecifier::FileLineInfo)) {
// Get the line table for this compile unit.
Modified: llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp?rev=160365&r1=160364&r2=160365&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.cpp Tue Jul 17 10:28:35 2012
@@ -456,35 +456,38 @@
return false;
}
-static inline const char*
-getSubprogramNameFromDie(const DWARFCompileUnit *cu,
- const DWARFDebugInfoEntryMinimal *die) {
- const char *result = 0;
- if (!die->isNULL() && die->getTag() == DW_TAG_subprogram) {
- // Try to get mangled name if possible.
- result = die->getAttributeValueAsString(cu, DW_AT_MIPS_linkage_name, 0);
- if (result == 0)
- result = die->getAttributeValueAsString(cu, DW_AT_linkage_name, 0);
- if (result == 0)
- result = die->getAttributeValueAsString(cu, DW_AT_name, 0);
- }
- return result;
-}
-
const char*
DWARFDebugInfoEntryMinimal::getSubprogramName(
const DWARFCompileUnit *cu) const {
if (isNULL() || getTag() != DW_TAG_subprogram)
return 0;
- const char *name = getSubprogramNameFromDie(cu, this);
- if (name == 0) {
- // Try to get name from specification DIE.
- uint32_t ref = getAttributeValueAsReference(cu, DW_AT_specification, -1U);
- if (ref != -1U) {
- DWARFDebugInfoEntryMinimal spec_die;
- if (spec_die.extract(cu, &ref))
- name = getSubprogramNameFromDie(cu, &spec_die);
+ // Try to get mangled name if possible.
+ if (const char *name =
+ getAttributeValueAsString(cu, DW_AT_MIPS_linkage_name, 0))
+ return name;
+ if (const char *name = getAttributeValueAsString(cu, DW_AT_linkage_name, 0))
+ return name;
+ if (const char *name = getAttributeValueAsString(cu, DW_AT_name, 0))
+ return name;
+ // Try to get name from specification DIE.
+ uint32_t spec_ref =
+ getAttributeValueAsReference(cu, DW_AT_specification, -1U);
+ if (spec_ref != -1U) {
+ DWARFDebugInfoEntryMinimal spec_die;
+ if (spec_die.extract(cu, &spec_ref)) {
+ if (const char *name = spec_die.getSubprogramName(cu))
+ return name;
+ }
+ }
+ // Try to get name from abstract origin DIE.
+ uint32_t abs_origin_ref =
+ getAttributeValueAsReference(cu, DW_AT_abstract_origin, -1U);
+ if (abs_origin_ref != -1U) {
+ DWARFDebugInfoEntryMinimal abs_origin_die;
+ if (abs_origin_die.extract(cu, &abs_origin_ref)) {
+ if (const char *name = abs_origin_die.getSubprogramName(cu))
+ return name;
}
}
- return name;
+ return 0;
}
Modified: llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.h?rev=160365&r1=160364&r2=160365&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.h (original)
+++ llvm/trunk/lib/DebugInfo/DWARFDebugInfoEntry.h Tue Jul 17 10:28:35 2012
@@ -132,8 +132,10 @@
bool addressRangeContainsAddress(const DWARFCompileUnit *cu,
const uint64_t address) const;
- // If a DIE represents a subroutine, returns its mangled name
- // (or short name, if mangled is missing). Otherwise returns null.
+ // If a DIE represents a subprogram, returns its mangled name
+ // (or short name, if mangled is missing). This name may be fetched
+ // from specification or abstract origin for this subprogram.
+ // Returns null if no name is found.
const char* getSubprogramName(const DWARFCompileUnit *cu) const;
};
Added: llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test3.elf-x86-64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test3.elf-x86-64?rev=160365&view=auto
==============================================================================
Binary file - no diff available.
Propchange: llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test3.elf-x86-64
------------------------------------------------------------------------------
svn:executable = *
Propchange: llvm/trunk/test/DebugInfo/Inputs/dwarfdump-test3.elf-x86-64
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: llvm/trunk/test/DebugInfo/dwarfdump-test.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwarfdump-test.test?rev=160365&r1=160364&r2=160365&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/dwarfdump-test.test (original)
+++ llvm/trunk/test/DebugInfo/dwarfdump-test.test Tue Jul 17 10:28:35 2012
@@ -8,6 +8,8 @@
RUN: --address=0x4004b8 --functions | FileCheck %s -check-prefix MANY_CU_1
RUN: llvm-dwarfdump %p/Inputs/dwarfdump-test2.elf-x86-64 \
RUN: --address=0x4004c4 --functions | FileCheck %s -check-prefix MANY_CU_2
+RUN: llvm-dwarfdump %p/Inputs/dwarfdump-test3.elf-x86-64 \
+RUN: --address=0x538 --functions | FileCheck %s -check-prefix ABS_ORIGIN_1
MAIN: main
MAIN-NEXT: dwarfdump-test.cc:16:10
@@ -23,3 +25,6 @@
MANY_CU_2: main
MANY_CU_2-NEXT: main.cc:4:0
+
+ABS_ORIGIN_1: C
+ABS_ORIGIN_1-NEXT: def.cc:3:0
Modified: llvm/trunk/test/DebugInfo/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/lit.local.cfg?rev=160365&r1=160364&r2=160365&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/lit.local.cfg (original)
+++ llvm/trunk/test/DebugInfo/lit.local.cfg Tue Jul 17 10:28:35 2012
@@ -1 +1 @@
-config.suffixes = ['.ll', '.c', '.cpp']
+config.suffixes = ['.ll', '.c', '.cpp', '.test']
More information about the llvm-commits
mailing list