[Bug gdb/25647] New: when build a gdb target = riscv32-unkown-elf , next instructions can't normal execution

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/25647] New: when build a gdb target = riscv32-unkown-elf , next instructions can't normal execution

glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25647

            Bug ID: 25647
           Summary: when build a gdb target = riscv32-unkown-elf , next
                    instructions can't normal execution
           Product: gdb
           Version: 8.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: konglingling4 at huawei dot com
  Target Milestone: ---

Created attachment 12361
  --> https://sourceware.org/bugzilla/attachment.cgi?id=12361&action=edit
finish.c

I build a cross-compilation toolchain(include gcc gdb binutils)
The configure is : build =i686-pc-linux-gnu host = i686-pc-linux-gnu
target = riscv32-unknown-elf

use this gcc to build an executable file.this executable file run  under the
simulation environment of qemu-riscv32.

Execute the following command:
file **
target remote * : *
b finish.c:33
b finish.c:99
c
n
n
n

Debugging results are as follows
(gdb) b finish.c:99
Breakpoint 1 at 0x10e20: file ../riscv/finish.c, line 99.
(gdb) b finish.c:33
Breakpoint 2 at 0x10d26: file ../riscv/finish.c, line 34.
(gdb) c
Continuing.

Breakpoint 2, void_func () at ../riscv/finish.c:34
34        void_test = 1;
(gdb) n
35      }
(gdb) n
uniGdbTest (VOID=0) at ../riscv/finish.c:73
73      {
(gdb) n
75          unsigned int uwLocalVal = 0;
(gdb) l
98        void_func ();                              /* call to void_func */
99        uniGdbTest ();                                             /*
void_checkpoint */
100       char_resultval      = char_func ();            /* char_checkpoint */
101       short_resultval     = short_func ();           /* short_checkpoint */
102       int_resultval       = int_func ();             /* int_checkpoint */
103       long_resultval      = long_func ();            /* long_checkpoint */
104       long_long_resultval = long_long_func ();       /*
long_long_checkpoint

n(next)  instruction should  jump to finish.c:100,
but it into the uniGdbTest() ,this is not what I expected.this is step rather
than next.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/25647] when build a gdb target = riscv32-unkown-elf , next instructions can't normal execution

glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25647

Andrew Burgess <andrew.burgess at embecosm dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrew.burgess at embecosm dot com

--- Comment #1 from Andrew Burgess <andrew.burgess at embecosm dot com> ---
The test file finish.c that you attached doesn't include a main function.

Could you add a new test that is stand alone that demonstrates the problem you
are seeing.  Also could you include the GCC flags that you used to compile the
test file.  Finally, please could you include information about which RISC-V
extensions you are using, specifically, C? and F?

Thanks.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/25647] when build a gdb target = riscv32-unkown-elf , next instructions can't normal execution

glaubitz at physik dot fu-berlin.de
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25647

Andrew Burgess <andrew.burgess at embecosm dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at sourceware dot org   |andrew.burgess at embecosm dot com

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/25647] when build a gdb target = riscv32-unkown-elf , next instructions can't normal execution

glaubitz at physik dot fu-berlin.de
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25647

--- Comment #2 from konglingling4 at huawei dot com ---
Created attachment 12374
  --> https://sourceware.org/bugzilla/attachment.cgi?id=12374&action=edit
finish.c (include main)

test.c include a main function

I compile the test file use gcc flags as follows:

riscv-none-embed-gcc.exe -g -O0 -c finish.c -o finish.o

riscv-none-embed-gcc.exe -specs=nosys.specs finish.o  test.o -o main


I'm using GCC toolchain can be downloaded here
https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v8.2.0-3.1/xpack-riscv-none-embed-gcc-8.2.0-3.1-win32-x32.zip

riscv-none-embed-gcc.exe -v
Using built-in specs.
COLLECT_GCC=riscv-none-embed-gcc.exe
COLLECT_LTO_WRAPPER=d:/share-old/xpack-riscv-none-embed-gcc-8.2.0-3.1-win32-x32/xpack/risc-v\
embedded\
gcc/8.2.0-3.1/bin/../libexec/gcc/riscv-none-embed/8.2.0/lto-wrapper.exe
Target: riscv-none-embed
Configured with:
/Host/home/ilg/Work/riscv-none-embed-gcc-8.2.0-3.1/sources/riscv-gcc-8.2.0-3.1/configure
--prefix=/Host/home/ilg/Work/riscv-none-embed-gcc-8.2.0-3.1/win32-x32/install/riscv-none-embed-gcc
--infodir=/Host/home/ilg/Work/riscv-none-embed-gcc-8.2.0-3.1/win32-x32/install/riscv-none-embed-gcc/doc/info
--mandir=/Host/home/ilg/Work/riscv-none-embed-gcc-8.2.0-3.1/win32-x32/install/riscv-none-embed-gcc/doc/man
--htmldir=/Host/home/ilg/Work/riscv-none-embed-gcc-8.2.0-3.1/win32-x32/install/riscv-none-embed-gcc/doc/html
--pdfdir=/Host/home/ilg/Work/riscv-none-embed-gcc-8.2.0-3.1/win32-x32/install/riscv-none-embed-gcc/doc/pdf
--build=i686-pc-linux-gnu --host=i686-w64-mingw32 --target=riscv-none-embed
--with-pkgversion='xPack GNU RISC-V Embedded GCC\x2C 32-bit'
--with-bugurl=https://github.com/sifive/freedom-tools/issues
--enable-languages=c,c++ --enable-mingw-wildcard --enable-plugins --enable-lto
--disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap
--disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls
--disable-threads --disable-tls --enable-checking=yes --with-gnu-as
--with-gnu-ld --with-newlib --with-headers=yes
--with-python-dir=share/gcc-riscv-none-embed
--with-sysroot=/Host/home/ilg/Work/riscv-none-embed-gcc-8.2.0-3.1/win32-x32/install/riscv-none-embed-gcc/riscv-none-embed
--with-abi=ilp32 --with-arch=rv32imac --disable-rpath
--disable-build-format-warnings --with-system-zlib
Thread model: single
gcc version 8.2.0 (xPack GNU RISC-V Embedded GCC, 32-bit)

use this riscv-none-embed-gdb.exe has the same problem with my
riscv32-unkown-elf.gdb

GNU gdb (xPack GNU RISC-V Embedded GCC, 32-bit) 8.3
Copyright (C) 2019 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=i686-w64-mingw32 --target=riscv-none-embed".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://github.com/sifive/freedom-tools/issues>.
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".
0x000100aa in _start ()
Breakpoint 1 at 0x1017e: file finish.c, line 34.
Breakpoint 2 at 0x10278: file finish.c, line 99.
(gdb) c
Continuing.

Breakpoint 1, void_func () at finish.c:34
34        void_test = 1;
(gdb) n
35      }
(gdb) n
uniGdbTest (VOID=0) at finish.c:73
73      {
(gdb) n
75          unsigned int uwLocalVal = 0;
(gdb) n
77          uwStaticVal ++;
(gdb) n
78          uwLocalVal ++;
(gdb) n
79          return;
(gdb) n
80      }
(gdb) n
char_func () at finish.c:38
38      {
(gdb) quit
A debugging session is active.

        Inferior 1 [process 1] will be killed.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/25647] when build a gdb target = riscv32-unkown-elf , next instructions can't normal execution

glaubitz at physik dot fu-berlin.de
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25647

--- Comment #3 from konglingling4 at huawei dot com ---
sorry , I want to say finish.c include main function. I removed test.c.

I found a strange phenomenon, when I change the GDB target=riscv32-unkown-elf
into target=riscv32-linux. Next function is one of my expectations.The results
are as follows:

Copyright (C) 2019 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=i686-w64-mingw32 --target=riscv-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://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".
0x000100aa in _start ()
Breakpoint 1 at 0x1017e: file finish.c, line 34.
Breakpoint 2 at 0x10278: file finish.c, line 99.
(gdb) c
Continuing.

Breakpoint 1, void_func () at finish.c:34
34        void_test = 1;
(gdb) n
35      }
(gdb) n

Breakpoint 2, main () at finish.c:99
99        uniGdbTest ();                                             /*
void_checkpoint */
(gdb) n
100       char_resultval      = char_func ();            /* char_checkpoint */
(gdb) n
101       short_resultval     = short_func ();           /* short_checkpoint */
(gdb) n
102       int_resultval       = int_func ();             /* int_checkpoint */
(gdb) n
103       long_resultval      = long_func ();            /* long_checkpoint */
(gdb) n
104       long_long_resultval = long_long_func ();       /*
long_long_checkpoint */
(gdb) quit
A debugging session is active.

        Inferior 1 [process 1] will be killed.

Quit anyway? (y or n) y

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/25647] when build a gdb target = riscv32-unkown-elf , next instructions can't normal execution

Sourceware - gdb-prs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25647

Jim Wilson <wilson at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wilson at gcc dot gnu.org

--- Comment #4 from Jim Wilson <wilson at gcc dot gnu.org> ---
I wasn't able to reproduce this problem.  I tried using the GNU MCU toolchain
you are using, though I used the linux hosted one not the windows one.

One thing that might be different is the qemu version.  I'm using a top of tree
qemu.  I didn't see any mention of which qemu version you are using.  It is
possible that this is a qemu issue not a gdb issue.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/25647] when build a gdb target = riscv32-unkown-elf , next instructions can't normal execution

Sourceware - gdb-prs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25647

--- Comment #5 from konglingling4 at huawei dot com ---
I use qemu-4.0.0. qemu is built without kenel and is user mode.
--target=riscv32-user

And we don't have kenel in fpga. FPGA don't has linux system.
The gdb use under the fpga next instruction still exceptions

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/25647] when build a gdb target = riscv32-unkown-elf , next instructions can't normal execution

Sourceware - gdb-prs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25647

--- Comment #6 from konglingling4 at huawei dot com ---

Qemu building code from
https://github.com/riscv/riscv-qemu/tree/riscv-qemu-4.0.0, it is 3.1.9 qemu
version.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/25647] when build a gdb target = riscv32-unkown-elf , next instructions can't normal execution

Sourceware - gdb-prs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25647

--- Comment #7 from Jim Wilson <wilson at gcc dot gnu.org> ---
The github.com/riscv/riscv-qemu tree is obsolete.  The web page even tells you
that.  We stopped maintaining it over a year ago.  Use upstream qemu at
qemu.org instead.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/25647] when build a gdb target = riscv32-unkown-elf , next instructions can't normal execution

Sourceware - gdb-prs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25647

--- Comment #8 from Andrew Burgess <andrew.burgess at embecosm dot com> ---
It's possible this is a qemu issue, but I suspect this is more a compiler / GDB
issue, though I can't explain why the bare-metal vs linux builds had different
results.

You could try gathering some extra debug information; just before the "next"
command that goes wrong do "set debug infrun 1", then run the "next".  You
should get a bunch of debug output, which you should post.

Also can you try building latest GDB head from upstream and see if the issue
still occurs please - ideally gather any debug for latest upstream version.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/25647] when build a gdb target = riscv32-unkown-elf , next instructions can't normal execution

Sourceware - gdb-prs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25647

--- Comment #9 from konglingling4 at huawei dot com ---
Created attachment 12389
  --> https://sourceware.org/bugzilla/attachment.cgi?id=12389&action=edit
riscv32-linux-gdb-log

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/25647] when build a gdb target = riscv32-unkown-elf , next instructions can't normal execution

Sourceware - gdb-prs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25647

--- Comment #10 from konglingling4 at huawei dot com ---
Created attachment 12390
  --> https://sourceware.org/bugzilla/attachment.cgi?id=12390&action=edit
riscv32-unknown-elf-gdb

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug gdb/25647] when build a gdb target = riscv32-unkown-elf , next instructions can't normal execution

Sourceware - gdb-prs mailing list
In reply to this post by glaubitz at physik dot fu-berlin.de
https://sourceware.org/bugzilla/show_bug.cgi?id=25647

--- Comment #11 from konglingling4 at huawei dot com ---
I use a latest gdb 9.1 still has the same  issue.

I use gcc target=riscv32-unknown-elf compile a maintest

riscv32-unknown-elf.exe -g -O0 -c finish.c -o finish.o
riscv32-unknown-elf.exe -specs=nosys.specs finish.o  -o maintest

The maintest running on the qemu 3.1.9.

I use gdb build with target=riscv32-unknown-elf test with "set debug infrun 1".
The test results in riscv32-unkown-elf-gdb-log.txt.

And I use gdb  build with target=riscv32-linux with "set debug infrun 1".
The test results in riscv32-linux-gdb-log.txt

I don't know why the bare-metal vs linux builds GDB to debug the same binary
had different results.

Looking forward to your reply
Thank you for your help

--
You are receiving this mail because:
You are on the CC list for the bug.