-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add more magic breakpoints fix #55 #56
add more magic breakpoints fix #55 #56
Conversation
bochs/.bochsrc
Outdated
# debugger mode. This might be useful for software development. | ||
# | ||
# Example: | ||
# Register number id: | ||
# 0: DISABLE MAGIC_BREAK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
I haven't even notice these pull requests.
For some reason I didn't receive a notification from github,
This one is fine (with small adjustments to make to match general Bochs coding style).
How about adding capability to control/toggle them from inside the debugger interface ?
How about enabling more than one together ?
I think it should be a bitmask of 8 bits instead of bool in bx_dbg.magic_break and checking smth like
((1<dst()) & bx_dbg.magic_break)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome idea! I will do it :-)
bochs/bx_debug/dbg_main.cc
Outdated
{ | ||
new_mask |= 1 << 1; | ||
} | ||
if (strstr(str, "%sp") != NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you think strstr is better than strcmp ?
in your case %spd will be catched too as well as %sp
@stlintel take a look! more suggestions? |
bochs/bx_debug/dbg_main.cc
Outdated
{ | ||
new_mask |= 1 << MBP_CX; | ||
} | ||
if (strstr(str, "dx") != NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still - why strstr ?
bochs/bx_debug/dbg_main.cc
Outdated
@@ -3791,7 +3840,7 @@ void bx_dbg_print_help(void) | |||
dbg_printf("h|help command - show short command description\n"); | |||
dbg_printf("-*- Debugger control -*-\n"); | |||
dbg_printf(" help, q|quit|exit, set, instrument, show, trace, trace-reg,\n"); | |||
dbg_printf(" trace-mem, u|disasm, ldsym, slist, addlyt, remlyt, lyt, source\n"); | |||
dbg_printf(" trace-mem, u|disasm, ldsym, setmagicbps, slist, addlyt, remlyt, lyt, source\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about clearmagicbps ?
di is the 7 register id, so I store it in 7nth position in mask Bits are counted from 0: why -1 ? BTW, to generate 1000000 you need 1<<7 |
Please also pay attention on indentation requirements |
@stlintel I fix my coding style and I remove -1 and checking 0. do you like in this way? Tested and working 100% |
done! @stlintel |
bochs/bx_debug/dbg_main.cc
Outdated
{ | ||
dbg_printf("magic breakpoint mask: 0x%x ", mask); | ||
|
||
if (mask & MBP_CX) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static const char *regs = { "ax" /* not accessible */, "cx", "dx", "bx", "sp", "bp", "si", "di" };
for (int i=1;i<8;i++)
if (mask & (1<<i))
dbg_printf("%s ", regs[i]);
bochs/bx_debug/dbg_main.cc
Outdated
|
||
Bit8u bx_dbg_get_magic_bp_mask_from_str(const char *str) | ||
{ | ||
Bit8u new_mask = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
for (int i=1; i<8;i++)
if (strstr(str, regs[i])
new_mask |= (1<<i)
// bx for backward compatilibility
if (new_mask == 0)
new_mask = (1<<BX_16BIT_REG_BX);
bochs/bx_debug/debug.h
Outdated
@@ -204,6 +208,16 @@ int bx_dbg_lbreakpoint_symbol_command(const char *Symbol, const char *condition) | |||
bx_address bx_dbg_get_symbol_value(const char *Symbol); | |||
const char* bx_dbg_disasm_symbolic_address(bx_address eip, bx_address base); | |||
|
|||
typedef enum { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and without that enum
This PR was moved to #58
Implemented support for various types of magic breakpoints, along with the ability to modify them at runtime from within the debugger. So, the Windows XP NTLDR will no longer be a problem.
fix #55
windows xp ntldr have code like this:
And this code is called a lot of times!
ring3 code CANT execute OUT instruction (0x8AE0)
So the ring3-dev cant use magic breakpoints on Bochs debugger (on first instance)
with this PR, the user can select what register should breaks:
This PR is 100% backward compatibility
Added a new command to change from debugger the mask of registers, example adding XCHGW %DI, %DI or XCHGW %BX, %BX
@stlintel @vruppert do you like it?