summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author yz70s <yz70s@users.noreply.github.com>2021-08-25 21:07:51 +0200
committer yz70s <yz70s@users.noreply.github.com>2021-08-25 21:41:48 +0200
commit668b276842c05dce22fd465d8ae43e349e02c71e (patch)
tree8971b7c72d2c330610668ac577d2f75bd7bb070f
parentbb7a62bb5abe05d3c95592f57c5d022edeed5cb6 (diff)
i386.cpp: when DEBUG_MISSING_OPCODE is defined, log a small backtrace
This way together with the full list of bytes that form the non recognized opcode there are the addresses of the previously executed instructions.
-rw-r--r--src/devices/cpu/i386/i386.cpp18
-rw-r--r--src/devices/cpu/i386/i386.h2
2 files changed, 16 insertions, 4 deletions
diff --git a/src/devices/cpu/i386/i386.cpp b/src/devices/cpu/i386/i386.cpp
index ce92ca6b679..67fcb48db3b 100644
--- a/src/devices/cpu/i386/i386.cpp
+++ b/src/devices/cpu/i386/i386.cpp
@@ -1557,10 +1557,13 @@ void i386_device::report_invalid_opcode()
#ifndef DEBUG_MISSING_OPCODE
logerror("i386: Invalid opcode %02X at %08X %s\n", m_opcode, m_pc - 1, m_lock ? "with lock" : "");
#else
- logerror("i386: Invalid opcode");
+ logerror("Invalid opcode");
for (int a = 0; a < m_opcode_bytes_length; a++)
logerror(" %02X", m_opcode_bytes[a]);
- logerror(" at %08X\n", m_opcode_pc);
+ logerror(" at %08X %s\n", m_opcode_pc, m_lock ? "with lock" : "");
+ logerror("Backtrace:\n");
+ for (uint32_t i = 1; i < 16; i++)
+ logerror(" %08X\n", m_opcode_addrs[(m_opcode_addrs_index - i) & 15]);
#endif
}
@@ -1569,10 +1572,13 @@ void i386_device::report_invalid_modrm(const char* opcode, uint8_t modrm)
#ifndef DEBUG_MISSING_OPCODE
logerror("i386: Invalid %s modrm %01X at %08X\n", opcode, modrm, m_pc - 2);
#else
- logerror("i386: Invalid %s modrm %01X", opcode, modrm);
+ logerror("Invalid %s modrm %01X", opcode, modrm);
for (int a = 0; a < m_opcode_bytes_length; a++)
logerror(" %02X", m_opcode_bytes[a]);
- logerror(" at %08X\n", m_opcode_pc);
+ logerror(" at %08X %s\n", m_opcode_pc, m_lock ? "with lock" : "");
+ logerror("Backtrace:\n");
+ for (uint32_t i = 1; i < 16; i++)
+ logerror(" %08X\n", m_opcode_addrs[(m_opcode_addrs_index - i) & 15]);
#endif
i386_trap(6, 0, 0);
}
@@ -2441,6 +2447,8 @@ void i386_device::zero_state()
memset( m_opcode_bytes, 0, sizeof(m_opcode_bytes) );
m_opcode_pc = 0;
m_opcode_bytes_length = 0;
+ memset(m_opcode_addrs, 0, sizeof(m_opcode_addrs));
+ m_opcode_addrs_index = 0;
}
void i386_device::device_reset()
@@ -2790,6 +2798,8 @@ void i386_device::execute_run()
#ifdef DEBUG_MISSING_OPCODE
m_opcode_bytes_length = 0;
m_opcode_pc = m_pc;
+ m_opcode_addrs[m_opcode_addrs_index] = m_opcode_pc;
+ m_opcode_addrs_index = (m_opcode_addrs_index + 1) & 15;
#endif
try
{
diff --git a/src/devices/cpu/i386/i386.h b/src/devices/cpu/i386/i386.h
index 64730816b66..d1080b9608c 100644
--- a/src/devices/cpu/i386/i386.h
+++ b/src/devices/cpu/i386/i386.h
@@ -386,6 +386,8 @@ protected:
uint8_t m_opcode_bytes[16];
uint32_t m_opcode_pc;
int m_opcode_bytes_length;
+ offs_t m_opcode_addrs[16];
+ uint32_t m_opcode_addrs_index;
uint64_t m_debugger_temp;