diff --git a/src/apps/debugger/dwarf/DwarfUtils.h b/src/apps/debugger/dwarf/DwarfUtils.h index e0da2323fe..092aa75643 100644 --- a/src/apps/debugger/dwarf/DwarfUtils.h +++ b/src/apps/debugger/dwarf/DwarfUtils.h @@ -28,7 +28,38 @@ public: const char*& _directory, const char*& _file, int32& _line, int32& _column); + + template + static EntryType* GetDIEByPredicate(EntryType* entry, + const Predicate& predicate); }; +template +/*static*/ EntryType* +DwarfUtils::GetDIEByPredicate(EntryType* entry, const Predicate& predicate) +{ + if (predicate(entry)) + return entry; + + // try the abstract origin + if (EntryType* abstractOrigin = dynamic_cast( + entry->AbstractOrigin())) { + entry = abstractOrigin; + if (predicate(entry)) + return entry; + } + + // try the specification + if (EntryType* specification = dynamic_cast( + entry->Specification())) { + entry = specification; + if (predicate(entry)) + return entry; + } + + return NULL; +} + + #endif // DWARF_UTILS_H