about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorTheofilos Augoustis <theofilos.augoustis@gmail.com>2025-10-17 13:06:08 +0000
committerTheofilos Augoustis <theofilos.augoustis@gmail.com>2025-10-30 13:41:07 +0000
commit8d374649c8103c4f7a2c1e9f48c444254b079f3a (patch)
treea725413a4b5dfa930ea89beb0b1808d8a06e2983
parent5b712ab8e1fdc3f18181d5a5970db6ef3e314c95 (diff)
downloadfocaccia-8d374649c8103c4f7a2c1e9f48c444254b079f3a.tar.gz
focaccia-8d374649c8103c4f7a2c1e9f48c444254b079f3a.zip
Enable LLDB disassembly when Miasm disassembly fails for better diagnostics
-rw-r--r--src/focaccia/lldb_target.py5
-rw-r--r--src/focaccia/symbolic.py9
2 files changed, 13 insertions, 1 deletions
diff --git a/src/focaccia/lldb_target.py b/src/focaccia/lldb_target.py
index c5042d5..8d3dbd9 100644
--- a/src/focaccia/lldb_target.py
+++ b/src/focaccia/lldb_target.py
@@ -316,3 +316,8 @@ class LLDBConcreteTarget:
                 if s.GetStartAddress().GetLoadAddress(self.target) > addr:
                     addr = s.GetEndAddress().GetLoadAddress(self.target)
         return addr
+
+    def get_disassembly(self, addr: int) -> str:
+        inst = self.target.ReadInstructions(lldb.SBAddress(addr, self.target), 1)[0]
+        return f'{inst.GetMnemonic(self.target)} {inst.GetOperands(self.target)}'
+
diff --git a/src/focaccia/symbolic.py b/src/focaccia/symbolic.py
index 39b3f6e..7e82628 100644
--- a/src/focaccia/symbolic.py
+++ b/src/focaccia/symbolic.py
@@ -644,7 +644,14 @@ def collect_symbolic_trace(env: TraceEnvironment,
             instr = ctx.mdis.dis_instr(pc)
         except:
             err = sys.exc_info()[1]
-            warn(f'Unable to disassemble instruction at {hex(pc)}: {err}.'
+
+            # Try to get the LLDB disassembly instead to simplify debugging
+            try:
+                alt_disas = target.get_disassembly(pc)
+            except:
+                warn(f'Unable to disassemble instruction at {hex(pc)}: {err}.'
+                     f' Skipping.')
+            warn(f'Unable to disassemble instruction {alt_disas} at {hex(pc)}: {err}.'
                  f' Skipping.')
             target.step()
             continue