Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Debugging: How to find difference in Code Flow Paths?

Sometimes, while debugging Java Code I find myself doing the following to find bugs:

  1. Put a breakpoint on a method invocation
  2. Run the program in debug mode
  3. Note the code flow path as a result of method invocation
  4. Change the parameters and rerun the program in debug mode
  5. Again note the code flow path from the point where the method is invoked
  6. Find the difference between the code flow paths and zero in on the potential buggy path.

Is there a tool that makes this job easier by recording the code flow path in a file and comparing two such files?

like image 368
Rohit Banga Avatar asked Mar 16 '11 14:03

Rohit Banga


People also ask

How does Eclipse determine flow code?

CTRL + ALT + H shows you the call hierarchy for a method. Perhaps that's what you wanted. So it you highlight a method and click CTRL + ALT + H, it shows, in the Call Hierarchy window, all the methods the call that method, and for each of those methods, all the methods that call them, and so on ...

What is JDB in Java?

The Java Debugger, jdb, is a simple command-line debugger for Java classes. It is a demonstration of the Java Platform Debugger Architecture that provides inspection and debugging of a local or remote Java Virtual Machine.


2 Answers

Try using something like emma, it is a unit test code coverage tool which should be able to tell you which classes have unused or untested code paths.

There is a plugin available for eclipse that should provide a pretty concise report.

like image 195
Dave G Avatar answered Oct 20 '22 00:10

Dave G


You can use logging. If you code path traversers libraries with source code out of your control you can set a conditional breakpoint that prints some message and returns false.

like image 21
Ha. Avatar answered Oct 20 '22 01:10

Ha.