hrev45696 adds 2 changesets to branch 'master' old head: d1a797e6cdcf558b80967fe29a9f9077c74b9245 new head: c05a041eac2efd14e3e77ac1cc0f3e89fe89f4c5 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=c05a041+%5Ed1a797e ---------------------------------------------------------------------------- c81a7bd: Refactor DIE name resolution. Factor out DwarfUtils::GetDIETypeName(). Make use of it for both Subprogram parameters and modified types in general. Resolves TODO. c05a041: Add Type column to VariablesView. Resolves #9779. [ Rene Gollent <anevilyak@xxxxxxxxx> ] ---------------------------------------------------------------------------- 4 files changed, 84 insertions(+), 51 deletions(-) .../debugger/debug_info/DwarfTypeFactory.cpp | 1 - src/apps/debugger/dwarf/DwarfUtils.cpp | 118 +++++++++++-------- src/apps/debugger/dwarf/DwarfUtils.h | 3 + .../gui/team_window/VariablesView.cpp | 13 +- ############################################################################ Commit: c81a7bda64316b7c255c6a9a8e36d3bc54e4e0c7 URL: http://cgit.haiku-os.org/haiku/commit/?id=c81a7bd Author: Rene Gollent <anevilyak@xxxxxxxxx> Date: Sat May 18 00:40:21 2013 UTC Refactor DIE name resolution. Factor out DwarfUtils::GetDIETypeName(). Make use of it for both Subprogram parameters and modified types in general. Resolves TODO. ---------------------------------------------------------------------------- diff --git a/src/apps/debugger/debug_info/DwarfTypeFactory.cpp b/src/apps/debugger/debug_info/DwarfTypeFactory.cpp index ed28f88..032c129 100644 --- a/src/apps/debugger/debug_info/DwarfTypeFactory.cpp +++ b/src/apps/debugger/debug_info/DwarfTypeFactory.cpp @@ -301,7 +301,6 @@ DwarfTypeFactory::CreateType(DIEType* typeEntry, DwarfType*& _type) // try the type cache first BString name; DwarfUtils::GetFullyQualifiedDIEName(typeEntry, name); -// TODO: The DIE may not have a name (e.g. pointer and reference types don't). TypeLookupConstraints constraints( dwarf_tag_to_type_kind(typeEntry->Tag())); diff --git a/src/apps/debugger/dwarf/DwarfUtils.cpp b/src/apps/debugger/dwarf/DwarfUtils.cpp index f328161..88fd0de 100644 --- a/src/apps/debugger/dwarf/DwarfUtils.cpp +++ b/src/apps/debugger/dwarf/DwarfUtils.cpp @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxx. - * Copyright 2011-2012, Rene Gollent, rene@xxxxxxxxxxx. + * Copyright 2011-2013, Rene Gollent, rene@xxxxxxxxxxx. * Distributed under the terms of the MIT License. */ @@ -40,6 +40,67 @@ DwarfUtils::GetDIEName(const DebugInfoEntry* entry, BString& _name) /*static*/ void +DwarfUtils::GetDIETypeName(const DebugInfoEntry* entry, BString& _name) +{ + const DIEType* type = dynamic_cast<const DIEType*>(entry); + if (type == NULL) + return; + + const DIEModifiedType* modifiedType = dynamic_cast<const DIEModifiedType*>( + type); + BString typeName; + BString modifier; + + if (modifiedType != NULL) { + const DIEType* baseType = type; + while ((modifiedType = dynamic_cast<const DIEModifiedType*>( + baseType)) != NULL) { + switch (modifiedType->Tag()) { + case DW_TAG_pointer_type: + modifier.Prepend("*"); + break; + case DW_TAG_reference_type: + modifier.Prepend("&"); + break; + case DW_TAG_const_type: + modifier.Prepend(" const "); + break; + default: + break; + } + + baseType = modifiedType->GetType(); + } + type = baseType; + } + + // if the parameter has no type associated, + // then it's the unspecified type. + if (type == NULL) + typeName = "void"; + else + GetFullyQualifiedDIEName(type, typeName); + + if (modifier.Length() > 0) { + if (modifier[modifier.Length() - 1] == ' ') + modifier.Truncate(modifier.Length() - 1); + + // if the modifier has a leading const, treat it + // as the degenerate case and prepend it to the + // type name since that's the more typically used + // representation in source + if (modifier[0] == ' ') { + typeName.Prepend("const "); + modifier.Remove(0, 7); + } + typeName += modifier; + } + + _name = typeName; +} + + +/*static*/ void DwarfUtils::GetFullDIEName(const DebugInfoEntry* entry, BString& _name) { BString generatedName; @@ -62,9 +123,13 @@ DwarfUtils::GetFullDIEName(const DebugInfoEntry* entry, BString& _name) } } - // we found no name for this entry whatsoever, abort. - if (name == NULL) + if (name == NULL) { + if (dynamic_cast<const DIEModifiedType*>(entry) != NULL) + GetDIETypeName(entry, _name); + + // we found no name for this entry whatsoever, abort. return; + } generatedName = name; @@ -98,51 +163,7 @@ DwarfUtils::GetFullDIEName(const DebugInfoEntry* entry, BString& _name) BString paramName; BString modifier; DIEType* type = parameter->GetType(); - if (DIEModifiedType* modifiedType = dynamic_cast<DIEModifiedType*>( - type)) { - DIEType* baseType = type; - while ((modifiedType = dynamic_cast<DIEModifiedType*>( - baseType)) != NULL) { - switch (modifiedType->Tag()) { - case DW_TAG_pointer_type: - modifier.Prepend("*"); - break; - case DW_TAG_reference_type: - modifier.Prepend("&"); - break; - case DW_TAG_const_type: - modifier.Prepend(" const "); - break; - default: - break; - } - - baseType = modifiedType->GetType(); - } - type = baseType; - } - - // if the parameter has no type associated, - // then it's the unspecified type. - if (type == NULL) - paramName = "void"; - else - GetFullyQualifiedDIEName(type, paramName); - - if (modifier.Length() > 0) { - if (modifier[modifier.Length() - 1] == ' ') - modifier.Truncate(modifier.Length() - 1); - - // if the modifier has a leading const, treat it - // as the degenerate case and prepend it to the - // type name since that's the more typically used - // representation in source - if (modifier[0] == ' ') { - paramName.Prepend("const "); - modifier.Remove(0, 7); - } - paramName += modifier; - } + GetDIETypeName(type, paramName); if (firstParameter) firstParameter = false; @@ -158,7 +179,6 @@ DwarfUtils::GetFullDIEName(const DebugInfoEntry* entry, BString& _name) generatedName += "void"; generatedName += ")"; } - _name = generatedName; } diff --git a/src/apps/debugger/dwarf/DwarfUtils.h b/src/apps/debugger/dwarf/DwarfUtils.h index 092aa75..1bedfd0 100644 --- a/src/apps/debugger/dwarf/DwarfUtils.h +++ b/src/apps/debugger/dwarf/DwarfUtils.h @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxx. + * Copyright 2013, Rene Gollent, rene@xxxxxxxxxxx. * Distributed under the terms of the MIT License. */ #ifndef DWARF_UTILS_H @@ -17,6 +18,8 @@ class DwarfUtils { public: static void GetDIEName(const DebugInfoEntry* entry, BString& _name); + static void GetDIETypeName(const DebugInfoEntry* entry, + BString& _name); static void GetFullDIEName(const DebugInfoEntry* entry, BString& _name); static void GetFullyQualifiedDIEName( ############################################################################ Revision: hrev45696 Commit: c05a041eac2efd14e3e77ac1cc0f3e89fe89f4c5 URL: http://cgit.haiku-os.org/haiku/commit/?id=c05a041 Author: Rene Gollent <anevilyak@xxxxxxxxx> Date: Sat May 18 00:42:32 2013 UTC Ticket: https://dev.haiku-os.org/ticket/9779 Add Type column to VariablesView. Resolves #9779. ---------------------------------------------------------------------------- diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp index 913f802..9826f74 100644 --- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp @@ -1110,7 +1110,7 @@ VariablesView::VariableTableModel::ValueNodeValueChanged(ValueNode* valueNode) int32 VariablesView::VariableTableModel::CountColumns() const { - return 2; + return 3; } @@ -1198,6 +1198,15 @@ VariablesView::VariableTableModel::GetValueAt(void* object, int32 columnIndex, _value.SetTo(node, VALUE_NODE_TYPE); return true; + case 2: + { + Type* type = node->GetType(); + if (type == NULL) + return false; + + _value.SetTo(type->Name(), B_VARIANT_DONT_COPY_DATA); + return true; + } default: return false; } @@ -1889,6 +1898,8 @@ VariablesView::_Init() B_TRUNCATE_END, B_ALIGN_LEFT)); fVariableTable->AddColumn(new VariableValueColumn(1, "Value", 80, 40, 1000, B_TRUNCATE_END, B_ALIGN_RIGHT)); + fVariableTable->AddColumn(new StringTableColumn(2, "Type", 80, 40, 1000, + B_TRUNCATE_END, B_ALIGN_LEFT)); fVariableTableModel = new VariableTableModel; if (fVariableTableModel->Init() != B_OK)