LoadedCodeobjDecoder Class Reference

LoadedCodeobjDecoder Class Reference#

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

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

+ Collaboration diagram for rocprofiler::codeobj::disassembly::LoadedCodeobjDecoder:

Public Member Functions

 LoadedCodeobjDecoder (const char *filepath, uint64_t _load_addr, uint64_t _memsize)
 
 LoadedCodeobjDecoder (const void *data, uint64_t size, uint64_t _load_addr, unsigned long _memsize)
 
std::unique_ptr< Instructionget (uint64_t ld_addr)
 
uint64_t begin () const
 
uint64_t end () const
 
uint64_t size () const
 
bool inrange (uint64_t addr) const
 
const char * getSymbolName (uint64_t addr) const
 
std::map< uint64_t, SymbolInfo > & getSymbolMap () const
 

Data Fields

const uint64_t load_addr
 

Detailed Description

Definition at line 193 of file code_printing.hpp.

Constructor & Destructor Documentation

◆ LoadedCodeobjDecoder() [1/2]

rocprofiler::codeobj::disassembly::LoadedCodeobjDecoder::LoadedCodeobjDecoder ( const char *  filepath,
uint64_t  _load_addr,
uint64_t  _memsize 
)
inline

Definition at line 196 of file code_printing.hpp.

197 : load_addr(_load_addr)
198 , load_end(_load_addr + _memsize)
199 {
200 if(!filepath) throw std::runtime_error("Empty filepath.");
201
202 std::string_view fpath(filepath);
203
204 if(fpath.rfind(".out") + 4 == fpath.size())
205 {
206 std::ifstream file(filepath, std::ios::in | std::ios::binary);
207
208 if(!file.is_open()) throw std::runtime_error("Invalid file " + std::string(filepath));
209
210 std::vector<char> buffer;
211 file.seekg(0, file.end);
212 buffer.resize(file.tellg());
213 file.seekg(0, file.beg);
214 file.read(buffer.data(), buffer.size());
215
216 decoder = std::make_unique<CodeobjDecoderComponent>(buffer.data(), buffer.size());
217 }
218 else
219 {
220 std::unique_ptr<CodeObjectBinary> binary = std::make_unique<CodeObjectBinary>(filepath);
221 auto& buffer = binary->buffer;
222 decoder = std::make_unique<CodeobjDecoderComponent>(buffer.data(), buffer.size());
223 }
224 }

◆ LoadedCodeobjDecoder() [2/2]

rocprofiler::codeobj::disassembly::LoadedCodeobjDecoder::LoadedCodeobjDecoder ( const void *  data,
uint64_t  size,
uint64_t  _load_addr,
unsigned long  _memsize 
)
inline

Definition at line 225 of file code_printing.hpp.

226 : load_addr(_load_addr)
227 , load_end(load_addr + _memsize)
228 {
229 decoder =
230 std::make_unique<CodeobjDecoderComponent>(reinterpret_cast<const char*>(data), size);
231 }

References size().

+ Here is the call graph for this function:

Member Function Documentation

◆ begin()

uint64_t rocprofiler::codeobj::disassembly::LoadedCodeobjDecoder::begin ( ) const
inline

Definition at line 246 of file code_printing.hpp.

246{ return load_addr; };

References load_addr.

Referenced by inrange().

+ Here is the caller graph for this function:

◆ end()

uint64_t rocprofiler::codeobj::disassembly::LoadedCodeobjDecoder::end ( ) const
inline

Definition at line 247 of file code_printing.hpp.

247{ return load_end; }

Referenced by inrange().

+ Here is the caller graph for this function:

◆ get()

std::unique_ptr< Instruction > rocprofiler::codeobj::disassembly::LoadedCodeobjDecoder::get ( uint64_t  ld_addr)
inline

Definition at line 232 of file code_printing.hpp.

233 {
234 if(!decoder || ld_addr < load_addr) return nullptr;
235
236 uint64_t voffset = ld_addr - load_addr;
237 auto faddr = decoder->va2fo(voffset);
238 if(!faddr) return nullptr;
239
240 auto unique = decoder->disassemble_instruction(*faddr, voffset);
241 if(unique == nullptr || unique->size == 0) return nullptr;
242 unique->ld_addr = ld_addr;
243 return unique;
244 }

References load_addr.

◆ getSymbolMap()

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

Definition at line 261 of file code_printing.hpp.

262 {
263 if(!decoder) throw std::exception();
264 return decoder->m_symbol_map;
265 }

◆ getSymbolName()

const char * rocprofiler::codeobj::disassembly::LoadedCodeobjDecoder::getSymbolName ( uint64_t  addr) const
inline

Definition at line 251 of file code_printing.hpp.

252 {
253 if(!decoder) return nullptr;
254
255 auto it = decoder->m_symbol_map.find(addr - load_addr);
256 if(it != decoder->m_symbol_map.end()) return it->second.name.data();
257
258 return nullptr;
259 }

References load_addr.

◆ inrange()

bool rocprofiler::codeobj::disassembly::LoadedCodeobjDecoder::inrange ( uint64_t  addr) const
inline

Definition at line 249 of file code_printing.hpp.

References begin(), and end().

+ Here is the call graph for this function:

◆ size()

uint64_t rocprofiler::codeobj::disassembly::LoadedCodeobjDecoder::size ( ) const
inline

Definition at line 248 of file code_printing.hpp.

248{ return load_end - load_addr; }

References load_addr.

Referenced by LoadedCodeobjDecoder().

+ Here is the caller graph for this function:

Field Documentation

◆ load_addr

const uint64_t rocprofiler::codeobj::disassembly::LoadedCodeobjDecoder::load_addr

Definition at line 266 of file code_printing.hpp.

Referenced by begin(), get(), getSymbolName(), and size().


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