public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug tdep/31087] New: [gdb/tdep, arm] FAIL: gdb.base/func-ptrs.exp: continue to decr
@ 2023-11-24 23:22 vries at gcc dot gnu.org
0 siblings, 0 replies; only message in thread
From: vries at gcc dot gnu.org @ 2023-11-24 23:22 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=31087
Bug ID: 31087
Summary: [gdb/tdep, arm] FAIL: gdb.base/func-ptrs.exp: continue
to decr
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: tdep
Assignee: unassigned at sourceware dot org
Reporter: vries at gcc dot gnu.org
Target Milestone: ---
On a pinebook (with gcc defaulting to generating thumb mode insns) I run into:
...
(gdb) PASS: gdb.base/func-ptrs.exp: go back to main from incr, first time
set calc = decr^M
(gdb) PASS: gdb.base/func-ptrs.exp: set calc to decr
continue^M
Continuing.^M
^M
Program received signal SIGBUS, Bus error.^M
decr (i=-1) at /home/rock/gdb/src/gdb/testsuite/gdb.base/func-ptrs.c:33^M
33 {^M
(gdb) FAIL: gdb.base/func-ptrs.exp: continue to decr
...
The calc variable initially is set to point to incr:
...
(gdb) p calc
$2 = (int (*)(int)) 0xaaaaa4f7 <incr>
...
where incr is:
...
000004f6 <incr>:
4f6: b580 push {r7, lr}
4f8: b082 sub sp, #8
4fa: af00 add r7, sp, #0
4fc: 6078 str r0, [r7, #4]
4fe: f7ff fff3 bl 4e8 <sentinel>
502: 687b ldr r3, [r7, #4]
504: 3301 adds r3, #1
506: 4618 mov r0, r3
508: 3708 adds r7, #8
50a: 46bd mov sp, r7
50c: bd80 pop {r7, pc}
...
So the first instruction is at 0x4f6, but the lowest bit set in the function
pointer indicates we're jumping to a thumb function.
This is not taken into account when doing "set calc = decr".
In fact, we have the same problem if we do "set calc = incr":
...
(gdb) p calc
$1 = (int (*)(int)) 0xaaaaa4f7 <incr>
(gdb) set calc = incr
(gdb) p calc
$2 = (int (*)(int)) 0xaaaaa4f6 <incr>
...
So I guess this is right:
...
(gdb) p incr
$3 = {int (int)} 0xaaaaa4f6 <incr>
...
but this is wrong:
...
(gdb) p &incr
$4 = (int (*)(int)) 0xaaaaa4f6 <incr>
...
Note btw that manually patching in the thumb bit works fine, and likewise for
decr:
...
(gdb) set calc = incr + 1
(gdb) continue
...
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-11-24 23:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-24 23:22 [Bug tdep/31087] New: [gdb/tdep, arm] FAIL: gdb.base/func-ptrs.exp: continue to decr vries at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).