cloudius-systems / osv

OSv, a new operating system for the cloud.
osv.io
Other
4.12k stars 605 forks source link

gdb debugging of OSv is broken in Fedora 40 #1324

Closed nyh closed 3 months ago

nyh commented 4 months ago

In Feodra 40, debugging OSv with gdb stopped working.

First, when running gdb build/last/loader.elf we get a warning:

$ gdb build/last/loader.elf 
GNU gdb (Fedora Linux) 14.2-2.fc40
Copyright (C) 2023 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 "x86_64-redhat-linux-gnu".
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/last/loader.elf...
/home/nyh/tmp/osv/scripts/loader.py:1152: SyntaxWarning: invalid escape sequence '\['
  callouts = re.findall('\[([0-9]+)\] = (0x[0-9a-zA-Z]+)', c)
/home/nyh/tmp/osv/scripts/loader.py:1698: SyntaxWarning: invalid escape sequence '\['
  linear_vmas = re.findall('\[([0-9]+)\] = (0x[0-9a-zA-Z]+)', l)

Then, connect gives strange warnings too but does seem to work:

(gdb) connect
warning: Remote gdbserver does not support determining executable automatically.
RHEL <=6.8 and <=7.2 versions of gdbserver do not support such automatic executable detection.
The following versions of gdbserver support it:
- Upstream version of gdbserver (unsupported) 7.10 or later
- Red Hat Developer Toolset (DTS) version of gdbserver from DTS 4.0 or later (only on x86_64)
- RHEL-7.3 versions of gdbserver (on any architecture)
nmi (ef=0x400000a56088) at arch/x64/exceptions.cc:308
308         while (true) {

Finally, osv syms is broken and doesn't work:

(gdb) osv syms
manifest.find_file: path=/usr/lib/fs/libsolaris.so, found file=/home/nyh/tmp/osv/build/release.x64/
/home/nyh/tmp/osv/build/release.x64/ 0x100000000000
readelf: Error: '/home/nyh/tmp/osv/build/release.x64/' is not an ordinary file
add symbol table from file "/home/nyh/tmp/osv/build/release.x64/" at
Traceback (most recent call last):
  File "/home/nyh/tmp/osv/scripts/loader.py", line 711, in invoke
    load_elf(path, base)
  File "/home/nyh/tmp/osv/scripts/loader.py", line 74, in load_elf
    gdb.execute('add-symbol-file %s %s %s' % (path, text_addr, args))
gdb.error: A syntax error in expression, near `?'.
Error occurred in Python: A syntax error in expression, near `?'.
wkozaczuk commented 3 months ago

The latter part is similar to what is saw with older version of Fedora. I will take a look at it.