Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: Re: Teach gdbserver to step over internal breakpoints
Date: Wed, 24 Mar 2010 22:00:00 -0000	[thread overview]
Message-ID: <201003242200.10102.pedro@codesourcery.com> (raw)
In-Reply-To: <201003242122.39450.pedro@codesourcery.com>

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
 }
 


      parent reply	other threads:[~2010-03-24 22:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-16 18:40 Pedro Alves
2010-03-24  0:05 ` Pedro Alves
2010-03-24 12:13   ` Pedro Alves
2010-03-24 21:22     ` Pedro Alves
2010-03-24 21:34       ` Pedro Alves
2010-03-24 22:00       ` Pedro Alves [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201003242200.10102.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox