CodeobjAddressTranslate Class Reference

CodeobjAddressTranslate Class Reference#

Rocprofiler SDK Developer API: rocprofiler::sdk::codeobj::disassembly::CodeobjAddressTranslate Class Reference
Rocprofiler SDK Developer API 0.5.0
ROCm Profiling API and tools
rocprofiler::sdk::codeobj::disassembly::CodeobjAddressTranslate Class Reference

Translates virtual addresses to elf file offsets. More...

#include "rocprofiler-sdk/cxx/codeobj/code_printing.hpp"

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

Public Member Functions

 CodeobjAddressTranslate ()=default
 
 ~CodeobjAddressTranslate () override=default
 
void addDecoder (const char *filepath, marker_id_t id, uint64_t load_addr, uint64_t memsize) override
 
void addDecoder (const void *data, unsigned long memory_size, marker_id_t id, uint64_t load_addr, uint64_t memsize) override
 
virtual bool removeDecoder (marker_id_t id, uint64_t load_addr)
 
std::unique_ptr< Instructionget (uint64_t vaddr)
 
std::unique_ptr< Instructionget (marker_id_t id, uint64_t offset)
 
const char * getSymbolName (uint64_t vaddr)
 
std::map< uint64_t, SymbolInfogetSymbolMap () const
 
std::map< uint64_t, SymbolInfogetSymbolMap (marker_id_t id) const
 
virtual bool removeDecoderbyId (marker_id_t id)
 
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

Translates virtual addresses to elf file offsets.

Definition at line 339 of file code_printing.hpp.

Constructor & Destructor Documentation

◆ CodeobjAddressTranslate()

rocprofiler::sdk::codeobj::disassembly::CodeobjAddressTranslate::CodeobjAddressTranslate ( )
default

◆ ~CodeobjAddressTranslate()

rocprofiler::sdk::codeobj::disassembly::CodeobjAddressTranslate::~CodeobjAddressTranslate ( )
overridedefault

Member Function Documentation

◆ addDecoder() [1/2]

void rocprofiler::sdk::codeobj::disassembly::CodeobjAddressTranslate::addDecoder ( const char *  filepath,
marker_id_t  id,
uint64_t  load_addr,
uint64_t  memsize 
)
inlineoverridevirtual

Reimplemented from rocprofiler::sdk::codeobj::disassembly::CodeobjMap.

Definition at line 347 of file code_printing.hpp.

351 {
352 this->Super::addDecoder(filepath, id, load_addr, memsize);
353 auto ptr = decoders.at(id);
354 table.insert({ptr->begin(), ptr->size(), id});
355 }
std::unordered_map< marker_id_t, std::shared_ptr< LoadedCodeobjDecoder > > decoders
virtual void addDecoder(const char *filepath, marker_id_t id, uint64_t load_addr, uint64_t memsize)

References rocprofiler::sdk::codeobj::disassembly::CodeobjMap::addDecoder(), and rocprofiler::sdk::codeobj::disassembly::CodeobjMap::decoders.

+ Here is the call graph for this function:

◆ addDecoder() [2/2]

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

Reimplemented from rocprofiler::sdk::codeobj::disassembly::CodeobjMap.

Definition at line 357 of file code_printing.hpp.

362 {
363 this->Super::addDecoder(data, memory_size, id, load_addr, memsize);
364 auto ptr = decoders.at(id);
365 table.insert({ptr->begin(), ptr->size(), id});
366 }

References rocprofiler::sdk::codeobj::disassembly::CodeobjMap::addDecoder(), and rocprofiler::sdk::codeobj::disassembly::CodeobjMap::decoders.

+ Here is the call graph for this function:

◆ get() [1/2]

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

Definition at line 379 of file code_printing.hpp.

380 {
381 if(id == 0)
382 return get(offset);
383 else
384 return this->Super::get(id, offset);
385 }
std::unique_ptr< Instruction > get(uint64_t vaddr)
std::unique_ptr< Instruction > get(marker_id_t id, uint64_t offset)

References rocprofiler::sdk::codeobj::disassembly::CodeobjMap::get(), and get().

+ Here is the call graph for this function:

◆ get() [2/2]

std::unique_ptr< Instruction > rocprofiler::sdk::codeobj::disassembly::CodeobjAddressTranslate::get ( uint64_t  vaddr)
inline

Definition at line 373 of file code_printing.hpp.

374 {
375 auto addr_range = table.find_codeobj_in_range(vaddr);
376 return this->Super::get(addr_range.id, vaddr - addr_range.addr);
377 }

References rocprofiler::sdk::codeobj::segment::CodeobjTableTranslator::find_codeobj_in_range(), and rocprofiler::sdk::codeobj::disassembly::CodeobjMap::get().

Referenced by get().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSymbolMap() [1/2]

std::map< uint64_t, SymbolInfo > rocprofiler::sdk::codeobj::disassembly::CodeobjAddressTranslate::getSymbolMap ( ) const
inline

Definition at line 397 of file code_printing.hpp.

398 {
399 std::map<uint64_t, SymbolInfo> symbols;
400
401 for(const auto& [_, dec] : decoders)
402 {
403 auto& smap = dec->getSymbolMap();
404 for(auto& [vaddr, sym] : smap)
405 symbols[vaddr + dec->load_addr] = sym;
406 }
407
408 return symbols;
409 }

References rocprofiler::sdk::codeobj::disassembly::CodeobjMap::decoders.

◆ getSymbolMap() [2/2]

std::map< uint64_t, SymbolInfo > rocprofiler::sdk::codeobj::disassembly::CodeobjAddressTranslate::getSymbolMap ( marker_id_t  id) const
inline

Definition at line 411 of file code_printing.hpp.

412 {
413 if(decoders.find(id) == decoders.end()) return {};
414
415 try
416 {
417 return decoders.at(id)->getSymbolMap();
418 } catch(...)
419 {
420 return {};
421 }
422 }

References rocprofiler::sdk::codeobj::disassembly::CodeobjMap::decoders.

◆ getSymbolName() [1/2]

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

Definition at line 320 of file code_printing.hpp.

321 {
322 try
323 {
324 auto& decoder = decoders.at(id);
325 uint64_t vaddr = decoder->begin() + offset;
326 if(decoder->inrange(vaddr)) return decoder->getSymbolName(vaddr);
327 } catch(std::out_of_range&)
328 {}
329 return nullptr;
330 }

References rocprofiler::sdk::codeobj::disassembly::CodeobjMap::decoders.

◆ getSymbolName() [2/2]

const char * rocprofiler::sdk::codeobj::disassembly::CodeobjAddressTranslate::getSymbolName ( uint64_t  vaddr)
inline

Definition at line 387 of file code_printing.hpp.

388 {
389 for(auto& [_, decoder] : decoders)
390 {
391 if(!decoder->inrange(vaddr)) continue;
392 return decoder->getSymbolName(vaddr);
393 }
394 return nullptr;
395 }

References rocprofiler::sdk::codeobj::disassembly::CodeobjMap::decoders.

◆ removeDecoder()

virtual bool rocprofiler::sdk::codeobj::disassembly::CodeobjAddressTranslate::removeDecoder ( marker_id_t  id,
uint64_t  load_addr 
)
inlinevirtual

Definition at line 368 of file code_printing.hpp.

369 {
370 return table.remove(load_addr) && this->Super::removeDecoderbyId(id);
371 }

References rocprofiler::sdk::codeobj::segment::CodeobjTableTranslator::remove(), and rocprofiler::sdk::codeobj::disassembly::CodeobjMap::removeDecoderbyId().

+ Here is the call graph for this function:

◆ removeDecoderbyId()

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

Definition at line 305 of file code_printing.hpp.

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

References rocprofiler::sdk::codeobj::disassembly::CodeobjMap::decoders.

Referenced by removeDecoder().

+ Here is the caller graph for this function:

Field Documentation

◆ decoders


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