* gdbarch.h, gdbarch.c: Regenerate.
* gcore.c (default_gcore_target): Make return value const.
Call gdbarch_gcore_bfd_target if present.
(default_gcore_arch, default_gcore_mach): Use target_gdbarch.
* corelow.c (core_read_description): Call gdbarch_core_read_description
on core_gdbarch instead of current_gdbarch.
* ppc-linux-tdep.c (ppc_linux_init_abi): Install gcore_bfd_target.
+2009-06-17 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * gdbarch.sh (gcore_bfd_target): New gdbarch callback.
+ * gdbarch.h, gdbarch.c: Regenerate.
+
+ * gcore.c (default_gcore_target): Make return value const.
+ Call gdbarch_gcore_bfd_target if present.
+ (default_gcore_arch, default_gcore_mach): Use target_gdbarch.
+
+ * corelow.c (core_read_description): Call gdbarch_core_read_description
+ on core_gdbarch instead of current_gdbarch.
+
+ * ppc-linux-tdep.c (ppc_linux_init_abi): Install gcore_bfd_target.
+
2009-06-17 Ulrich Weigand <uweigand@de.ibm.com>
* gdbtypes.c (create_string_type): Receive character type as argument.
static const struct target_desc *
core_read_description (struct target_ops *target)
{
- if (gdbarch_core_read_description_p (current_gdbarch))
- return gdbarch_core_read_description (current_gdbarch, target, core_bfd);
+ if (core_gdbarch && gdbarch_core_read_description_p (core_gdbarch))
+ return gdbarch_core_read_description (core_gdbarch, target, core_bfd);
return NULL;
}
generate-core-file for programs with large resident data. */
#define MAX_COPY_BYTES (1024 * 1024)
-static char *default_gcore_target (void);
+static const char *default_gcore_target (void);
static enum bfd_architecture default_gcore_arch (void);
static unsigned long default_gcore_mach (void);
static int gcore_memory_sections (bfd *);
return 0;
#else
- const struct bfd_arch_info *bfdarch = gdbarch_bfd_arch_info (current_gdbarch);
+ const struct bfd_arch_info *bfdarch = gdbarch_bfd_arch_info (target_gdbarch);
if (bfdarch != NULL)
return bfdarch->mach;
static enum bfd_architecture
default_gcore_arch (void)
{
- const struct bfd_arch_info * bfdarch = gdbarch_bfd_arch_info
- (current_gdbarch);
+ const struct bfd_arch_info *bfdarch = gdbarch_bfd_arch_info (target_gdbarch);
if (bfdarch != NULL)
return bfdarch->arch;
return bfd_get_arch (exec_bfd);
}
-static char *
+static const char *
default_gcore_target (void)
{
- /* FIXME: This may only work for ELF targets. */
+ /* The gdbarch may define a target to use for core files. */
+ if (gdbarch_gcore_bfd_target_p (target_gdbarch))
+ return gdbarch_gcore_bfd_target (target_gdbarch);
+
+ /* Otherwise, try to fall back to the exec_bfd target. This will probably
+ not work for non-ELF targets. */
if (exec_bfd == NULL)
return NULL;
else
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;
+ const char * gcore_bfd_target;
int vtable_function_descriptors;
int vbit_in_delta;
gdbarch_skip_permanent_breakpoint_ftype *skip_permanent_breakpoint;
0, /* core_regset_sections */
0, /* core_xfer_shared_libraries */
0, /* core_pid_to_str */
+ 0, /* gcore_bfd_target */
0, /* vtable_function_descriptors */
0, /* vbit_in_delta */
0, /* skip_permanent_breakpoint */
/* 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 */
/* Skip verify of vtable_function_descriptors, invalid_p == 0 */
/* Skip verify of vbit_in_delta, invalid_p == 0 */
/* Skip verify of skip_permanent_breakpoint, has predicate */
fprintf_unfiltered (file,
"gdbarch_dump: frame_red_zone_size = %s\n",
plongest (gdbarch->frame_red_zone_size));
+ fprintf_unfiltered (file,
+ "gdbarch_dump: gdbarch_gcore_bfd_target_p() = %d\n",
+ gdbarch_gcore_bfd_target_p (gdbarch));
+ fprintf_unfiltered (file,
+ "gdbarch_dump: gcore_bfd_target = %s\n",
+ gdbarch->gcore_bfd_target);
fprintf_unfiltered (file,
"gdbarch_dump: gdbarch_get_longjmp_target_p() = %d\n",
gdbarch_get_longjmp_target_p (gdbarch));
gdbarch->core_pid_to_str = core_pid_to_str;
}
+int
+gdbarch_gcore_bfd_target_p (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ return gdbarch->gcore_bfd_target != 0;
+}
+
+const char *
+gdbarch_gcore_bfd_target (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ /* Check variable changed from pre-default. */
+ gdb_assert (gdbarch->gcore_bfd_target != 0);
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_gcore_bfd_target called\n");
+ return gdbarch->gcore_bfd_target;
+}
+
+void
+set_gdbarch_gcore_bfd_target (struct gdbarch *gdbarch,
+ const char * gcore_bfd_target)
+{
+ gdbarch->gcore_bfd_target = gcore_bfd_target;
+}
+
int
gdbarch_vtable_function_descriptors (struct gdbarch *gdbarch)
{
extern char * gdbarch_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid);
extern void set_gdbarch_core_pid_to_str (struct gdbarch *gdbarch, gdbarch_core_pid_to_str_ftype *core_pid_to_str);
+/* BFD target to use when generating a core file. */
+
+extern int gdbarch_gcore_bfd_target_p (struct gdbarch *gdbarch);
+
+extern const char * gdbarch_gcore_bfd_target (struct gdbarch *gdbarch);
+extern void set_gdbarch_gcore_bfd_target (struct gdbarch *gdbarch, const char * gcore_bfd_target);
+
/* If the elements of C++ vtables are in-place function descriptors rather
than normal function pointers (which may point to code or a descriptor),
set this to one. */
# string.
M:char *:core_pid_to_str:ptid_t ptid:ptid
+# BFD target to use when generating a core file.
+V:const char *:gcore_bfd_target:::0:0:::gdbarch->gcore_bfd_target
+
# If the elements of C++ vtables are in-place function descriptors rather
# than normal function pointers (which may point to code or a descriptor),
# set this to one.
/* Trampolines. */
tramp_frame_prepend_unwinder (gdbarch, &ppc32_linux_sigaction_tramp_frame);
tramp_frame_prepend_unwinder (gdbarch, &ppc32_linux_sighandler_tramp_frame);
+
+ /* BFD target for core files. */
+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
+ set_gdbarch_gcore_bfd_target (gdbarch, "elf32-powerpcle");
+ else
+ set_gdbarch_gcore_bfd_target (gdbarch, "elf32-powerpc");
}
if (tdep->wordsize == 8)
/* Trampolines. */
tramp_frame_prepend_unwinder (gdbarch, &ppc64_linux_sigaction_tramp_frame);
tramp_frame_prepend_unwinder (gdbarch, &ppc64_linux_sighandler_tramp_frame);
+
+ /* BFD target for core files. */
+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
+ set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpcle");
+ else
+ set_gdbarch_gcore_bfd_target (gdbarch, "elf64-powerpc");
}
set_gdbarch_regset_from_core_section (gdbarch, ppc_linux_regset_from_core_section);
set_gdbarch_core_read_description (gdbarch, ppc_linux_core_read_description);