Attach debugger to application using Eclipse

前端 未结 3 1983
天命终不由人
天命终不由人 2020-12-05 02:00

Can you attach to a running application using Eclipse, similar to how you attach using Visual Studio?

相关标签:
3条回答
  • 2020-12-05 02:17

    The Debug Configurations panel has a menu item Remote Java Application:

    enter image description here

    0 讨论(0)
  • 2020-12-05 02:25

    How about just do this:

    "Open the DDMS perspective, select the device and attach to your app's process (you will see the package name listed)"

    .. thanks to this post: https://stackoverflow.com/a/10074263/2162226

    0 讨论(0)
  • 2020-12-05 02:34

    Yes.

    If you start your server with the debug port open, by adding this into your java command:

    -Xdebug -Xrunjdwp:transport=dt_socket,address=127.0.0.1:8888,server=y,suspend=n
    

    And you have the source code in your project (technically this isn't required, but it's kind of useless unless you do), you can connect to the running server by setting up a "debug configuration" with host = the machine the server is running on and port = 8888 (for example - see options above)

    You can then set break points and the debug session will halt the server there and you can inspect variables/fields, and even set their values.


    Update

    The more modern command-line options for the JVM to do this are

     -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:8888,server=y,suspend=n
    
    0 讨论(0)
提交回复
热议问题