SWDEV-241902 - Using COMGR APIs for extracing code object.
Change-Id: I96f1cee9c28f89f0b0fa5af0c2ae7966beb3207d
[ROCm/clr commit: 0d9e1de4e3]
Цей коміт міститься в:
зафіксовано
Karthik Jayaprakash
джерело
cb4aa60a37
коміт
c5c1b7fd56
@@ -115,6 +115,10 @@ class Os : AllStatic {
|
||||
// Given a valid file name, returns file descriptor and file size
|
||||
static bool GetFileHandle(const char* fname, FileDesc* fd_ptr, size_t* sz_ptr);
|
||||
|
||||
// Returns the file name & file offset of mapped memory if the file is mapped.
|
||||
static bool FindFileNameFromAddress(const void* image, std::string* fname_ptr,
|
||||
size_t* foffset_ptr);
|
||||
|
||||
// Given a valid file descriptor returns mmaped memory for size and offset
|
||||
static bool MemoryMapFileDesc(FileDesc fdesc, size_t fsize, size_t foffset,
|
||||
const void** mmap_ptr);
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
#include <mutex>
|
||||
#include <fstream>
|
||||
|
||||
namespace amd {
|
||||
|
||||
@@ -746,7 +747,6 @@ void Os::getAppPathAndFileName(std::string& appName, std::string& appPathAndName
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool Os::GetURIFromMemory(const void* image, size_t image_size, std::string& uri) {
|
||||
pid_t pid = getpid();
|
||||
std::ostringstream uri_stream;
|
||||
@@ -790,6 +790,57 @@ bool Os::GetFileHandle(const char* fname, FileDesc* fd_ptr, size_t* sz_ptr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool amd::Os::FindFileNameFromAddress(const void* image, std::string* fname_ptr,
|
||||
size_t* foffset_ptr) {
|
||||
|
||||
// Get the list of mapped file list
|
||||
bool ret_value = false;
|
||||
std::ifstream proc_maps;
|
||||
proc_maps.open("/proc/self/maps", std::ifstream::in);
|
||||
if (!proc_maps.is_open() || !proc_maps.good()) {
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
// For every line on the list map find out low, high address
|
||||
std::string line;
|
||||
while (std::getline(proc_maps, line)) {
|
||||
char dash;
|
||||
std::stringstream tokens(line);
|
||||
uintptr_t low_address, high_address;
|
||||
tokens >> std::hex >> low_address >> std::dec
|
||||
>> dash
|
||||
>> std::hex >> high_address >> std::dec;
|
||||
if (dash != '-') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If address is > low_address and < high_address, then this
|
||||
// is the mapped file. Get the URI path and offset.
|
||||
uintptr_t address = reinterpret_cast<uintptr_t>(image);
|
||||
if ((address >= low_address) && (address < high_address)) {
|
||||
std::string permissions, device, uri_file_path;
|
||||
size_t offset;
|
||||
uint64_t inode;
|
||||
tokens >> permissions
|
||||
>> std::hex >> offset >> std::dec
|
||||
>> device
|
||||
>> inode
|
||||
>> uri_file_path;
|
||||
|
||||
if (inode == 0 || uri_file_path.empty()) {
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
*fname_ptr = uri_file_path;
|
||||
*foffset_ptr = offset + address - low_address;
|
||||
ret_value = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
bool Os::MemoryMapFileDesc(FileDesc fdesc, size_t fsize, size_t foffset, const void** mmap_ptr) {
|
||||
if (fdesc <= 0) {
|
||||
return false;
|
||||
|
||||
@@ -935,6 +935,12 @@ bool Os::MemoryMapFileTruncated(const char* fname, const void** mmap_ptr, size_t
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Os::FindFileNameFromAddress(const void* image, std::string* fname_ptr, size_t* foffset_ptr) {
|
||||
// TODO: Implementation on windows side pending.
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace amd
|
||||
|
||||
#endif // _WIN32 || __CYGWIN__
|
||||
|
||||
@@ -277,7 +277,9 @@ release(uint, ROC_SIGNAL_POOL_SIZE, 32, \
|
||||
release(bool, ROC_SKIP_KERNEL_ARG_COPY, false, \
|
||||
"If true, then runtime can skip kernel arg copy") \
|
||||
release(bool, GPU_STREAMOPS_CP_WAIT, false, \
|
||||
"Force the stream wait memory operation to wait on CP.")
|
||||
"Force the stream wait memory operation to wait on CP.") \
|
||||
release(bool, HIP_USE_RUNTIME_UNBUNDLER, false, \
|
||||
"Use HIP runtime unbundler") \
|
||||
|
||||
namespace amd {
|
||||
|
||||
|
||||
Посилання в новій задачі
Заблокувати користувача