From cc85dc8afbc56c93a1e870102e025d7756787d1e Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 13 Jan 2012 20:07:15 +0100 Subject: [PATCH] Let GDB monitor use HLT for breakpoints, fix #83 The patch fixes a corner-case problem with using the two-byte 'INT 0' instruction for breakpoints. The fix changes the breakpoint instruction to the single-byte 'HLT'. 'HLT' is a privileged instruction and triggers an exception when executed in user mode. Patch by Christian Prochaska. --- .../app/gdb_monitor/gdbserver_genode.patch | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ports/src/app/gdb_monitor/gdbserver_genode.patch b/ports/src/app/gdb_monitor/gdbserver_genode.patch index da4260bd8..8c3d9d764 100644 --- a/ports/src/app/gdb_monitor/gdbserver_genode.patch +++ b/ports/src/app/gdb_monitor/gdbserver_genode.patch @@ -584,18 +584,23 @@ diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c } static void -@@ -414,8 +443,8 @@ +@@ -414,7 +443,15 @@ } } --static const unsigned char x86_breakpoint[] = { 0xCC }; --#define x86_breakpoint_len 1 -+static const unsigned char x86_breakpoint[] = { /*0xCC*/0xCD, 0x00 }; -+#define x86_breakpoint_len 2 ++#ifdef __GENODE__ ++/* The 'INT3' instruction is used by some kernel debuggers and thus cannot ++ * serve as breakpoint instruction for the GDB monitor. Instead, the 'HLT' ++ * instruction gets used. It's a privileged instruction which triggers an ++ * exception when executed in user mode */ ++static const unsigned char x86_breakpoint[] = { 0xF4 }; ++#else + static const unsigned char x86_breakpoint[] = { 0xCC }; ++#endif + #define x86_breakpoint_len 1 static int - x86_breakpoint_at (CORE_ADDR pc) -@@ -2576,7 +2605,7 @@ +@@ -2576,7 +2613,7 @@ x86_siginfo_fixup, x86_linux_new_process, x86_linux_new_thread,