This is the mail archive of the gdb-patches@sources.redhat.com 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]

[PATCH] Some Linux i386 and Linux x86-64 native cleanup


This cleans up some things in the recently added ps_get_thread_areas
support and gets rid of two ARI warnings.

Checked in.

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>
 
	* i386-linux-nat.c (ps_get_thread_area): Don't define as extern.
	Only define PTRACE_GET_THREAD_AREA is not already defined.
	Various style fixes in code and comments and some additional
	spelling fixes in comments.  Move after functions dealing with
	debug registers.
	* x86-64-linux-nat.c (ps_get_thread_area): Don't define as extern.
	Fix coding-style.

Index: i386-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-linux-nat.c,v
retrieving revision 1.50
diff -u -p -r1.50 i386-linux-nat.c
--- i386-linux-nat.c 26 Aug 2003 19:34:53 -0000 1.50
+++ i386-linux-nat.c 31 Aug 2003 15:16:40 -0000
@@ -687,41 +687,6 @@ i386_linux_dr_set (int regnum, unsigned 
     perror_with_name ("Couldn't write debug register");
 }
 
-/* Called by libthread_db.  Return's a pointer to the thread local
-   storage (or it's descriptor).  */
-extern ps_err_e
-ps_get_thread_area(const struct ps_prochandle *ph, 
-		   lwpid_t lwpid, int idx, void **base)
-{
-  /* NOTE: cagney/2003-08-26: The definition of this buffer is found
-     in the kernel header <asm-i386/ldt.h>.  It, after padding, is 4 x
-     4 byte integers in size: "entry_number", "base_addr", "limit",
-     and a bunch of status bits.
-
-     The values returned by this ptrace call should be part of the
-     regcache buffer, and ps_get_thread_area should channel its
-     request through the regcache.  That way remote targets could
-     provide the value using the remote protocol and not this direct
-     call.
-
-     Is this function needed?  I'm guessing that the "base" is the
-     address of a a descriptor that libthread_db uses to find the
-     thread local address base that GDB needs.  Perhaphs that
-     descriptor is defined by the ABI.  Anyway, given that
-     libthread_db calls this function without prompting (gdb
-     requesting tls base) I guess it needs info in there anyway.  */
-  unsigned int desc[4];
-  gdb_assert (sizeof (int) == 4);
-#define PTRACE_GET_THREAD_AREA 25
-
-  if  (ptrace (PTRACE_GET_THREAD_AREA, 
-	       lwpid, (void *) idx, (unsigned long) &desc) < 0)
-    return PS_ERR;
-
-  *(int *)base = desc[1];
-  return PS_OK;
-}
-
 void
 i386_linux_dr_set_control (unsigned long control)
 {
@@ -748,6 +713,46 @@ unsigned long
 i386_linux_dr_get_status (void)
 {
   return i386_linux_dr_get (DR_STATUS);
+}
+
+
+/* Called by libthread_db.  Returns a pointer to the thread local
+   storage (or its descriptor).  */
+
+ps_err_e
+ps_get_thread_area (const struct ps_prochandle *ph, 
+		    lwpid_t lwpid, int idx, void **base)
+{
+  /* NOTE: cagney/2003-08-26: The definition of this buffer is found
+     in the kernel header <asm-i386/ldt.h>.  It, after padding, is 4 x
+     4 byte integers in size: `entry_number', `base_addr', `limit',
+     and a bunch of status bits.
+
+     The values returned by this ptrace call should be part of the
+     regcache buffer, and ps_get_thread_area should channel its
+     request through the regcache.  That way remote targets could
+     provide the value using the remote protocol and not this direct
+     call.
+
+     Is this function needed?  I'm guessing that the `base' is the
+     address of a a descriptor that libthread_db uses to find the
+     thread local address base that GDB needs.  Perhaphs that
+     descriptor is defined by the ABI.  Anyway, given that
+     libthread_db calls this function without prompting (gdb
+     requesting tls base) I guess it needs info in there anyway.  */
+  unsigned int desc[4];
+  gdb_assert (sizeof (int) == 4);
+
+#ifndef PTRACE_GET_THREAD_AREA
+#define PTRACE_GET_THREAD_AREA 25
+#endif
+
+  if (ptrace (PTRACE_GET_THREAD_AREA, lwpid,
+	      (void *) idx, (unsigned long) &desc) < 0)
+    return PS_ERR;
+
+  *(int *)base = desc[1];
+  return PS_OK;
 }
 
 
Index: x86-64-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-linux-nat.c,v
retrieving revision 1.28
diff -u -p -r1.28 x86-64-linux-nat.c
--- x86-64-linux-nat.c 29 Aug 2003 16:28:38 -0000 1.28
+++ x86-64-linux-nat.c 31 Aug 2003 15:16:40 -0000
@@ -348,12 +348,12 @@ x86_64_linux_dr_get_status (void)
 {
   return x86_64_linux_dr_get (DR_STATUS);
 }
+
 
-extern ps_err_e
+ps_err_e
 ps_get_thread_area (const struct ps_prochandle *ph,
                     lwpid_t lwpid, int idx, void **base)
 {
-
 /* This definition comes from prctl.h, but some kernels may not have it.  */
 #ifndef PTRACE_ARCH_PRCTL
 #define PTRACE_ARCH_PRCTL      30
@@ -367,17 +367,18 @@ ps_get_thread_area (const struct ps_proc
     {
     case FS:
       if (ptrace (PTRACE_ARCH_PRCTL, lwpid, base, ARCH_GET_FS) == 0)
-       return PS_OK;
+	return PS_OK;
       break;
     case GS:
       if (ptrace (PTRACE_ARCH_PRCTL, lwpid, base, ARCH_GET_GS) == 0)
-       return PS_OK;
+	return PS_OK;
       break;
     default:                   /* Should not happen.  */
       return PS_BADADDR;
     }
   return PS_ERR;               /* ptrace failed.  */
 }
+
 
 void
 child_post_startup_inferior (ptid_t ptid)


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