From 5f1b3713c0790a94bf026e612765cbd199f6092d Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Thu, 8 Dec 2011 17:05:15 -0500 Subject: [PATCH] Add support for parameters when building function names. When asked for a fully qualified DIE name, we now add the parameters of functions as well. This allows them to show up in, e.g. the function list view. Still needs some work but basically functional. --- src/apps/debugger/dwarf/DwarfUtils.cpp | 72 +++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/src/apps/debugger/dwarf/DwarfUtils.cpp b/src/apps/debugger/dwarf/DwarfUtils.cpp index be1f36b7b4..53d988d35a 100644 --- a/src/apps/debugger/dwarf/DwarfUtils.cpp +++ b/src/apps/debugger/dwarf/DwarfUtils.cpp @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2011, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -8,6 +9,7 @@ #include #include "CompilationUnit.h" +#include "Dwarf.h" #include "DwarfFile.h" @@ -59,9 +61,75 @@ DwarfUtils::GetFullDIEName(const DebugInfoEntry* entry, BString& _name) } } - // TODO: Get template and function parameters! - _name = name; + + const DIESubprogram* subProgram = dynamic_cast( + entry); + if (subProgram != NULL) { + // TODO: retrieve template parameters + _name += "("; + BString parameters; + DebugInfoEntryList::ConstIterator iterator + = subProgram->Parameters().GetIterator(); + + // this function is a class method, skip the first parameter + // as it supplies our 'this' pointer and shouldn't be visible + // in the signature + if (dynamic_cast(subProgram->Parent()) != NULL) + iterator.Next(); + + while (iterator.HasNext()) { + const DIEFormalParameter* parameter + = dynamic_cast(iterator.Next()); + if (parameter == NULL) + continue; + + BString paramName; + BString modifier; + DIEType* type = parameter->GetType(); + if (DIEModifiedType* modifiedType = dynamic_cast( + type)) { + DIEType* baseType = type; + while ((modifiedType = dynamic_cast( + baseType)) != NULL && modifiedType->GetType() != NULL) { + switch (modifiedType->Tag()) { + case DW_TAG_pointer_type: + modifier += "*"; + break; + case DW_TAG_reference_type: + modifier += "&"; + break; + case DW_TAG_const_type: + modifier += " const "; + break; + default: + break; + } + + baseType = modifiedType->GetType(); + } + type = baseType; + } + + GetFullyQualifiedDIEName(type, paramName); + parameters += paramName; + if (modifier.Length() > 0) { + if (modifier[modifier.Length() - 1] == ' ') + modifier.Truncate(modifier.Length() - 1); + parameters += modifier; + } + + if (iterator.HasNext()) + parameters += ", "; + } + + if (parameters.Length() > 0) + _name += parameters; + else + _name += "void"; + _name += ")"; + } + }