From 07ff2ebf9b29084670fb3fa46f8427d3272117d5 Mon Sep 17 00:00:00 2001 From: Oxore Date: Sat, 4 Jan 2025 16:07:56 +0300 Subject: Integrate the new trace table parser --- src/disasm.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/disasm.cpp') diff --git a/src/disasm.cpp b/src/disasm.cpp index 572030d..a7dc07b 100644 --- a/src/disasm.cpp +++ b/src/disasm.cpp @@ -5,8 +5,9 @@ #include "m68k.h" #include -#include #include +#include +#include void DisasmNode::AddReferencedBy(const uint32_t address_from, const ReferenceType ref_type) { @@ -150,6 +151,31 @@ bool DisasmMap::ApplySymbolsFromElf(const ELF::Image &elf) return true; } +void DisasmMap::ConsumeTraceTable(TraceTable &&tt) +{ + this->_tt = static_cast(tt); + const size_t nodes_count = _tt.NodesCount(); + for (size_t n = 0; n < nodes_count; n++) { + const auto &node = _tt.Node(n); + if (node.kind == TraceNodeKind::kPc) { + if (node.address % 2) { + fprintf(stderr, + "Error: Uneven PC values are not supported " + "(got PC=0x%08" PRIu32 "), exiting\n", + node.address); + exit(1); + } else if (static_cast(node.address) > kRomSizeBytes) { + fprintf(stderr, + "Error: PC values > 4MiB are not supported " + "(got PC=0x%08" PRIu32 "), exiting\n", + node.address); + exit(1); + } + insertNode(node.address, NodeType::kTracedInstruction); + } + } +} + static constexpr bool IsNextLikelyAnInstruction(const Op &op) { return (op.opcode != OpCode::kNone && -- cgit v1.2.3