Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@suse.de>
To: gdb-patches@sources.redhat.com
Subject: Re: pthreads debug with gdbserver
Date: Sun, 21 Nov 2004 00:58:00 -0000	[thread overview]
Message-ID: <m3y8gw588f.fsf@igel.m5r.de> (raw)
In-Reply-To: <20041120164209.GA15174@nevyn.them.org> (Daniel Jacobowitz's message of "Sat, 20 Nov 2004 11:42:10 -0500")

Daniel Jacobowitz <drow@false.org> writes:

> Take a look at the source code to gdbserver.  Andreas, now I remember
> why I enabled thread_db support on a per-target basis - there are other
> support routines that have to be written.

Here is the gdbserver support for thread_db and regsets on m68k-linux.
OK?

Andreas.

2004-11-21  Andreas Schwab  <schwab@suse.de>

	* linux-m68k-low.c (m68k_num_gregs): Define.
	(m68k_fill_gregset, m68k_store_gregset, m68k_fill_fpregset)
	(m68k_store_fpregset, target_regsets) [HAVE_LINUX_REGSETS]: New.
	(m68k_breakpoint, m68k_breakpoint_len, m68k_get_pc, m68k_set_pc)
	(m68k_breakpoint_at): New.  Add to the_low_target.

	* configure.srv (m68*-*-linux*): Set srv_linux_regsets and
	srv_linux_thread_db to yes.

Index: gdb/gdbserver/configure.srv
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/configure.srv,v
retrieving revision 1.7
diff -u -a -p -r1.7 configure.srv
--- gdb/gdbserver/configure.srv	8 Aug 2003 00:47:28 -0000	1.7
+++ gdb/gdbserver/configure.srv	21 Nov 2004 00:54:18 -0000
@@ -36,6 +36,8 @@ case "${target}" in
   m68*-*-linux*)	srv_regobj=reg-m68k.o
 			srv_tgtobj="linux-low.o linux-m68k-low.o"
 			srv_linux_usrregs=yes
+			srv_linux_regsets=yes
+			srv_linux_thread_db=yes
 			;;
   mips*-*-linux*)	srv_regobj=reg-mips.o
 			srv_tgtobj="linux-low.o linux-mips-low.o"
Index: gdb/gdbserver/linux-m68k-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/linux-m68k-low.c,v
retrieving revision 1.4
diff -u -a -p -r1.4 linux-m68k-low.c
--- gdb/gdbserver/linux-m68k-low.c	4 Jan 2003 21:55:30 -0000	1.4
+++ gdb/gdbserver/linux-m68k-low.c	21 Nov 2004 00:54:18 -0000
@@ -1,5 +1,5 @@
 /* GNU/Linux/m68k specific low level interface, for the remote server for GDB.
-   Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003
+   Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -27,6 +27,7 @@
 #endif
 
 #define m68k_num_regs 29
+#define m68k_num_gregs 18
 
 /* This table must line up with REGISTER_NAMES in tm-m68k.h */
 static int m68k_regmap[] =
@@ -64,9 +65,103 @@ m68k_cannot_fetch_register (int regno)
   return (regno >= m68k_num_regs);
 }
 
+#ifdef HAVE_LINUX_REGSETS
+#include <sys/procfs.h>
+#include <sys/ptrace.h>
+
+static void
+m68k_fill_gregset (void *buf)
+{
+  int i;
+
+  for (i = 0; i < m68k_num_gregs; i++)
+    collect_register (i, (char *) buf + m68k_regmap[i]);
+}
+
+static void
+m68k_store_gregset (const void *buf)
+{
+  int i;
+
+  for (i = 0; i < m68k_num_gregs; i++)
+    supply_register (i, (const char *) buf + m68k_regmap[i]);
+}
+
+static void
+m68k_fill_fpregset (void *buf)
+{
+  int i;
+
+  for (i = m68k_num_gregs; i < m68k_num_regs; i++)
+    collect_register (i, ((char *) buf
+			  + (m68k_regmap[i] - m68k_regmap[m68k_num_gregs])));
+}
+
+static void
+m68k_store_fpregset (const void *buf)
+{
+  int i;
+
+  for (i = m68k_num_gregs; i < m68k_num_regs; i++)
+    supply_register (i, ((const char *) buf
+			 + (m68k_regmap[i] - m68k_regmap[m68k_num_gregs])));
+}
+
+
+struct regset_info target_regsets[] = {
+  { PTRACE_GETREGS, PTRACE_SETREGS, sizeof (elf_gregset_t),
+    GENERAL_REGS,
+    m68k_fill_gregset, m68k_store_gregset },
+  { PTRACE_GETFPREGS, PTRACE_SETFPREGS, sizeof (elf_fpregset_t),
+    FP_REGS,
+    m68k_fill_fpregset, m68k_store_fpregset },
+  { 0, 0, -1, -1, NULL, NULL }
+};
+
+#endif /* HAVE_LINUX_REGSETS */
+
+static const char m68k_breakpoint[] = { 0x4E, 0x4F };
+#define m68k_breakpoint_len 2
+
+static CORE_ADDR
+m68k_get_pc ()
+{
+  unsigned long pc;
+
+  collect_register_by_name ("pc", &pc);
+  return pc;
+}
+
+static void
+m68k_set_pc (CORE_ADDR value)
+{
+  unsigned long newpc = value;
+
+  supply_register_by_name ("pc", &newpc);
+}
+
+static int
+m68k_breakpoint_at (CORE_ADDR pc)
+{
+  unsigned char c[2];
+
+  read_inferior_memory (pc, c, 2);
+  if (c[0] == 0x4E && c[1] == 0x4F)
+    return 1;
+
+  return 0;
+}
+
 struct linux_target_ops the_low_target = {
   m68k_num_regs,
   m68k_regmap,
   m68k_cannot_fetch_register,
   m68k_cannot_store_register,
+  m68k_get_pc,
+  m68k_set_pc,
+  m68k_breakpoint,
+  m68k_breakpoint_len,
+  NULL,
+  2,
+  m68k_breakpoint_at,
 };

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


       reply	other threads:[~2004-11-21  0:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200411191233.22357.vladimir.vorobyov@iss.org.ua>
     [not found] ` <200411191641.15822.vladimir.vorobyov@iss.org.ua>
     [not found]   ` <20041120013220.GB27485@nevyn.them.org>
     [not found]     ` <200411201427.13557.vladimir.vorobyov@iss.org.ua>
     [not found]       ` <20041120164209.GA15174@nevyn.them.org>
2004-11-21  0:58         ` Andreas Schwab [this message]
2004-11-21  1:11           ` Daniel Jacobowitz

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=m3y8gw588f.fsf@igel.m5r.de \
    --to=schwab@suse.de \
    --cc=gdb-patches@sources.redhat.com \
    /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