aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2009-06-17 18:48:26 +0000
committerUlrich Weigand <uweigand@de.ibm.com>2009-06-17 18:48:26 +0000
commita78c2d625ffe6bf34934991e815db484d3393a76 (patch)
tree41b36b94ddb5c674e832c0297b24550ec4c7d606
parent3b7538c0317072d430eca4e808b183dac5bd5e45 (diff)
downloadfsf-binutils-gdb-a78c2d625ffe6bf34934991e815db484d3393a76.zip
fsf-binutils-gdb-a78c2d625ffe6bf34934991e815db484d3393a76.tar.gz
fsf-binutils-gdb-a78c2d625ffe6bf34934991e815db484d3393a76.tar.bz2
* 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.
-rw-r--r--gdb/ChangeLog14
-rw-r--r--gdb/corelow.c4
-rw-r--r--gdb/gcore.c16
-rw-r--r--gdb/gdbarch.c34
-rw-r--r--gdb/gdbarch.h7
-rwxr-xr-xgdb/gdbarch.sh3
-rw-r--r--gdb/ppc-linux-tdep.c12
7 files changed, 82 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ec1e3d5..48952aa 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,19 @@
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.
* gdbtypes.h (create_string_type): Add character type argument.
* dwarf2read.c (read_tag_string_type): Pass character type to
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 88dfe99..b69c2a1 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -721,8 +721,8 @@ core_thread_alive (struct target_ops *ops, ptid_t ptid)
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;
}
diff --git a/gdb/gcore.c b/gdb/gcore.c
index ec1be44..b227721 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -35,7 +35,7 @@
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 *);
@@ -125,7 +125,7 @@ default_gcore_mach (void)
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;
@@ -139,8 +139,7 @@ default_gcore_mach (void)
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;
@@ -150,10 +149,15 @@ default_gcore_arch (void)
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
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 1268fea..37b8677 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -226,6 +226,7 @@ struct gdbarch
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;
@@ -362,6 +363,7 @@ struct gdbarch startup_gdbarch =
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 */
@@ -616,6 +618,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* 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 */
@@ -846,6 +849,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *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));
fprintf_unfiltered (file,
@@ -2987,6 +2996,31 @@ set_gdbarch_core_pid_to_str (struct gdbarch *gdbarch,
}
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)
{
gdb_assert (gdbarch != NULL);
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index a41d190..fa3f82e 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -668,6 +668,13 @@ typedef char * (gdbarch_core_pid_to_str_ftype) (struct gdbarch *gdbarch, ptid_t
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. */
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index cc00965..e787235 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -609,6 +609,9 @@ M:LONGEST:core_xfer_shared_libraries:gdb_byte *readbuf, ULONGEST offset, LONGEST
# 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.
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index da332f3..2bb88b3 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -1102,6 +1102,12 @@ ppc_linux_init_abi (struct gdbarch_info info,
/* 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)
@@ -1119,6 +1125,12 @@ ppc_linux_init_abi (struct gdbarch_info info,
/* 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);