-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor extracting CU tags from DWARF (#1495)
This centralizes the process and gives readable names to what's happening.
- Loading branch information
Showing
3 changed files
with
41 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef DWARFDYNINST_DWARF_CU_INFO_HPP | ||
#define DWARFDYNINST_DWARF_CU_INFO_HPP | ||
|
||
#include <dwarf.h> | ||
#include <elfutils/libdw.h> | ||
#include <string> | ||
|
||
namespace Dyninst { namespace DwarfDyninst { | ||
|
||
inline bool is_fullcu(Dwarf_Die die) { return dwarf_tag(&die) == DW_TAG_compile_unit; } | ||
inline bool is_partialcu(Dwarf_Die die) { return dwarf_tag(&die) == DW_TAG_partial_unit; } | ||
inline bool is_typecu(Dwarf_Die die) { return dwarf_tag(&die) == DW_TAG_type_unit; } | ||
|
||
inline bool is_cudie(Dwarf_Die die) { | ||
// If there is an inner CU attribute, then it's not a CU | ||
if (die.cu) | ||
return false; | ||
|
||
// These are best guess. Ideally, we'd like to interrogate | ||
// the internals of the die, but that's not currently possible | ||
// with libdw. The internal function there is `is_cudie`. | ||
// | ||
// We purposefully don't include DW_TAG_skeleton_unit here as | ||
// libdw should merge those into a single CU for us. | ||
return is_fullcu(die) || is_partialcu(die) || is_typecu(die); | ||
} | ||
}} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters