tdep/2029: rs6000/powerpc stack backtrace bugs (skip_prologue)

strauman@slac.stanford.edu strauman@slac.stanford.edu
Tue Nov 8 02:08:00 GMT 2005


>Number:         2029
>Category:       tdep
>Synopsis:       rs6000/powerpc stack backtrace bugs (skip_prologue)
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          patch
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 08 02:08:02 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Till Straumann
>Release:        6.3
>Organization:
>Environment:
powerpc-linux; powerpc-rtems
>Description:
There are problems with gdb's stack backtrace sometimes not working properly (powerpc target). The backtrace gets into what seems an endless loop that is terminated with the message:
"Previous frame inner to this frame (corrupt stack?)"

a) in some cases, code compiled with '-fpic/PIC' causes problems
b) in some cases, code generated with more recent gcc does.
>How-To-Repeat:
a) for '-fpic' see http://sourceware.org/ml/gdb/2004-11/msg00060.html

for b) use gdb on itself (compiled with gcc 3.3.5 (Debian 1:3.3.5-13)), set breakpoint in skip_prologue
and try a backtrace ;-)

gdb gdb
GNU gdb 6.3
...
(gdb) set prompt (gdb-mom)
(gdb-mom)break skip_prologue
Breakpoint 1 at 0x1006668c: file ../../gdb/rs6000-tdep.c, line 848.
(gdb-mom)run
GNU gdb 6.3
....
(gdb) file gdb
(gdb) break main

Breakpoint 1, skip_prologue (pc=275643600, lim_pc=275655304, fdata=0x10430000) at ../../gdb/rs6000-tdep.c:848

848       const struct bfd_arch_info *arch_info = gdbarch_bfd_arch_info (current_gdbarch);
(gdb-mom) bt
#0  skip_prologue (pc=275643600, lim_pc=275655304, fdata=0x10430000) at ../../gdb/rs6000-tdep.c:848
#1  0x1006607c in rs6000_skip_prologue (pc=268756968) at ../../gdb/rs6000-tdep.c:499
#2  0x1010bcf8 in gdbarch_skip_prologue (gdbarch=0x0, ip=0) at ../../gdb/gdbarch.c:2902
#3  0x1010bcf8 in gdbarch_skip_prologue (gdbarch=0x0, ip=0) at ../../gdb/gdbarch.c:2902
#4  0x1010bcf8 in gdbarch_skip_prologue (gdbarch=0x0, ip=0) at ../../gdb/gdbarch.c:2902
#5  0x1010bcf8 in gdbarch_skip_prologue (gdbarch=0x0, ip=0) at ../../gdb/gdbarch.c:2902
#6  0x1010bcf8 in gdbarch_skip_prologue (gdbarch=0x0, ip=0) at ../../gdb/gdbarch.c:2902
#7  0x1010bcf8 in gdbarch_skip_prologue (gdbarch=0x0, ip=0) at ../../gdb/gdbarch.c:2902
...
Previous frame inner to this frame (corrupt stack?)
(gdb-mom)
>Fix:
a) -fpic uses a 'bcl' instruction to read the contents of LR which is not recognized by 'skip_prologue'.
b) the code forcing 'skip_prologue' to scan beyond unrecognized instructions is wrong causing the scan to be aborted prematurely (recent gcc moves other instructions into the prologue more aggressively).

Proposed fixes can be found (along with some more detailed explanations) in the attached 'diff-file'.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-patch; name="rs6000.diff"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="rs6000.diff"

UGF0Y2ggYWdhaW5zdCBnZGIgNi4zIHRvIGZpeCBzdGFjayBiYWNrdHJhY2luZyBwcm9ibGVtcyBv
biByczYwMDAvcG93ZXJwYwoKQXV0aG9yOiBUaWxsIFN0cmF1bWFubiA8c3RyYXVtYW5Ac2xhYy5z
dGFuZm9yZC5lZHU+LCAyMDA1LzExCgpUaGlzIHBhdGNoIGFkZHJlc3NlcyB0aGUgZm9sbG93aW5n
IGlzc3VlczoKICBhKSBnY2MgLWZwaWMgZ2VuZXJhdGVzIGEgJ2JjbCB4eCcgaW5zdHJ1Y3Rpb24g
dG8gcmVhZCB0aGUgTFIgY29udGVudHMuCiAgICAgVGhlIHBhdGNoIGFkZHMgYSBjaGVjayAoc2tp
cF9wcm9sb2d1ZSkgYW5kIHNraXBzIHRoaXMgaW5zdHJ1Y3Rpb24KCSAoYXMgd2VsbCBhcyBiYyB4
eHgpIGlmIHRoZSBicmFuY2ggb2Zmc2V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2ggaWYgd2UgaGF2ZSBubyB2YWxpZCBmcmFt
ZSB5ZXQgb3IgaWYgdGhlIHJldHVybgogIAkgICAgIGFkZHJlc3MgaXMgbm90IHlldCBzYXZlZCBp
biB0aGUgZnJhbWUuICAqLwogIAkgIGlmIChmZGF0YS0+ZnJhbWVsZXNzID09IDAKISAJICAgICAg
JiYgKGxyX3JlZyA9PSAtMSB8fCBmZGF0YS0+bm9zYXZlZHBjID09IDApKQogIAkgICAgYnJlYWs7
CiAgCiAgCSAgaWYgKG9wID09IDB4NGU4MDAwMjAJCS8qIGJsciAqLwotLS0gMTMyMiwxMzI4IC0t
LS0KICAJICAgICB0aGUgc2VhcmNoIGlmIHdlIGhhdmUgbm8gdmFsaWQgZnJhbWUgeWV0IG9yIGlm
IHRoZSByZXR1cm4KICAJICAgICBhZGRyZXNzIGlzIG5vdCB5ZXQgc2F2ZWQgaW4gdGhlIGZyYW1l
LiAgKi8KICAJICBpZiAoZmRhdGEtPmZyYW1lbGVzcyA9PSAwCiEgCSAgICAgICYmIChmZGF0YS0+
bm9zYXZlZHBjID09IDApKQogIAkgICAgYnJlYWs7CiAgCiAgCSAgaWYgKG9wID09IDB4NGU4MDAw
MjAJCS8qIGJsciAqLwo=



More information about the Gdb-prs mailing list