summaryrefslogtreecommitdiff
path: root/src/disasm.cpp
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2025-01-04 16:07:56 +0300
committerOxore <oxore@protonmail.com>2025-01-07 14:39:01 +0300
commit07ff2ebf9b29084670fb3fa46f8427d3272117d5 (patch)
treed8dd69aa52800b6c17ec0bee78b840dc9784a74a /src/disasm.cpp
parentcb96278e25140cfcc1afc22df2102bcf3b6ae38c (diff)
Integrate the new trace table parser
Diffstat (limited to 'src/disasm.cpp')
-rw-r--r--src/disasm.cpp28
1 files changed, 27 insertions, 1 deletions
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 <cassert>
-#include <cstring>
#include <cerrno>
+#include <cinttypes>
+#include <cstring>
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<TraceTable &&>(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<unsigned long>(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 &&