- Fix `gcore' command for 32bit PPC inferiors on 64bit PPC hosts (BZ

232015).
- Resolves: rhbz#232015
This commit is contained in:
Jan Kratochvil 2007-04-26 00:41:22 +00:00
parent a32d62ae37
commit 1499556e03
2 changed files with 211 additions and 3 deletions

View File

@ -0,0 +1,201 @@
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=232014
Based on `gdb-6.5-gcore-i386-on-amd64.patch'.
diff -u -rup gdb-6.6-orig/gdb/Makefile.in gdb-6.6/gdb/Makefile.in
--- gdb-6.6-orig/gdb/Makefile.in 2007-03-12 17:59:56.000000000 -0400
+++ gdb-6.6/gdb/Makefile.in 2007-04-23 13:05:05.000000000 -0400
@@ -2481,7 +2481,7 @@ ppcbug-rom.o: ppcbug-rom.c $(defs_h) $(g
ppc-linux-nat.o: ppc-linux-nat.c $(defs_h) $(gdb_string_h) $(frame_h) \
$(inferior_h) $(gdbcore_h) $(regcache_h) $(gdb_assert_h) \
$(gdb_wait_h) $(gregset_h) $(ppc_tdep_h) $(target_h) \
- $(linux_nat_h)
+ $(linux_nat_h) $(elf_bfd_h) $(gdb_procfs32_h)
ppc-linux-tdep.o: ppc-linux-tdep.c $(defs_h) $(frame_h) $(inferior_h) \
$(symtab_h) $(target_h) $(gdbcore_h) $(gdbcmd_h) $(symfile_h) \
$(objfiles_h) $(regcache_h) $(value_h) $(osabi_h) $(regset_h) \
diff -u -rup gdb-6.6-orig/gdb/gdb_procfs32.h gdb-6.6/gdb/gdb_procfs32.h
--- gdb-6.6-orig/gdb/gdb_procfs32.h 2007-03-12 17:59:55.000000000 -0400
+++ gdb-6.6/gdb/gdb_procfs32.h 2007-04-23 13:07:03.000000000 -0400
@@ -23,6 +23,8 @@
#ifndef _SYS_PROCFS32_H
#define _SYS_PROCFS32_H 1
+#if defined(__x86_64__) || defined(__ppc64__) || defined(__powerpc64__)
+
/* This is somewhat modelled after the file of the same name on SVR4
systems. It provides a definition of the core file format for ELF
used on Linux. It doesn't have anything to do with the /proc file
@@ -49,17 +51,27 @@ typedef unsigned int elf_greg32_t;
user_regs_struct' directly in the typedef, but tradition says that
the register set is an array, which does have some peculiar
semantics, so leave it that way. */
+#if defined(__x86_64__)
#define ELF_NGREG32 (sizeof (struct user_regs32_struct) / sizeof(elf_greg32_t))
+#elif defined(__ppc64__) || defined(__powerpc64__)
+#define ELF_NGREG32 48
+#else
+#error "Unsupported platform"
+#endif
typedef elf_greg32_t elf_gregset32_t[ELF_NGREG32];
/* Register set for the floating-point registers. */
-typedef struct user_fpregs32_struct elf_fpregset32_t;
-
/* Register set for the extended floating-point registers. Includes
the Pentium III SSE registers in addition to the classic
floating-point stuff. */
+#if defined(__x86_64__)
+typedef struct user_fpregs32_struct elf_fpregset32_t;
typedef struct user_fpxregs32_struct elf_fpxregset32_t;
-
+#elif defined(__ppc64__) || defined(__powerpc64__)
+typedef elf_fpregset_t elf_fpregset32_t;
+#else
+#error "Unsupported platform"
+#endif
/* Definitions to generate Intel SVR4-like core files. These mostly
have the same names as the SVR4 types with "elf_" tacked on the
@@ -100,8 +112,15 @@
char pr_zomb; /* Zombie. */
char pr_nice; /* Nice val. */
unsigned int pr_flag; /* Flags. */
+#if defined(__x86_64__)
unsigned short int pr_uid;
unsigned short int pr_gid;
+#elif defined(__ppc64__) || defined(__powerpc64__)
+ unsigned int pr_uid;
+ unsigned int pr_gid;
+#else
+#error "Unsupported platform"
+#endif
int pr_pid, pr_ppid, pr_pgrp, pr_sid;
/* Lots missing */
char pr_fname[16]; /* Filename of executable. */
@@ -123,6 +135,8 @@ typedef struct elf_prpsinfo32 prpsinfo32
__END_DECLS
+#endif /* defined(__x86_64__) || defined(__ppc64__) || defined(__powerpc64__) */
+
#endif /* _SYS_PROCFS32_H */
#endif /* HAVE_SYS_PROCFS32_H */
diff -u -rup gdb-6.6-orig/gdb/gdb_user32.h gdb-6.6/gdb/gdb_user32.h
--- gdb-6.6-orig/gdb/gdb_user32.h 2007-03-12 17:59:55.000000000 -0400
+++ gdb-6.6/gdb/gdb_user32.h 2007-04-23 13:05:05.000000000 -0400
@@ -32,6 +32,8 @@ typedef unsigned int gdb_uint32_t;
#ifndef _SYS_USER32_H
#define _SYS_USER32_H 1
+#ifdef __x86_64__
+
/* These are the 32-bit x86 structures. */
struct user_fpregs32_struct
@@ -103,6 +105,8 @@ struct user32
int u_debugreg [8];
};
+#endif /* __x86_64__ */
+
#endif /* _SYS_USER32_H */
#endif /* HAVE_SYS_USER32_H */
diff -u -rup gdb-6.6-orig/gdb/ppc-linux-nat.c gdb-6.6/gdb/ppc-linux-nat.c
--- gdb-6.6-orig/gdb/ppc-linux-nat.c 2006-05-05 16:45:03.000000000 -0400
+++ gdb-6.6/gdb/ppc-linux-nat.c 2007-04-23 13:16:09.000000000 -0400
@@ -29,6 +29,8 @@
#include "gdb_assert.h"
#include "target.h"
#include "linux-nat.h"
+#include "bfd/elf-bfd.h"
+#include "gdb_procfs32.h"
#include <stdint.h>
#include <sys/types.h>
@@ -1002,6 +1004,68 @@ fill_fpregset (gdb_fpregset_t *fpregsetp
}
}
+#if defined(__ppc64__) || defined(__powerpc64__)
+
+/* This functions make ELF32 32-bit elfcore note sections
+ on ppc64 environment. */
+
+static char *
+ppc_linux_elfcore_write_prpsinfo (bfd *abfd, char *buf, int *bufsiz,
+ const char *fname, const char *psargs)
+{
+ if (gdbarch_ptr_bit(current_gdbarch) == 32)
+ {
+ int note_type;
+ char *note_name = "CORE";
+ struct elf_prpsinfo32 data;
+ note_type = NT_PRPSINFO;
+
+ memset (&data, 0, sizeof (data));
+ strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
+ strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
+ return elfcore_write_note (abfd, buf, bufsiz,
+ note_name, note_type, &data, sizeof (data));
+ }
+ else
+ return elfcore_write_prpsinfo (abfd, buf, bufsiz, fname, psargs);
+}
+
+static void
+ppc_linux_set_registers (const gdb_byte *gregs, gdb_byte *buf)
+{
+ int i;
+ const int elf_ngreg = 48;
+
+ /* Copy the ppc registers in the ppc64 layout into ppc layout. */
+ for (i = 0; i < elf_ngreg; i++)
+ memcpy (buf + 4 * i, gregs + 8 * i + 4, 4);
+ /* CR and XER are an exception as they are shifted left there,
+ see fill_gregset(). */
+ memcpy (buf + 4 * PT_CCR, gregs + 8 * PT_CCR + 0, 4);
+ memcpy (buf + 4 * PT_XER, gregs + 8 * PT_XER + 0, 4);
+}
+
+static char *
+ppc_linux_elfcore_write_prstatus (bfd *abfd, char *buf, int *bufsiz,
+ long pid, int cursig, const void *gregs)
+{
+ if (gdbarch_ptr_bit(current_gdbarch) == 32)
+ {
+ char *note_name = "CORE";
+ struct elf_prstatus32 prstat;
+ memset (&prstat, 0, sizeof (prstat));
+ prstat.pr_pid = pid;
+ prstat.pr_cursig = cursig;
+ ppc_linux_set_registers (gregs, (gdb_byte *) &prstat.pr_reg);
+ return elfcore_write_note (abfd, buf, bufsiz, note_name,
+ NT_PRSTATUS, &prstat, sizeof (prstat));
+ }
+ else
+ return elfcore_write_prstatus (abfd, buf, bufsiz, pid, cursig, gregs);
+}
+
+#endif /* defined(__ppc64__) || defined(__powerpc64__) */
+
void _initialize_ppc_linux_nat (void);
void
@@ -1024,6 +1084,12 @@ _initialize_ppc_linux_nat (void)
t->to_stopped_by_watchpoint = ppc_linux_stopped_by_watchpoint;
t->to_stopped_data_address = ppc_linux_stopped_data_address;
+#if defined(__ppc64__) || defined(__powerpc64__)
+ /* This functions make elfcore note sections. */
+ linux_elfcore_write_prpsinfo = ppc_linux_elfcore_write_prpsinfo;
+ linux_elfcore_write_prstatus = ppc_linux_elfcore_write_prstatus;
+#endif /* defined(__ppc64__) || defined(__powerpc64__) */
+
/* Register the target. */
linux_nat_add_target (t);
}

View File

@ -11,7 +11,7 @@ Name: gdb
Version: 6.6
# The release always contains a leading reserved number, start it at 1.
Release: 12%{?dist}
Release: 13%{?dist}
License: GPL
Group: Development/Debuggers
@ -338,7 +338,10 @@ Patch246: gdb-6.6-bz237096-watchthreads-testcasefix.patch
# Notify user of a child forked process being detached (BZ 235197).
Patch247: gdb-6.6-bz234468-fork-detach-info.patch
# New testcase for 32bit inferiors on 64bit hosts.
# Fix `gcore' command for 32bit PPC inferiors on 64bit PPC hosts (BZ 232014).
Patch248: gdb-6.6-bz232014-gcore-ppc-on-ppc64.patch
# New testcase for gcore of 32bit inferiors on 64bit hosts.
Patch249: gdb-6.6-gcore32-test.patch
# Enable PowerPC to print 128-bit long double variables (BZ 237872).
@ -484,6 +487,7 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
%patch245 -p1
%patch246 -p1
%patch247 -p1
%patch248 -p1
%patch249 -p1
%patch251 -p1
@ -633,9 +637,12 @@ fi
# don't include the files in include, they are part of binutils
%changelog
* Wed Apr 25 2007 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.6-13
- Fix `gcore' command for 32bit PPC inferiors on 64bit PPC hosts (BZ 232015).
* Wed Apr 25 2007 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.6-12
- Enable PowerPC to print 128-bit long double variables (BZ 237872).
- New testcase for 32bit inferiors on 64bit hosts.
- New testcase for gcore of 32bit inferiors on 64bit hosts.
* Tue Apr 24 2007 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.6-11
- Package review, analysed by Ralf Corsepius (BZ 225783).