This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] Improved e500 native debug support
- From: Daniel Jacobowitz <drow at false dot org>
- To: gdb-patches at sourceware dot org
- Date: Fri, 5 Oct 2007 13:50:22 -0400
- Subject: [patch] Improved e500 native debug support
This patch, which depends on my previous patches for preparsed
descriptions and PowerPC XML support, improves automatic detection of
e500 binaries. Right now the e500 register set is selected if
the main executable contains a .PPC.EMB.apuinfo section. That
actually means that the executable uses SPE instructions, not that it
was compiled for an e500 target or that we're running on one.
So, for instance, you can not display the e500 registers if you run a
soft-float binary - even if it is linked with a shared library which
uses e500 registers for optimization.
The first time I solved this, for MontaVista a year or two ago, there
was no clean solution. Now there is. Check whether PTRACE_GETEVRREGS
can access the vector registers; if it can, then this must be an
e500 target and we should report the e500 registers.
I've tested this natively on PowerPC systems with and without SPE.
I'll commit it when the patches it depends on are merged.
--
Daniel Jacobowitz
CodeSourcery
2007-10-05 Daniel Jacobowitz <dan@codesourcery.com>
* ppc-linux-nat.c (ppc_linux_read_description): New.
(_initialize_ppc_linux_nat): Set to_read_description.
* ppc-tdep.h (tdesc_powerpc_e500): Declare.
---
gdb/ppc-linux-nat.c | 29 +++++++++++++++++++++++++++++
gdb/ppc-tdep.h | 2 ++
2 files changed, 31 insertions(+)
Index: src/gdb/ppc-linux-nat.c
===================================================================
--- src.orig/gdb/ppc-linux-nat.c 2007-10-04 11:25:50.000000000 -0400
+++ src/gdb/ppc-linux-nat.c 2007-10-04 14:24:16.000000000 -0400
@@ -940,6 +940,33 @@ fill_fpregset (const struct regcache *re
fpregsetp, sizeof (*fpregsetp));
}
+static const struct target_desc *
+ppc_linux_read_description (struct target_ops *ops)
+{
+ if (have_ptrace_getsetevrregs)
+ {
+ struct gdb_evrregset_t evrregset;
+ int tid = TIDGET (inferior_ptid);
+
+ if (tid == 0)
+ tid = PIDGET (inferior_ptid);
+
+ if (ptrace (PTRACE_GETEVRREGS, tid, 0, &evrregset) >= 0)
+ return tdesc_powerpc_e500;
+ else
+ {
+ /* EIO means that the PTRACE_GETEVRREGS request isn't supported. */
+ if (errno == EIO)
+ return NULL;
+ else
+ /* Anything else needs to be reported. */
+ perror_with_name (_("Unable to fetch SPE registers"));
+ }
+ }
+
+ return NULL;
+}
+
void _initialize_ppc_linux_nat (void);
void
@@ -962,6 +989,8 @@ _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;
+ t->to_read_description = ppc_linux_read_description;
+
/* Register the target. */
linux_nat_add_target (t);
linux_nat_set_new_thread (t, ppc_linux_new_thread);
Index: src/gdb/ppc-tdep.h
===================================================================
--- src.orig/gdb/ppc-tdep.h 2007-10-04 11:26:31.000000000 -0400
+++ src/gdb/ppc-tdep.h 2007-10-04 11:26:32.000000000 -0400
@@ -227,4 +227,6 @@ enum {
/* Estimate for the maximum number of instrctions in a function epilogue. */
#define PPC_MAX_EPILOGUE_INSTRUCTIONS 52
+extern struct target_desc *tdesc_powerpc_e500;
+
#endif /* ppc-tdep.h */