Pinpoint plugin accumulation dump
This commit is contained in:
parent
5f28fd2b22
commit
31d80c3783
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
<sourcefile>.spslr:
|
<sourcefile>.spslr:
|
||||||
|
|
||||||
SPSLR_FINALIZE_HEADER <CU filename> <CU uid symbol>
|
SPSLR <CU filename> <CU uid symbol>
|
||||||
target <name> <local uid> <size> <field count>
|
target <name> <local uid> <size> <field count>
|
||||||
f <offset> <size> <flags>
|
f <offset> <size> <flags>
|
||||||
f <offset> <size> <flags>
|
f <offset> <size> <flags>
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#include <stage1.h>
|
#include <stage1.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
#include <safe-input.h>
|
#include <safe-input.h>
|
||||||
#include <safe-output.h>
|
#include <safe-output.h>
|
||||||
@ -98,6 +99,15 @@ static void emit_cu_uid_label(const std::string& uid) {
|
|||||||
fprintf(asm_out_file, "%s:\n", label);
|
fprintf(asm_out_file, "%s:\n", label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::ofstream open_spslr_output_file(const std::filesystem::path& p) {
|
||||||
|
std::filesystem::create_directories(p.parent_path());
|
||||||
|
std::ofstream out(p);
|
||||||
|
if (!out)
|
||||||
|
pinpoint_fatal("open_spslr_output_file failed to open spslr dump file");
|
||||||
|
|
||||||
|
return std::move(out);
|
||||||
|
}
|
||||||
|
|
||||||
void on_finish_unit(void* plugin_data, void* user_data) {
|
void on_finish_unit(void* plugin_data, void* user_data) {
|
||||||
std::filesystem::path infile = relative_src_path();
|
std::filesystem::path infile = relative_src_path();
|
||||||
std::filesystem::path outfile = spslr_output_file(infile);
|
std::filesystem::path outfile = spslr_output_file(infile);
|
||||||
@ -110,20 +120,45 @@ void on_finish_unit(void* plugin_data, void* user_data) {
|
|||||||
|
|
||||||
emit_cu_uid_label(cu_uid);
|
emit_cu_uid_label(cu_uid);
|
||||||
|
|
||||||
// TODO -> Dump to outfile
|
// Dump all accumulated data to spslr file
|
||||||
|
|
||||||
for (const auto& [uid, target] : TargetType::all())
|
std::ofstream out = open_spslr_output_file(outfile);
|
||||||
std::cout << " Target " << uid << " -> \"" << target.name() << "\" (" << target.size() << ")" << std::endl;
|
|
||||||
|
// Header associates data with compilation unit
|
||||||
|
|
||||||
|
out << "SPSLR " << infile.string() << " " << cu_uid << std::endl;
|
||||||
|
|
||||||
|
// Dump all target structs
|
||||||
|
|
||||||
|
for (const auto& [uid, target] : TargetType::all()) {
|
||||||
|
// target <name> <local uid> <size> <field count>
|
||||||
|
out << "target " << target.name() << " " << uid << " " << target.size()
|
||||||
|
<< " " << target.fields().size() << std::endl;
|
||||||
|
|
||||||
|
if (!target.has_fields())
|
||||||
|
pinpoint_fatal("on_finish_unit encountered incomplete target type");
|
||||||
|
|
||||||
|
for (const auto& [off, field] : target.fields()) {
|
||||||
|
// f <offset> <size> <flags>
|
||||||
|
out << "f " << field.offset << " " << field.size << " " << field.flags << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dump all data pins
|
||||||
|
|
||||||
for (const DataPin& dpin : DataPin::all()) {
|
for (const DataPin& dpin : DataPin::all()) {
|
||||||
std::cout << " " << (dpin.global ? "Global" : "Local") << " data pin at symbol \""
|
for (const DataPin::Component& c : dpin.components) {
|
||||||
<< dpin.symbol << "\":" << std::endl;
|
// dpin <local/global> <symbol> <offset> <level> <target uid>
|
||||||
for (const DataPin::Component& c : dpin.components)
|
out << "dpin " << (dpin.global ? "g" : "l") << " " << dpin.symbol << " "
|
||||||
std::cout << " offset " << c.offset << " (level " << c.level << ") -> target " << c.target << std::endl;
|
<< c.offset << " " << c.level << " " << c.target << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dump all instruction pins
|
||||||
|
|
||||||
for (const auto& [uid, ipin] : S1InstructionPin::all()) {
|
for (const auto& [uid, ipin] : S1InstructionPin::all()) {
|
||||||
std::cout << " Instruction pin at symbol \"" << SPSLR_PINPOINT_STAGE1_PIN
|
// ipin <label> <target uid> <field offset>
|
||||||
<< uid << "\" -> target " << ipin.target << ", offset " << ipin.offset << std::endl;
|
out << "ipin " << SPSLR_PINPOINT_STAGE1_PIN << uid << " "
|
||||||
|
<< ipin.target << " " << ipin.offset << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,7 +42,8 @@ public:
|
|||||||
~TargetType();
|
~TargetType();
|
||||||
|
|
||||||
bool valid() const;
|
bool valid() const;
|
||||||
bool fields() const;
|
bool has_fields() const;
|
||||||
|
const std::map<std::size_t, Field>& fields() const;
|
||||||
std::string name() const;
|
std::string name() const;
|
||||||
const Field* field(std::size_t off, bool exact = true) const;
|
const Field* field(std::size_t off, bool exact = true) const;
|
||||||
UID uid() const;
|
UID uid() const;
|
||||||
|
|||||||
@ -26,10 +26,14 @@ bool TargetType::valid() const {
|
|||||||
return (m_flags & FLAG_MAIN_VARIANT) != 0;
|
return (m_flags & FLAG_MAIN_VARIANT) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TargetType::fields() const {
|
bool TargetType::has_fields() const {
|
||||||
return (m_flags & FLAG_FIELDS) != 0;
|
return (m_flags & FLAG_FIELDS) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::map<std::size_t, TargetType::Field>& TargetType::fields() const {
|
||||||
|
return m_fields;
|
||||||
|
}
|
||||||
|
|
||||||
std::string TargetType::name() const {
|
std::string TargetType::name() const {
|
||||||
const char* error_name = "<error>";
|
const char* error_name = "<error>";
|
||||||
const char* anonymous_name = "<anonymous>";
|
const char* anonymous_name = "<anonymous>";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user