4 Replies Latest reply on May 30, 2012 2:38 PM by mariomarinato

    Use Byteman to debug an RCP application

    mariomarinato

      I'm trying to use Byteman to debug an RCP application, but I can't make it work.

       

      I tried adding the arguments to the command line and to an .ini file, with no success.

       

      Has anyone ever tried it before?

        • 1. Re: Use Byteman to debug an RCP application
          adinn

          Hi Mario,

          Mário Marinato wrote:

           

          I'm trying to use Byteman to debug an RCP application, but I can't make it work.

           

          I tried adding the arguments to the command line and to an .ini file, with no success.

           

          Has anyone ever tried it before?

          Can you explain what you mean by an RCP application. Do you mean Rich Client Platfom (as in Eclipse)?

           

          If so then one thing which might be of relevance is that you cannot use Byteman with bytecode generated by the Eclipse Java compiler (see BYTEMAN-197)

           

          Perhaps you can explain more about what your application is doing and how you are starting it.

           

          regards,

           

           

          Andrew Dinn

          • 2. Re: Use Byteman to debug an RCP application
            mariomarinato

            Hi, Andrew

             

            Yes, I mean an Eclipse Rich Client Platform.

             

            I am able to use Byteman on debug mode, by adding the -javaagent parameters on Eclipse's debug configuration dialog, and it works great (it's amazing how great it is, by the way).

             

            But when I try to use it on the exported application, I can't make it.

             

            My first try was to add the -javaagent parameters to the command line and the second one was adding the parameters to the .ini file, but none of them produced any results.

             

            Best regards,

             

            Mario Marinato

            • 3. Re: Use Byteman to debug an RCP application
              adinn

              Hi Mario,

              Mário Marinato wrote:

               

              Yes, I mean an Eclipse Rich Client Platform.

               

              I am able to use Byteman on debug mode, by adding the -javaagent parameters on Eclipse's debug configuration dialog, and it works great (it's amazing how great it is, by the way).

               

              Good. I'm glad you have found it useful. Can you provide any details of what you have been using it for? -- others might benefit from hearing what you are doing with it.

               

              Mário Marinato wrote:

               

              But when I try to use it on the exported application, I can't make it.

               

              My first try was to add the -javaagent parameters to the command line and the second one was adding the parameters to the .ini file, but none of them produced any results.

               

              I am not familiar with how an exported RCP application gets run. In theory if you are starting the JVM with the correct -javaagent options then the Byteman should  do what it normally does, injecting rules or listening for submit requests. If your JVM supports he -javaagent flag then it shoudl just work. What options did you pass to the agent after the = sign in the -javaagent options list? (e.g. id you specify something like -javaagent:byteman.jar=script:my.Script,listener:true).  Could you try adding -Dorg.joss.byteman.verbose as an extra command line argument to see whether  the agent generates any messages to System.out.

               

              Another thing you might try is to start the exported application, run jps-l (or just ps) to obtain the process id of the Java VM and then try to install the agent after the app has started using script bminstall.sh (which you will find in $BYTEMAN_HOME/bin). If bminstall quietly completes then try running bmsubmit.sh (also in the bin dir) to talk to the agent.

              • 4. Re: Use Byteman to debug an RCP application
                mariomarinato

                Hi, Andrew,

                Andrew Dinn wrote:

                 

                Good. I'm glad you have found it useful. Can you provide any details of what you have been using it for? -- others might benefit from hearing what you are doing with it.

                 

                I came to it because I'm profiling my software with jvisualvm and it reported that a given SWT method was the one taking most processing time.  As this method is called from many places on my code, I wanted to check where most of the calls came from, but didn't want to spread debug messages all around.  With Byteman I was able to log the stack trace whenever the method was called without changing a line of code.

                 

                 

                Andrew Dinn wrote:

                 

                I am not familiar with how an exported RCP application gets run. In theory if you are starting the JVM with the correct -javaagent options then the Byteman should  do what it normally does, injecting rules or listening for submit requests. If your JVM supports he -javaagent flag then it shoudl just work. What options did you pass to the agent after the = sign in the -javaagent options list? (e.g. id you specify something like -javaagent:byteman.jar=script:my.Script,listener:true).  Could you try adding -Dorg.joss.byteman.verbose as an extra command line argument to see whether  the agent generates any messages to System.out.

                 

                When you export an RCP application, it's placed on a folder following Eclipse structure (plugins, workspace, etc.), plus two files:  an .exe and a startup.jar.

                 

                I tried calling this (the arguments are the same I use on debug mode, from inside Eclipse):

                     myexe.exe -Dorg.jboss.byteman.verbose -javaagent:"$BYTEMAN_HOME\lib\byteman.jar"=script:myRules.btm,boot:"$BYTEMAN_HOME\lib\byteman.jar" -Dorg.jboss.byteman.transform.all

                 

                But it didn't work.  I also created an .ini file and placed the arguments in it, which is the default way to do it on RCP applications, but again no success.  I also tried to write traces into a file, and again it failed.

                 

                Andrew Dinn wrote:

                 

                Another thing you might try is to start the exported application, run jps-l (or just ps) to obtain the process id of the Java VM and then try to install the agent after the app has started using script bminstall.sh (which you will find in $BYTEMAN_HOME/bin). If bminstall quietly completes then try running bmsubmit.sh (also in the bin dir) to talk to the agent.

                 

                I'll try this one too.  Thanks for the tip.