We can either step-over, step-in or simply continue the execution. Stepping through the codeĪfter examining the situation, let’s say we are ready to move past this breakpoint. Examining the state in deeper stack-frames can be useful to understanding the broader context of the current breakpoint. For example, here we can switch to the fourth stack-frame to see the value of the arguments parameter. You can inspect values of fields and variables in stack frames other than the top-most one. For example, we can invoke the getApplications() method on the object referenced by the service variable, which is currently in scope of the breakpoint. Note that besides viewing variables, you can also evaluate expressions. You can find the full context in the Variables view of the Debug tool window. Note how IntelliJ IDEA shows the values right in the editor, where the fields and variables are in use. Doing that will trigger our conditional breakpoint and the view will automatically switch to IntelliJ IDEA, with the active breakpoint line highlighted.Īt this point, we can inspect variables and fields. Now, let’s activate the reactive forwarding application. Note that the debug console contains the message from our logging breakpoint, but that the program execution has not been suspended. First, let’s activate the proxy ARP application. Now that we have some breakpoints, let’s invoke the onos:app command and let’s see what happens. Note how the auto-completion works nicely here. We’ll chose to log our own message, which prints out a message with the value of the appId field. Doing that will reveal a number of logging options. Let’s try this out by setting another breakpoint on line 90 and then turn off the Suspend check-box. Logging break-pointsĪlternatively, we can turn a breakpoint into a logging one, which means that it will log a value of an expression, rather than suspend the program execution. Let’s make our breakpoint conditional on the name of the application ending with the “.fwd” string. To turn a breakpoint into a conditional one, we just need to type a Java boolean expression into the Condition field. Let’s do this for our break-point.Īnother useful breakpoint functionality is the ability to break only when a certain condition is met. Because other threads are free to continue execution, you are less likely to disrupt normal processing paths, due to missed heart-beats or time-outs. One useful customization is to change the break-point so that it suspends only the executing Thread rather than all threads in the VM. To customize a break-point we can simply right-click on it and then tailor its properties. Let’s open this file and let’s set a breakpoint on line 60. In our example, we will set some breakpoints in the ApplicationCommand.java, which is a CLI handler for the onos:app command. To do that we simply need to click in the left-hand margin of the code editor. Setting break-pointsĪt this point, we are ready to start setting breakpoints in our code. This will immediately open the Debug console with a message that IntelliJ has connected to the target virtual machine on localhost and on port 5005. Now all we need to do to attach the debugger to the ONOS process is to press the debug button. Note that the newly created debug configuration has been selected in the upper right hand corner. Let’s press OK to apply the changes and to close the dialog. If we were debugging ONOS running on another machine we would simply specify the IP address or DNS name of that machine here. Since we’ll be debugging local ONOS, let’s name our configuration Local and let’s leave the default Host address as localhost. While ONOS is starting up, let’s switch to IntelliJ IDEA and from the Run menu, select Edit Configurations… Then, let’s add a new configuration by pressing the + sign and select the Remote configuration. Attaching IntelliJ IDEA to the remote ONOS process In our demonstration, we will use the locally run ONOS, so let’s start it. Installations deployed via the onos-install utility already include the debug option by default.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |