This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Teach gdbserver to step over internal breakpoints
On Wednesday 24 March 2010 21:22:39, Pedro Alves wrote:
> Also tested on x86_64, with and without a thread
> event breakpoint, and also with a had that makes x86-64
> use reinsert breakpoints. I'll show that for the archives
> shortly.
s/a had/ a hack/. Here it is. This makes an x86 gdbserver
use reinsert (single software single-step) breakpoints to
step over the thread event breakpoint, thus it make it
easier to test those code paths on my devel machine.
I've only used it thoroughly with x86-64, but it should
work with ix86 as well.
For the archives.
--
Pedro Alves
---
gdb/gdbserver/linux-low.c | 2 +-
gdb/gdbserver/linux-x86-low.c | 35 ++++++++++++++++++++++++++++++++++-
2 files changed, 35 insertions(+), 2 deletions(-)
Index: src/gdb/gdbserver/linux-x86-low.c
===================================================================
--- src.orig/gdb/gdbserver/linux-x86-low.c 2010-03-24 20:34:18.000000000 +0000
+++ src/gdb/gdbserver/linux-x86-low.c 2010-03-24 21:41:42.000000000 +0000
@@ -824,6 +824,39 @@ x86_arch_setup (void)
num_xmm_registers = 8;
}
+/* We only place breakpoints in empty marker functions, and thread
+ locking is outside of the function. So rather than importing
+ software single-step, we can just run until exit. */
+
+static CORE_ADDR
+x86_reinsert_addr (void)
+{
+ struct regcache *regcache = get_thread_regcache (current_inferior, 1);
+
+#ifdef __x86_64__
+ int use_64bit = register_size (0) == 8;
+
+ if (use_64bit)
+ {
+ unsigned long sp, ret;
+
+ collect_register_by_name (regcache, "rsp", &sp);
+ if (read_inferior_memory (sp, (unsigned char *) &ret, 8) != 0)
+ return 0;
+ return ret;
+ }
+ else
+#endif
+ {
+ unsigned int sp, ret;
+
+ collect_register_by_name (regcache, "esp", &sp);
+ if (read_inferior_memory (sp, (unsigned char *) &ret, 4) != 0)
+ return 0;
+ return ret;
+ }
+}
+
/* This is initialized assuming an amd64 target.
x86_arch_setup will correct it for i386 or amd64 targets. */
@@ -838,7 +871,7 @@ struct linux_target_ops the_low_target =
x86_set_pc,
x86_breakpoint,
x86_breakpoint_len,
- NULL,
+ x86_reinsert_addr,
1,
x86_breakpoint_at,
x86_insert_point,
Index: src/gdb/gdbserver/linux-low.c
===================================================================
--- src.orig/gdb/gdbserver/linux-low.c 2010-03-24 21:43:01.000000000 +0000
+++ src/gdb/gdbserver/linux-low.c 2010-03-24 21:55:16.000000000 +0000
@@ -3421,7 +3421,7 @@ linux_look_up_symbols (void)
/* If the kernel supports tracing forks then it also supports tracing
clones, and then we don't need to use the magic thread event breakpoint
to learn about threads. */
- thread_db_init (!linux_supports_tracefork_flag);
+ thread_db_init (1);
#endif
}