This is the mail archive of the gdb-patches@sources.redhat.com 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]

[RFA] ARM : prologue scan


Here is a patch to improve the interpretation of the prologue for the
ARM targets.  Consider this C code :

void r() {
  void s () {
  }

  void q () {
    s();
  }

  q();
}

with GCC 3.2.3 configured for xscale-elf, this assembler is generated:

[...]

q.1:
        @ Nested: function declared inside another function.
        @ args = 0, pretend = 0, frame = 4
        @ frame_needed = 1, uses_anonymous_args = 0
        str     ip, [sp, #-4]!
        add     ip, sp, #4
        stmfd   sp!, {fp, ip, lr, pc}
        sub     fp, ip, #8
        ldr     ip, [fp, #4]
        @ ip needed for prologue
        sub     sp, sp, #4
        str     ip, [fp, #-16]
        mov     r3, ip
        mov     ip, r3
        bl      s.0
        ldmea   fp, {fp, sp, pc}
.Lfe2:

[...]

The prologue is compliant with the ARM Thumb procedure call standard, but
GDB is not able to interprete the instruction "add     ip, sp, #4",
and builds a bogus backtrace:

(gdb) l r.c:2
1       void r() {
2         void s () {
3         }
4
5         void q () {
6           s();
7         }
8
9         q();
10      }
(gdb) b 2
Breakpoint 1 at 0x0: file r.c, line 2.
(gdb) r r
Starting program: /cardiff.a/guitton/fsf/gdb/tmp/r.o r

Breakpoint 1, s.0 () at r.c:2
2         void s () {
(gdb) bt
#0  s.0 () at r.c:2
#1  q.1 () at r.c:6
#2  0xa2eebb940 in system__exception_table__exception_htable__iterator_indexXn
(gdb)

This patch adds the interpretation of the missing "add" (resp. "sub")
instruction. I have run the testsuite with the simulator, and I
found no regression; but there was a lot of test that failed, so I have
some suspicion on my setup. Can someone give me the average success/failure
on this target, or (even better :-) test it on his own setup?
Is the arm simulator (HEAD) reliable?

-- 
Jerome

Attachment: arm_bt.dif
Description: Text document


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