Skip to content

Commit

Permalink
Compilation Unit Header Support (#75)
Browse files Browse the repository at this point in the history
* attribute class evaluation

* compilation unit pre-processing for `fetch_one_die` to better read the one die we are trying to fetch.

* proper path appending if the `decl_file` is determined to be relative.

* better error handling during die processing

* throw when we pass over essential attributes

* Yet another build break
  • Loading branch information
fosterbrereton authored Feb 8, 2024
1 parent d5552d0 commit bcda6e1
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 143 deletions.
2 changes: 1 addition & 1 deletion include/orc/dwarf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct dwarf {

void process_all_dies();

die_pair fetch_one_die(std::size_t debug_info_offset);
die_pair fetch_one_die(std::size_t debug_info_offset, std::size_t cu_address);

private:
struct implementation;
Expand Down
16 changes: 3 additions & 13 deletions include/orc/dwarf_structs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,6 @@ struct attribute_value {
return _uint;
}

void die(const struct die& d) {
_type |= type::die;
_die = &d;
}

const auto& die() const {
assert(has(type::die));
return *_die;
}

std::size_t hash() const;

auto type() const { return _type; }
Expand All @@ -111,7 +101,6 @@ struct attribute_value {
bool has_sint() const { return has(type::sint); }
bool has_string() const { return has(type::string); }
bool has_reference() const { return has(type::reference); }
bool has_die() const { return has(type::die); }

private:
friend bool operator==(const attribute_value& x, const attribute_value& y);
Expand All @@ -120,7 +109,6 @@ struct attribute_value {
std::uint64_t _uint{0};
std::int64_t _int{0};
pool_string _string;
const struct die* _die{nullptr};
};

inline bool operator==(const attribute_value& x, const attribute_value& y) {
Expand Down Expand Up @@ -157,7 +145,6 @@ struct attribute {
const auto& string() const { return _value.string(); }
auto uint() const { return _value.uint(); }
auto string_hash() const { return _value.string_hash(); }
const auto& die() const { return _value.die(); }
};

inline bool operator==(const attribute& x, const attribute& y) {
Expand Down Expand Up @@ -315,6 +302,8 @@ struct object_ancestry {
}
};

std::ostream& operator<<(std::ostream& s, const object_ancestry& x);

/**************************************************************************************************/
// A die is constructed by reading an abbreviation entry, then filling in the abbreviation's
// attribute values with data taken from _debug_info. Thus it is possible for more than one die to
Expand All @@ -329,6 +318,7 @@ struct die {
std::size_t _hash{0};
std::size_t _fatal_attribute_hash{0};
std::uint32_t _ofd_index{0}; // object file descriptor index
std::size_t _cu_die_address{0}; // address of associated compilation unit die entry
std::uint32_t _debug_info_offset{0}; // relative from top of __debug_info
dw::tag _tag{dw::tag::none};
arch _arch{arch::unknown};
Expand Down
4 changes: 2 additions & 2 deletions include/orc/string_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ struct pool_string {
pool_string() = default;
~pool_string() = default;

bool empty() const { return _data == nullptr; }
bool empty() const { return _data == nullptr || size() == 0; }

explicit operator bool() const { return empty(); }
explicit operator bool() const { return !empty(); }

std::string_view view() const {
// a string_view is empty iff _data is a nullptr
Expand Down
Loading

0 comments on commit bcda6e1

Please sign in to comment.