11// SPDX-License-Identifier: Apache-2.0
22// Copyright (C) 2026 Advanced Micro Devices, Inc. All rights reserved.
3+ #define XCL_DRIVER_DLL_EXPORT // in same dll as exported xrt apis
4+ #define XRT_CORE_COMMON_SOURCE // in same dll as coreutil
5+ #define XRT_API_SOURCE // in same dll as coreutil
6+
37#include " capture.h"
48#include " detail/capture_artifacts.h"
59#include " detail/capture_fnfwd.h"
913
1014#include " core/common/config_reader.h"
1115#include " core/common/debug.h"
16+ #include " core/common/error.h"
1217#include " core/common/api/bo_int.h"
1318#include " core/common/api/elf_int.h"
1419#include " core/common/api/hw_context_int.h"
@@ -53,7 +58,7 @@ insert_json_object(json& dest, const json& src)
5358static uint64_t
5459to_uint64 (span<const uint8_t > data)
5560{
56- if (data.size () > 8 )
61+ if (data.size () > sizeof ( uint64_t ) )
5762 throw std::runtime_error (" Wrong data size" );
5863
5964 uint64_t value = 0 ;
@@ -114,6 +119,7 @@ class frames
114119 }
115120
116121 public:
122+ explicit
117123 bo (xrt::bo bo)
118124 : m_bo{std::move (bo)}
119125 , m_id{get_uid ()}
@@ -208,6 +214,7 @@ class frames
208214 }
209215
210216 public:
217+ explicit
211218 run (const xrt::run_impl* hdl)
212219 : m_hdl{hdl}
213220 , m_run{xrt_core::kernel_int::get_run_from_impl (m_hdl)}
@@ -314,6 +321,7 @@ class frames
314321 const xrt::runlist_impl* m_hdl;
315322 std::vector<const run*> m_runs;
316323 public:
324+ explicit
317325 runlist (const xrt::runlist_impl* hdl)
318326 : m_hdl{hdl}
319327 {}
@@ -400,7 +408,7 @@ class frames
400408
401409 // Process current run args. Dump data if arg is a bo.
402410 for (auto & rarg : run->get_args ()) {
403- std::visit ([&args, &repo, run] (auto & v) {
411+ std::visit ([&args, &repo, run] (const auto & v) {
404412 using T = std::decay_t <decltype (v)>;
405413 if constexpr (std::is_same_v<T, const bo*>) {
406414 if (!v->is_valid (run)) {
@@ -414,8 +422,12 @@ class frames
414422 v->set_run (run);
415423 }
416424 }
417- else if constexpr (std::is_same_v<T, uint64_t >)
418- args.push_back (v);
425+ else if constexpr (std::is_same_v<T, uint64_t >) {
426+ // gcc14 comple error requires explicit help here
427+ // args.push_back(v); // fails RHEL10 (gcc14)
428+ // args.emplace_back(arg_type{v}); // also fails
429+ args.emplace_back (std::in_place_index<0 >, v);
430+ }
419431 }, rarg);
420432 }
421433 XRT_DEBUGF (" <- capture_frame_start(run:0x%x)\n " , run);
@@ -451,10 +463,11 @@ class frames
451463 {
452464 return std::visit ([](const auto & v) -> const void * {
453465 using T = std::decay_t <decltype (v)>;
466+ // branch clone is repeated to make compiler happy
454467 if constexpr (std::is_same_v<T, run*>)
455- return v->get_handle ();
468+ return v->get_handle (); // NOLINT
456469 else if constexpr (std::is_same_v<T, runlist*>)
457- return v->get_handle ();
470+ return v->get_handle (); // NOLINT
458471 }, m_frame);
459472 }
460473
@@ -532,7 +545,13 @@ class frames
532545
533546 ~frames ()
534547 {
535- save_replay_script ();
548+ try {
549+ save_replay_script ();
550+ }
551+ catch (const std::exception& ex) {
552+ xrt_core::send_exception_message (" could not save replay script: " + std::string (ex.what ()));
553+ }
554+
536555 }
537556
538557 std::string
0 commit comments