keiths / rpms / gdb

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