Skip to content

Commit

Permalink
Add support for template type/value parameter packs.
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
anevilyak committed Jan 23, 2013
1 parent b68166e commit 900ce21
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 1 deletion.
98 changes: 97 additions & 1 deletion 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.
*/

Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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;
Expand Down
45 changes: 45 additions & 0 deletions 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
Expand Down Expand Up @@ -1596,6 +1597,50 @@ class DIESharedType : public DIEModifiedType {
};


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


Expand Down
4 changes: 4 additions & 0 deletions src/apps/debugger/dwarf/Dwarf.h
Expand Up @@ -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
};

Expand Down

0 comments on commit 900ce21

Please sign in to comment.