Skip to content
Snippets Groups Projects
Commit 62d67c1e authored by Raymond Toy's avatar Raymond Toy
Browse files

More cleanups

When installing a breakpoint, we only need to save the single byte.
When removing a breakpoint, we only need to restore the single byte.
parent 46620f56
Branches
No related tags found
1 merge request!72Fix #97: Use UD1 instruction instead of INT3
Pipeline #3376 failed
......@@ -213,17 +213,21 @@ arch_set_pseudo_atomic_interrupted(os_context_t * context)
/*
* Installs a breakpoint (INT3) at |pc|. We return the byte that was
* replaced by the int3 instruction.
*/
unsigned long
arch_install_breakpoint(void *pc)
{
unsigned char* ptr = (unsigned char *) pc;
unsigned long result = ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24);
unsigned long result = *ptr;
DPRINTF(debug_handlers,
(stderr, "arch_install_breakpoint at %p, old code = 0x%lx\n",
pc, result));
*(char *) pc = BREAKPOINT_INST; /* x86 INT3 */
*ptr = BREAKPOINT_INST; /* x86 INT3 */
return result;
}
......@@ -235,14 +239,9 @@ arch_remove_breakpoint(void *pc, unsigned long orig_inst)
pc, orig_inst));
unsigned char *ptr = (unsigned char *) pc;
/*
* Just restore all the bytes from orig_inst. Should we just
* re-install just the one byte that was taken by the int3
* instruction?
* Just restore the byte from orig_inst.
*/
ptr[0] = orig_inst & 0xff;
ptr[1] = (orig_inst >> 8) & 0xff;
ptr[2] = (orig_inst >> 16) & 0xff;
ptr[3] = (orig_inst >> 24) & 0xff;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment