Skip to content

Commit

Permalink
Merge pull request #52 from disba1ancer/gdbstub-x86-64-eip-patch
Browse files Browse the repository at this point in the history
Fix for gdbstub with x86-64 that truncates instruction pointer while breakpoint check
  • Loading branch information
stlintel committed Aug 19, 2023
2 parents ba2747b + c11006a commit b7d4445
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bochs/bochs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion bochs/cpu/cpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions bochs/gdbstub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit b7d4445

Please sign in to comment.