Bug 26363 - [i586] gdb/i386-linux-nat.c:530: internal-error: Got request for bad register number 41
Summary: [i586] gdb/i386-linux-nat.c:530: internal-error: Got request for bad register...
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: tdep (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-10 14:22 UTC by Tom de Vries
Modified: 2020-08-12 12:02 UTC (History)
0 users

See Also:
Host: i586-linux-gnu
Target: i586-linux-gnu
Build: i586-linux-gnu
Last reconfirmed:


Attachments
gdb.sum, gdb.log, outputs/gdb.xml/tdesc-reload/ (9.88 KB, application/x-compressed-tar)
2020-08-12 11:41 UTC, Tom de Vries
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2020-08-10 14:22:58 UTC
On openSUSE tumbleweed:
...
(gdb) info all-registers^M
  ...
foseg          0x0                 0^M
fooff          0x0                 0^M
fop            0x0                 0^M
mxcsr          0x1f80              [ IM DM ZM OM UM PM ]^M
../../gdb/i386-linux-nat.c:530: internal-error: Got request for bad register number 41.^M
A problem internal to GDB has been detected,^M
further debugging may prove unreliable.^M
FAIL: gdb.xml/tdesc-reload.exp: Run info registers (GDB internal error)
...

In i386-tdep.h we find:
...
enum i386_regnum
{
   ...
  I386_MXCSR_REGNUM = 40,       /* %mxcsr */
  I386_YMM0H_REGNUM,            /* %ymm0h */
...
Comment 1 Tom de Vries 2020-08-12 11:41:59 UTC
Created attachment 12765 [details]
gdb.sum, gdb.log, outputs/gdb.xml/tdesc-reload/

Reproduced using:
- osc build openSUSE_Factory i586
- osc chroot openSUSE_Factory i586
- make check RUNTESTFLAGS=gdb.xml/tdesc-reload.exp

Got different bad register number though: 53.
Comment 2 Tom de Vries 2020-08-12 11:46:53 UTC
(In reply to Tom de Vries from comment #1)
> Created attachment 12765 [details]
> gdb.sum, gdb.log, outputs/gdb.xml/tdesc-reload/
> 
> Reproduced using:
> - osc build openSUSE_Factory i586
> - osc chroot openSUSE_Factory i586
> - make check RUNTESTFLAGS=gdb.xml/tdesc-reload.exp
> 
> Got different bad register number though: 53.

To reproduce on command line:
...
$ gdb \
  outputs/gdb.xml/tdesc-reload/tdesc-reload \
  -batch \
  -ex start \
  -iex "set tdesc filename outputs/gdb.xml/tdesc-reload/outfile1.xml" \
  -ex "info all-registers"
Temporary breakpoint 1 at 0x1196: file tdesc-reload.c, line 21.

Temporary breakpoint 1, main () at tdesc-reload.c:21
21        return 0;
eax            0x56559000          1448448000
ecx            0x9684472e          -1769715922
edx            0xffffd8f4          -9996
ebx            0x0                 0
esp            0xffffd8b8          0xffffd8b8
ebp            0xffffd8b8          0xffffd8b8
esi            0xf7fc2e44          -134468028
edi            0xf7fc2e44          -134468028
eip            0x56556196          0x56556196 <main+13>
eflags         0x216               [ PF AF IF ]
cs             0x23                35
ss             0x2b                43
ds             0x2b                43
es             0x2b                43
fs             0x0                 0
gs             0x63                99
st0            0                   (raw 0x00000000000000000000)
st1            0                   (raw 0x00000000000000000000)
st2            0                   (raw 0x00000000000000000000)
st3            0                   (raw 0x00000000000000000000)
st4            0                   (raw 0x00000000000000000000)
st5            0                   (raw 0x00000000000000000000)
st6            0                   (raw 0x00000000000000000000)
st7            0                   (raw 0x00000000000000000000)
fctrl          0x37f               895
fstat          0x0                 0
ftag           0xffff              65535
fiseg          0x0                 0
fioff          0x0                 0
foseg          0x0                 0
fooff          0x0                 0
fop            0x0                 0
mxcsr          0x1f80              [ IM DM ZM OM UM PM ]
../../gdb/i386-linux-nat.c:530: internal-error: Got request for bad register number 53.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) [answered Y; input not from terminal]

This is a bug, please report it.  For instructions, see:
<http://bugs.opensuse.org/>.

../../gdb/i386-linux-nat.c:530: internal-error: Got request for bad register number 53.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) [answered Y; input not from terminal]
Aborted (core dumped)
...
Comment 3 Tom de Vries 2020-08-12 11:48:13 UTC
Backtrace at abort:
...
Thread 1 "gdb" received signal SIGABRT, Aborted.
0xf736a889 in raise () from /lib/libc.so.6
(gdb) bt
#0  0xf736a889 in raise () from /lib/libc.so.6
#1  0xf73522c3 in abort () from /lib/libc.so.6
#2  0x56a0cc9c in dump_core () at ../../gdb/utils.c:204
#3  0x56a11b55 in internal_vproblem (
    problem=0x570a1638 <_ZL22internal_error_problem.lto_priv.0>, 
    file=0x56ca56dc "../../gdb/i386-linux-nat.c", line=530, 
    fmt=0x56ca52cc "Got request for bad register number %d.", ap=0xffffd17c "5")
    at ../../gdb/utils.c:414
#4  0x56bab37f in internal_verror (ap=<optimized out>, fmt=<optimized out>, 
    line=<optimized out>, file=<optimized out>) at ../../gdb/utils.c:439
#5  internal_error (file=0x56ca56dc "../../gdb/i386-linux-nat.c", line=530, 
    fmt=0x56ca52cc "Got request for bad register number %d.")
    at ../../gdbsupport/errors.cc:55
#6  0x567bd6eb in i386_linux_nat_target::fetch_registers (
    this=0x570baf80 <_ZL25the_i386_linux_nat_target.lto_priv.0>, regcache=0x5739e320, 
    regno=53) at ../../gdb/i386-linux-nat.c:530
#7  0x569c9600 in target_fetch_registers (regcache=0x5739e320, regno=53)
    at ../../gdb/target.c:3394
#8  0x568e80e9 in regcache::raw_update (regnum=53, this=0x5739e320)
    at ../../gdb/regcache.c:542
#9  regcache::raw_update (this=0x5739e320, regnum=53) at ../../gdb/regcache.c:531
#10 0x568e8316 in readable_regcache::raw_read (this=this@entry=0x5739e320, 
    regnum=regnum@entry=53, buf=0x572c3cc0 "") at ../../gdb/regcache.c:556
#11 0x568e848a in readable_regcache::cooked_read (this=this@entry=0x5739e320, 
    regnum=regnum@entry=53, buf=<optimized out>) at ../../gdb/regcache.c:648
#12 0x568e86ce in readable_regcache::cooked_read_value (this=0x5739e320, regnum=53)
    at ../../gdb/regcache.c:706
#13 0x56958470 in sentinel_frame_prev_register (this_frame=0x572292f8, 
    this_prologue_cache=0x57229304, regnum=53) at ../../gdb/sentinel-frame.c:53
#14 0x5678cc13 in frame_unwind_register_value (next_frame=0x572292f8, regnum=53)
    at ../../gdb/frame.c:1241
#15 0x56a25ee9 in value_fetch_lazy_register (val=0x5745a6f0) at ../../gdb/value.c:3826
#16 value_fetch_lazy (val=0x5745a6f0) at ../../gdb/value.c:3932
#17 0x5678c1c0 in value_of_register (frame=0x57229374, regnum=53) at ../../gdb/findvar.c:274
#18 value_of_register (regnum=53, frame=0x57229374) at ../../gdb/findvar.c:263
#19 0x567db042 in default_print_registers_info (gdbarch=0x57338698, file=0x57330e10, 
    frame=0x57229374, regnum=-1, print_all=1) at ../../gdb/infcmd.c:2199
#20 0x5679e824 in gdbarch_print_registers_info (gdbarch=0x57338698, file=0x57330e10, 
    frame=0x57229374, regnum=-1, all=1) at ../../gdb/gdbarch.c:2422
#21 0x567dd79d in registers_info (addr_exp=0x0, fpregs=1) at ../../gdb/infcmd.c:2218
#22 0x566bab23 in cmd_func (cmd=<optimized out>, args=0x0, from_tty=<optimized out>)
    at ../../gdb/cli/cli-decode.c:2181
#23 0x569d5354 in execute_command (p=<optimized out>, 
    p@entry=<error reading variable: value has been optimized out>, from_tty=0, 
    from_tty@entry=<error reading variable: value has been optimized out>)
    at ../../gdb/top.c:668
#24 0x56838696 in catch_command_errors (command=<optimized out>, arg=<optimized out>, 
    from_tty=<optimized out>) at ../../gdb/main.c:457
#25 0x56c01985 in captured_main_1(captured_main_args*) [clone .constprop.0] (
    context=context@entry=0xffffd7d0) at ../../gdb/main.c:1218
#26 0x565f5e67 in captured_main (data=0xffffd7d0) at ../../gdb/main.c:1239
#27 gdb_main (args=0xffffd7d0) at ../../gdb/main.c:1268
#28 main (argc=9, argv=0xffffd8b4) at ../../gdb/gdb.c:32
...
Comment 4 Tom de Vries 2020-08-12 12:02:44 UTC
So, reading reg 53 fails, because this fails:
...
511           if (fetch_xstateregs (regcache, tid))
...
because:
...
336       if (have_ptrace_getregset != TRIBOOL_TRUE)
(gdb) p have_ptrace_getregset
$3 = TRIBOOL_UNKNOWN
...

It seems have_ptrace_getregset is set in x86_linux_nat_target::read_description , but that one's never called.