When we debug, breakpoints are set before attaching to the process(even before starting application) and even though there are times that debugger go to places that has not been set to access.
I've checked and not modified the breakpoints list before starting program.
Regards
In eclipse preferences there is Java -> Debug. Check if the option Suspend execution on uncaught exceptions is checked. If that option is checked, the debugger will suspend execution when such an exception is thrown.
My friend who has no SO has solved that issue. There were break points in library that was imported by debugged project.
Those breakpoints are not visible in main project.
Related
Today when I was working like every day I have noticed something odd in the android studio. The 2 kinds of breakpoints I have never seen it before. I want to know what is the differences and why?
Thanks.
copied from IntelliJ
a circular breakpoint is a line breakpoint, while a diamond breakpoint is a method breakpoint.
Line breakpoints: suspend the program upon reaching the line of code where the breakpoint was set. This type of breakpoints can be set on any executable line of code.
Method breakpoints: suspend the program upon entering or exiting the specified method or one of its implementations, allowing you to check the method's entry/exit conditions.
for more info about breakpoints and their types check this link
I’m confused by the Debugger. It seems to pause the app and show the Debug window for some breakpoints and not for other breakpoints. It still ticks the breakpoints, though it doesn’t pause the app. And when I open the Debug window I see no frame so I couldn’t look at variables. I’ve looked at many documents and they haven’t cleared my problem. So what I’d like to know are:
how frame and thread are related
does breakpoint work differently in different place or different class in the app?
As it seems the Guide provided by Google doesn't answer your question, I will add an extra explanation, hope it helps:
1- The Frame is directly related to application process which can be consisted of multiple thread used by application, means that as long as application process is up and running the frame is available too.
However this doesn't mean that you can watch variables whenever you want, the Variables window frame become available once the debugger hits a breakpoint.
2- Yes, for the debugger to hit a breakpoint few criteria should be met. It's a long list but here is the more important ones:
App must be debuggable in the first place, if the app is defined as
not debuggable (like release builds) then the debugger won't work.
The code must be readable hence executable to debugger, that means codes that are obfuscated or tampered with won't cause the debugger to stop at breakpoints..
Code must be executable, that means codes that aren't executable like variable declaration or codes that are unreachable won't cause debugger to stop.
P.S: Of course these are only few major causes and there are lots of others like instant run that can make a piece of code undebuggable.
So there is a small java program to add two numbers.
There is one break-point.
I used Debug as -> Java Application.
But still, Step Into, Step Over, Resume, Suspend and Terminate buttons are disabled in my eclipse.
See below:
Debugger recognized the breakpoint at int b = 3 but still the buttons are disabled.
Everything was working fine yesterday.
What should be the cause?
Possibles solutions and cause here.
The commands got disabled, probably from previous customization, (check General -> Keys) but I wouldn't think this can be the only reason to be cause of this issue.
Hope this helps you out.
I have met the same issue and fixed it. The following are the possible solutions:
Make sure that your skip all break point option is disabled
Reset your debug perspective in perspective options.
Make sure to restart eclipse after doing above things
From Javascript, I can simply write
debugger;
and when that line executes, it stops the code as if I had put a breakpoint there.
Is there an equivalent in Java? I need it to work in Eclipse specifically.
EDIT: can we take it as read that I am not an idiot and if placing a breakpoint with the IDE itself were an option, I would have already done so?
FURTHER EDIT: I had not thought it necessary to point out that since placing a breakpoint with IDE is not an option, any answer that revolves around placing a breakpoint with IDE is not likely to be helpful. In case everybody is dying of curiosity, the original code is not written in Java -- it's processed down to Java byte-code. As a result, Eclipse is confused enough it doesn't want to set breakpoints.
The JVM debugger, which Eclipse uses (mostly) under the covers, can set breakpoint at a line number in a method IF compiled with certain optional debugging info OR at method entry (always).
If your classes were compiled without debugging "lines" so the debugger can't set a line breakpoint, and you don't want to or can't recompile them, you can still set a method-entry breakpoint. In Package Explorer -- NOT an edit window for the source -- right-click the method name/signature and Toggle Method Breakpoint to on.
This can be combined with the comment by #ajp: add a method e.g. void [static] debugger(){} that doesn't do anything when you call it, but provides a convenient target where you can set a method breakpoint.
Warning: although it is possible to compile with partial debugging info, like debugging "vars" but not debugging "lines", generally people just use "debug on" or "debug off". If your classes are compiled without debugging "vars", the debugger will be much less useful.
I am probably going to get a few downvotes, but so be it...
If you open a source file in Eclipse and right-click on the left edge of the document view, you will get the popup menu illustrated in the image below.
As you can see, you have the option to toggle a breakpoint and also to turn off and on the line numbers. So, I am not sure what you mean by "My Eclipse is being operated in an environment where it cannot find line numbers to the source code". Unless you have some modified version of Eclipse that does not show this menu, I don't know what you mean by that. The option is there.
You wrote:
From Javascript, I can simply write
debugger;
and when that line executes, it stops the code as if I had put a breakpoint there.
And also:
can we take it as read that I am not an idiot and if placing a
breakpoint with the IDE itself were an option, I would have already
done so?
Option 1: The simple, "incorrect" answer is that there is no instruction in the Java language to make the program pause in a breakpoint nor there is an option like in languages like C++ to
make a debug build. So, your "ONLY" option is to execute a breakpoint from the IDE.
Option 2: The complicated, correct answer is that you can do what you want following these instructions: https://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html
In your case, I don't believe that you don't have the option to place a breakpoint with the IDE to debug your program; no matter how complex your program is. BUT, I am not here to debate that point. According to your post, you have to do option 2 laid out here.
I have been using Eclipse for 2 years for development, but this filter concept I am still struggling to understand during debugging.
I usually debug in remote port mode.
Most of the times, My Eclipse catches the break point/exception in Unwanted Packages [Packages usually from other Sources like Spring, Java ThreadPool etc..] and annoys me by bringing up the debug window.
I would like to configure Eclipse to catch breakpoints in my package only. Just ignore any where else, don't halt them or notify me.
As far as I know we can add package filters for exception breakpoints but for the normal line breakpoints, I think a long way to manually disable one by one will work,
You can look at Eclipse Creating Expression Filter for more information.
This figure provide info ho we can open Java Exception Breakpoint,
I think this should help you:
Window --> Preferences --> Java --> Debug
Uncheck the following:
Suspend exceution on uncaught exceptions
Suspend exceution on compilation errors
Open popup when suspended on exception
Click on Apply & then OK.