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]

AIX threaded cores.


AIX threaded cores came up in the target-async series.  I tried things
out on gcc111, but stumbled on a couple things.  First, a BFD patch
was necessary:
<https://sourceware.org/ml/binutils/2014-03/msg00052.html>

Then, I found out that even after that, we have more breakage:

 [New Thread 1]
 [New Thread 258]
 Error in re-setting breakpoint -1: aix-thread: ptrace (52, 25231783) returned -1 (errno = 3 The process does not exist.)
 Error in re-setting breakpoint -1: aix-thread: ptrace (52, 25231783) returned -1 (errno = 3 The process does not exist.)
 Core was generated by `crash'.
 Program terminated with signal SIGABRT, Aborted.
 #0  0xd05187c0 in pthread_kill () from /usr/lib/libpthreads.a(shr_xpg5.o)
 (gdb) info threads
   Id   Target Id         Frame
   3    Thread 258 (tid 25231783, running) aix-thread: ptrace (52, 25231783) returned -1 (errno = 3 The process does not exist.)
...

Obviously, we shouldn't be using ptrace when debugging cores...

So I wrote this GDB-side patch below last night, and now get the
number of threads right:

 [New Thread 1]
 [New Thread 258]
 Core was generated by `crash'.
 Program terminated with signal SIGABRT, Aborted.
 #0  0xd05187c0 in pthread_kill () from /usr/lib/libpthreads.a(shr_xpg5.o)
 (gdb) info threads
   Id   Target Id         Frame
   3    Thread 258 (tid 25231783, running) 0xd05187c0 in pthread_kill () from /usr/lib/libpthreads.a(shr_xpg5.o)
   2    Thread 1 (tid 88801287, sleeping) 0xd05187c0 in pthread_kill () from /usr/lib/libpthreads.a(shr_xpg5.o)
 * 1    process 1         0xd05187c0 in pthread_kill () from /usr/lib/libpthreads.a(shr_xpg5.o)

... and no ptrace errors.  Good.

But, then all threads show the same registers (and that's wrong,
thread 3 isn't really stopped in pthread_kill).  That's because the
bfd side doesn't know to create .reg/NNN sections for each kernel
thread in the core...  Bad.

$ objdump -h ~/core

/home/palves/core:     file format aixcoff-rs6000

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .stack        00001000  2ff22000  00000000  00000e9c  2**8
                  CONTENTS, ALLOC, LOAD
  1 .reg          00000250  00000000  00000000  000001a0  2**8
                  CONTENTS
  2 .ldinfo       000000fc  00000000  00000000  00000a88  2**8
                  CONTENTS
  3 .data         000316e0  20000000  00000000  00122170  2**8
                  CONTENTS, ALLOC, LOAD
  4 .data         00000830  20000e90  00000000  00123000  2**8
                  CONTENTS, ALLOC, LOAD
  5 .data         00043920  f0254000  00000000  00001f0c  2**8
                  CONTENTS, ALLOC, LOAD
  6 .data         00000120  f07b46a8  00000000  0004582c  2**8
                  CONTENTS, ALLOC, LOAD
  7 .data         00003fcc  f0298000  00000000  0004594c  2**8
                  CONTENTS, ALLOC, LOAD
  8 .data         000d8858  f06dafe0  00000000  00049918  2**8
                  CONTENTS, ALLOC, LOAD

Not sure if threaded cores ever worked on AIX.  There are comments in
the code that might suggest so.  But maybe that was on machines where
all user threads map to one kernel thread.  Dunno.

So to make this fully work, we'd need something like the below on the
GDB side, but we'd also need to fix the bfd side.  I'm clueless on
xcoff core format though, and I don't really plan on learning it
now...  But I thought I'd post this anyway for the archives.
---
 gdb/aix-thread.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index 444a025..b135d3f 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -1323,7 +1323,21 @@ aix_thread_fetch_registers (struct target_ops *ops,
       if (tid == PTHDB_INVALID_TID)
 	fetch_regs_user_thread (regcache, thread->private->pdtid);
       else
-	fetch_regs_kernel_thread (regcache, regno, tid);
+	{
+	  /* Can't simply defer to the target beneath for live
+	    processes (must use PTT_READ_SPRS, etc.).  */
+	  if (target_has_execution)
+	    fetch_regs_kernel_thread (regcache, regno, tid);
+	  else
+	    {
+	      struct cleanup *old_chain;
+
+	      old_chain = save_inferior_ptid ();
+	      inferior_ptid = pid_to_ptid (tid);
+	      beneath->to_fetch_registers (beneath, regcache, regno);
+	      do_cleanups (old_chain);
+	    }
+	}
     }
 }
 
-- 
1.7.11.7


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