1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:47:34 +00:00

LibDebug: Add caches of DIE objects to DwarfInfo

There is one cache that indexes DIE objects by the start address of
their range, and another cache that indexes by their offset in the
debug_info section.

Both caches are implemented with RedBlackTree, and are optional - they
will only be populated if 'build_cached_dies' is invoked.
This commit is contained in:
Itamar 2021-06-19 11:50:24 +03:00 committed by Andreas Kling
parent a5f69efa5c
commit 92d4962d04
2 changed files with 74 additions and 2 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
* Copyright (c) 2020-2021, Itamar S. <itamar8910@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -39,6 +39,7 @@ public:
private:
void populate_compilation_units();
void build_cached_dies() const;
ReadonlyBytes section_data(const StringView& section_name) const;
@ -50,6 +51,22 @@ private:
ReadonlyBytes m_debug_line_strings_data;
NonnullOwnPtrVector<Dwarf::CompilationUnit> m_compilation_units;
struct DIERange {
FlatPtr start_address { 0 };
FlatPtr end_address { 0 };
};
struct DIEAndRange {
DIE die;
DIERange range;
};
using DIEStartAddress = FlatPtr;
mutable RedBlackTree<DIEStartAddress, DIEAndRange> m_cached_dies_by_range;
mutable RedBlackTree<FlatPtr, DIE> m_cached_dies_by_offset;
mutable bool m_built_cached_dies { false };
};
template<typename Callback>