9#ifndef LLDB_TARGET_TRACE_HTR_H
10#define LLDB_TARGET_TRACE_HTR_H
16#include <unordered_map>
17#include <unordered_set>
37 size_t num_instructions,
38 llvm::DenseMap<ConstString, size_t> &&func_calls)
220 std::optional<ConstString> func_name);
239 std::unordered_map<lldb::addr_t, std::optional<ConstString>>
m_call_isns;
300typedef std::unique_ptr<lldb_private::HTRInstructionLayer>
328 llvm::Error
Export(std::string outfile);
HTR layer composed of blocks of the trace.
std::unordered_map< size_t, HTRBlock > m_block_defs
Maps a unique Block ID to the corresponding HTRBlock.
HTRBlock const * GetBlockById(size_t block_id) const
Get an HTRBlock from its block id.
size_t GetNumUnits() const override
Get the total number of units (instruction or block) in this layer.
HTRBlockLayer(size_t id)
Construct new block layer.
std::vector< size_t > m_block_id_trace
Reduce memory footprint by just storing a trace of block IDs and use m_block_defs to map a block_id t...
void AppendRepeatedBlock(size_t block_id)
Appends a repeated block to the layer.
llvm::ArrayRef< size_t > GetBlockIdTrace() const
Get the block ID trace for this layer.
void AppendNewBlock(size_t block_id, HTRBlock &&block)
Appends a new block to the layer.
HTRBlockMetadata GetMetadataByIndex(size_t index) const override
Get the metadata of a unit (instruction or block) in the layer.
Block structure representing a sequence of trace "units" (ie instructions).
size_t GetSize() const
Get the number of blocks/instructions that make up this block in the previous layer.
size_t m_size
Number of blocks/instructions that make up this block in the previous layer.
size_t GetOffset() const
Get the offset of the start of this block in the previous layer.
HTRBlock(size_t offset, size_t size, HTRBlockMetadata metadata)
Constructor for a block of an HTR layer.
size_t m_offset
Offset in the previous layer.
HTRBlockMetadata m_metadata
General metadata for this block.
HTRBlockMetadata const & GetMetadata() const
Get the metadata for this block.
"Base" layer of HTR representing the dynamic instructions of the trace.
size_t GetNumUnits() const override
Get the total number of units (instruction or block) in this layer.
std::vector< lldb::addr_t > m_instruction_trace
std::unordered_map< lldb::addr_t, std::optional< ConstString > > m_call_isns
HTRBlockMetadata GetMetadataByIndex(size_t index) const override
Get the metadata of a unit (instruction or block) in the layer.
void AppendInstruction(lldb::addr_t load_addr)
Append the load address of an instruction to the dynamic instruction trace.
void AddCallInstructionMetadata(lldb::addr_t load_addr, std::optional< ConstString > func_name)
Add metadata for a 'call' instruction of the trace.
llvm::ArrayRef< lldb::addr_t > GetInstructionTrace() const
Get the dynamic instruction trace.
HTRInstructionLayer(size_t id)
Construct new instruction layer.
HTR layer interface See lldb/docs/htr.rst for comprehensive HTR documentation.
IHTRLayer(size_t id)
Construct new HTR layer.
virtual size_t GetNumUnits() const =0
Get the total number of units (instruction or block) in this layer.
HTRBlock MergeUnits(size_t start_unit_index, size_t num_units)
Creates a new block from the result of merging a contiguous sequence of "units" (instructions or bloc...
virtual ~IHTRLayer()=default
size_t m_layer_id
ID of the layer.
size_t GetLayerId() const
Get the ID of the layer.
virtual HTRBlockMetadata GetMetadataByIndex(size_t index) const =0
Get the metadata of a unit (instruction or block) in the layer.
Class used for iterating over the instructions of a thread's trace, among other kinds of information.
Top-level HTR class See lldb/docs/htr.rst for comprehensive HTR documentation.
std::vector< HTRBlockLayerUP > m_block_layer_ups
llvm::ArrayRef< HTRBlockLayerUP > GetBlockLayers() const
Get the block layers of this HTR.
HTRInstructionLayer const & GetInstructionLayer() const
Get the instruction layer of this HTR.
llvm::Error Export(std::string outfile)
Export HTR layers to the specified format and outfile.
void AddNewBlockLayer(HTRBlockLayerUP &&block_layer)
Add a new block layer to this HTR.
void ExecutePasses()
Executes passes on the HTR layers until no further summarization/compression is achieved.
HTRInstructionLayerUP m_instruction_layer_up
A class that represents a running process on the host machine.
std::unique_ptr< lldb_private::HTRInstructionLayer > HTRInstructionLayerUP
HTRBlockLayerUP BasicSuperBlockMerge(IHTRLayer &layer)
The HTR passes are defined below:
std::unique_ptr< lldb_private::HTRBlockLayer > HTRBlockLayerUP
llvm::json::Value toJSON(const TraceSupportedResponse &packet)