Bug 29439 - mips simulator (jmr3904) unable to run executables
Summary: mips simulator (jmr3904) unable to run executables
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: sim (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Mike Frysinger
URL: https://sourceware.org/pipermail/gdb-...
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-02 21:03 UTC by Joel Sherrill
Modified: 2023-10-15 15:42 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2022-10-23 00:00:00


Attachments
RTEMS hello.exe to reproduce the issue (47.00 KB, application/x-xz)
2022-08-02 21:03 UTC, Joel Sherrill
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joel Sherrill 2022-08-02 21:03:27 UTC
Created attachment 14251 [details]
RTEMS hello.exe to reproduce the issue

This is from RTEMS and the executable in question is hello.exe (attached). This same executable works with gdb 10.2 but fails with 11.2 and later. There is an objdump, git bisect, and attached executable to reproduce this. 

When investigating remember the --board=jmr3904 argument to "tar sim" or the run command. 

We are tracking it as:

https://devel.rtems.org/ticket/4689

This looks like a GDB or other tool issue. Maybe a sign extension bug:

$ objdump -h build/mips/jmr3904/testsuites/samples/ticker.exe

build/mips/jmr3904/testsuites/samples/ticker.exe:     file format elf32-tradbigmips

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         000115a0  88000000  88000000  00001000  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .rtemsroset   00000070  880115a0  880115a0  000125a0  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .init         00000048  88011610  88011610  00012610  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  3 .fini         00000030  88011658  88011658  00012658  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  4 .ctors        00000008  88011688  88011688  00012688  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  5 .dtors        00000008  88011690  88011690  00012690  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  6 .rdata        00002030  880116a0  880116a0  000126a0  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  7 .MIPS.abiflags 00000018  880136d0  880136d0  000146d0  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA, LINK_ONCE_SAME_SIZE
  8 .data         000005c0  880136e8  880136e8  000146e8  2**3
                  CONTENTS, ALLOC, LOAD, DATA
  9 .bss          00001410  88013cb0  88013cb0  00014ca8  2**4
                  ALLOC
 10 .noinit       00001310  880150c0  880150c0  00014ca8  2**3
                  ALLOC
 11 .rtemsstack   00004000  880163d0  880163d0  00014ca8  2**4
                  ALLOC
 12 .debug_aranges 00002958  00000000  00000000  00014ca8  2**3
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 13 .debug_info   00109cb1  00000000  00000000  00017600  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 14 .debug_abbrev 00023397  00000000  00000000  001212b1  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 15 .debug_line   0003dc56  00000000  00000000  00144648  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 16 .debug_frame  000048f4  00000000  00000000  001822a0  2**2
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 17 .debug_str    0001160c  00000000  00000000  00186b94  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 18 .gnu.attributes 00000010  00000000  00000000  001981a0  2**0
                  CONTENTS, READONLY
 19 .comment      00000063  00000000  00000000  001981b0  2**0
                  CONTENTS, READONLY
 20 .debug_line_str 000001be  00000000  00000000  00198213  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 21 .debug_loclists 00022d89  00000000  00000000  001983d1  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 22 .debug_rnglists 0000605d  00000000  00000000  001bb15a  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
~/src/rtems (master) > /opt/rtems/6/bin/mipstx39-rtems6-gdb build/mips/jmr3904/testsuites/samples/ticker.exe 
GNU gdb (GDB) 11.2
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=mipstx39-rtems6".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from build/mips/jmr3904/testsuites/samples/ticker.exe...
(gdb) tar sim
Connected to the simulator.
(gdb) load
Loading section .text, size 0x115a0 lma ffffffff88000000
Loading section .rtemsroset, size 0x70 lma ffffffff880115a0
Loading section .init, size 0x48 lma ffffffff88011610
Loading section .fini, size 0x30 lma ffffffff88011658
Loading section .ctors, size 0x8 lma ffffffff88011688
Loading section .dtors, size 0x8 lma ffffffff88011690
Loading section .rdata, size 0x2030 lma ffffffff880116a0
Loading section .MIPS.abiflags, size 0x18 lma ffffffff880136d0
Loading section .data, size 0x5c0 lma ffffffff880136e8
Start address ffffffff88000004
Transfer rate: 648448 bits in <1 sec.
(gdb) r
Starting program: /tmp/sh/b-rtems/mips/jmr3904/testsuites/samples/ticker.exe 
mips-core: 4 byte read to unmapped address 0xffffffff88000004 at 0xffffffff88000004

Program received signal SIGBUS, Bus error.
_start () at /home/EB/sebastian_h/src/rtems/bsps/mips/jmr3904/start/start.S:57
57              bal     $LF1

=================================================================
  
I did a git bisect after narrowing down which release branches it worked on. That let me track it down to a commit based on git bisect. Here is that information:

$ git bisect log
git bisect start
# good: [ce35d7163e779b1321058b22f005c70ce1524b25] Set GDB version number to 10.2.
git bisect good ce35d7163e779b1321058b22f005c70ce1524b25
# bad: [ef6ec3333e80e39ce207c6c5d5628bdd5402111d] Set GDB version number to 11.2.
git bisect bad ef6ec3333e80e39ce207c6c5d5628bdd5402111d
# good: [8087c3fa8b5d695e3e29e69d70d0b35ec902ac59] Fix GDB build in infrun.c when configured with unit tests disabled
git bisect good 8087c3fa8b5d695e3e29e69d70d0b35ec902ac59
# skip: [d3dacd0fafba473fd42fdf3ca86fd3203db28ae8] Automatic date update in version.in
git bisect skip d3dacd0fafba473fd42fdf3ca86fd3203db28ae8
# skip: [40d07d07d051308626f6079fa6d1598fafb445c7] Change exp_uses_objfile to return bool
git bisect skip 40d07d07d051308626f6079fa6d1598fafb445c7
# good: [a4eba6087d4cec81f8b41477b4da56ff87b88e91] Fix a bug in the s390x linker when discarding all inpuit files.
git bisect good a4eba6087d4cec81f8b41477b4da56ff87b88e91
# good: [546b77fe78bb366bbec3c708ac371e2f553bbdae] GDBserver remote packet support for memory tagging
git bisect good 546b77fe78bb366bbec3c708ac371e2f553bbdae
# good: [2e8adb6448c78fdb748c13c7859b68f3e7984c4d] Update config.sub and config.guess for MIPS R3 and R5 ISA support
git bisect good 2e8adb6448c78fdb748c13c7859b68f3e7984c4d
# bad: [50a6759f0f541ea965c7330bfbfe335cb8d66af8] Use gdb::function_view in addrmap_foreach
git bisect bad 50a6759f0f541ea965c7330bfbfe335cb8d66af8
# good: [c572c4580e774f1ec0115948d31dcf8a5b04878e] Automatic date update in version.in
git bisect good c572c4580e774f1ec0115948d31dcf8a5b04878e
# good: [209f108f73888741bf31d03d35722b6e0b521ec8] sim: mn10300: tweak static inlines
git bisect good 209f108f73888741bf31d03d35722b6e0b521ec8
# bad: [57a922a59801a9e7684f9661a65fa2ed5833d65d] sim: move UNUSED before TYPE in SIM_ENDIAN_INLINE's definition
git bisect bad 57a922a59801a9e7684f9661a65fa2ed5833d65d
# good: [162c6aef1f3a96923e75f0b4ef430822d273465c] gas: fold symbol table entries generated for .startof.() / .sizeof.()
git bisect good 162c6aef1f3a96923e75f0b4ef430822d273465c
# good: [07490bf81d2fc91676eb71b77e07f80f20fc1b54] sim: unify various library testing logic
git bisect good 07490bf81d2fc91676eb71b77e07f80f20fc1b54
# bad: [ce3ec98acd2f344ae911de3f41dd2e3c6c68b141] sim: unify gettext/intl probing logic
git bisect bad ce3ec98acd2f344ae911de3f41dd2e3c6c68b141
# good: [c30420d82a0b743285cf8333f90ca85274632714] elf: Update GNU_PROPERTY_UINT32_[AND|OR]_XXX tests
git bisect good c30420d82a0b743285cf8333f90ca85274632714
# bad: [bc56166f66244a9e3abc62c7bc595a6f800f23b0] sim: unify toolchain dependency logic
git bisect bad bc56166f66244a9e3abc62c7bc595a6f800f23b0

=================================================================
Comment 1 Joel Sherrill 2022-08-02 21:20:06 UTC
If I did the git right, this is the commit it identified as the breaking one:

commit d3562f83a7b8a1ae6e333cd5561419d3da18fcb4 (HEAD)
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Fri Jun 18 10:45:03 2021 -0400

    sim: unify toolchain probing logic
    
    Move these options up to the common dir so we only test & export
Comment 2 Mike Frysinger 2022-10-23 16:44:54 UTC
please describe exactly how you're running configure
Comment 3 Joel Sherrill 2022-10-23 17:23:07 UTC
This is from the log of the last tool build I did using the RTEMS Source Builder:

script:163: LIBS_STATIC=${GDB_LIBS_STATIC}  LIBS=${GDB_LIBS}  ../${source_dir_gdb}/configure  --build=x86_64-linux-gnu --host=x86_64-linux-gnu  --target=mipstx39-rtems6  --verbose --disable-nls  --disable-gas --disable-binutils --disable-ld --disable-gold --disable-gprof    --without-included-gettext  --disable-win32-registry  --disable-werror  --enable-sim  --enable-sim-hardware  --without-zlib  --with-expat  --with-guile=no    --with-python=/usr/bin/python3  --prefix=/home/joel/rtems-work/tools/6 --bindir=/home/joel/rtems-work/tools/6/bin  --exec-prefix=/home/joel/rtems-work/tools/6  --includedir=/home/joel/rtems-work/tools/6/include --libdir=/home/joel/rtems-work/tools/6/lib  --mandir=/home/joel/rtems-work/tools/6/share/man --infodir=/home/joel/rtems-work/tools/6/share/info
Comment 4 Mike Frysinger 2022-10-23 18:27:10 UTC
should be fixed by:
https://sourceware.org/pipermail/gdb-patches/2022-October/193052.html
Comment 5 Mike Frysinger 2022-10-23 20:32:39 UTC
pushed
Comment 6 Joel Sherrill 2022-10-24 13:48:56 UTC
I can confirm that I managed to run an RTEMS test again after this was pushed.

Thanks. This is the mips platform we use in automated testing so it is appreciated.
Comment 7 Jan-Benedict Glaw 2023-03-03 21:26:58 UTC
This fix seems to have a side effect:

.../configure --prefix=/tmp/gdb-mipsisa64sb1-elf --target=mipsisa64sb1-elf

make V=1 all-gdb
[...]
[all 2023-03-03 21:07:56] /usr/lib/gcc-snapshot/bin/gcc  -DHAVE_CONFIG_H -DWITH_TARGET_WORD_BITSIZE=64 -DWITH_TARGET_WORD_MSB=63 -DWITH_FLOATING_POINT=HARD_FLOATING_POINT -DWITH_TARGET_FLOATING_POINT_BITSIZE=64 -DWITH_HW=1 -DHAVE_DV_SOCKSER -DDEFAULT_INLINE=0 -Wall -Wdeclaration-after-statement -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wno-error=maybe-uninitialized -Wmissing-declarations -Wmissing-prototypes -Wdeclaration-after-statement -Wmissing-parameter-type -Wpointer-sign -Wold-style-declaration -Werror  -I. -I/var/lib/laminar/run/gdb-mipsisa64sb1-elf/51/binutils-gdb/sim/mips -I../common -I/var/lib/laminar/run/gdb-mipsisa64sb1-elf/51/binutils-gdb/sim/mips/../common -I../../include -I/var/lib/laminar/run/gdb-mipsisa64sb1-elf/51/binutils-gdb/sim/mips/../../include -I../../bfd -I/var/lib/laminar/run/gdb-mipsisa64sb1-elf/51/binutils-gdb/sim/mips/../../bfd -I../../opcodes -I/var/lib/laminar/run/gdb-mipsisa64sb1-elf/51/binutils-gdb/sim/mips/../../opcodes -I../..  -I/var/lib/laminar/run/gdb-mipsisa64sb1-elf/51/binutils-gdb/sim/mips/../../gnulib/import -I../../gnulib/import -DTARGET_ENABLE_FR=1 -DMIPS_MACH_DEFAULT=bfd_mach_mips_sb1 -g -O2   -c -o semantics.o -MT semantics.o -MMD -MP -MF .deps/semantics.Tpo semantics.c
[all 2023-03-03 21:07:56] sb1.igen: In function 'semantic_PABSDIFC_fmt_MDMX':
[all 2023-03-03 21:07:56] sb1.igen:178:21: error: unknown conversion type character 'v' in format [-Werror=format=]
[all 2023-03-03 21:07:56]   178 |   check_mdmx (SD_, instruction_0);
[all 2023-03-03 21:07:56]       |                     ^~~~~~~~~~~~~~        
[all 2023-03-03 21:07:56] sb1.igen:178:21: error: format '%ld' expects argument of type 'long int', but argument 9 has type 'unsigned int' [-Werror=format=]
[all 2023-03-03 21:07:56]   178 |   check_mdmx (SD_, instruction_0);
[all 2023-03-03 21:07:56]       |                     ^~~~~~~~~~~~~~        
[all 2023-03-03 21:07:56] sb1.igen:178:21: error: too many arguments for format [-Werror=format-extra-args]
[all 2023-03-03 21:08:05] cc1: all warnings being treated as errors

Sorry for taking so long to report it.
Comment 8 Mike Frysinger 2023-10-15 10:30:21 UTC
i doubt that is related.  please file a new bug.
Comment 9 Jan-Benedict Glaw 2023-10-15 15:42:21 UTC
Thanks for the committed fix (30ebc4310b0ec608bc7e34e153340935147c45d5), this seems to work properly: http://toolchain.lug-owl.de/laminar/jobs/gdb-mipsisa64sb1-elf/69