This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit+commit 7.3][cell] Fix Cell/B.E. regressions
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 6 May 2011 22:51:48 +0200 (CEST)
- Subject: [commit+commit 7.3][cell] Fix Cell/B.E. regressions
Hello,
a recent change to regcache.c caused a serious regression to the Cell/B.E.
combined debugger: all attempts to backtrace from PowerPC code into SPU
code now run into this assert in regcache_save:
gdb_assert (status != REG_UNKNOWN);
This is because ppc-linux-tdep.c:ppu2spu_sniffer deliberately called
regcache_save with a callback that let all pseudo registers unknown;
in the past, that caused regcache to simply call the back-end to
compute their values via gdbarch_pseudo_register_read.
With the new regcache logic, this is no longer supported. Thus, the
patch below instead sets all pseudos to UNAVAILABLE, and simply calls
gdbarch_pseudo_register_read directly when their value is needed.
While debugging this I noticed a bug in prologue parsing that turned
out to be caused by a wrong instruction op-code. Fixed as well.
Finally, the patch fixes a couple of testsuite failures due to
problems in the testsuite itself that were either introduced or
exposed due to other changes in the meantime.
All in all, the patch gets GDB back to passing all gdb.cell tests
(both native and via gdbserver).
Tested on powerpc-linux (32-/64-bit, native and gdbserver).
Committed to mainline and 7.3 branch.
Bye,
Ulrich
ChangeLog:
* ppc-linux-tdep.c (ppu2spu_prev_register): Handle pseudo registers.
(ppu2spu_unwind_register): Mark pseudo registers unavailable.
* spu-tdep.c (op_selb): Use correct value.
testsuite/ChangeLog:
* gdb.cell/bt.exp: Delete breakpoints before running to signal
to avoid race condition.
* gdb.cell/coremaker.c: Use small stack size.
* gdb.cell/ea-standalone.exp: Use file name without path as
argument to c_to.
* gdb.cell/fork.exp: Allow other output when continuing to end.
Index: gdb/ppc-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v
retrieving revision 1.128
diff -u -p -r1.128 ppc-linux-tdep.c
--- gdb/ppc-linux-tdep.c 18 Mar 2011 18:52:31 -0000 1.128
+++ gdb/ppc-linux-tdep.c 6 May 2011 16:21:59 -0000
@@ -1367,7 +1367,12 @@ ppu2spu_prev_register (struct frame_info
gdb_byte *buf;
buf = alloca (register_size (gdbarch, regnum));
- regcache_cooked_read (cache->regcache, regnum, buf);
+
+ if (regnum < gdbarch_num_regs (gdbarch))
+ regcache_raw_read (cache->regcache, regnum, buf);
+ else
+ gdbarch_pseudo_register_read (gdbarch, cache->regcache, regnum, buf);
+
return frame_unwind_got_bytes (this_frame, regnum, buf);
}
@@ -1392,9 +1397,9 @@ ppu2spu_unwind_register (void *src, int
else if (regnum == SPU_PC_REGNUM)
store_unsigned_integer (buf, 4, byte_order, data->npc);
else
- return 0;
+ return REG_UNAVAILABLE;
- return 1;
+ return REG_VALID;
}
static int
Index: gdb/spu-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/spu-tdep.c,v
retrieving revision 1.72
diff -u -p -r1.72 spu-tdep.c
--- gdb/spu-tdep.c 18 Mar 2011 18:52:32 -0000 1.72
+++ gdb/spu-tdep.c 6 May 2011 16:21:59 -0000
@@ -456,7 +456,7 @@ enum
op_a = 0x0c0,
op_ai = 0x1c,
- op_selb = 0x4,
+ op_selb = 0x8,
op_br = 0x64,
op_bra = 0x60,
Index: gdb/testsuite/gdb.cell/bt.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cell/bt.exp,v
retrieving revision 1.2
diff -u -p -r1.2 bt.exp
--- gdb/testsuite/gdb.cell/bt.exp 1 Jan 2011 15:33:43 -0000 1.2
+++ gdb/testsuite/gdb.cell/bt.exp 6 May 2011 16:22:00 -0000
@@ -72,6 +72,7 @@ if ![runto_main] then {
return 0
}
+delete_breakpoints
gdb_test "continue" ".*Program received signal SIGABRT, Aborted.*"
gdb_test "backtrace" ".*abort.*crash_handler.*base.*offset.*<cross-architecture call>.*main.*speid.*argp.*envp.*at.*$spu2_file.c.*<cross-architecture call>.*spe_context_run.*indirect_handler.*base.*offset.*<cross-architecture call>.*main.*speid.*argp.*envp.*at.*$spu_file.c.*<cross-architecture call>.*spe_context_run.*spe_thread.*at.*$ppu_file.c.*"
Index: gdb/testsuite/gdb.cell/coremaker.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cell/coremaker.c,v
retrieving revision 1.2
diff -u -p -r1.2 coremaker.c
--- gdb/testsuite/gdb.cell/coremaker.c 1 Jan 2011 15:33:43 -0000 1.2
+++ gdb/testsuite/gdb.cell/coremaker.c 6 May 2011 16:22:00 -0000
@@ -43,18 +43,25 @@ int
main (void)
{
int thread_id[nr_t];
+ pthread_attr_t attr;
pthread_t pts[nr_t];
spe_context_ptr_t ctx[nr_t];
unsigned int value;
int cnt;
+ /* Use small thread stacks to speed up writing out core file. */
+ pthread_attr_init (&attr);
+ pthread_attr_setstacksize (&attr, 2*PTHREAD_STACK_MIN);
+
for (cnt = 0; cnt < nr_t; cnt++)
{
ctx[cnt] = spe_context_create (0, NULL);
thread_id[cnt]
- = pthread_create (&pts[cnt], NULL, &spe_thread, &ctx[cnt]);
+ = pthread_create (&pts[cnt], &attr, &spe_thread, &ctx[cnt]);
}
+ pthread_attr_destroy (&attr);
+
for (cnt = 0; cnt < nr_t; cnt++)
spe_out_intr_mbox_read (ctx[cnt], &value, 1, SPE_MBOX_ALL_BLOCKING);
Index: gdb/testsuite/gdb.cell/ea-standalone.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cell/ea-standalone.exp,v
retrieving revision 1.2
diff -u -p -r1.2 ea-standalone.exp
--- gdb/testsuite/gdb.cell/ea-standalone.exp 1 Jan 2011 15:33:43 -0000 1.2
+++ gdb/testsuite/gdb.cell/ea-standalone.exp 6 May 2011 16:22:00 -0000
@@ -44,12 +44,12 @@ if ![runto_main] then {
return 0
}
-c_to "Marker SPUEA1" $srcfile
+c_to "Marker SPUEA1" $testfile.c
gdb_test "p myarray\[0\]" \
".*= 0" \
"p myarray\[0\]"
-c_to "Marker SPUEA2" $srcfile
+c_to "Marker SPUEA2" $testfile.c
gdb_test "p myarray\[0\]" \
".*= 1" \
"p myarray\[0\]"
Index: gdb/testsuite/gdb.cell/fork.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cell/fork.exp,v
retrieving revision 1.3
diff -u -p -r1.3 fork.exp
--- gdb/testsuite/gdb.cell/fork.exp 7 Mar 2011 16:03:02 -0000 1.3
+++ gdb/testsuite/gdb.cell/fork.exp 6 May 2011 16:22:00 -0000
@@ -77,7 +77,7 @@ gdb_test_no_output "delete \$bpnum" "del
gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, func \\(\\) at .*$spu_file.c:.*" \
"run until breakpoint hit"
-gdb_continue_to_end
+gdb_continue_to_end "" continue 1
gdb_exit
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com