Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gdb error in terminal when debugging translators #97

Open
chunhualiao opened this issue Nov 6, 2019 · 4 comments
Open

gdb error in terminal when debugging translators #97

chunhualiao opened this issue Nov 6, 2019 · 4 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@chunhualiao
Copy link
Owner

freecc@node1:rose-ast$ gdb dotGenerator -c func1.c

GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 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-linux-gnu".
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"...
Reading symbols from dotGenerator...done.
"/home/freecc/rose-ast/func1.c" is not a core dump: File format not recognized
(gdb) r
Starting program: /home/freecc/install/rose_install/bin/dotGenerator
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Installing openjdk unwinder
Traceback (most recent call last):
  File "/usr/share/gdb/auto-load/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so-gdb.py", line 52, in <module>
    class Types(object):
  File "/usr/share/gdb/auto-load/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so-gdb.py", line 66, in Types
    nmethodp_t = gdb.lookup_type('nmethod').pointer()
gdb.error: No type named nmethod.
[Inferior 1 (process 464) exited normally]
@chunhualiao
Copy link
Owner Author

@chunhualiao chunhualiao added the good first issue Good for newcomers label Jun 22, 2020
@chunhualiao
Copy link
Owner Author

@ouankou Can we have a docker image with debug build of ROSE?
We would like to add a few tutorials about how to debug later on, using text from https://en.wikibooks.org/wiki/ROSE_Compiler_Framework/How-tos#How_to_debug_a_translator

@ouankou
Copy link
Collaborator

ouankou commented Jun 22, 2020

OK, I created a specific docker image for previous loop stride bug.
https://github.com/freeCompilerCamp/play-with-compiler/blob/master/dockerfiles/dind/Dockerfile.rose_bug

I'll create a similar one for debug build of ROSE and address this issue.

ouankou added a commit to freeCompilerCamp/play-with-compiler that referenced this issue Jun 23, 2020
@ouankou
Copy link
Collaborator

ouankou commented Jun 23, 2020

@chunhualiao I've uploaded a new docker image of ROSE debug build. freeCompilerCamp/play-with-compiler@96bf3fa

docker pull freecompilercamp/pwc:rose-debug

A related tutorial has been set to use this specific image as example. http://freecompilercamp.org/rose-ast-traversal/

About this issue, I tried several different configurations of JDK and OS. It seems like an upstream bug of JDK8 debug extension of GDB. When GDB loads the JDK 8 debugger plugin openjdk unwinder, it can't find the correct location of JDK libraries.
With OpenJDK8, I tried to use GDB to debug any JAR file and it will throw the same error.

Installing openjdk unwinder
Traceback (most recent call last):
  File "/usr/share/gdb/auto-load/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so-gdb.py", line 52, in <module>
    class Types(object):
  File "/usr/share/gdb/auto-load/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so-gdb.py", line 66, in Types
    nmethodp_t = gdb.lookup_type('nmethod').pointer()
gdb.error: No type named nmethod.

If I switch to OpenJDK 11, debugging the same JAR file is fine. It's not an issue of ROSE. Any program that involves JDK 8 will trigger this bug in GDB.

I used the same method from this link to test, however, its solution doesn't work.
https://debian-bugs-dist.debian.narkive.com/Ap0ST04C/bug-867314-openjdk-8-jre-headless-openjdk-unwinder-for-gdb-crashes

This page has a long discussion about this issue. In their case, OpenJDK 9 works while OpenJDK 8 has the same issue as ours.
https://savannah.gnu.org/bugs/?53733

I think the possible solutions could be:

  1. Remove the OpenJDK 8 plugin in GDB by renaming or removing the py file /usr/share/gdb/auto-load/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so-gdb.py.
  2. dig the GDB source code and find out how does it locate the JDK library.
  3. update ROSE to support JDK higher than 8, ideally JDK 11, the LTS version. Currently, ROSE only support JDK 8 because it requires javah, a tool removed since JDK 9.

Solution 1 is just a workaround. Solution 3 may be better in the long term. ROSE will eventually use some more recent version of OpenJDK anyway. Later I'll check whether Oracle JDK 8 has the same issue or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants