This discussion is archived
8 Replies Latest reply: Jul 7, 2011 10:09 PM by 872659 RSS

how to use gdb to debug Java directly

872659 Newbie
Currently Being Moderated
Without using GCJ from GNU, how to debug Java application with gdb directly.

e.g.

$ gdb java

(gdb) r HelloWorld

Could someone have more info about this?

Thank you in advance!
  • 1. Re: how to use gdb to debug Java directly
    796440 Guru
    Currently Being Moderated
    You'll be able to debug the JVM, but I don't think you'll be able to debug your Java program that way.

    Any decent IDE--including free ones like Eclipse--should come with a graphical debugger. Also, I think there's a console debugger--jdb--included with the JDK download.
  • 2. Re: how to use gdb to debug Java directly
    872659 Newbie
    Currently Being Moderated
    since application is running at a remote pc and I can not use Eclipse gui to debug. And JDB has no so enough functions as GDB. JVM is written in C/C++ and it can be debugged with gdb. So there is no way to debug Java application via gdb?

    Anyway, thank you again.
  • 3. Re: how to use gdb to debug Java directly
    sabre150 Expert
    Currently Being Moderated
    user1992749 wrote:
    since application is running at a remote pc and I can not use Eclipse gui to debug.
    Rubbish - http://www.eclipsezone.com/eclipse/forums/t53459.html .
    And JDB has no so enough functions as GDB. JVM is written in C/C++ and it can be debugged with gdb.
    You obviously know very little about how C/C++ debugging works. Do you think the standard JVM will have been built with all the debugging type information left in? And even if it is left in what good is it going to do you to debug the JVM when it is your Java code that is likely to be the source of any problems you have.
    So there is no way to debug Java application via gdb?
    'gdb' uses symbols left in the executable - your Java program does not export it's symbols to the executable.

    And if you don't like Eclipse or Netbeans then there are several standalone Java debuggers all based on the standard Java debugger. For example - http://www.debugtools.com .

    Edited by: sabre150 on 06-Jul-2011 06:00

    I have just downloaded JDebugTool again, installed it on one machine and debugged a Java program running on a different machine. Dead easy!
  • 4. Re: how to use gdb to debug Java directly
    796440 Guru
    Currently Being Moderated
    user1992749 wrote:
    since application is running at a remote pc and I can not use Eclipse gui to debug.
    Have you confirmed that, or are you just assuming? I haven't used Eclipse for a long time, however, I use IntelliJ for remote debugging all the time. I would guess that Eclipse has similar capabilities.

    Given that you apparently know that gdb can be used for remote debugging, why would you assume that a graphical debugger cannot?
  • 5. Re: how to use gdb to debug Java directly
    872659 Newbie
    Currently Being Moderated
    Sorry that I did not make a clear description about my environment. I have to do a work as follows:

    my PC <--> a virtualbox OS <--> a remote PC(application is running)

    The steppingstone machine(virtualbox OS) above doesn't have enough disk size/mem to let me use Netbeans or Eclipse to debug an application running at another machine.
  • 6. Re: how to use gdb to debug Java directly
    872659 Newbie
    Currently Being Moderated
    Thank you for your info.

    Since I saw HP WDB provided by HP for their HP-UX that is based on jdb can debug java application, I asked the question if GDB from GNU also provide such extension functions.
    Sometimes I can not use IDEs to debug at some machines where applications are running.

    Eclipse and Netbeans are great tools for debugging. It is my first time to hear JDebugTool. Does it have some features outweighing Eclipse and Netbeans? It seems you need to buy it.

    Edited by: user1992749 on 2011/07/06 22:07
  • 7. Re: how to use gdb to debug Java directly
    872853 Newbie
    Currently Being Moderated
    Check this link you find useful:
    http://download.oracle.com/javase/1.3/docs/tooldocs/solaris/jdb.html
    http://javarevisited.blogspot.com/2011/07/java-debugging-tutorial-example-tips.html
  • 8. Re: how to use gdb to debug Java directly
    872659 Newbie
    Currently Being Moderated
    anyway, thank you!

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points