This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gdbserver Solaris [8/9] - solaris extra functions



gdb ChangeLog entry:

2010-04-23  Pieter Maljaars  <pieter.maljaars@altenpts.nl>

        * remote.c: Print also LWP on Solaris.

gdb/gdbserver ChangeLog entry:

2010-04-23  Pieter Maljaars  <pieter.maljaars@altenpts.nl>

	* target.h: New target function.
        * server.c: Send also LWP on Solaris to gdb.

diff -upN src-orig/src/gdb/remote.c src/gdb/remote.c
--- src-orig/src/gdb/remote.c	2010-04-16 09:49:35.000000000 +0200
+++ src/gdb/remote.c	2010-04-20 15:20:27.000000000 +0200
 {
   char *p = buf;
   char *pp;
-  ULONGEST pid = 0, tid = 0;
+  ULONGEST pid = 0, lwp = 0, tid = 0;
 
   if (*p == 'p')
     {
@@ -1805,6 +1805,17 @@ read_ptid (char *buf, char **obuf)
   /* No multi-process.  Just a tid.  */
   pp = unpack_varlen_hex (p, &tid);
 
+#ifdef sun
+  if (*pp == '.')
+    {
+      /* It was a LWP.  */
+      lwp = tid;
+
+      /* Read now the real tid.  */
+      pp = unpack_varlen_hex (pp + 1, &tid);
+    }
+#endif
+
   /* Since the stub is not sending a process id, then default to
      what's in inferior_ptid, unless it's null at this point.  If so,
      then since there's no way to know the pid of the reported
@@ -1816,7 +1827,7 @@ read_ptid (char *buf, char **obuf)
 
   if (obuf)
     *obuf = pp;
-  return ptid_build (pid, 0, tid);
+  return ptid_build (pid, lwp, tid);
 }
 
 /* Encode 64 bits in 16 chars of hex.  */
@@ -8385,8 +8396,14 @@ remote_pid_to_str (struct target_ops *op
 	xsnprintf (buf, sizeof buf, "Thread %d.%ld",
 		   ptid_get_pid (ptid), ptid_get_tid (ptid));
       else
-	xsnprintf (buf, sizeof buf, "Thread %ld",
-		   ptid_get_tid (ptid));
+	{
+	  if (ptid_get_lwp (ptid) > 0)
+	    xsnprintf (buf, sizeof buf, "Thread %ld (LWP %ld)",
+	  	ptid_get_lwp (ptid), ptid_get_tid (ptid));
+	  else
+	    xsnprintf (buf, sizeof buf, "LWP    %ld        ",
+		ptid_get_tid (ptid));
+	}
       return buf;
     }
 }
diff -upN src-orig/src/gdb/gdbserver/target.h src/gdb/gdbserver/target.h
--- src-orig/src/gdb/gdbserver/target.h	2010-04-16 09:49:37.000000000 +0200
+++ src/gdb/gdbserver/target.h	2010-04-21 11:40:03.000000000 +0200
@@ -312,6 +312,11 @@ struct target_ops
 
   /* Read Thread Information Block address.  */
   int (*get_tib_address) (ptid_t ptid, CORE_ADDR *address);
+
+#ifdef sun
+  /* Return the LWP and thread ID.  */
+  int (*thread_lwp_id) (ptid_t, char *);
+#endif
 };
 
 extern struct target_ops *the_target;
diff -upN src-orig/src/gdb/gdbserver/server.c src/gdb/gdbserver/server.c
--- src-orig/src/gdb/gdbserver/server.c	2010-04-16 09:49:36.000000000 +0200
+++ src/gdb/gdbserver/server.c	2010-04-21 11:38:11.000000000 +0200
@@ -748,6 +751,25 @@ handle_monitor_command (char *mon)
     }
 }
 
+#ifdef sun
+static void
+write_thread_lwp (char *buf, ptid_t ptid)
+{
+  /* On solaris print not only LWP, but also the thread ID.  */
+  int tid = ptid_get_tid (ptid);
+  if (tid != 0)
+  {
+    if (the_target->thread_lwp_id)
+      (*the_target->thread_lwp_id) (ptid, buf);
+
+    if (tid < 0)
+      sprintf (buf, "%s.-%x", buf, -tid);
+    else	
+      sprintf (buf, "%s.%x", buf, tid);
+  }
+}
+#endif
+
 static void
 handle_threads_qxfer_proper (struct buffer *buffer)
 {
@@ -763,6 +785,9 @@ handle_threads_qxfer_proper (struct buff
       char core_s[21];
 
       write_ptid (ptid_s, ptid);
+#ifdef sun
+      write_thread_lwp (ptid_s, ptid);
+#endif
 
       if (the_target->core_of_thread)
 	core = (*the_target->core_of_thread) (ptid);
@@ -930,6 +955,9 @@ handle_query (char *own_buf, int packet_
 	  *own_buf++ = 'm';
 	  gdb_id = thread_to_gdb_id ((struct thread_info *)thread_ptr);
 	  write_ptid (own_buf, gdb_id);
+#ifdef sun
+	  write_thread_lwp (own_buf, gdb_id);
+#endif
 	  thread_ptr = thread_ptr->next;
 	  return;
 	}
@@ -944,6 +972,9 @@ handle_query (char *own_buf, int packet_
 	      *own_buf++ = 'm';
 	      gdb_id = thread_to_gdb_id ((struct thread_info *)thread_ptr);
 	      write_ptid (own_buf, gdb_id);
+#ifdef sun
+	      write_thread_lwp (own_buf, gdb_id);
+#endif
 	      thread_ptr = thread_ptr->next;
 	      return;
 	    }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]