Merge pull request #52 from disba1ancer/gdbstub-x86-64-eip-patch

Fix for gdbstub with x86-64 that truncates instruction pointer while breakpoint check
This commit is contained in:
Stanislav Shwartsman 2023-08-19 10:50:52 +03:00 committed by GitHub
commit b7d4445d34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View File

@ -271,7 +271,7 @@ void print_statistics_tree(bx_param_c *node, int level = 0);
// defines for GDB stub
void bx_gdbstub_init(void);
void bx_gdbstub_break(void);
int bx_gdbstub_check(unsigned int eip);
int bx_gdbstub_check(Bit64u eip);
#define GDBSTUB_STOP_NO_REASON (0xac0)
#if BX_SUPPORT_SMP

View File

@ -775,7 +775,12 @@ bool BX_CPU_C::dbg_instruction_epilog(void)
#if BX_GDBSTUB
if (bx_dbg.gdbstub_enabled) {
unsigned reason = bx_gdbstub_check(EIP);
unsigned reason =
#if BX_SUPPORT_X86_64 == 0
bx_gdbstub_check(EIP);
#else
bx_gdbstub_check(RIP);
#endif
if (reason != GDBSTUB_STOP_NO_REASON) return(1);
}
#endif

View File

@ -257,7 +257,7 @@ void bx_gdbstub_break(void)
bx_enter_gdbstub = 1;
}
int bx_gdbstub_check(unsigned int eip)
int bx_gdbstub_check(Bit64u eip)
{
unsigned int i;
unsigned char ch;
@ -306,7 +306,7 @@ int bx_gdbstub_check(unsigned int eip)
{
if (eip == breakpoints[i])
{
BX_INFO(("found breakpoint at %x", eip));
BX_INFO(("found breakpoint at " FMT_ADDRX64, eip));
last_stop_reason = GDBSTUB_EXECUTION_BREAKPOINT;
return GDBSTUB_EXECUTION_BREAKPOINT;
}