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]

Use the new bfd_core_file_pid interface


This is the GDB side of this bfd patch I just sent to binutils@:

 http://sourceware.org/ml/binutils/2010-08/msg00163.html

It gets rid of the gdbarch_core_reg_section_encodes_pid hack, and
makes use of a new bfd_core_file_pid bfd function that that bfd
patch mentioned above adds.

I'll apply this together with the bfd patch, once that is approved.

-- 
Pedro Alves

2010-08-14  Pedro Alves  <pedro@codesourcery.com>

	PR corefile/8210

	gdb/
	* corelow.c (add_to_thread_list): Don't use
	gdbarch_core_reg_section_encodes_pid.  Use bfd_core_file_pid.
	(get_core_register_section): Don't use
	gdbarch_core_reg_section_encodes_pid.

	* gdbarch.sh (core_reg_section_encodes_pid): Delete.
	* gdbarch.h, gdbarch.c: Regenerate.
	* amd64-sol2-tdep.c (amd64_sol2_init_abi): Don't set
	gdbarch_core_reg_section_encodes_pid.
	* i386-sol2-tdep.c (i386_sol2_init_abi): Ditto.
	* sparc-sol2-tdep.c (sparc32_sol2_init_abi): Ditto.
	* sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Ditto.

---
 gdb/amd64-sol2-tdep.c   |    4 ----
 gdb/corelow.c           |   38 +++++---------------------------------
 gdb/gdbarch.c           |   23 -----------------------
 gdb/gdbarch.h           |    9 ---------
 gdb/gdbarch.sh          |    7 -------
 gdb/i386-sol2-tdep.c    |    4 ----
 gdb/sparc-sol2-tdep.c   |    4 ----
 gdb/sparc64-sol2-tdep.c |    4 ----
 8 files changed, 5 insertions(+), 88 deletions(-)

Index: src/gdb/corelow.c
===================================================================
--- src.orig/gdb/corelow.c	2010-08-14 18:38:43.000000000 +0100
+++ src/gdb/corelow.c	2010-08-14 18:39:15.000000000 +0100
@@ -252,29 +252,15 @@ add_to_thread_list (bfd *abfd, asection 
 
   core_tid = atoi (bfd_section_name (abfd, asect) + 5);
 
-  if (core_gdbarch
-      && gdbarch_core_reg_section_encodes_pid (core_gdbarch))
-    {
-      uint32_t merged_pid = core_tid;
-      pid = merged_pid & 0xffff;
-      lwpid = merged_pid >> 16;
-
-      /* This can happen on solaris core, for example, if we don't
-	 find a NT_PSTATUS note in the core, but do find NT_LWPSTATUS
-	 notes.  */
-      if (pid == 0)
-	{
-	  core_has_fake_pid = 1;
-	  pid = CORELOW_PID;
-	}
-    }
-  else
+  pid = bfd_core_file_pid (core_bfd);
+  if (pid == 0)
     {
       core_has_fake_pid = 1;
       pid = CORELOW_PID;
-      lwpid = core_tid;
     }
 
+  lwpid = core_tid;
+
   if (current_inferior ()->pid == 0)
     inferior_appeared (current_inferior (), pid);
 
@@ -520,21 +506,7 @@ get_core_register_section (struct regcac
 
   xfree (section_name);
 
-  if (core_gdbarch
-      && gdbarch_core_reg_section_encodes_pid (core_gdbarch))
-    {
-      uint32_t merged_pid;
-      int pid = ptid_get_pid (inferior_ptid);
-
-      if (core_has_fake_pid)
-	pid = 0;
-
-      merged_pid = ptid_get_lwp (inferior_ptid);
-      merged_pid = merged_pid << 16 | pid;
-
-      section_name = xstrprintf ("%s/%s", name, plongest (merged_pid));
-    }
-  else if (ptid_get_lwp (inferior_ptid))
+  if (ptid_get_lwp (inferior_ptid))
     section_name = xstrprintf ("%s/%ld", name, ptid_get_lwp (inferior_ptid));
   else
     section_name = xstrdup (name);
Index: src/gdb/gdbarch.c
===================================================================
--- src.orig/gdb/gdbarch.c	2010-08-14 18:38:43.000000000 +0100
+++ src/gdb/gdbarch.c	2010-08-14 18:39:15.000000000 +0100
@@ -234,7 +234,6 @@ struct gdbarch
   gdbarch_register_reggroup_p_ftype *register_reggroup_p;
   gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument;
   gdbarch_regset_from_core_section_ftype *regset_from_core_section;
-  int core_reg_section_encodes_pid;
   struct core_regset_section * core_regset_sections;
   gdbarch_core_xfer_shared_libraries_ftype *core_xfer_shared_libraries;
   gdbarch_core_pid_to_str_ftype *core_pid_to_str;
@@ -385,7 +384,6 @@ struct gdbarch startup_gdbarch =
   default_register_reggroup_p,  /* register_reggroup_p */
   0,  /* fetch_pointer_argument */
   0,  /* regset_from_core_section */
-  0,  /* core_reg_section_encodes_pid */
   0,  /* core_regset_sections */
   0,  /* core_xfer_shared_libraries */
   0,  /* core_pid_to_str */
@@ -667,7 +665,6 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of register_reggroup_p, invalid_p == 0 */
   /* Skip verify of fetch_pointer_argument, has predicate */
   /* Skip verify of regset_from_core_section, has predicate */
-  /* Skip verify of core_reg_section_encodes_pid, invalid_p == 0 */
   /* Skip verify of core_xfer_shared_libraries, has predicate */
   /* Skip verify of core_pid_to_str, has predicate */
   /* Skip verify of gcore_bfd_target, has predicate */
@@ -818,9 +815,6 @@ gdbarch_dump (struct gdbarch *gdbarch, s
                       "gdbarch_dump: core_read_description = <%s>\n",
                       host_address_to_string (gdbarch->core_read_description));
   fprintf_unfiltered (file,
-                      "gdbarch_dump: core_reg_section_encodes_pid = %s\n",
-                      plongest (gdbarch->core_reg_section_encodes_pid));
-  fprintf_unfiltered (file,
                       "gdbarch_dump: core_regset_sections = %s\n",
                       host_address_to_string (gdbarch->core_regset_sections));
   fprintf_unfiltered (file,
@@ -3095,23 +3089,6 @@ set_gdbarch_regset_from_core_section (st
   gdbarch->regset_from_core_section = regset_from_core_section;
 }
 
-int
-gdbarch_core_reg_section_encodes_pid (struct gdbarch *gdbarch)
-{
-  gdb_assert (gdbarch != NULL);
-  /* Skip verify of core_reg_section_encodes_pid, invalid_p == 0 */
-  if (gdbarch_debug >= 2)
-    fprintf_unfiltered (gdb_stdlog, "gdbarch_core_reg_section_encodes_pid called\n");
-  return gdbarch->core_reg_section_encodes_pid;
-}
-
-void
-set_gdbarch_core_reg_section_encodes_pid (struct gdbarch *gdbarch,
-                                          int core_reg_section_encodes_pid)
-{
-  gdbarch->core_reg_section_encodes_pid = core_reg_section_encodes_pid;
-}
-
 struct core_regset_section *
 gdbarch_core_regset_sections (struct gdbarch *gdbarch)
 {
Index: src/gdb/gdbarch.h
===================================================================
--- src.orig/gdb/gdbarch.h	2010-08-14 18:38:43.000000000 +0100
+++ src/gdb/gdbarch.h	2010-08-14 18:39:15.000000000 +0100
@@ -666,15 +666,6 @@ typedef const struct regset * (gdbarch_r
 extern const struct regset * gdbarch_regset_from_core_section (struct gdbarch *gdbarch, const char *sect_name, size_t sect_size);
 extern void set_gdbarch_regset_from_core_section (struct gdbarch *gdbarch, gdbarch_regset_from_core_section_ftype *regset_from_core_section);
 
-/* When creating core dumps, some systems encode the PID in addition
-   to the LWP id in core file register section names.  In those cases, the
-   "XXX" in ".reg/XXX" is encoded as [LWPID << 16 | PID].  This setting
-   is set to true for such architectures; false if "XXX" represents an LWP
-   or thread id with no special encoding. */
-
-extern int gdbarch_core_reg_section_encodes_pid (struct gdbarch *gdbarch);
-extern void set_gdbarch_core_reg_section_encodes_pid (struct gdbarch *gdbarch, int core_reg_section_encodes_pid);
-
 /* Supported register notes in a core file. */
 
 extern struct core_regset_section * gdbarch_core_regset_sections (struct gdbarch *gdbarch);
Index: src/gdb/gdbarch.sh
===================================================================
--- src.orig/gdb/gdbarch.sh	2010-08-14 18:38:43.000000000 +0100
+++ src/gdb/gdbarch.sh	2010-08-14 18:39:15.000000000 +0100
@@ -612,13 +612,6 @@ F:CORE_ADDR:fetch_pointer_argument:struc
 # name SECT_NAME and size SECT_SIZE.
 M:const struct regset *:regset_from_core_section:const char *sect_name, size_t sect_size:sect_name, sect_size
 
-# When creating core dumps, some systems encode the PID in addition
-# to the LWP id in core file register section names.  In those cases, the
-# "XXX" in ".reg/XXX" is encoded as [LWPID << 16 | PID].  This setting
-# is set to true for such architectures; false if "XXX" represents an LWP
-# or thread id with no special encoding.
-v:int:core_reg_section_encodes_pid:::0:0::0
-
 # Supported register notes in a core file.
 v:struct core_regset_section *:core_regset_sections:const char *name, int len::::::host_address_to_string (gdbarch->core_regset_sections)
 
Index: src/gdb/amd64-sol2-tdep.c
===================================================================
--- src.orig/gdb/amd64-sol2-tdep.c	2010-08-14 18:38:43.000000000 +0100
+++ src/gdb/amd64-sol2-tdep.c	2010-08-14 18:39:15.000000000 +0100
@@ -114,10 +114,6 @@ amd64_sol2_init_abi (struct gdbarch_info
   set_solib_svr4_fetch_link_map_offsets
     (gdbarch, svr4_lp64_fetch_link_map_offsets);
 
-  /* Solaris encodes the pid of the inferior in regset section
-     names.  */
-  set_gdbarch_core_reg_section_encodes_pid (gdbarch, 1);
-
   /* How to print LWP PTIDs from core files.  */
   set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str);
 }
Index: src/gdb/i386-sol2-tdep.c
===================================================================
--- src.orig/gdb/i386-sol2-tdep.c	2010-08-14 18:38:43.000000000 +0100
+++ src/gdb/i386-sol2-tdep.c	2010-08-14 18:39:15.000000000 +0100
@@ -136,10 +136,6 @@ i386_sol2_init_abi (struct gdbarch_info 
   set_solib_svr4_fetch_link_map_offsets
     (gdbarch, svr4_ilp32_fetch_link_map_offsets);
 
-  /* Solaris encodes the pid of the inferior in regset section
-     names.  */
-  set_gdbarch_core_reg_section_encodes_pid (gdbarch, 1);
-
   /* How to print LWP PTIDs from core files.  */
   set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str);
 }
Index: src/gdb/sparc-sol2-tdep.c
===================================================================
--- src.orig/gdb/sparc-sol2-tdep.c	2010-08-14 18:38:43.000000000 +0100
+++ src/gdb/sparc-sol2-tdep.c	2010-08-14 18:39:15.000000000 +0100
@@ -232,10 +232,6 @@ sparc32_sol2_init_abi (struct gdbarch_in
 
   frame_unwind_append_unwinder (gdbarch, &sparc32_sol2_sigtramp_frame_unwind);
 
-  /* Solaris encodes the pid of the inferior in regset section
-     names.  */
-  set_gdbarch_core_reg_section_encodes_pid (gdbarch, 1);
-
   /* How to print LWP PTIDs from core files.  */
   set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str);
 }
Index: src/gdb/sparc64-sol2-tdep.c
===================================================================
--- src.orig/gdb/sparc64-sol2-tdep.c	2010-08-14 18:38:43.000000000 +0100
+++ src/gdb/sparc64-sol2-tdep.c	2010-08-14 18:39:15.000000000 +0100
@@ -181,10 +181,6 @@ sparc64_sol2_init_abi (struct gdbarch_in
   /* Solaris has kernel-assisted single-stepping support.  */
   set_gdbarch_software_single_step (gdbarch, NULL);
 
-  /* Solaris encodes the pid of the inferior in regset section
-     names.  */
-  set_gdbarch_core_reg_section_encodes_pid (gdbarch, 1);
-
   /* How to print LWP PTIDs from core files.  */
   set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str);
 }


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