Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/runtime_src/core/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ endif()
# INSTALL_INTERFACE is for external targets that link XRT::xrt_coreutil
# Link aiebu dtrace library when aiebu is built
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.18.0")
target_link_libraries(xrt_coreutil PRIVATE cert_dtrace_static)
target_link_libraries(xrt_coreutil_static PRIVATE cert_dtrace_static)
target_link_libraries(xrt_coreutil PRIVATE cert_dtrace_static aiebu_static)
target_link_libraries(xrt_coreutil_static PRIVATE cert_dtrace_static aiebu_static)
endif()

target_include_directories(xrt_coreutil
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_src/core/common/aiebu
Submodule aiebu updated 145 files
1 change: 1 addition & 0 deletions src/runtime_src/core/common/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ target_include_directories(core_common_api_library_objects
PRIVATE
${XRT_SOURCE_DIR}/runtime_src
${XRT_SOURCE_DIR}/runtime_src/core/common/elf
${XRT_SOURCE_DIR}/runtime_src/core/common/aiebu/src/cpp/include
Comment thread
sayyanna marked this conversation as resolved.
Outdated
)
52 changes: 47 additions & 5 deletions src/runtime_src/core/common/api/xrt_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
#include "core/common/runner/capture.h"
#include "core/common/xdp/profile.h"

#include "core/common/aiebu/src/cpp/include/aiebu/aiebu_debug.h"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't "aiebu/aiebu_debug.h" enough?

@stsoe stsoe Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't "aiebu/aiebu_debug.h" enough?

We could add core/common/aiebu/src/cpp/include to include search path for specific targerts. That would allow #include "aiebu/aiebu_debug.h" We should then make sure dtrace has its exported header files in same folder.


#include <boost/format.hpp>

#include <algorithm>
Expand Down Expand Up @@ -2725,6 +2727,19 @@ class run_impl : public std::enable_shared_from_this<run_impl>
return m_module;
}

std::shared_ptr<xrt::elf_impl>
Comment thread
sayyanna marked this conversation as resolved.
Outdated
get_elf_handle() const
{
if (!m_module)
return {};
try {
return xrt_core::module_int::get_elf_handle(m_module);
}
catch (const std::exception&) {
return {};
}
Comment thread
sayyanna marked this conversation as resolved.
Outdated
}

kernel_command*
get_cmd() const
{
Expand Down Expand Up @@ -5047,7 +5062,7 @@ what() const noexcept
static std::string
aie_error_message_v1(const ert_packet* epkt, const std::string& msg,
const std::string& elf_filename, const std::string& kernel_instance,
const std::string& elf_uuid)
const std::string& elf_uuid, const xrt::elf_impl* elf_impl_ptr = nullptr)
{
constexpr auto indent8 = 8;
auto ctx_health = get_ert_ctx_health_data_v1(epkt);
Expand Down Expand Up @@ -5118,6 +5133,29 @@ aie_error_message_v1(const ert_packet* epkt, const std::string& msg,
<< "\nuc_esr=0x" << std::setw(indent8)
<< ctx_health->aie4.uc_info[i].uc_esr
<< "\n";

// Decode the opcode at (uc_idx, page_idx, offset) directly from the ELF binary
if (elf_impl_ptr) {
aiebu::AIEDebug dbg(elf_impl_ptr->get_elfio());
auto info = dbg.get_opcode_information(
kernel_instance,
ctx_health->aie4.uc_info[i].uc_idx,
ctx_health->aie4.uc_info[i].page_idx,
ctx_health->aie4.uc_info[i].offset);
if (info.found) {
oss << "\nOpcode: " << info.opcode_name;
if (!info.args_str.empty())
oss << " " << info.args_str;
oss << "\nOpcode Size: 0x" << std::hex << info.opcode_size;
if (info.line > 0)
oss << "\nLine: " << std::dec << info.line;
if (!info.source_file.empty())
oss << "\nFile: " << info.source_file;
oss << "\n";
}
if (!info.diag_info.empty())
oss << "Opcode diag_info: " << info.diag_info << "\n";
}
}
}
return oss.str();
Expand All @@ -5138,12 +5176,11 @@ get_elf_identity_from_run(const xrt::run& run)
if (!impl)
return {};

const auto& mod = impl->get_module();
if (!mod)
auto elf_handle = impl->get_elf_handle();
if (!elf_handle)
return {};

try {
auto elf_handle = xrt_core::module_int::get_elf_handle(mod);
return {xrt_core::elf_int::get_filename(elf_handle.get()),
impl->get_kernel()->get_full_name(),
elf_handle->get_cfg_uuid().to_string()};
Expand All @@ -5163,7 +5200,12 @@ amend_aie_error_message(const xrt::run& run, const std::string& msg)

if (epkt->data[0] == ERT_CTX_HEALTH_DATA_V1) {
auto [elf_filename, kernel_instance, elf_uuid] = get_elf_identity_from_run(run);
return aie_error_message_v1(epkt, msg, elf_filename, kernel_instance, elf_uuid);
// Retrieve parsed ELF for efficient binary decode (no re-parsing overhead)
std::shared_ptr<xrt::elf_impl> elf_handle;
if (auto impl = run.get_handle())
elf_handle = impl->get_elf_handle();
return aie_error_message_v1(epkt, msg, elf_filename, kernel_instance, elf_uuid,
elf_handle.get());
Comment thread
sayyanna marked this conversation as resolved.
Outdated
}
else if (epkt->data[0] != ERT_CTX_HEALTH_DATA_V0)
return msg;
Expand Down
Loading