Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::vm::profile_instr_map Class Reference

#include <debug_info.hpp>

Classes

struct  builder
 

Public Member Functions

void set (builder &&b)
 
 profile_instr_map ()=default
 
 profile_instr_map (const profile_instr_map &)=delete
 
profile_instr_mapoperator= (const profile_instr_map &)=delete
 
void relocate (const void *new_base)
 
std::uint32_t translate (const void *pc) const
 
void set (builder &&b)
 
 profile_instr_map ()=default
 
 profile_instr_map (const profile_instr_map &)=delete
 
profile_instr_mapoperator= (const profile_instr_map &)=delete
 
void relocate (const void *new_base)
 
std::uint32_t translate (const void *pc) const
 

Detailed Description

Definition at line 22 of file debug_info.hpp.

Constructor & Destructor Documentation

◆ profile_instr_map() [1/4]

sysio::vm::profile_instr_map::profile_instr_map ( )
default

◆ profile_instr_map() [2/4]

sysio::vm::profile_instr_map::profile_instr_map ( const profile_instr_map & )
delete

◆ profile_instr_map() [3/4]

sysio::vm::profile_instr_map::profile_instr_map ( )
default

◆ profile_instr_map() [4/4]

sysio::vm::profile_instr_map::profile_instr_map ( const profile_instr_map & )
delete

Member Function Documentation

◆ operator=() [1/2]

profile_instr_map & sysio::vm::profile_instr_map::operator= ( const profile_instr_map & )
delete

◆ operator=() [2/2]

profile_instr_map & sysio::vm::profile_instr_map::operator= ( const profile_instr_map & )
delete

◆ relocate() [1/2]

void sysio::vm::profile_instr_map::relocate ( const void * new_base)
inline

Definition at line 71 of file debug_info.hpp.

71{ base_address = new_base; }

◆ relocate() [2/2]

void sysio::vm::profile_instr_map::relocate ( const void * new_base)
inline

Definition at line 71 of file debug_info.hpp.

71{ base_address = new_base; }

◆ set() [1/2]

void sysio::vm::profile_instr_map::set ( builder && b)
inline

Definition at line 57 of file debug_info.hpp.

57 {
58 data = std::move(b.data);
59 std::sort(data.begin(), data.end(), [](const addr_entry& lhs, const addr_entry& rhs){ return lhs.offset < rhs.offset; });
60 base_address = b.code_base;
61 code_size = reinterpret_cast<const char*>(b.code_end) - reinterpret_cast<const char*>(base_address);
62 offset_to_addr = data.data();
63 offset_to_addr_len = data.size();
64 }

◆ set() [2/2]

void sysio::vm::profile_instr_map::set ( builder && b)
inline

Definition at line 57 of file debug_info.hpp.

57 {
58 data = std::move(b.data);
59 std::sort(data.begin(), data.end(), [](const addr_entry& lhs, const addr_entry& rhs){ return lhs.offset < rhs.offset; });
60 base_address = b.code_base;
61 code_size = reinterpret_cast<const char*>(b.code_end) - reinterpret_cast<const char*>(base_address);
62 offset_to_addr = data.data();
63 offset_to_addr_len = data.size();
64 }

◆ translate() [1/2]

std::uint32_t sysio::vm::profile_instr_map::translate ( const void * pc) const
inline

Definition at line 74 of file debug_info.hpp.

74 {
75 std::size_t diff = (reinterpret_cast<const char*>(pc) - reinterpret_cast<const char*>(base_address)); // negative values wrap
76 if(diff >= code_size || diff < offset_to_addr[0].offset) return 0xFFFFFFFFu;
77 std::uint32_t offset = diff;
78
79 // Loop invariant: offset_to_addr[lower].offset <= offset < offset_to_addr[upper].offset
80 std::size_t lower = 0, upper = offset_to_addr_len;
81 while(upper - lower > 1) {
82 std::size_t mid = lower + (upper - lower) / 2;
83 if(offset_to_addr[mid].offset <= offset) {
84 lower = mid;
85 } else {
86 upper = mid;
87 }
88 }
89
90 return offset_to_addr[lower].wasm_addr;
91 }
void diff(const std::string &a, const std::string &b)
Definition jmp.cpp:18
Here is the call graph for this function:
Here is the caller graph for this function:

◆ translate() [2/2]

std::uint32_t sysio::vm::profile_instr_map::translate ( const void * pc) const
inline

Definition at line 74 of file debug_info.hpp.

74 {
75 std::size_t diff = (reinterpret_cast<const char*>(pc) - reinterpret_cast<const char*>(base_address)); // negative values wrap
76 if(diff >= code_size || diff < offset_to_addr[0].offset) return 0xFFFFFFFFu;
77 std::uint32_t offset = diff;
78
79 // Loop invariant: offset_to_addr[lower].offset <= offset < offset_to_addr[upper].offset
80 std::size_t lower = 0, upper = offset_to_addr_len;
81 while(upper - lower > 1) {
82 std::size_t mid = lower + (upper - lower) / 2;
83 if(offset_to_addr[mid].offset <= offset) {
84 lower = mid;
85 } else {
86 upper = mid;
87 }
88 }
89
90 return offset_to_addr[lower].wasm_addr;
91 }
Here is the call graph for this function:

The documentation for this class was generated from the following files: