From 900ce215d30e09071a970eded2a8d15e87e3f29e Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Tue, 22 Jan 2013 20:10:45 -0500 Subject: [PATCH] Add support for template type/value parameter packs. - Implements support for two proposed but not yet formalized additions to the DWARF spec with regards to variadic template parameters. These are nevertheless already being generated by gcc under some user extension tags when C++0x is specified. Fixes #9398. --- src/apps/debugger/dwarf/DebugInfoEntries.cpp | 98 +++++++++++++++++++- src/apps/debugger/dwarf/DebugInfoEntries.h | 45 +++++++++ src/apps/debugger/dwarf/Dwarf.h | 4 + 3 files changed, 146 insertions(+), 1 deletion(-) diff --git a/src/apps/debugger/dwarf/DebugInfoEntries.cpp b/src/apps/debugger/dwarf/DebugInfoEntries.cpp index d4643a46e5..be38f23a2c 100644 --- a/src/apps/debugger/dwarf/DebugInfoEntries.cpp +++ b/src/apps/debugger/dwarf/DebugInfoEntries.cpp @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2011, Rene Gollent, rene@gollent.com. + * Copyright 2011-2013, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -2514,6 +2514,96 @@ DIESharedType::AddAttribute_decl_column(uint16 attributeName, } +// #pragma mark - DIETemplateTypeParameterPack + + +DIETemplateTypeParameterPack::DIETemplateTypeParameterPack() + : + fName(NULL) +{ +} + + +uint16 +DIETemplateTypeParameterPack::Tag() const +{ + return DW_TAG_GNU_template_parameter_pack; +} + + +const char* +DIETemplateTypeParameterPack::Name() const +{ + return fName; +} + + +status_t +DIETemplateTypeParameterPack::AddAttribute_name(uint16 attributeName, + const AttributeValue& value) +{ + fName = value.string; + return B_OK; +} + + +status_t +DIETemplateTypeParameterPack::AddChild(DebugInfoEntry* child) +{ + if (child->Tag() == DW_TAG_template_type_parameter) { + fChildren.Add(child); + return B_OK; + } + + return DIEDeclaredBase::AddChild(child); +} + + +// #pragma mark - DIETemplateValueParameterPack + + +DIETemplateValueParameterPack::DIETemplateValueParameterPack() + : + fName(NULL) +{ +} + + +uint16 +DIETemplateValueParameterPack::Tag() const +{ + return DW_TAG_GNU_formal_parameter_pack; +} + + +const char* +DIETemplateValueParameterPack::Name() const +{ + return fName; +} + + +status_t +DIETemplateValueParameterPack::AddAttribute_name(uint16 attributeName, + const AttributeValue& value) +{ + fName = value.string; + return B_OK; +} + + +status_t +DIETemplateValueParameterPack::AddChild(DebugInfoEntry* child) +{ + if (child->Tag() == DW_TAG_formal_parameter) { + fChildren.Add(child); + return B_OK; + } + + return DIEDeclaredBase::AddChild(child); +} + + // #pragma mark - DebugInfoEntryFactory @@ -2699,6 +2789,12 @@ DebugInfoEntryFactory::CreateDebugInfoEntry(uint16 tag, DebugInfoEntry*& _entry) case DW_TAG_shared_type: entry = new(std::nothrow) DIESharedType; break; + case DW_TAG_GNU_template_parameter_pack: + entry = new(std::nothrow) DIETemplateTypeParameterPack; + break; + case DW_TAG_GNU_formal_parameter_pack: + entry = new(std::nothrow) DIETemplateValueParameterPack; + break; default: return B_ENTRY_NOT_FOUND; break; diff --git a/src/apps/debugger/dwarf/DebugInfoEntries.h b/src/apps/debugger/dwarf/DebugInfoEntries.h index 757007fe54..a4a5c01ce4 100644 --- a/src/apps/debugger/dwarf/DebugInfoEntries.h +++ b/src/apps/debugger/dwarf/DebugInfoEntries.h @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2013, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef DEBUG_INFO_ENTRIES_H @@ -1596,6 +1597,50 @@ private: }; +class DIETemplateTypeParameterPack : public DIEDeclaredBase { +public: + DIETemplateTypeParameterPack(); + + virtual uint16 Tag() const; + + virtual const char* Name() const; + + virtual status_t AddAttribute_name(uint16 attributeName, + const AttributeValue& value); + + const DebugInfoEntryList& Children() const + { return fChildren; } + + virtual status_t AddChild(DebugInfoEntry* child); + +private: + const char* fName; + DebugInfoEntryList fChildren; +}; + + +class DIETemplateValueParameterPack : public DIEDeclaredBase { +public: + DIETemplateValueParameterPack(); + + virtual uint16 Tag() const; + + virtual const char* Name() const; + + virtual status_t AddAttribute_name(uint16 attributeName, + const AttributeValue& value); + + const DebugInfoEntryList& Children() const + { return fChildren; } + + virtual status_t AddChild(DebugInfoEntry* child); + +private: + const char* fName; + DebugInfoEntryList fChildren; +}; + + // #pragma mark - DebugInfoEntryFactory diff --git a/src/apps/debugger/dwarf/Dwarf.h b/src/apps/debugger/dwarf/Dwarf.h index 1d83cbaffd..1e9c99bc74 100644 --- a/src/apps/debugger/dwarf/Dwarf.h +++ b/src/apps/debugger/dwarf/Dwarf.h @@ -65,6 +65,10 @@ enum { DW_TAG_condition = 0x3f, DW_TAG_shared_type = 0x40, DW_TAG_lo_user = 0x4080, + DW_TAG_GNU_template_parameter_pack + = 0x4107, + DW_TAG_GNU_formal_parameter_pack + = 0x4108, DW_TAG_hi_user = 0xffff };