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]

[ob] Fix sizeof buffer used by ptrace(tls)


Hello,

The buffer returned by PTRACE_GET_THREAD_AREA is 4x4 bytes not 3x4 bytes. This fixes the size and adds a few more comments about what is happening.

committed to mainline and 6.0 branch,
Andrew
2003-08-26  Andrew Cagney  <cagney@redhat.com>

	* i386-linux-nat.c (ps_get_thread_area): Make "desc" four "int"s
	in size.  Add comments.

Index: i386-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-linux-nat.c,v
retrieving revision 1.49
diff -u -r1.49 i386-linux-nat.c
--- i386-linux-nat.c	23 Aug 2003 08:56:45 -0000	1.49
+++ i386-linux-nat.c	26 Aug 2003 19:33:12 -0000
@@ -687,11 +687,31 @@
     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)
 {
-  unsigned long int desc[3];
+  /* 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, 

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