This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] Fix MIPS frame prologue scan problem


  I am trying to extend the Free Pascal compiler to support
MIPS architecture.

  From what I read so far, register $s8 (register number 30) can be used as
a frame register,
but when I set $s8 to the value of the stack pointer ($sp, register number
29)
I get all my locals and parameter of functions wrong.

  I traced it down to the fact that GDB seems to use a
'virtual' frame pointer register called $fp,
but which is miscalculated in my case.

  In GCC generated code, $s8 register gets the same value as
$sp register, so that this problem does not show up in that case,
but for me, if I have a prologue that reserves 80 bytes, 
I will typically get 

  # Reserve 80 bytes for locals and area for called function parameters
  addi $sp,$sp,-80
  # Save $ra and $s8 registers, there could be others...
  sw    $ra,44($sp)
  sw   $s8,40($sp)
  # Set $s8 to function entry value of $sp
  addi $s8,$sp,80 

  Analysis of first instruction leads to setting of
frame_offset to 80.

  The problem is that when the last instruction
is analyzed by mips32_scan_prologue,
it switches the frame_reg from $sp to $s8,
but does not modify frame_offset value.
  This leads to a frame pointer $fp
being computed as $s8 + frame_offset
which is equal to $sp + 2*frame_offset.
  Thus all my locals are wrong :(

  Substraction of the constant in the last addi instruction (low_word)
to frame_offset seems to cure my problem.

 
 I tried to run a testsuite comparison and
I got a bunch of regression, but I have no idea if those
regression are relevant or a problem of stability of results...
See below if you understand those failures.


Comments are most welcome,


Pierre Muller


2012-06-11  Pierre Muller  <muller@ics.u-strasbg.fr>

        * mips-tdep.c (mpis32_scan_prologue): Fix value of frame_offset
        for ADDIU $s8,$sp,FrameSize.


Index: src/gdb/mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.556
diff -u -p -r1.556 mips-tdep.c
--- src/gdb/mips-tdep.c 6 Jun 2012 21:34:12 -0000       1.556
+++ src/gdb/mips-tdep.c 10 Jun 2012 23:43:44 -0000
@@ -3226,6 +3226,7 @@ restart:
                (this_frame, gdbarch_num_regs (gdbarch) + 30);

              alloca_adjust = (unsigned) (frame_addr - (sp + low_word));
+             frame_offset -= low_word;
              if (alloca_adjust > 0)
                {
                   /* FP > SP + frame_size.  This may be because of

Regressions with my patch:

muller@gcc42:~/auto-test-gdb/state/patched/2012_06_13_10_34_41$ cat report
Calling update for "HEAD"
cleanup called
Calling git clean -d -x -f
Calling git reset --hard
cleanup called
Calling git clean -d -x -f
Calling git reset --hard
apply_patch called
cleanup called
Calling git clean -d -x -f
Calling git reset --hard
(cat /home/muller/auto-test-gdb/state/testing/patched/report
with your patch there are 23 regressions.
list of regressions with your patch:
gdb.sum gdb.base/checkpoint.exp: break2 10 one
gdb.sum gdb.base/checkpoint.exp: break2 2 one
gdb.sum gdb.base/checkpoint.exp: break2 3 one
gdb.sum gdb.base/checkpoint.exp: break2 4 one
gdb.sum gdb.base/checkpoint.exp: break2 5 one
gdb.sum gdb.base/checkpoint.exp: break2 6 one
gdb.sum gdb.base/checkpoint.exp: break2 7 one
gdb.sum gdb.base/checkpoint.exp: break2 8 one
gdb.sum gdb.base/checkpoint.exp: break2 9 one
gdb.sum gdb.base/checkpoint.exp: break4 one
gdb.sum gdb.base/checkpoint.exp: delete copy1
gdb.sum gdb.base/checkpoint.exp: outfile still open 1
gdb.sum gdb.base/checkpoint.exp: outfile still open 10
gdb.sum gdb.base/checkpoint.exp: outfile still open 2
gdb.sum gdb.base/checkpoint.exp: outfile still open 3
gdb.sum gdb.base/checkpoint.exp: outfile still open 4
gdb.sum gdb.base/checkpoint.exp: outfile still open 5
gdb.sum gdb.base/checkpoint.exp: outfile still open 6
gdb.sum gdb.base/checkpoint.exp: outfile still open 7
gdb.sum gdb.base/checkpoint.exp: outfile still open 8
gdb.sum gdb.base/checkpoint.exp: outfile still open 9
gdb.sum gdb.base/checkpoint.exp: restart 0 one
gdb.sum gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint
after
 the second fork
tac)
(cat /home/muller/auto-test-gdb/state/testing/patched/gdb.sum.diff
1c1
< Test Run By muller on Wed Jun 13 12:04:38 2012
---
> Test Run By muller on Wed Jun 13 10:52:26 2012
2759,2760c2759,2760
< FAIL: gdb.base/checkpoint.exp: breakpoint 1 6 one (timeout)
< FAIL: gdb.base/checkpoint.exp: step in 6 two
---
> PASS: gdb.base/checkpoint.exp: breakpoint 1 6 one
> FAIL: gdb.base/checkpoint.exp: step in 6 two (timeout)
2767,2772c2767,2775
< PASS: gdb.base/checkpoint.exp: restart 0 one
< PASS: gdb.base/checkpoint.exp: break4 one
< PASS: gdb.base/checkpoint.exp: delete copy1
< PASS: gdb.base/checkpoint.exp: restart 1 three
< PASS: gdb.base/checkpoint.exp: break2 1 one
< PASS: gdb.base/checkpoint.exp: outfile still open 1
---
> FAIL: gdb.base/checkpoint.exp: restart 0 one
> FAIL: gdb.base/checkpoint.exp: setting breakpoint at 58
> FAIL: gdb.base/checkpoint.exp: break4 one
> FAIL: gdb.base/checkpoint.exp: delete copy1
> ERROR: breakpoints not deleted
> UNRESOLVED: gdb.base/checkpoint.exp: setting breakpoint at 53 (timeout)
> FAIL: gdb.base/checkpoint.exp: restart 1 three (got interactive prompt)
> FAIL: gdb.base/checkpoint.exp: break2 1 one (the program exited)
> FAIL: gdb.base/checkpoint.exp: outfile still open 1
2774,2775c2777,2778
< PASS: gdb.base/checkpoint.exp: break2 2 one
< PASS: gdb.base/checkpoint.exp: outfile still open 2
---
> FAIL: gdb.base/checkpoint.exp: break2 2 one
> FAIL: gdb.base/checkpoint.exp: outfile still open 2
2777,2778c2780,2781
< PASS: gdb.base/checkpoint.exp: break2 3 one
< PASS: gdb.base/checkpoint.exp: outfile still open 3
---
> FAIL: gdb.base/checkpoint.exp: break2 3 one
> FAIL: gdb.base/checkpoint.exp: outfile still open 3
2780,2781c2783,2784
< PASS: gdb.base/checkpoint.exp: break2 4 one
< PASS: gdb.base/checkpoint.exp: outfile still open 4
---
> FAIL: gdb.base/checkpoint.exp: break2 4 one
> FAIL: gdb.base/checkpoint.exp: outfile still open 4
2783,2784c2786,2787
< PASS: gdb.base/checkpoint.exp: break2 5 one
< PASS: gdb.base/checkpoint.exp: outfile still open 5
---
> FAIL: gdb.base/checkpoint.exp: break2 5 one
> FAIL: gdb.base/checkpoint.exp: outfile still open 5
2786,2787c2789,2790
< PASS: gdb.base/checkpoint.exp: break2 6 one
< PASS: gdb.base/checkpoint.exp: outfile still open 6
---
> FAIL: gdb.base/checkpoint.exp: break2 6 one
> FAIL: gdb.base/checkpoint.exp: outfile still open 6
2789,2790c2792,2793
< PASS: gdb.base/checkpoint.exp: break2 7 one
< PASS: gdb.base/checkpoint.exp: outfile still open 7
---
> FAIL: gdb.base/checkpoint.exp: break2 7 one
> FAIL: gdb.base/checkpoint.exp: outfile still open 7
2792,2793c2795,2796
< PASS: gdb.base/checkpoint.exp: break2 8 one
< PASS: gdb.base/checkpoint.exp: outfile still open 8
---
> FAIL: gdb.base/checkpoint.exp: break2 8 one
> FAIL: gdb.base/checkpoint.exp: outfile still open 8
2795,2796c2798,2799
< PASS: gdb.base/checkpoint.exp: break2 9 one
< PASS: gdb.base/checkpoint.exp: outfile still open 9
---
> FAIL: gdb.base/checkpoint.exp: break2 9 one
> FAIL: gdb.base/checkpoint.exp: outfile still open 9
2798,2799c2801,2802
< PASS: gdb.base/checkpoint.exp: break2 10 one
< PASS: gdb.base/checkpoint.exp: outfile still open 10
---
> FAIL: gdb.base/checkpoint.exp: break2 10 one
> FAIL: gdb.base/checkpoint.exp: outfile still open 10
5022,5023c5025,5026
< gdb compile failed, /tmp/ccv7IQuN.s: Assembler messages:
< /tmp/ccv7IQuN.s:7: Error: unrecognized symbol type "gnu_indirect_function"
---
> gdb compile failed, /tmp/cc3V0Vhb.s: Assembler messages:
> /tmp/cc3V0Vhb.s:7: Error: unrecognized symbol type "gnu_indirect_function"
8861,8867c8864,8870
< FAIL: gdb.base/sigaltstack.exp: finish from catch LEAF (the program
exited)
< FAIL: gdb.base/sigaltstack.exp: finish to throw INNER (the program is no
longe
r running)
< FAIL: gdb.base/sigaltstack.exp: finish to catch INNER (the program is no
longe
r running)
< FAIL: gdb.base/sigaltstack.exp: finish from catch INNER (the program is no
lon
ger running)
< FAIL: gdb.base/sigaltstack.exp: finish to OUTER (the program is no longer
runn
ing)
< FAIL: gdb.base/sigaltstack.exp: finish to catch MAIN (the program is no
longer
 running)
< FAIL: gdb.base/sigaltstack.exp: finish to MAIN (the program is no longer
runni
ng)
---
> PASS: gdb.base/sigaltstack.exp: finish from catch LEAF
> PASS: gdb.base/sigaltstack.exp: finish to throw INNER
> PASS: gdb.base/sigaltstack.exp: finish to catch INNER
> PASS: gdb.base/sigaltstack.exp: finish from catch INNER
> PASS: gdb.base/sigaltstack.exp: finish to OUTER
> PASS: gdb.base/sigaltstack.exp: finish to catch MAIN
> PASS: gdb.base/sigaltstack.exp: finish to MAIN
15571c15574
< FAIL: gdb.java/jprint.exp: unambiguous static call
---
> FAIL: gdb.java/jprint.exp: unambiguous static call (the program exited)
19245,19249c19248,19252
< FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: hardware
breakpo
ints work (timeout)
< FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoints
work

< FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint
after
 the first fork
< FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoint
after
 the first fork (timeout)
< PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint
after
 the second fork
---
> PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: hardware
breakpo
ints work
> PASS: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoints
work

> FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint
after
 the first fork (timeout)
> FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: watchpoint
after
 the first fork
> FAIL: gdb.threads/watchpoint-fork.exp: child: singlethreaded: breakpoint
after
 the second fork
19265c19268
< FAIL: gdb.threads/watchpoint-fork.exp: child: multithreaded: watchpoint A
afte
r the second fork (timeout)
---
> FAIL: gdb.threads/watchpoint-fork.exp: child: multithreaded: watchpoint A
afte
r the second fork
19267c19270
< FAIL: gdb.threads/watchpoint-fork.exp: child: multithreaded: finish
---
> FAIL: gdb.threads/watchpoint-fork.exp: child: multithreaded: finish
(timeout)
19564,19565c19567,19568
< # of expected passes          17184
< # of unexpected failures      1033
---
> # of expected passes          17169
> # of unexpected failures      1049
19570c19573
< # of unresolved testcases     32
---
> # of unresolved testcases     33
tac)
FAILs with patched version in failed
FAILs with pristine version in pristine-failed
The files used for the validation of your patch are stored in
/home/muller/auto-
test-gdb/state/patched/2012_06_13_10_34_41 on the tester machine.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]