I'm working with Jrules and ODM.
One of my evaluations fails due to a null pointer, and I want to know which particular condition failed.
How can I do this? The Jrules tutorials shows setting debug point in the action part, but not the evaluation (if...) part.
Is there a direct way to step condition by condition, so that I can locate which particular condition (evaluation) failed?
You can debug in the actions by putting some print statements in the initialaction and finalaction of each rules.
initialaction{
System.err.println("Debug here"+variable);
};
you can also add a sysout in the setter of the variable or loops used for actions and can see the system.out.log file inside sample server folder
(location: it depends in which drive we have installed the file) to trace what see what value is passing through that variable.
Thanks
Mohammed Khaleel
Related
Using evaluate expression/code fragment:
https://www.jetbrains.com/idea/help/evaluating-expressions.html
Is it possible to debug evaluated expression/code fragment on intellij?.
On eclipse if you launch a code evaluation on display window and that code has any breakpoint inside, eclipse debugger stops on that breakpoint. If you try again eclipse says it can execute inspections on nested debug session.
Intellij seems to launch expression in a different session.
My workflow on this is to stop on "whatever line" of code and add fragment I want to evaluate for a Q&D debug. Many times this leads to a debug restart.
Unfortunately it's not possible in Intellij 14 and stated in the official link you provided:
If a method invoked within the Expression Evaluation has a breakpoint inside its body, this breakpoint will be ignored.
To eliminate the problem you mentioned with frequent restarting of a debug session I use the following work-around with the drop-frame debug feature:
Step in to a method and before return use the drop-frame functionality to fall back to a previous stack frame. See the drop-frame icon's location on the screenshot below:
Now it's possible to rerun this method with different parameters without restarting the debug session (parameters can be set using Evaluate Expression dialog).
The feature is not available in IntelliJ IDEA 2019.2
The workaround I use is to update the code as follows,
Boolean shouldExecute = false;
if(shouldExecute){
//method call
}
During the debug session, I will change shouldExecute flag to true. This way I can debug the method call when needed.
Of coarse this is just a workaround, I need to remove this flag later.
Alt + F8 is the shortcut for evaluation of an expression or variable.
However, you can also select the variable, right click on it and evaluate as explained in this article.
Select the variable that you want to evaluate and press Alt + F8. Detail steps is given here:
https://www.websparrow.org/misc/shortcut-key-to-evaluate-expression-variable-in-intellij-idea
I have a code like this
String s="Test-Code-Data";
String[] splitedData = s.split("-");
I have a break point at second line. When my code reaches that point, can i start coding below that and immediately see the output. For example. I want to see the output from below code, and i type it when the execution reaches the second line only.
System.out.println(splitedData[1])
Is this possible in eclipse?
To answer your question, NO you cannot effectively alter code while the code is in execution without making Eclipse warn you that the code is 'out of sync'.
However, you can look at the actual values of your various variables in the various stages of execution of your code. And, once the execution is complete, then you can edit the code and Run the program in Debug again and keep going that way.
You can use the Inspect Variable feature to look at the value of a variable while in execution and paused at a breakpoint by selecting the variable you'd like to inspect and using the keyboard shortcut Ctrl+Shift+I to get the value of the variable.
Is there a way in NetBeans that while you are debugging a Java program to modify or check the value that a function or variable returns. The same way you can use the console in Matlab.
I'm not speaking about the usual debugging tools variable windows etc.
Example I want to break at a method in car class and input
>car.getMileage()
and get..
>car.getMileage()
>2500
or
>car.setMileage(100)
>car.getMileage()
>100
In Netbeans there is a tab under your source code window (there by default I think) called Variables. In that window you can edit the Value field of any variable that is in scope while suspended at a breakpoint. This value should update for the java application as you change it in real time. You can invoke methods the same way, by adding a watch. Like say you had a static method getInt(); which returns some value. Just make a watch for getInt(), and the Value column will show you the return value. So for your example, make a watch for car.setMileage(100) after your breakpoint is hit. The value column will likely be 'void'. Then make another watch for car.getMileage(). 100 should be returned.
Use an IDE such as Eclipse. You can set breakpoints, set statements and execute them. This is a feature of most modern IDEs actually.
More info on the display view can be found here : http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.jdt.doc.user/reference/views/debug/ref-debug_view.htm
For a nice overview of the debugging features of Eclipse, check out this post : http://www.cavdar.net/2008/09/13/5-tips-for-debugging-java-code-in-eclipse/
Eclipse is awesome for writing java programs but today I find that it's awesome to trick new coders like me. #_#
I write a snippet as following,
public static void main(String[] args) {
for(int i=0;i<3;i++){
System.out.println("i = " + i);
}
}
then I add a breakpoint at the line of "System.out.print....", click "Debug" button, eclipse goes to the "Debug" perspective and the line of breakpoint is highlighted, then I move the cursor over variable "i", its value is "0" as expected.
And then, I select the "i++" and click "Inspect"(or press "Ctrl+Shift+I") once, I move the cursor over variable "i", its value changed to "1". I repeat "Inspect" again, the value of i changed to "2"......(its value will add by 1 every time I clicked the "Inspect")!!
Why does this happend!? I ONLY want to watch the value of "i" for debug propuse, DO NOT want to really change its value until I step into next statement. I think that "Inspect", as well as "Display" are only for viewing the variable/expression, they should not impact the value, but in this case, it doesn't work as I expect to.
Could anyone tell me what went wrong?
My eclipse version info:
Version: Indigo Service Release 2
Build id: 20120216-1857
If you inspect an expression, eclipse has to execute that expression so you can get the value. Therefore, if you inspect i++, eclipse adds one to i.
Think about it this way: If instead of i++, you inspected myFunction(i), would you expect eclipse to execute the function "myFunction" to get the value? It's the same with i++.
If you are concerned about displaying/showing values while debugging and do you want to be sure not affecting the value, you should select the variable or expression and use the "Watch" option.
This will track the variable/expression value without executing, just updating the new value each time this is run. I think is the most secure way.
As Pablo mentioned, it has to evaluate the code in order to tell you what value it returns. You could instead put a watch on "i+1" and that would give you the value you want without the side effect you don't want.
Basically, you need to be aware of any side effects of anything you launch, whether from the "main" code or from the debugging tools. As Erhannis mentioned, this is very useful at times for modifying values while debugging your code. (For example, you can verify that a tweak/fix is indeed helpful before actually tweaking your code.)
You were expecting "an isolate area" but this would be extremely hard to do, especially in an object-oriented context where many objects are linked to many other objects. Running the whole thing in parallel might sometimes work, but you'd lose the tweaking ability above. And in any context, you'd run into tons of problems with fighting over resources; e.g. both copies trying to read/write a particular file such as a log file. Also, the two execution paths could diverge, leading to incorrect/misleading watch values.
So, preventing such side effects is not really a feasible option here and would rarely be useful anyway. Just expect that the watches can both reflect and affect the code execution.
Im using Java (JNA) to use a function in a third party .dll file. The functions I'm calling are returing the integer value 1.
After reading, I've discovered that this return value is traditionally 0 if everything runs correctly.
Was wondering if this is always the case or if theres any way to determine what it should be?
In the .h file bundled with the .dll it has the comment
// rc: EXIT_SUCCESS means NO ERROR
After the function.
Check actual dll documentation, there should be the way to tell what's wrong.
If nothing helps try calling GetLastError() WinAPI - some meaningful error code might be reported.
Also try to look at debug output during function call - some traces might be there even in Release build
Yes, zero typically means success in the C/C++ world.
In the days before exception handling you had to have a way to indicate failure and the return value was pretty much reserved for failure/success. As for what '1' means, you will have to look in the header of the dll for the function that is returning '1' and see if they included anything about error conditions. There are too many possibilities without seeing the code or knowing more about the dll to provide any easy answers.
What is the name of the function? What is it attempting to do? What can you do if you know the function failed?