Files
TheRock/compiler/amd-llvm/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_amdgpu.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

105 lines
3.1 KiB
C++

//===-- sanitizer_symbolizer_amdgpu.cpp -------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
#if SANITIZER_AMDGPU
# include "sanitizer_symbolizer_amdgpu.h"
# include <dlfcn.h> //For dlsym
namespace __sanitizer {
static COMgrFunctions comgr = {false};
void getSourceLocation(const char *Result, void *ScopedString) {
InternalScopedString *ScopedStringObj = (InternalScopedString *)ScopedString;
ScopedStringObj->Append(Result);
}
void AMDGPUCodeObjectSymbolizer::InitCOMgr() {
if (!comgr.inited_) {
comgr.create_data =
(decltype(comgr.create_data))dlsym(RTLD_NEXT, "amd_comgr_create_data");
comgr.set_data =
(decltype(comgr.set_data))dlsym(RTLD_NEXT, "amd_comgr_set_data");
comgr.set_data_from_file_slice =
(decltype(comgr.set_data_from_file_slice))dlsym(
RTLD_NEXT, "amd_comgr_set_data_from_file_slice");
comgr.create_symbolizer = (decltype(comgr.create_symbolizer))dlsym(
RTLD_NEXT, "amd_comgr_create_symbolizer_info");
comgr.symbolize =
(decltype(comgr.symbolize))dlsym(RTLD_NEXT, "amd_comgr_symbolize");
comgr.destroy_symbolizer = (decltype(comgr.destroy_symbolizer))dlsym(
RTLD_NEXT, "amd_comgr_destroy_symbolizer_info");
comgr.release_data = (decltype(comgr.release_data))dlsym(
RTLD_NEXT, "amd_comgr_release_data");
comgr.inited_ = comgr.create_data && comgr.set_data &&
comgr.set_data_from_file_slice && comgr.create_symbolizer &&
comgr.symbolize && comgr.destroy_symbolizer &&
comgr.release_data;
}
}
void AMDGPUCodeObjectSymbolizer::Init(int fd, uint64_t off, uint64_t size) {
InitCOMgr();
if (comgr.inited_) {
if (comgr.create_data(AMD_COMGR_DATA_KIND_EXECUTABLE, &codeobject))
return;
object_cnt = comgr_objects::data;
if (fd != -1) {
if (comgr.set_data_from_file_slice(codeobject, fd, off, size)) {
Release();
return;
}
} else {
if (comgr.set_data(codeobject, size, off)) {
Release();
return;
}
}
if (comgr.create_symbolizer(codeobject, &getSourceLocation, &symbolizer)) {
Release();
return;
}
object_cnt = comgr_objects::data_and_symb;
init = true;
}
}
bool AMDGPUCodeObjectSymbolizer::SymbolizePC(uptr addr,
InternalScopedString &source_loc) {
if (!init)
return false;
comgr.symbolize(symbolizer, addr, true, (void *)&source_loc);
return true;
}
void AMDGPUCodeObjectSymbolizer::Release() {
// fall-through is avoided to silence warnings.
switch (object_cnt) {
case comgr_objects::data_and_symb: {
comgr.destroy_symbolizer(symbolizer);
comgr.release_data(codeobject);
break;
}
case comgr_objects::data: {
comgr.release_data(codeobject);
break;
}
default: {
}
}
}
} // namespace __sanitizer
#endif