Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl3/gdb/dist/gdb Deal with core file initializatio...



details:   https://anonhg.NetBSD.org/src/rev/c83dc8102fac
branches:  trunk
changeset: 770343:c83dc8102fac
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Oct 13 16:00:37 2011 +0000

description:
Deal with core file initialization. The code is till wrong: all the core_ops
are unused and adding the core target does not work.

diffstat:

 external/gpl3/gdb/dist/gdb/nbsd-thread.c |  59 ++++++++++++++++++-------------
 1 files changed, 34 insertions(+), 25 deletions(-)

diffs (127 lines):

diff -r d0487a915084 -r c83dc8102fac external/gpl3/gdb/dist/gdb/nbsd-thread.c
--- a/external/gpl3/gdb/dist/gdb/nbsd-thread.c  Thu Oct 13 14:40:06 2011 +0000
+++ b/external/gpl3/gdb/dist/gdb/nbsd-thread.c  Thu Oct 13 16:00:37 2011 +0000
@@ -504,6 +504,24 @@
 }
 
 
+static void
+nbsd_add_to_thread_list (bfd *abfd, asection *asect, PTR reg_sect_arg)
+{
+  int regval;
+  td_thread_t *dummy;
+
+  if (strncmp (bfd_section_name (abfd, asect), ".reg/", 5) != 0)
+    return;
+
+  regval = atoi (bfd_section_name (abfd, asect) + 5);
+
+#ifdef notyet
+  td_map_lwp2thr (main_ta, regval >> 16, &dummy);
+#endif
+
+  add_thread (BUILD_LWP(regval >> 16, main_ptid));
+}
+
 /* This routine is called whenever a new symbol table is read in, or when all
    symbol tables are removed.  libthread_db can only be initialized when it
    finds the right variables in libthread.so.  Since it's a shared library,
@@ -517,7 +535,7 @@
 void
 nbsd_thread_new_objfile (struct objfile *objfile)
 {
-  int val;
+  int val, core_pid;
 
   if (!objfile)
     {
@@ -529,6 +547,7 @@
   if (nbsd_thread_active)
     goto quit;
 
+
   /* Now, initialize the thread debugging library.  This needs to be
      done after the shared libraries are located because it needs
      information from the user's thread library.  */
@@ -549,6 +568,16 @@
       push_target (&nbsd_thread_ops);
       nbsd_thread_activate();
     }
+
+  core_pid = elf_tdata (core_bfd)->core_pid;
+  if (core_pid)
+    {
+      main_ptid = pid_to_ptid (core_pid);
+      nbsd_thread_active = 1;
+      init_thread_list ();
+      bfd_map_over_sections (core_bfd, nbsd_add_to_thread_list, NULL);
+      nbsd_find_new_threads (NULL);
+    }
 quit:
   return;
 }
@@ -615,6 +644,8 @@
   if (td_thr_info (th, &ti) != 0)
       return -1;
 
+printf("find new thread %d\n", ti.thread_id);
+
   ptid = BUILD_THREAD (ti.thread_id, main_ptid);
   if (ti.thread_type == TD_TYPE_USER &&
       ti.thread_state != TD_STATE_BLOCKED &&
@@ -950,32 +981,13 @@
 }
 
 static void
-nbsd_add_to_thread_list (bfd *abfd, asection *asect, PTR reg_sect_arg)
-{
-  int regval;
-  td_thread_t *dummy;
-
-  if (strncmp (bfd_section_name (abfd, asect), ".reg/", 5) != 0)
-    return;
-
-  regval = atoi (bfd_section_name (abfd, asect) + 5);
-
-#ifdef notyet
-  td_map_lwp2thr (main_ta, regval >> 16, &dummy);
-#endif
-
-  add_thread (BUILD_LWP(regval >> 16, main_ptid));
-}
-
-#ifdef notyet
-static void
 nbsd_core_open (char *filename, int from_tty)
 {
   int val;
 
   nbsd_thread_core = 1;
 
-  beneath->to_open (filename, from_tty);
+  core_target->to_open (filename, from_tty);
 
   if (nbsd_thread_present)
     {
@@ -1003,9 +1015,8 @@
    */
   inferior_ptid = minus_one_ptid;
 
-  beneath->to_close (quitting);
+  core_target->to_close (quitting);
 }
-#endif
 
 static void
 nbsd_core_detach (struct target_ops *ops, char *args, int from_tty)
@@ -1237,10 +1248,8 @@
   nbsd_core_ops.to_shortname = "netbsd-core";
   nbsd_core_ops.to_longname = "NetBSD core pthread.";
   nbsd_core_ops.to_doc = "NetBSD pthread support for core files.";
-#ifdef notyet
   nbsd_core_ops.to_open = nbsd_core_open;
   nbsd_core_ops.to_close = nbsd_core_close;
-#endif
   nbsd_core_ops.to_detach = nbsd_core_detach;
   nbsd_core_ops.to_fetch_registers = nbsd_thread_fetch_registers;
   nbsd_core_ops.to_xfer_partial = nbsd_thread_xfer_partial;



Home | Main Index | Thread Index | Old Index