CodeobjAddressTranslate Class Reference

CodeobjAddressTranslate Class Reference#

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

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

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

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

Public Member Functions

 CodeobjAddressTranslate ()=default
 
 ~CodeobjAddressTranslate () override=default
 
virtual void addDecoder (const char *filepath, marker_id_t id, uint64_t load_addr, uint64_t memsize) override
 
virtual 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 335 of file code_printing.hpp.

Constructor & Destructor Documentation

◆ CodeobjAddressTranslate()

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

◆ ~CodeobjAddressTranslate()

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

Member Function Documentation

◆ addDecoder() [1/2]

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

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

Definition at line 343 of file code_printing.hpp.

347 {
348 this->Super::addDecoder(filepath, id, load_addr, memsize);
349 auto ptr = decoders.at(id);
350 table.insert({ptr->begin(), ptr->size(), id});
351 }
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::codeobj::disassembly::CodeobjMap::addDecoder(), and rocprofiler::codeobj::disassembly::CodeobjMap::decoders.

+ Here is the call graph for this function:

◆ addDecoder() [2/2]

virtual void rocprofiler::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::codeobj::disassembly::CodeobjMap.

Definition at line 353 of file code_printing.hpp.

358 {
359 this->Super::addDecoder(data, memory_size, id, load_addr, memsize);
360 auto ptr = decoders.at(id);
361 table.insert({ptr->begin(), ptr->size(), id});
362 }

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

+ Here is the call graph for this function:

◆ get() [1/2]

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

Definition at line 375 of file code_printing.hpp.

376 {
377 if(id == 0)
378 return get(offset);
379 else
380 return this->Super::get(id, offset);
381 }
std::unique_ptr< Instruction > get(uint64_t vaddr)
std::unique_ptr< Instruction > get(marker_id_t id, uint64_t offset)

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

+ Here is the call graph for this function:

◆ get() [2/2]

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

Definition at line 369 of file code_printing.hpp.

370 {
371 auto addr_range = table.find_codeobj_in_range(vaddr);
372 return this->Super::get(addr_range.id, vaddr - addr_range.addr);
373 }
address_range_t find_codeobj_in_range(uint64_t addr)
Definition segment.hpp:67

References rocprofiler::codeobj::segment::CodeobjTableTranslator::find_codeobj_in_range(), and rocprofiler::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::codeobj::disassembly::CodeobjAddressTranslate::getSymbolMap ( ) const
inline

Definition at line 393 of file code_printing.hpp.

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

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

◆ getSymbolMap() [2/2]

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

Definition at line 407 of file code_printing.hpp.

408 {
409 if(decoders.find(id) == decoders.end()) return {};
410
411 try
412 {
413 return decoders.at(id)->getSymbolMap();
414 } catch(...)
415 {
416 return {};
417 }
418 }

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

◆ getSymbolName() [1/2]

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

Definition at line 316 of file code_printing.hpp.

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

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

◆ getSymbolName() [2/2]

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

Definition at line 383 of file code_printing.hpp.

384 {
385 for(auto& [_, decoder] : decoders)
386 {
387 if(!decoder->inrange(vaddr)) continue;
388 return decoder->getSymbolName(vaddr);
389 }
390 return nullptr;
391 }

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

◆ removeDecoder()

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

Definition at line 364 of file code_printing.hpp.

365 {
366 return table.remove(load_addr) && this->Super::removeDecoderbyId(id);
367 }
virtual bool removeDecoderbyId(marker_id_t id)
bool remove(const address_range_t &range)
Definition segment.hpp:79

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

+ Here is the call graph for this function:

◆ removeDecoderbyId()

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

Definition at line 301 of file code_printing.hpp.

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

References rocprofiler::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: