57 lines
1.7 KiB
C++
57 lines
1.7 KiB
C++
#include <iostream>
|
|
#include <final.h>
|
|
#include <stage0.h>
|
|
#include <stage1.h>
|
|
|
|
#include <safe-input.h>
|
|
#include <safe-md5.h>
|
|
#include <pinpoint_config.h>
|
|
#include <pinpoint_error.h>
|
|
|
|
unsigned char cu_uid_md5[16];
|
|
char cu_uid_hex[33];
|
|
|
|
static const unsigned char* calculate_cu_uid_md5() {
|
|
if (!main_input_filename)
|
|
return nullptr;
|
|
|
|
md5_buffer(main_input_filename, strlen(main_input_filename), cu_uid_md5);
|
|
return cu_uid_md5;
|
|
}
|
|
|
|
static const char* calculate_cu_uid_hex() {
|
|
const unsigned char* digest = calculate_cu_uid_md5();
|
|
if (!digest)
|
|
return nullptr;
|
|
|
|
for (int i = 0; i < 16; ++i)
|
|
sprintf(cu_uid_hex + 2*i, "%02x", digest[i]);
|
|
|
|
cu_uid_hex[32] = '\0';
|
|
return cu_uid_hex;
|
|
}
|
|
|
|
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");
|
|
|
|
std::cout << "Finishing unit \"" << lbasename(main_input_filename) << "\" ..." << std::endl;
|
|
std::cout << " Unit UID is 0x" << cu_uid << std::endl;
|
|
|
|
for (const auto& [uid, target] : TargetType::all())
|
|
std::cout << " Target " << uid << " -> \"" << target.name() << "\" (" << target.size() << ")" << std::endl;
|
|
|
|
for (const DataPin& dpin : DataPin::all()) {
|
|
std::cout << " " << (dpin.global ? "Global" : "Local") << " data pin at symbol \""
|
|
<< dpin.symbol << "\":" << std::endl;
|
|
for (const DataPin::Component& c : dpin.components)
|
|
std::cout << " offset " << c.offset << " (level " << c.level << ") -> target " << c.target << std::endl;
|
|
}
|
|
|
|
for (const auto& [uid, ipin] : S1InstructionPin::all()) {
|
|
std::cout << " Instruction pin at symbol \"" << SPSLR_PINPOINT_STAGE1_PIN
|
|
<< uid << "\" -> target " << ipin.target << ", offset " << ipin.offset << std::endl;
|
|
}
|
|
}
|