CodeobjAddressTranslate Class Reference

CodeobjAddressTranslate Class Reference#

ROCprofiler-SDK developer API: rocprofiler::sdk::codeobj::disassembly::CodeobjAddressTranslate Class Reference
ROCprofiler-SDK developer API 1.3.5
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

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
 
bool removeDecoder (marker_id_t id, uint64_t load_addr)
 
bool removeDecoder (marker_id_t id)
 
std::unique_ptr< Instruction > get (uint64_t vaddr)
 
std::unique_ptr< Instruction > get (marker_id_t id, uint64_t offset)
 
const char * getSymbolName (uint64_t vaddr)
 
std::map< uint64_t, SymbolInfo > getSymbolMap () const
 
std::map< uint64_t, SymbolInfo > getSymbolMap (marker_id_t id) const
 
std::vector< std::pair< marker_id_t, funcmap::Funcmap::EntryPtr > > findMarkerAny (uint32_t funcmap_id) const
 
uint32_t getWaveSize () const
 
virtual bool removeDecoderbyId (marker_id_t id)
 
const char * getSymbolName (marker_id_t id, uint64_t offset)
 
funcmap::Funcmap::EntryPtr getMarker (marker_id_t id, uint32_t funcmap_id) const
 
std::optional< funcmap::Funcmap > getFuncmap (marker_id_t id) const
 

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 570 of file code_printing.hpp.

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 578 of file code_printing.hpp.

582 {
583 this->Super::addDecoder(filepath, id, load_addr, memsize);
584 auto ptr = decoders.at(id);
585 table.insert({ptr->begin(), ptr->size(), id});
586 }

◆ 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 588 of file code_printing.hpp.

593 {
594 this->Super::addDecoder(data, memory_size, id, load_addr, memsize);
595 auto ptr = decoders.at(id);
596 table.insert({ptr->begin(), ptr->size(), id});
597 }

◆ findMarkerAny()

std::vector< std::pair< marker_id_t, funcmap::Funcmap::EntryPtr > > rocprofiler::sdk::codeobj::disassembly::CodeobjAddressTranslate::findMarkerAny ( uint32_t  funcmap_id) const
inline

Definition at line 703 of file code_printing.hpp.

704{
705 std::vector<std::pair<marker_id_t, funcmap::Funcmap::EntryPtr>> out;
706 for(const auto& [id, dec] : decoders)
707 {
708 try
709 {
710 if(auto entry = dec->getFuncmap().find(funcmap_id))
711 out.emplace_back(id, std::move(entry));
712 } catch(...)
713 {}
714 }
715 return out;
716}

◆ get() [1/2]

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

Definition at line 618 of file code_printing.hpp.

619 {
620 if(id == 0)
621 return get(offset);
622 else
623 return this->Super::get(id, offset);
624 }

◆ get() [2/2]

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

Definition at line 612 of file code_printing.hpp.

613 {
614 auto addr_range = table.find_codeobj_in_range(vaddr);
615 return this->Super::get(addr_range.id, vaddr - addr_range.addr);
616 }

◆ getFuncmap()

std::optional< funcmap::Funcmap > rocprofiler::sdk::codeobj::disassembly::CodeobjMap::getFuncmap ( marker_id_t  id) const
inlineinherited

Definition at line 695 of file code_printing.hpp.

696{
697 auto it = decoders.find(id);
698 if(it == decoders.end() || !it->second || !it->second->has_decoder()) return std::nullopt;
699 return it->second->getFuncmap();
700}

◆ getMarker()

funcmap::Funcmap::EntryPtr rocprofiler::sdk::codeobj::disassembly::CodeobjMap::getMarker ( marker_id_t  id,
uint32_t  funcmap_id 
) const
inlineinherited

Definition at line 680 of file code_printing.hpp.

681{
682 auto it = decoders.find(id);
683 if(it == decoders.end()) return nullptr;
684
685 try
686 {
687 return it->second->getFuncmap().find(funcmap_id);
688 } catch(...)
689 {
690 return nullptr;
691 }
692}

◆ getSymbolMap() [1/2]

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

Definition at line 636 of file code_printing.hpp.

637 {
638 std::map<uint64_t, SymbolInfo> symbols;
639
640 for(const auto& [_, dec] : decoders)
641 {
642 auto& smap = dec->getSymbolMap();
643 for(auto& [vaddr, sym] : smap)
644 symbols[vaddr + dec->load_addr] = sym;
645 }
646
647 return symbols;
648 }

◆ getSymbolMap() [2/2]

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

Definition at line 650 of file code_printing.hpp.

651 {
652 if(decoders.find(id) == decoders.end()) return {};
653
654 try
655 {
656 return decoders.at(id)->getSymbolMap();
657 } catch(...)
658 {
659 return {};
660 }
661 }

◆ getSymbolName() [1/2]

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

Definition at line 542 of file code_printing.hpp.

543 {
544 try
545 {
546 auto& decoder = decoders.at(id);
547 uint64_t vaddr = decoder->begin() + offset;
548 if(decoder->inrange(vaddr)) return decoder->getSymbolName(vaddr);
549 } catch(std::out_of_range&)
550 {}
551 return nullptr;
552 }

◆ getSymbolName() [2/2]

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

Definition at line 626 of file code_printing.hpp.

627 {
628 for(auto& [_, decoder] : decoders)
629 {
630 if(!decoder->inrange(vaddr)) continue;
631 return decoder->getSymbolName(vaddr);
632 }
633 return nullptr;
634 }

◆ getWaveSize()

uint32_t rocprofiler::sdk::codeobj::disassembly::CodeobjAddressTranslate::getWaveSize ( ) const
inline

Definition at line 719 of file code_printing.hpp.

720{
721 uint32_t agreed = 0;
722 for(const auto& [id, dec] : decoders)
723 {
724 uint32_t w = 0;
725 try
726 {
727 w = dec->getFuncmap().wave_size;
728 } catch(...)
729 {
730 continue;
731 }
732
733 if(w == 0) continue;
734 if(agreed == 0)
735 {
736 agreed = w;
737 }
738 else if(agreed != w)
739 {
740 std::cerr << "rocprofiler-sdk: .sqtt_funcmap wave size disagreement (" << agreed
741 << " vs " << w << " from codeobj id " << id << ")\n";
742 return 0;
743 }
744 }
745 return agreed;
746}

◆ removeDecoder() [1/2]

bool rocprofiler::sdk::codeobj::disassembly::CodeobjAddressTranslate::removeDecoder ( marker_id_t  id)
inline

Definition at line 604 of file code_printing.hpp.

605 {
606 uint64_t addr = 0;
607 if(decoders.find(id) != decoders.end()) addr = decoders.at(id)->begin();
608
609 return removeDecoder(id, addr);
610 }

◆ removeDecoder() [2/2]

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

Definition at line 599 of file code_printing.hpp.

600 {
601 return table.remove(load_addr) && this->Super::removeDecoderbyId(id);
602 }

◆ removeDecoderbyId()

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

Definition at line 527 of file code_printing.hpp.

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

Field Documentation

◆ decoders

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

Definition at line 564 of file code_printing.hpp.

564{};

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