Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Make remote-m32r-sdi target already register a main thread
@ 2008-08-08  2:03 Pedro Alves
  2008-08-08  2:20 ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2008-08-08  2:03 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 265 bytes --]

This adjust the remote-m32r-sdi target to add a thread to gdb's thread table.

I've no means to test this, although the changes are very similar
to what I've done to monitor.c, and remote-sim.c, the latter I
did test at the time I changed it.

OK?

-- 
Pedro Alves

[-- Attachment #2: remote-m32r-sdi_always_a_thread.diff --]
[-- Type: text/x-diff, Size: 2692 bytes --]

2008-08-08  Pedro Alves  <pedro@codesourcery.com>

	* remote-m32r-sdi.c (remote_m32r_ptid): New.
	(m32r_close): Delete the main thread.
	(m32r_resume): Set inferior_ptid toA remote_m32r_ptid. Add the
	main thread.
	(m32r_kill, m32r_load, sdireset_command): Delete the main thread.
	(_initialize_remote_m32r): Initialize remote_m32r_ptid.

---
 gdb/remote-m32r-sdi.c |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

Index: src/gdb/remote-m32r-sdi.c
===================================================================
--- src.orig/gdb/remote-m32r-sdi.c	2008-08-07 20:58:31.000000000 +0100
+++ src/gdb/remote-m32r-sdi.c	2008-08-08 02:57:01.000000000 +0100
@@ -84,6 +84,11 @@ static int interrupted = 0;
 /* Forward data declarations */
 extern struct target_ops m32r_ops;
 
+/* This is the ptid we use while we're connected to the remote.  Its
+   value is arbitrary, as the target doesn't have a notion of
+   processes or threads, but we need something non-null to place in
+   inferior_ptid.  */
+static ptid_t remote_m32r_ptid;
 
 /* Commands */
 #define SDI_OPEN                 1
@@ -432,6 +437,7 @@ m32r_close (int quitting)
     }
 
   inferior_ptid = null_ptid;
+  delete_thread_silent (remote_m32r_ptid);
   return;
 }
 
@@ -667,7 +673,8 @@ m32r_resume (ptid_t ptid, int step, enum
      target is active.  These functions should be split out into seperate
      variables, especially since GDB will someday have a notion of debugging
      several processes.  */
-  inferior_ptid = pid_to_ptid (32);
+  inferior_ptid = remote_m32r_ptid;
+  add_thread_silent (remote_m32r_ptid);
 
   return;
 }
@@ -1127,6 +1134,7 @@ m32r_kill (void)
     fprintf_unfiltered (gdb_stdlog, "m32r_kill()\n");
 
   inferior_ptid = null_ptid;
+  delete_thread_silent (remote_m32r_ptid);
 
   return;
 }
@@ -1366,6 +1374,7 @@ m32r_load (char *args, int from_tty)
     write_pc (bfd_get_start_address (exec_bfd));
 
   inferior_ptid = null_ptid;	/* No process now */
+  delete_thread_silent (remote_m32r_ptid);
 
   /* This is necessary because many things were based on the PC at the time
      that we attached to the monitor, which is no longer valid now that we
@@ -1490,6 +1499,7 @@ sdireset_command (char *args, int from_t
   send_cmd (SDI_OPEN);
 
   inferior_ptid = null_ptid;
+  delete_thread_silent (remote_m32r_ptid);
 }
 
 
@@ -1648,4 +1658,8 @@ _initialize_remote_m32r (void)
 	   _("Set breakpoints by IB break."));
   add_com ("use_dbt_break", class_obscure, use_dbt_breakpoints_command,
 	   _("Set breakpoints by dbt."));
+
+  /* Yes, 42000 is arbitrary.  The only sense out of it, is that it
+     isn't 0.  */
+  remote_m32r_ptid = ptid_build (42000, 0, 42000);
 }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Make remote-m32r-sdi target already register a main thread
  2008-08-08  2:03 Make remote-m32r-sdi target already register a main thread Pedro Alves
@ 2008-08-08  2:20 ` Daniel Jacobowitz
  2008-08-08  2:48   ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2008-08-08  2:20 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On Fri, Aug 08, 2008 at 03:03:55AM +0100, Pedro Alves wrote:
> This adjust the remote-m32r-sdi target to add a thread to gdb's thread table.
> 
> I've no means to test this, although the changes are very similar
> to what I've done to monitor.c, and remote-sim.c, the latter I
> did test at the time I changed it.
> 
> OK?

OK.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Make remote-m32r-sdi target already register a main thread
  2008-08-08  2:20 ` Daniel Jacobowitz
@ 2008-08-08  2:48   ` Pedro Alves
  0 siblings, 0 replies; 3+ messages in thread
From: Pedro Alves @ 2008-08-08  2:48 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 561 bytes --]

On Friday 08 August 2008 03:19:56, Daniel Jacobowitz wrote:
> On Fri, Aug 08, 2008 at 03:03:55AM +0100, Pedro Alves wrote:
> > This adjust the remote-m32r-sdi target to add a thread to gdb's thread
> > table.
> >
> > I've no means to test this, although the changes are very similar
> > to what I've done to monitor.c, and remote-sim.c, the latter I
> > did test at the time I changed it.
> >
> > OK?
>
> OK.

Thanks!

I checked it in, ..., only to realise afterwards that I missed
two target methods.  I've checked in the attached as obvious.

-- 
Pedro Alves

[-- Attachment #2: remote-m32r_thread_alive.diff --]
[-- Type: text/x-diff, Size: 2058 bytes --]

Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.9620
diff -u -p -r1.9620 ChangeLog
--- ChangeLog	8 Aug 2008 02:34:08 -0000	1.9620
+++ ChangeLog	8 Aug 2008 02:44:33 -0000
@@ -1,5 +1,10 @@
 2008-08-08  Pedro Alves  <pedro@codesourcery.com>
 
+	* remote-m32r-sdi.c (m32r_thread_alive, m32r_pid_to_str): New.
+	(init_m32r_ops): Register m32r_thread_alive and m32r_pid_to_str.
+
+2008-08-08  Pedro Alves  <pedro@codesourcery.com>
+
 	* remote-m32r-sdi.c: Include "gdbthread.h".
 	(remote_m32r_ptid): New.
 	(m32r_close): Delete the main thread.
Index: remote-m32r-sdi.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-m32r-sdi.c,v
retrieving revision 1.32
diff -u -p -r1.32 remote-m32r-sdi.c
--- remote-m32r-sdi.c	8 Aug 2008 02:34:10 -0000	1.32
+++ remote-m32r-sdi.c	8 Aug 2008 02:44:33 -0000
@@ -1490,6 +1490,34 @@ m32r_stopped_by_watchpoint (void)
   return m32r_stopped_data_address (&current_target, &addr);
 }
 
+/* Check to see if a thread is still alive.  */
+
+static int
+m32r_thread_alive (ptid_t ptid)
+{
+  if (ptid_equal (ptid, remote_m32r_ptid))
+    /* The main task is always alive.  */
+    return 1;
+
+  return 0;
+}
+
+/* Convert a thread ID to a string.  Returns the string in a static
+   buffer.  */
+
+static char *
+m32r_pid_to_str (ptid_t ptid)
+{
+  static char buf[64];
+
+  if (ptid_equal (remote_m32r_ptid, ptid))
+    {
+      xsnprintf (buf, sizeof buf, "Thread <main>");
+      return buf;
+    }
+
+  return normal_pid_to_str (ptid);
+}
 
 static void
 sdireset_command (char *args, int from_tty)
@@ -1612,6 +1640,8 @@ init_m32r_ops (void)
   m32r_ops.to_mourn_inferior = m32r_mourn_inferior;
   m32r_ops.to_stop = m32r_stop;
   m32r_ops.to_log_command = serial_log_command;
+  m32r_ops.to_thread_alive = m32r_thread_alive;
+  m32r_ops.to_pid_to_str = m32r_pid_to_str;
   m32r_ops.to_stratum = process_stratum;
   m32r_ops.to_has_all_memory = 1;
   m32r_ops.to_has_memory = 1;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-08-08  2:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-08  2:03 Make remote-m32r-sdi target already register a main thread Pedro Alves
2008-08-08  2:20 ` Daniel Jacobowitz
2008-08-08  2:48   ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox