Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/orc/dwarf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
using die_pair = std::tuple<die, attribute_sequence>;

struct dwarf {
struct implementation;

dwarf(std::uint32_t ofd_index, freader&& s, file_details&& details);

void register_section(std::string name, std::size_t offset, std::size_t size);
Expand All @@ -29,7 +31,6 @@ struct dwarf {
std::size_t cu_die_offset);

private:
struct implementation;
std::unique_ptr<implementation, void (*)(implementation*)> _impl{nullptr,
[](implementation*) {}};
};
Expand Down
12 changes: 12 additions & 0 deletions include/orc/dwarf_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,18 @@ enum class encoding_class {

encoding_class attribute_encoding_class(at attribute);

//--------------------------------------------------------------------------------------------------
// SPECREF: DWARF5 page 255 (237) line 2
enum class lnct : std::uint16_t {
path = 0x1,
directory_index = 0x2,
timestamp = 0x3,
size = 0x4,
md5 = 0x5,
lo_user = 0x2000,
hi_user = 0x3fff,
};

//--------------------------------------------------------------------------------------------------

} // namespace dw
Expand Down
25 changes: 13 additions & 12 deletions include/orc/parse_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#include <iostream>
#include <type_traits>

// adobe contract checks
#include "adobe/contract_checks.hpp"

// application
#include "orc/dwarf_structs.hpp"
#include "orc/hash.hpp"
Expand All @@ -32,18 +35,18 @@ struct freader {
explicit operator bool() const { return static_cast<bool>(_buffer) && _p <= _l; }

std::size_t size() const {
assert(*this);
ADOBE_INVARIANT(*this);
return _l - _f;
}

std::size_t tellg() const {
assert(*this);
ADOBE_INVARIANT(*this);
return _p - _f;
}

void seekg(std::istream::off_type offset) {
_p = _f + offset;
assert(*this);
ADOBE_INVARIANT(*this);
}

void seekg(std::istream::off_type offset, std::ios::seekdir dir) {
Expand All @@ -61,21 +64,21 @@ struct freader {
// GNU's libstdc++ has an end-of-options marker that the compiler
// will complain about as being unhandled here. It should *never*
// be used as a valid value for this enumeration.
assert(false);
ADOBE_INVARIANT(false);
} break;
}
assert(*this);
ADOBE_INVARIANT(*this);
}

void read(char* p, std::size_t n) {
std::memcpy(p, _p, n);
_p += n;
assert(*this);
ADOBE_INVARIANT(*this);
}

char get() {
char result = *_p++;
assert(*this);
ADOBE_INVARIANT(*this);
return result;
}

Expand All @@ -84,7 +87,7 @@ struct freader {
for (; *_p; ++_p) {
}
auto n = _p++ - f;
assert(*this);
ADOBE_INVARIANT(*this);
return std::string_view(f, n);
}

Expand Down Expand Up @@ -134,12 +137,10 @@ auto read_exactly(freader& s, std::size_t size, F&& f) {
auto start = s.tellg();
if constexpr (std::is_same<std::invoke_result_t<F, std::size_t>, void>::value) {
std::forward<F>(f)(size);
assert(s.tellg() == start + size);
if (s.tellg() != start + size) throw std::runtime_error("read_exactly failure");
ADOBE_INVARIANT(s.tellg() == start + size);
} else {
auto result = std::forward<F>(f)(size);
assert(s.tellg() == start + size);
if (s.tellg() != start + size) throw std::runtime_error("read_exactly failure");
ADOBE_INVARIANT(s.tellg() == start + size);
return result;
}
}
Expand Down
Loading
Loading