CodeobjMap Class Reference

CodeobjMap Class Reference#

ROCprofiler-SDK developer API: rocprofiler::sdk::codeobj::disassembly::CodeobjMap Class Reference
ROCprofiler-SDK developer API 1.0.0
ROCm Profiling API and tools
rocprofiler::sdk::codeobj::disassembly::CodeobjMap Class Reference

Maps ID and offsets into instructions. More...

#include <rocprofiler-sdk/cxx/codeobj/code_printing.hpp>

+ Inheritance diagram for rocprofiler::sdk::codeobj::disassembly::CodeobjMap:
+ Collaboration diagram for rocprofiler::sdk::codeobj::disassembly::CodeobjMap:

Public Member Functions

virtual void addDecoder (const char *filepath, marker_id_t id, uint64_t load_addr, uint64_t memsize)
 
virtual void addDecoder (const void *data, unsigned long memory_size, marker_id_t id, uint64_t load_addr, uint64_t memsize)
 
virtual bool removeDecoderbyId (marker_id_t id)
 
std::unique_ptr< Instruction > get (marker_id_t id, uint64_t offset)
 
const char * getSymbolName (marker_id_t id, uint64_t offset)
 

Protected Attributes

std::unordered_map< marker_id_t, std::shared_ptr< LoadedCodeobjDecoder > > decoders {}
 

Detailed Description

Maps ID and offsets into instructions.

Definition at line 371 of file code_printing.hpp.

Member Function Documentation

◆ addDecoder() [1/2]

virtual void rocprofiler::sdk::codeobj::disassembly::CodeobjMap::addDecoder ( const char *  filepath,
marker_id_t  id,
uint64_t  load_addr,
uint64_t  memsize 
)
inlinevirtual

Definition at line 377 of file code_printing.hpp.

381 {
382 decoders[id] = std::make_shared<LoadedCodeobjDecoder>(filepath, load_addr, memsize);
383 }

◆ addDecoder() [2/2]

virtual void rocprofiler::sdk::codeobj::disassembly::CodeobjMap::addDecoder ( const void *  data,
unsigned long  memory_size,
marker_id_t  id,
uint64_t  load_addr,
uint64_t  memsize 
)
inlinevirtual

Definition at line 385 of file code_printing.hpp.

390 {
391 decoders[id] =
392 std::make_shared<LoadedCodeobjDecoder>(data, memory_size, load_addr, memsize);
393 }

◆ get()

std::unique_ptr< Instruction > rocprofiler::sdk::codeobj::disassembly::CodeobjMap::get ( marker_id_t  id,
uint64_t  offset 
)
inline

Definition at line 397 of file code_printing.hpp.

398 {
399 try
400 {
401 auto& decoder = decoders.at(id);
402 auto inst = decoder->get(decoder->begin() + offset);
403 if(inst != nullptr) inst->codeobj_id = id;
404 return inst;
405 } catch(std::out_of_range&)
406 {}
407 return nullptr;
408 }

◆ getSymbolName()

const char * rocprofiler::sdk::codeobj::disassembly::CodeobjMap::getSymbolName ( marker_id_t  id,
uint64_t  offset 
)
inline

Definition at line 410 of file code_printing.hpp.

411 {
412 try
413 {
414 auto& decoder = decoders.at(id);
415 uint64_t vaddr = decoder->begin() + offset;
416 if(decoder->inrange(vaddr)) return decoder->getSymbolName(vaddr);
417 } catch(std::out_of_range&)
418 {}
419 return nullptr;
420 }

◆ removeDecoderbyId()

virtual bool rocprofiler::sdk::codeobj::disassembly::CodeobjMap::removeDecoderbyId ( marker_id_t  id)
inlinevirtual

Definition at line 395 of file code_printing.hpp.

395{ return decoders.erase(id) != 0; }

Field Documentation

◆ decoders

std::unordered_map<marker_id_t, std::shared_ptr<LoadedCodeobjDecoder> > rocprofiler::sdk::codeobj::disassembly::CodeobjMap::decoders {}
protected

Definition at line 423 of file code_printing.hpp.

423{};

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