From: Pedro Alves Date: Wed, 4 Aug 2010 15:27:57 +0000 (+0000) Subject: * corelow.c (core_pid_to_str): Default to using normal_pid_to_str X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a5ee0f0c4d286ed3437ded51e904016b1e26209d;p=binutils-gdb.git * corelow.c (core_pid_to_str): Default to using normal_pid_to_str instead of printing "Thread" here. * linux-tdep.c: Include inferior.h. (linux_core_pid_to_str): New. (linux_init_abi): New. * linux-tdep.h (linux_init_abi): Declare. * alpha-linux-tdep.c: Include linux-tdep.h. (alpha_linux_init_abi): Call linux_init_abi. * amd64-linux-tdep.c (amd64_linux_init_abi): Call linux_init_abi. * arm-linux-tdep.c (arm_linux_init_abi): Call linux_init_abi. * frv-linux-tdep.c: Include linux-tdep.h (frv_linux_init_abi): Call linux_init_abi. * hppa-linux-tdep.c: Include linux-tdep.h (hppa_linux_init_abi): Call linux_init_abi. * i386-linux-tdep.c (i386_linux_init_abi): Call linux_init_abi. * ia64-linux-tdep.c: Include linux-tdep.h. (ia64_linux_init_abi): Call linux_init_abi. * m32r-linux-tdep.c: Include linux-tdep.h. (m32r_linux_init_abi): Call linux_init_abi. * m68klinux-tdep.c: Include linux-tdep.h. (m68k_linux_init_abi): Call linux_init_abi. * microblaze-linux-tdep.c: Include linux-tdep.h. (microblaze_linux_init_abi): Call linux_init_abi. * mips-linux-tdep.c: Include linux-tdep.h. (mips_linux_init_abi): Call linux_init_abi. * mn10300-linux-tdep.c: Include linux-tdep.h. (am33_linux_init_osabi): Call linux_init_abi. Rename the 'gdbinfo' parameter to 'info'. * ppc-linux-tdep.c: Include linux-tdep.h. (ppc_linux_init_abi): Call linux_init_abi. * sh-linux-tdep.c: Include linux-tdep.h. (sh_linux_init_abi): Call linux_init_abi. * sparc-linux-tdep.c: Include linux-tdep.h. (sparc32_linux_init_abi): Call linux_init_abi. * sparc64-linux-tdep.c: Include linux-tdep.h. (sparc64_linux_init_abi): Call linux_init_abi. * xtensa-linux-tdep.c: Include linux-tdep.h. (xtensa_linux_init_abi): Call linux_init_abi. * i386-cygwin-tdep.c (i386_windows_core_pid_to_str): New. (i386_cygwin_init_abi): Install it as gdbarch_core_pid_to_str callback. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f107facee83..44ea5a995ee 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,47 @@ +2010-08-04 Pedro Alves + + * corelow.c (core_pid_to_str): Default to using normal_pid_to_str + instead of printing "Thread" here. + * linux-tdep.c: Include inferior.h. + (linux_core_pid_to_str): New. + (linux_init_abi): New. + * linux-tdep.h (linux_init_abi): Declare. + * alpha-linux-tdep.c: Include linux-tdep.h. + (alpha_linux_init_abi): Call linux_init_abi. + * amd64-linux-tdep.c (amd64_linux_init_abi): Call linux_init_abi. + * arm-linux-tdep.c (arm_linux_init_abi): Call linux_init_abi. + * frv-linux-tdep.c: Include linux-tdep.h + (frv_linux_init_abi): Call linux_init_abi. + * hppa-linux-tdep.c: Include linux-tdep.h + (hppa_linux_init_abi): Call linux_init_abi. + * i386-linux-tdep.c (i386_linux_init_abi): Call linux_init_abi. + * ia64-linux-tdep.c: Include linux-tdep.h. + (ia64_linux_init_abi): Call linux_init_abi. + * m32r-linux-tdep.c: Include linux-tdep.h. + (m32r_linux_init_abi): Call linux_init_abi. + * m68klinux-tdep.c: Include linux-tdep.h. + (m68k_linux_init_abi): Call linux_init_abi. + * microblaze-linux-tdep.c: Include linux-tdep.h. + (microblaze_linux_init_abi): Call linux_init_abi. + * mips-linux-tdep.c: Include linux-tdep.h. + (mips_linux_init_abi): Call linux_init_abi. + * mn10300-linux-tdep.c: Include linux-tdep.h. + (am33_linux_init_osabi): Call linux_init_abi. Rename the + 'gdbinfo' parameter to 'info'. + * ppc-linux-tdep.c: Include linux-tdep.h. + (ppc_linux_init_abi): Call linux_init_abi. + * sh-linux-tdep.c: Include linux-tdep.h. + (sh_linux_init_abi): Call linux_init_abi. + * sparc-linux-tdep.c: Include linux-tdep.h. + (sparc32_linux_init_abi): Call linux_init_abi. + * sparc64-linux-tdep.c: Include linux-tdep.h. + (sparc64_linux_init_abi): Call linux_init_abi. + * xtensa-linux-tdep.c: Include linux-tdep.h. + (xtensa_linux_init_abi): Call linux_init_abi. + * i386-cygwin-tdep.c (i386_windows_core_pid_to_str): New. + (i386_cygwin_init_abi): Install it as gdbarch_core_pid_to_str + callback. + 2010-08-03 Doug Evans * breakpoint.c (bpdisp_text): Constify bpdisps. diff --git a/gdb/alpha-linux-tdep.c b/gdb/alpha-linux-tdep.c index 3c71f2f03cd..d957c386e4c 100644 --- a/gdb/alpha-linux-tdep.c +++ b/gdb/alpha-linux-tdep.c @@ -26,7 +26,7 @@ #include "symtab.h" #include "regset.h" #include "regcache.h" - +#include "linux-tdep.h" #include "alpha-tdep.h" /* Under GNU/Linux, signal handler invocations can be identified by @@ -212,6 +212,8 @@ alpha_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep; + linux_init_abi (info, gdbarch); + /* Hook into the DWARF CFI frame unwinder. */ alpha_dwarf2_init_abi (info, gdbarch); diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c index ed75f97c9ea..a1f9db3684b 100644 --- a/gdb/amd64-linux-tdep.c +++ b/gdb/amd64-linux-tdep.c @@ -1291,6 +1291,8 @@ amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) gdb_assert (tdesc_data); + linux_init_abi (info, gdbarch); + tdep->gregset_reg_offset = amd64_linux_gregset_reg_offset; tdep->gregset_num_regs = ARRAY_SIZE (amd64_linux_gregset_reg_offset); tdep->sizeof_gregset = 27 * 8; diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c index 15fc1c92653..682054c44b4 100644 --- a/gdb/arm-linux-tdep.c +++ b/gdb/arm-linux-tdep.c @@ -862,6 +862,8 @@ arm_linux_init_abi (struct gdbarch_info info, { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + linux_init_abi (info, gdbarch); + tdep->lowest_pc = 0x8000; if (info.byte_order == BFD_ENDIAN_BIG) { diff --git a/gdb/corelow.c b/gdb/corelow.c index e96d0725333..9d0047124fd 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -853,21 +853,29 @@ static char * core_pid_to_str (struct target_ops *ops, ptid_t ptid) { static char buf[64]; + int pid; + /* The preferred way is to have a gdbarch/OS specific + implementation. */ if (core_gdbarch && gdbarch_core_pid_to_str_p (core_gdbarch)) - { - char *ret = gdbarch_core_pid_to_str (core_gdbarch, ptid); + return gdbarch_core_pid_to_str (core_gdbarch, ptid); - if (ret != NULL) - return ret; - } + /* Otherwise, if we don't have one, we'll just fallback to + "process", with normal_pid_to_str. */ - if (ptid_get_lwp (ptid) == 0) - xsnprintf (buf, sizeof buf, "
"); - else - xsnprintf (buf, sizeof buf, "Thread %ld", ptid_get_lwp (ptid)); + /* Try the LWPID field first. */ + pid = ptid_get_lwp (ptid); + if (pid != 0) + return normal_pid_to_str (pid_to_ptid (pid)); + + /* Otherwise, this isn't a "threaded" core -- use the PID field, but + only if it isn't a fake PID. */ + if (!core_has_fake_pid) + return normal_pid_to_str (ptid); + /* No luck. We simply don't have a valid PID to print. */ + xsnprintf (buf, sizeof buf, "
"); return buf; } diff --git a/gdb/frv-linux-tdep.c b/gdb/frv-linux-tdep.c index c051a4deb9f..b06597afa8c 100644 --- a/gdb/frv-linux-tdep.c +++ b/gdb/frv-linux-tdep.c @@ -32,6 +32,7 @@ #include "frame-unwind.h" #include "regset.h" #include "gdb_string.h" +#include "linux-tdep.h" /* Define the size (in bytes) of an FR-V instruction. */ static const int frv_instr_size = 4; @@ -490,8 +491,11 @@ frv_linux_regset_from_core_section (struct gdbarch *gdbarch, static void frv_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { + linux_init_abi (info, gdbarch); + /* Set the sigtramp frame sniffer. */ frame_unwind_append_unwinder (gdbarch, &frv_linux_sigtramp_frame_unwind); + set_gdbarch_regset_from_core_section (gdbarch, frv_linux_regset_from_core_section); } diff --git a/gdb/hppa-linux-tdep.c b/gdb/hppa-linux-tdep.c index ebfc2f5759b..70f53a6752b 100644 --- a/gdb/hppa-linux-tdep.c +++ b/gdb/hppa-linux-tdep.c @@ -32,7 +32,7 @@ #include "regset.h" #include "regcache.h" #include "hppa-tdep.h" - +#include "linux-tdep.h" #include "elf/common.h" /* Map DWARF DBX register numbers to GDB register numbers. */ @@ -523,6 +523,8 @@ hppa_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + linux_init_abi (info, gdbarch); + /* GNU/Linux is always ELF. */ tdep->is_elf = 1; diff --git a/gdb/i386-cygwin-tdep.c b/gdb/i386-cygwin-tdep.c index 50ce2e3f079..9d3d254a63b 100644 --- a/gdb/i386-cygwin-tdep.c +++ b/gdb/i386-cygwin-tdep.c @@ -28,6 +28,7 @@ #include "gdbcore.h" #include "solib.h" #include "solib-target.h" +#include "inferior.h" /* Core file support. */ @@ -199,6 +200,22 @@ windows_core_xfer_shared_libraries (struct gdbarch *gdbarch, return len; } +/* This is how we want PTIDs from core files to be printed. */ + +static char * +i386_windows_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid) +{ + static char buf[80]; + + if (ptid_get_lwp (ptid) != 0) + { + snprintf (buf, sizeof (buf), "Thread 0x%lx", ptid_get_lwp (ptid)); + return buf; + } + + return normal_pid_to_str (ptid); +} + static CORE_ADDR i386_cygwin_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) { @@ -233,6 +250,7 @@ i386_cygwin_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) (gdbarch, i386_windows_regset_from_core_section); set_gdbarch_core_xfer_shared_libraries (gdbarch, windows_core_xfer_shared_libraries); + set_gdbarch_core_pid_to_str (gdbarch, i386_windows_core_pid_to_str); set_gdbarch_auto_wide_charset (gdbarch, i386_cygwin_auto_wide_charset); diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c index 8ca73773e16..7b4a6418d4b 100644 --- a/gdb/i386-linux-tdep.c +++ b/gdb/i386-linux-tdep.c @@ -654,6 +654,8 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) gdb_assert (tdesc_data); + linux_init_abi (info, gdbarch); + /* GNU/Linux uses ELF. */ i386_elf_init_abi (info, gdbarch); diff --git a/gdb/ia64-linux-tdep.c b/gdb/ia64-linux-tdep.c index b12f2828e36..33d70ca3486 100644 --- a/gdb/ia64-linux-tdep.c +++ b/gdb/ia64-linux-tdep.c @@ -26,6 +26,7 @@ #include "osabi.h" #include "solib-svr4.h" #include "symtab.h" +#include "linux-tdep.h" /* The sigtramp code is in a non-readable (executable-only) region of memory called the ``gate page''. The addresses in question @@ -122,6 +123,8 @@ ia64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + linux_init_abi (info, gdbarch); + /* Set the method of obtaining the sigcontext addresses at which registers are saved. */ tdep->sigcontext_register_address = ia64_linux_sigcontext_register_address; diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 07fd67c887d..004451e5c1a 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -23,6 +23,7 @@ #include "auxv.h" #include "target.h" #include "elf/common.h" +#include "inferior.h" /* This function is suitable for architectures that don't extend/override the standard siginfo structure. */ @@ -152,3 +153,28 @@ linux_has_shared_address_space (void) return target_is_uclinux; } + +/* This is how we want PTIDs from core files to be printed. */ + +static char * +linux_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid) +{ + static char buf[80]; + + if (ptid_get_lwp (ptid) != 0) + { + snprintf (buf, sizeof (buf), "LWP %ld", ptid_get_lwp (ptid)); + return buf; + } + + return normal_pid_to_str (ptid); +} + +/* To be called from the various GDB_OSABI_LINUX handlers for the + various GNU/Linux architectures and machine types. */ + +void +linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +{ + set_gdbarch_core_pid_to_str (gdbarch, linux_core_pid_to_str); +} diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h index a8b522bfcbc..943df2d669a 100644 --- a/gdb/linux-tdep.h +++ b/gdb/linux-tdep.h @@ -22,4 +22,6 @@ struct type *linux_get_siginfo_type (struct gdbarch *); +extern void linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch); + #endif /* linux-tdep.h */ diff --git a/gdb/m32r-linux-tdep.c b/gdb/m32r-linux-tdep.c index 6804609f8bb..6a5cbecaee7 100644 --- a/gdb/m32r-linux-tdep.c +++ b/gdb/m32r-linux-tdep.c @@ -37,6 +37,8 @@ #include "frame-unwind.h" #include "m32r-tdep.h" +#include "linux-tdep.h" + /* Recognizing signal handler frames. */ @@ -404,6 +406,8 @@ m32r_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + linux_init_abi (info, gdbarch); + /* Since EVB register is not available for native debug, we reduce the number of registers. */ set_gdbarch_num_regs (gdbarch, M32R_NUM_REGS - 1); diff --git a/gdb/m68klinux-tdep.c b/gdb/m68klinux-tdep.c index 18bda74097f..fa4befa9cdc 100644 --- a/gdb/m68klinux-tdep.c +++ b/gdb/m68klinux-tdep.c @@ -38,6 +38,7 @@ #include "auxv.h" #include "observer.h" #include "elf/common.h" +#include "linux-tdep.h" /* Offsets (in target ints) into jmp_buf. */ @@ -338,6 +339,8 @@ m68k_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + linux_init_abi (info, gdbarch); + tdep->jb_pc = M68K_LINUX_JB_PC; tdep->jb_elt_size = M68K_LINUX_JB_ELEMENT_SIZE; diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c index a691b6221aa..b0751b58d64 100644 --- a/gdb/microblaze-linux-tdep.c +++ b/gdb/microblaze-linux-tdep.c @@ -35,7 +35,7 @@ #include "trad-frame.h" #include "frame-unwind.h" #include "tramp-frame.h" - +#include "linux-tdep.h" static int microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch, @@ -123,6 +123,8 @@ microblaze_linux_init_abi (struct gdbarch_info info, { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + linux_init_abi (info, gdbarch); + set_gdbarch_memory_remove_breakpoint (gdbarch, microblaze_linux_memory_remove_breakpoint); diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c index 5924b30984d..6d0e7f6c9d2 100644 --- a/gdb/mips-linux-tdep.c +++ b/gdb/mips-linux-tdep.c @@ -38,6 +38,7 @@ #include "target-descriptions.h" #include "mips-linux-tdep.h" #include "glibc-tdep.h" +#include "linux-tdep.h" static struct target_so_ops mips_svr4_so_ops; @@ -1140,6 +1141,8 @@ mips_linux_init_abi (struct gdbarch_info info, enum mips_abi abi = mips_abi (gdbarch); struct tdesc_arch_data *tdesc_data = (void *) info.tdep_info; + linux_init_abi (info, gdbarch); + switch (abi) { case MIPS_ABI_O32: diff --git a/gdb/mn10300-linux-tdep.c b/gdb/mn10300-linux-tdep.c index d4602a473c0..586e20dc9e8 100644 --- a/gdb/mn10300-linux-tdep.c +++ b/gdb/mn10300-linux-tdep.c @@ -32,6 +32,7 @@ #include "frame.h" #include "trad-frame.h" #include "tramp-frame.h" +#include "linux-tdep.h" #include @@ -709,8 +710,10 @@ am33_linux_sigframe_cache_init (const struct tramp_frame *self, Now's our chance to register our corefile handling. */ static void -am33_linux_init_osabi (struct gdbarch_info gdbinfo, struct gdbarch *gdbarch) +am33_linux_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch) { + linux_init_abi (info, gdbarch); + set_gdbarch_regset_from_core_section (gdbarch, am33_regset_from_core_section); set_solib_svr4_fetch_link_map_offsets diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index 8fc85125d63..0402de2cda8 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -48,6 +48,7 @@ #include "arch-utils.h" #include "spu-tdep.h" #include "xml-syscall.h" +#include "linux-tdep.h" #include "features/rs6000/powerpc-32l.c" #include "features/rs6000/powerpc-altivec32l.c" @@ -1486,6 +1487,8 @@ ppc_linux_init_abi (struct gdbarch_info info, struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); struct tdesc_arch_data *tdesc_data = (void *) info.tdep_info; + linux_init_abi (info, gdbarch); + /* PPC GNU/Linux uses either 64-bit or 128-bit long doubles; where 128-bit, they are IBM long double, not IEEE quad long double as in the System V ABI PowerPC Processor Supplement. We can safely diff --git a/gdb/sh-linux-tdep.c b/gdb/sh-linux-tdep.c index da4137bbed3..170a8b4abfc 100644 --- a/gdb/sh-linux-tdep.c +++ b/gdb/sh-linux-tdep.c @@ -25,6 +25,7 @@ #include "glibc-tdep.h" #include "sh-tdep.h" +#include "linux-tdep.h" #define REGSx16(base) \ {(base), 0}, \ @@ -72,6 +73,8 @@ static const struct sh_corefile_regmap fpregs_table[] = static void sh_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { + linux_init_abi (info, gdbarch); + /* GNU/Linux uses SVR4-style shared libraries. */ set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target); set_solib_svr4_fetch_link_map_offsets diff --git a/gdb/sparc-linux-tdep.c b/gdb/sparc-linux-tdep.c index 20644b471f7..db193e8c421 100644 --- a/gdb/sparc-linux-tdep.c +++ b/gdb/sparc-linux-tdep.c @@ -33,6 +33,7 @@ #include "trad-frame.h" #include "tramp-frame.h" #include "xml-syscall.h" +#include "linux-tdep.h" /* The syscall's XML filename for sparc 32-bit. */ #define XML_SYSCALL_FILENAME_SPARC32 "syscalls/sparc-linux.xml" @@ -273,6 +274,8 @@ sparc32_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + linux_init_abi (info, gdbarch); + tdep->gregset = regset_alloc (gdbarch, sparc32_linux_supply_core_gregset, sparc32_linux_collect_core_gregset); tdep->sizeof_gregset = 152; diff --git a/gdb/sparc64-linux-tdep.c b/gdb/sparc64-linux-tdep.c index 72bbb320f1a..f13c51c2a22 100644 --- a/gdb/sparc64-linux-tdep.c +++ b/gdb/sparc64-linux-tdep.c @@ -32,6 +32,7 @@ #include "trad-frame.h" #include "tramp-frame.h" #include "xml-syscall.h" +#include "linux-tdep.h" /* The syscall's XML filename for sparc 64-bit. */ #define XML_SYSCALL_FILENAME_SPARC64 "syscalls/sparc64-linux.xml" @@ -237,6 +238,8 @@ sparc64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + linux_init_abi (info, gdbarch); + tdep->gregset = regset_alloc (gdbarch, sparc64_linux_supply_core_gregset, sparc64_linux_collect_core_gregset); tdep->sizeof_gregset = 288; diff --git a/gdb/xtensa-linux-tdep.c b/gdb/xtensa-linux-tdep.c index 667d9b31b2e..0d2137828ea 100644 --- a/gdb/xtensa-linux-tdep.c +++ b/gdb/xtensa-linux-tdep.c @@ -19,7 +19,7 @@ #include "defs.h" #include "osabi.h" - +#include "linux-tdep.h" #include "solib-svr4.h" #include "symtab.h" @@ -28,6 +28,8 @@ static void xtensa_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { + linux_init_abi (info, gdbarch); + set_solib_svr4_fetch_link_map_offsets (gdbarch, svr4_ilp32_fetch_link_map_offsets); }