how to know what are the lines covered in the code for a particular point of execution in eclipse - eclipse

How to know what are the lines of code covered in the java class for a particular point of execution in eclipse. For example,if button click event is fired then how to know what are the lines of code is being executed during this event. Any plugins in eclipse or any free software for this to track the code ?

Go to the following page, it will instruct you through the process. The only thing you need to do is prepare a j-unit test for your code (for the method that gets called when pressing the button).
http://crunchify.com/what-is-the-best-code-coverage-plugin-you-should-use-in-eclipse-ide/

Related

Event listener breakpoints in Google Chrome Devtools

Event listener breakpoints in Google Chrome Devtools offers various number of options, but for me, they are not really of great use since they always throw me to some irrelevant part of code.
What I would like to know is if it is possible to limit it to just one class? For example onMouseClick send me to the 1st method that executes after mouse click, inside specific class. If none of the methods are fired inside this class, than simply do nothing.
You can set the breakpoints for each script and each line individually.
First open the debug-tools and chose a script in the sources-tab:
Then you can click on the line-number (here only no. 1) and it looks like this:
As you see now is the line marked, but also in the right col your individual breakpoint is listed.
After having marked the breakpoint you still have to reload the page that the scripts are executed again till to the breakpoint. Afterwards you can use the icons above the right col to step in or step over the commands following the breakpoint.
Having minified scripts, breakpoints are hard to use, so it's better to have a script where each line has only one command, it's much easier then to debug.
So for debugging you should change the corresponding script in your page to the non-minified version, perhaps also with a map-file if available.

Why is mouse click event listener breakpoint hit in a blackboxed script in Chrome?

I am trying to find out which Javascript method is called when I click a button. I have blackboxed some third party javascript files. I am using the latest versions of Chrome and Canary.
I have enabled the Mouse click event listener breakpoint in devtools. When I click a button, a debugger breakpoint is hit inside a js file which is blackboxed. I am using a third party button whose JS click event handler executes first before mine. I have blackboxed their code file hoping that my code gets the breakpoint. A 'This script is blackboxed in debugger' yellow message shows up for their code file.
Why is the breakpoint hit when the script file is blackboxed?
I created a test where I added a click Event Listener Breakpoint on this page and it paused in jquery-min.js. I blackboxed that script and tried again. It didn't break in jQuery anymore.
I re-read your post and you mentioned 'a debugger breakpoint is hit'. I now take that to mean an explicit breakpoint like a debugger; statement in the source code or one set in Dev Tools (by clicking line number), and that the Event Listener Breakpoint is irrelevant.
If you have a debugger; statement in a library that is blackboxed, the breakpoint will still be hit. You can disable the breakpoint by right clicking on the line number where the statement exists and selecting 'Never pause here'.
As it stands, if you put a breakpoint in a blackboxed library via Dev Tools, it will still break in that script. It shows more explicit intent to break on the code, rather than something perhaps left in by a 3rd party. You would have to disable or remove them.
There appears to be a debate about whether blackboxing a script should ignore breakpoints set in that library, as blackboxing could be considered to be more about not stepping into the library code/seeing it in the call stack. See the discussion here. Interestingly, the documentation includes the following still:
The debugger will not pause on any breakpoints set in library code.
https://developer.chrome.com/devtools/docs/blackboxing
This isn't the case.
There is come inconsistency here with the behaviour and documentation. I will try and get an update on this.

Running my program from PyDev with one click?

I am developing using the PyDev plugin in Eclipse. My program uses several classes in several files. I usually run the program using the green "play" icon or using Control+F11. The only problem is that it will run the file, which is currently in "focus". Usually this is not the one containing the starting point of my application. As I run my program something like 200 times a day, this means that I need 200 extra click on the mouse and often forget about this.
Is there any way of setting the default file to launch?
Yes, change the launching to rerun the last launched, so Ctrl+F11 will launch the last one -- and use F9 to launch the one with focus -- See instructions and details at: http://pydev.org/manual_101_run.html
For me, the shortcut is Ctrl+Shift+F9. I don't think I've changed any keybindings, so its strange that it would be different from the official documentation.
Go to Run->Run History, and select the run that is your 'main' run. Now you should be able to use Ctrl-Shift+F9 from any other file to rerun your main. If it isn't Ctrl+Shift+F9 for you, look on the console window that should be at the bottom of your screen showing the stdout after every run. There is an icon on the top of it that has the green start arrow with a yellow arrow underneath it pointing to the right. That is the command to relaunch with the same configuration. If you hover over that, it should tell you the keyboard shortcut you need.

iPhone -- Hunting Line of Code Being Executed

I am working on an iPhone project containing a ton of code. The application receives outside requests and performs actions. However, I cannot figure out exactly where the app begins executing code for a particular event. Is there some functionality in Xcode which would allow me to solve this problem?
Thank you.
Have you tried setting break points in your code? Click on the line numbers column in Xcode on the number to set a break point.
Without knowing more about what these requests are or where they are coming from, its hard to give any advice on what tools Xcode might have, but looking in any project files named <xxx>AppDelegate.m or <xxx>Controller.m would be a good start, placing breakpoints on likely sounding methods.
I figured out that you can use the Instruments Profiler to this end.
Start the profiler
Choose "Time Profiler"
In the bottom left section make sure the following are checked: Show Obj-C only and Hide System Libraries
In the timeline, click on the the point before the event occurred.
Click the left-most icon in "inspection range" (located on the top-bar immediately to the left of clock)
In the timeline, click on the point after the event completed. (optional)
Click the right-most icon in "inspection range"
Inspect the Call Tree.

Debugger / Profiler for Eclipse?

Is there any tutorial for debugging applications/ running profiler in eclipse? Please let me know thanks..
This will depend on what language you are using. How you setup for debugging PHP vs C++ is a little different as they use different underlying tools (PHP - Xdebug vs C++ - gdb)
In a general sense, you will configure the app much like you would set it up to run within Eclipse. In some cases you will have to be sure to enable debugging information within the code base for the debuggers to provide detailed information. From there you're looking at setting breakpoints, stepping, and setting up watches which is very similar language-to-language within the Debug Perspective in Eclipse.
A common scenario is to set a breakpoint within the codebase by clicking on the left bar in the editor, and selecting toggle breakpoint. Then click the debug button in the IDE and it should open the Debug Perspective and either break at the beginning of main, or will run to the breakpoint you set in the code. Once the break is hit, you will be able to browse the stack frames within one of the views within the perspective and you will see tabs for watches, breakpoints, etc. The buttons near the top that look similar to play, and then arrows jumping over dots are the way you control the execution from your breakpoint. If you click "step over" the code will go line by line in the source file you're in until it must goto another file to follow the execution of your code. It will not go into a function call, rather call it execute it and return to the next line in the current source. If you want to go into the function call and continue debugging from there, you would use the "step into" button which is right next to "step over" in most cases. Resume restarts regular execution and will run your program normally until the end or another breakpoint is hit.
Start from there and get comfortable with it and then start playing with things like conditional breakpoints and watches. Conditional breaks are exactly like breakpoints but they only stop execution if the condition you specify is met. With C++ this is usually done by right clicking on the breakpoint and providing the conditional expression where appropriate in the menu. (I forget the exact verbage)
Watches allow you to watch memory and have the program break when memory is read, written to, or both so you can inspect your application.
Some debuggers in Eclipse may lack some of these features or offer more advanced features than those listed above, but these concepts should get you well on your way.
Good luck!