Index: gdb/corelow.c =================================================================== RCS file: /cvs/src/src/gdb/corelow.c,v retrieving revision 1.84 diff -u -p -r1.84 corelow.c --- gdb/corelow.c 18 May 2009 12:12:16 -0000 1.84 +++ gdb/corelow.c 1 Jun 2009 15:05:39 -0000 @@ -239,19 +239,10 @@ add_to_thread_list (bfd *abfd, asection if (strncmp (bfd_section_name (abfd, asect), ".reg/", 5) != 0) return; - thread_id = atoi (bfd_section_name (abfd, asect) + 5); + ptid = gdbarch_ptid_from_core_section (core_gdbarch, abfd, asect); - if (core_gdbarch - && gdbarch_core_reg_section_encodes_pid (core_gdbarch)) - { - uint32_t merged_pid = thread_id; - ptid = ptid_build (merged_pid & 0xffff, - merged_pid >> 16, 0); - } - else - ptid = ptid_build (ptid_get_pid (inferior_ptid), thread_id, 0); - - if (ptid_get_lwp (inferior_ptid) == 0) + if (ptid_get_tid (inferior_ptid) == 0 + && ptid_get_lwp (inferior_ptid) == 0) /* The main thread has already been added before getting here, and this is the first time we hear about a thread id. Assume this is the main thread. */ @@ -465,20 +456,9 @@ get_core_register_section (struct regcac xfree (section_name); - if (core_gdbarch - && gdbarch_core_reg_section_encodes_pid (core_gdbarch)) - { - uint32_t merged_pid; - - merged_pid = ptid_get_lwp (inferior_ptid); - merged_pid = merged_pid << 16 | ptid_get_pid (inferior_ptid); - - section_name = xstrprintf ("%s/%s", name, plongest (merged_pid)); - } - else if (ptid_get_lwp (inferior_ptid)) - section_name = xstrprintf ("%s/%ld", name, ptid_get_lwp (inferior_ptid)); - else - section_name = xstrdup (name); + section_name = gdbarch_core_section_name_from_ptid (core_gdbarch, + name, + inferior_ptid); section = bfd_get_section_by_name (core_bfd, section_name); if (! section) Index: gdb/gdbarch.sh =================================================================== RCS file: /cvs/src/src/gdb/gdbarch.sh,v retrieving revision 1.489 diff -u -p -r1.489 gdbarch.sh --- gdb/gdbarch.sh 19 May 2009 00:23:49 -0000 1.489 +++ gdb/gdbarch.sh 1 Jun 2009 15:05:39 -0000 @@ -602,10 +602,11 @@ M:const struct regset *:regset_from_core # 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 +# "XXX" in ".reg/XXX" is encoded as [LWPID << 16 | PID]. Others have thread_id +# but no LWP. This let's different architectures provide their own +# ptid for a given section. +m:ptid_t:ptid_from_core_section:const bfd *abfd, const asection *asect:abfd, asect::default_ptid_from_core_section::0 +m:char *:core_section_name_from_ptid:const char *name, ptid_t ptid:name, ptid::default_core_section_name_from_ptid::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) @@ -1188,6 +1189,10 @@ cat <> 16); +} + +char * +sol2_core_section_name_from_ptid (struct gdbarch *gdbarch, const char *name, + ptid_t ptid) +{ + uint32_t merged_pid; + + merged_pid = ptid_get_lwp (ptid); + merged_pid = merged_pid << 16 | ptid_get_pid (ptid); + return xstrprintf ("%s/%s", name, plongest (merged_pid)); +} + Index: gdb/amd64-sol2-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/amd64-sol2-tdep.c,v retrieving revision 1.10 diff -u -p -r1.10 amd64-sol2-tdep.c --- gdb/amd64-sol2-tdep.c 23 Feb 2009 00:03:48 -0000 1.10 +++ gdb/amd64-sol2-tdep.c 1 Jun 2009 15:05:39 -0000 @@ -116,7 +116,8 @@ amd64_sol2_init_abi (struct gdbarch_info /* Solaris encodes the pid of the inferior in regset section names. */ - set_gdbarch_core_reg_section_encodes_pid (gdbarch, 1); + set_gdbarch_ptid_from_core_section (sol2_ptid_from_core_section); + set_gdbarch_core_section_name_from_ptid (sol2_core_section_name_from_ptid); /* How to print LWP PTIDs from core files. */ set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str); Index: gdb/sparc-sol2-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/sparc-sol2-tdep.c,v retrieving revision 1.20 diff -u -p -r1.20 sparc-sol2-tdep.c --- gdb/sparc-sol2-tdep.c 23 Feb 2009 00:03:50 -0000 1.20 +++ gdb/sparc-sol2-tdep.c 1 Jun 2009 15:05:39 -0000 @@ -234,7 +234,9 @@ sparc32_sol2_init_abi (struct gdbarch_in /* Solaris encodes the pid of the inferior in regset section names. */ - set_gdbarch_core_reg_section_encodes_pid (gdbarch, 1); + set_gdbarch_ptid_from_core_section (gdbarch, sol2_ptid_from_core_section); + set_gdbarch_core_section_name_from_ptid (gdbarch, + sol2_core_section_name_from_ptid); /* How to print LWP PTIDs from core files. */ set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str); Index: gdb/sparc64-sol2-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/sparc64-sol2-tdep.c,v retrieving revision 1.19 diff -u -p -r1.19 sparc64-sol2-tdep.c --- gdb/sparc64-sol2-tdep.c 23 Feb 2009 00:03:50 -0000 1.19 +++ gdb/sparc64-sol2-tdep.c 1 Jun 2009 15:05:39 -0000 @@ -183,7 +183,9 @@ sparc64_sol2_init_abi (struct gdbarch_in /* Solaris encodes the pid of the inferior in regset section names. */ - set_gdbarch_core_reg_section_encodes_pid (gdbarch, 1); + set_gdbarch_ptid_from_core_section (gdbarch, sol2_ptid_from_core_section); + set_gdbarch_core_section_name_from_ptid (gdbarch, + sol2_core_section_name_from_ptid); /* How to print LWP PTIDs from core files. */ set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str); Index: gdb/i386-sol2-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/i386-sol2-tdep.c,v retrieving revision 1.28 diff -u -p -r1.28 i386-sol2-tdep.c --- gdb/i386-sol2-tdep.c 23 Feb 2009 00:03:49 -0000 1.28 +++ gdb/i386-sol2-tdep.c 1 Jun 2009 15:05:39 -0000 @@ -138,7 +138,9 @@ i386_sol2_init_abi (struct gdbarch_info /* Solaris encodes the pid of the inferior in regset section names. */ - set_gdbarch_core_reg_section_encodes_pid (gdbarch, 1); + set_gdbarch_ptid_from_core_section (gdbarch, sol2_ptid_from_core_section); + set_gdbarch_core_section_name_from_ptid (gdbarch, + sol2_core_section_name_from_ptid); /* How to print LWP PTIDs from core files. */ set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str);