cloudius-systems / gcc.bin

imported gcc binaries
1 stars 0 forks source link

Syntax error in printers when python 3 is used #1

Open gberginc opened 9 years ago

gberginc commented 9 years ago

While trying to use GDB to debug an OSv instance that hangs with an undefined syscall, I got a strange syntax error:

lemmy@mike:~/work/osv⟫ gdb build/release/loader.elf 
[...]
Reading symbols from build/release/loader.elf...done.
Traceback (most recent call last):
  File "/home/lemmy/work/osv/scripts/loader.py", line 1483, in <module>
    setup_libstdcxx()
  File "/home/lemmy/work/osv/scripts/loader.py", line 1020, in setup_libstdcxx
    exec(compile(open(main).read(), main, 'exec'))
  File "/home/lemmy/work/osv/external/x64/gcc.bin/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.18-gdb.py", line 59, in <module>
    from libstdcxx.v6.printers import register_libstdcxx_printers
  File "/home/lemmy/work/osv/external/x64/gcc.bin/usr/share/gcc-4.8.2/python/libstdcxx/v6/printers.py", line 55
    raise ValueError, "Cannot find type %s::%s" % (str(orig), name)
                    ^
SyntaxError: invalid syntax

Although my default python is 2.7, GDB seems to be linked with python 3.4 causing a problem: python 3 does not support tuples when raising exceptions anymore.

Patch is rather trivial and requires changing this pattern on several places inside printers.py, like in this gist. Not sure how to submit the patch (either as a pull request or to the mailing list).

nyh commented 9 years ago

On Fri, Apr 17, 2015 at 2:46 PM, gberginc notifications@github.com wrote:

While trying to use GDB to debug an OSv instance that hangs with an undefined syscall, I got a strange syntax error:

lemmy@mike:~/work/osv⟫ gdb build/release/loader.elf [...] Reading symbols from build/release/loader.elf...done. Traceback (most recent call last): File "/home/lemmy/work/osv/scripts/loader.py", line 1483, in setup_libstdcxx() File "/home/lemmy/work/osv/scripts/loader.py", line 1020, in setup_libstdcxx exec(compile(open(main).read(), main, 'exec')) File "/home/lemmy/work/osv/external/x64/gcc.bin/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.18-gdb.py", line 59, in from libstdcxx.v6.printers import register_libstdcxx_printers File "/home/lemmy/work/osv/external/x64/gcc.bin/usr/share/gcc-4.8.2/python/libstdcxx/v6/printers.py", line 55 raise ValueError, "Cannot find type %s::%s" % (str(orig), name) ^ SyntaxError: invalid syntax

Although my default python is 2.7, GDB seems to be linked with python 3.4 causing a problem: python 3 does not support tuples when raising exceptions anymore.

Patch is rather trivial and requires changing this pattern on several places inside printers.py, like in this gist https://gist.github.com/gberginc/f5675c19c5947f9340ba. Not sure how to submit the patch (either as a pull request or to the mailing list).

— Reply to this email directly or view it on GitHub https://github.com/cloudius-systems/gcc.bin/issues/1.

Hi Gregor, I'm replying also to the OSv mailing list, because I don't think anyone even realized that the "gcc.bin" submodule has its own bug tracker (and as you can see this is the first bug there), and one of the annoying features of the Github bug tracker is that people need to be personally subscribed to the bug tracker to be notified about these bugs (and only 9 people ever bother to subscribe to the gcc.bin bug tracker).

And now to the point:

printers.py is part of gcc, not OSv. I think the mistake here (and this is a common theme lately...) is that we're using one from external/, whereas we should have used the one from the system. After all, the user compiled with his system's gcc, and is debugging with the system's gdb - so it doesn't make too much sense to suddenly bring our own glue code between those two - when the user's system probably has this glue code too - and has it for the right version of gcc, gdb and python.

I'll prepare a patch.

Nadav Har'El nyh@cloudius-systems.com