Pinpoint plugin CU identifier labels

This commit is contained in:
York Jasper Niebuhr 2025-10-26 14:15:18 +01:00
parent d3094ce698
commit 91a329122b
3 changed files with 21 additions and 0 deletions

View File

@ -4,6 +4,7 @@
#include <stage1.h> #include <stage1.h>
#include <safe-input.h> #include <safe-input.h>
#include <safe-output.h>
#include <safe-md5.h> #include <safe-md5.h>
#include <pinpoint_config.h> #include <pinpoint_config.h>
#include <pinpoint_error.h> #include <pinpoint_error.h>
@ -31,11 +32,22 @@ static const char* calculate_cu_uid_hex() {
return 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) { void on_finish_unit(void* plugin_data, void* user_data) {
const char* cu_uid = calculate_cu_uid_hex(); const char* cu_uid = calculate_cu_uid_hex();
if (!cu_uid) if (!cu_uid)
pinpoint_fatal("on_finish_unit failed to calculate compilation unit 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 << "Finishing unit \"" << lbasename(main_input_filename) << "\" ..." << std::endl;
std::cout << " Unit UID is 0x" << cu_uid << std::endl; std::cout << " Unit UID is 0x" << cu_uid << std::endl;

View File

@ -3,3 +3,4 @@
#define SPSLR_ATTRIBUTE "spslr" #define SPSLR_ATTRIBUTE "spslr"
#define SPSLR_PINPOINT_STAGE0_SEPARATOR "__spslr_offsetof" #define SPSLR_PINPOINT_STAGE0_SEPARATOR "__spslr_offsetof"
#define SPSLR_PINPOINT_STAGE1_PIN "__spslr_ipin_" /* suffixed with "<uid>" */ #define SPSLR_PINPOINT_STAGE1_PIN "__spslr_ipin_" /* suffixed with "<uid>" */
#define SPSLR_PINPOINT_CU_UID_LABEL "__spslr_cu_" /* suffixed with "<uid>" */

View File

@ -0,0 +1,8 @@
#include <safe-gcc-plugin.h>
#ifndef SAFEGCC_OUTPUT_H
#define SAFEGCC_OUTPUT_H
#include <output.h>
#endif