From 91a329122b43362314d174ce9e5d58baa1cf12a6 Mon Sep 17 00:00:00 2001 From: York Jasper Niebuhr Date: Sun, 26 Oct 2025 14:15:18 +0100 Subject: [PATCH] Pinpoint plugin CU identifier labels --- pinpoint/final/on_finish_unit.cpp | 12 ++++++++++++ pinpoint/pinpoint_config.h | 1 + pinpoint/safegcc/safe-output.h | 8 ++++++++ 3 files changed, 21 insertions(+) create mode 100644 pinpoint/safegcc/safe-output.h diff --git a/pinpoint/final/on_finish_unit.cpp b/pinpoint/final/on_finish_unit.cpp index a69d7b7..7d6c295 100644 --- a/pinpoint/final/on_finish_unit.cpp +++ b/pinpoint/final/on_finish_unit.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -31,11 +32,22 @@ static const char* calculate_cu_uid_hex() { return cu_uid_hex; } +static bool emit_cu_uid_label(const char* uid) { + char label[128]; + snprintf(label, sizeof(label), SPSLR_PINPOINT_CU_UID_LABEL "%s", uid); + + fprintf(asm_out_file, "%s:\n", label); + return true; +} + void on_finish_unit(void* plugin_data, void* user_data) { const char* cu_uid = calculate_cu_uid_hex(); if (!cu_uid) pinpoint_fatal("on_finish_unit failed to calculate compilation unit UID"); + if (!emit_cu_uid_label(cu_uid)) + pinpoint_fatal("on_finish_unit failed to emit CU UID label"); + std::cout << "Finishing unit \"" << lbasename(main_input_filename) << "\" ..." << std::endl; std::cout << " Unit UID is 0x" << cu_uid << std::endl; diff --git a/pinpoint/pinpoint_config.h b/pinpoint/pinpoint_config.h index 2ccbaf1..8666d27 100644 --- a/pinpoint/pinpoint_config.h +++ b/pinpoint/pinpoint_config.h @@ -3,3 +3,4 @@ #define SPSLR_ATTRIBUTE "spslr" #define SPSLR_PINPOINT_STAGE0_SEPARATOR "__spslr_offsetof" #define SPSLR_PINPOINT_STAGE1_PIN "__spslr_ipin_" /* suffixed with "" */ +#define SPSLR_PINPOINT_CU_UID_LABEL "__spslr_cu_" /* suffixed with "" */ diff --git a/pinpoint/safegcc/safe-output.h b/pinpoint/safegcc/safe-output.h new file mode 100644 index 0000000..5da7fec --- /dev/null +++ b/pinpoint/safegcc/safe-output.h @@ -0,0 +1,8 @@ +#include + +#ifndef SAFEGCC_OUTPUT_H +#define SAFEGCC_OUTPUT_H + +#include + +#endif