1#ifndef ARION_CODE_TRACER_HPP
2#define ARION_CODE_TRACER_HPP
13#define ARION_MAX_LIGHT_HITS 1024
15#define ARION_MAX_HEAVY_HITS 64
55 std::unique_ptr<std::map<REG, RVAL>>
regs;
69 CODE_HIT(uint32_t off,
size_t sz, uint16_t mod_id) : off(off), sz(sz), mod_id(mod_id) {};
115 std::vector<std::unique_ptr<CODE_HIT>>
hits;
117 std::vector<std::unique_ptr<TRACER_MAPPING>>
mappings;
This class is used to perform tracing operations over an Arion emulation and store the result in a de...
Definition code_tracer.hpp:93
void process_new_mapping(std::shared_ptr< ARION_MAPPING > mapping)
std::vector< std::unique_ptr< TRACER_MAPPING > > mappings
List of general data concerning memory mappings.
Definition code_tracer.hpp:117
CodeTracer(std::weak_ptr< Arion > arion)
Definition code_tracer.hpp:166
std::string out_f_path
Path to the output trace file.
Definition code_tracer.hpp:105
HOOK_ID curr_hook_id
Definition code_tracer.hpp:103
std::weak_ptr< Arion > arion
The Arion instance which emulation should be traced.
Definition code_tracer.hpp:96
std::vector< std::unique_ptr< CODE_HIT > > hits
List of code hits (instructions or basic blocks) which have not yet been flushed in the output trace ...
Definition code_tracer.hpp:115
void start(std::string out_f_path, TRACE_MODE mode)
static void instr_hook(std::shared_ptr< Arion > arion, ADDR addr, size_t sz, void *user_data)
std::ofstream out_f
Output stream of the output trace file.
Definition code_tracer.hpp:107
void process_hit(ADDR addr, size_t sz)
static std::unique_ptr< CodeTracer > initialize(std::weak_ptr< Arion > arion)
off_t mod_sec_off
Offset in the output trace file to the modules section.
Definition code_tracer.hpp:113
off_t total_hits_off
Offset in the output trace file to the total amount of hits.
Definition code_tracer.hpp:111
TRACE_MODE mode
Trace mode, conditions the output file.
Definition code_tracer.hpp:100
static void block_hook(std::shared_ptr< Arion > arion, ADDR addr, size_t sz, void *user_data)
size_t total_hits
Total amount of hits to be stored in the output trace file.
Definition code_tracer.hpp:109
#define ARION_EXPORT
Defines which symbols should be exported from the library.
Definition global_defs.hpp:13
Definition arch_x86-64.hpp:11
const float TRACER_FILE_VERSION
Version number of Arion tracer file format.
Definition code_tracer.hpp:25
const char TRACER_FILE_MAGIC[]
Magic string for headers of Arion tracer files.
Definition code_tracer.hpp:23
uint64_t ADDR
Identifies a memory address.
Definition global_defs.hpp:36
const uint16_t TRACER_FILE_HEADER_SIZE
Header size of Arion tracer files.
Definition code_tracer.hpp:27
uint64_t HOOK_ID
ID associated with a hook when created.
Definition hooks_manager.hpp:19
TRACE_MODE
These modes are used to configure the output file format.
Definition code_tracer.hpp:31
@ BLOCK
Arion tracer file which stores the address of every executed basic block (in control flow).
Definition code_tracer.hpp:35
@ INSTR
Arion tracer file which stores the address of every executed instruction.
Definition code_tracer.hpp:33
@ UNKNOWN
Unknown file format, should not be used.
Definition code_tracer.hpp:41
@ CTXT
Arion tracer file which stores the CPU context of every executed instruction.
Definition code_tracer.hpp:34
@ DRCOV
DrCov file format. Useful for compatibility with disassembler plugins.
Definition code_tracer.hpp:38
Definition code_tracer.hpp:47
std::unique_ptr< std::map< REG, RVAL > > regs
CPU context as a map of register values. Only used in TRACE_MODE::CTXT.
Definition code_tracer.hpp:55
CODE_HIT()
Definition code_tracer.hpp:60
uint16_t sz
Size of the hit. It can either be the instruction size or the basic block size depending on the used ...
Definition code_tracer.hpp:51
CODE_HIT(uint32_t off, size_t sz, uint16_t mod_id)
Definition code_tracer.hpp:69
uint16_t mod_id
ID of the hit module.
Definition code_tracer.hpp:53
uint32_t off
Offset of the hit relative to the start address of its module.
Definition code_tracer.hpp:49
Stores general data over a memory mapping to be stored in the output trace file.
Definition code_tracer.hpp:74
TRACER_MAPPING(ADDR start, ADDR end, std::string name)
Definition code_tracer.hpp:88
std::string name
Name associated with the memory mapping.
Definition code_tracer.hpp:80
ADDR start
Start address of the memory mapping.
Definition code_tracer.hpp:76
ADDR end
End address of the memory mapping.
Definition code_tracer.hpp:78