There is a nice hack in eclipse, that I can use "printpoints" during debugging:
This is especially useful if I have a threading issue, and I would change the behaviour of my program with a breakpoint, which stops the execution.
I tried the same in IntelliJ, and it does not work. Do I do something wrong?
Right click on the red breakpoint circle by the line number, click on 'more' at the bottom of the popup, you can then either log a fixed message to the console when that line is hit, or log an evaluated expression
Related
I just installed eclipse, but idk if something is wrong with the config or something.
I ran a simple test code that runs perfect, but I can't use the debug option. I installed the eclipse in my main pc and a laptop, but in both, debug work like the "run", running the code completely without allowing step option like it should, it doesn't even switch to the debug perspective or enable the options of step into step over....
Here is an img after pressing the debug
(cant post a img yet, so here is the direct link)
https://i.imgur.com/p09IznQ.png
hopefully, you guys can help me
Your app finishes instantly. To start debugging, you have to pause execution first, and you can't get there because this app is simple enough to get done in milliseconds. Click in the left margin somewhere near the 'top' of execution (such as: the first line of the main method), or double click - you want a green dot to appear (indicating a breakpoint). That'll cause a pause and then you can do all the stuff you wanna do. The debug view opens automatically on hitting a breakpoint, not on hitting the debug action. It's more convenient that way.
On the right, we can see something going on, and after it is done, it shows "x error found".
What is this exactly? Java compiler? Lint tool? Build-in analysis?
The problem is, when file gets large, it is hard to find out where the error is.
I know we can use F2 to navigate, but it also navigates to warnings. It would be nice to have a window showing all the errors in one place. Where is the navigation window for "x error found"?
Thanks for Vucko's answer. I didn't know it is clickable. Really appreciate it. But, I have to click that, hover my mouse over the codes, then wait for the error details to pop up, which costs lots of time. Also, warning is clickable, which is annoying. I still prefer a window.
Just Figured it out by myself.
After we Build > Make Project, Messages window pops up. All the errors show up here. We can click on each error to navigate to the corresponding file and location, or copy it to search on Google.
It is most likely Java compiler. Somehow it compiles on the fly. But, sometimes it is not reliable just like Instant Run is not reliable. If it becomes inconsistent with Messages window, try to restart Android Studio.
Never mind how big the file is, you can simply find the error by clicking the horizontal red line below. Every error will have it's own line and by clicking on it, you will be taken to that line immediately.
See the image for better understanding of what I mean:
Note: This is quite a useful tool for some other stuff as well, for example warnings will be shown and colored in orange (every color is customizable of course), and if you're using version control, e.g. Git, your changes will be colored in blue/green for edits/additions respectively.
I know we can use F2 to navigate, but it also navigates to warnings.
You can right-click on the scrollbar and select this option.
Go to high priority problems only
Have you tried filtering Logcat to Error? Like this:
Try Analyze --> Inspect code this will give you all your error with line number. it will even show typo
I'm debugging a normal Java application, no GUI, just a lot of computations and ~5 calls in the stack for the main thread when the problem occurs. Basically it keeps saying "Collecting data" in the local variable watch.
So instead of going step-by-step I've tried to add a breakpoint immediately after an press "Resume". Now it says "Waiting until last debugger command completes".
Have anyone had this problem before? Is changing the debugger the only way to figure this out?
On IntelliJ (2017.1.4 Community Edition), the following fixed the problem for me:
File->Settings
Type in "toString"
Navigate to Build, Execution, Deployment->Debugger->Data views->Java
Find the "Enable 'toString()' object view:" checkbox
Uncheck the box
Re-run the debugger.
The following fixed it for me on IntelliJ 2018.2.4:
Right click breakpoint
Toggle the setting to suspend "Thread" instead of "All"
This won't be helpful if you actually need to suspend all the threads for debugging, but it got rid of the "Collecting data..." and "Waiting until last debugger command completes" messages for me. The setting also persists for subsequent breakpoints, so you only need to change it once.
I just ran into what looks like the same issue. In my case it was a class (KafkaStream) in the breakpoint stack trace with a "bad" toString method. The toString method blocks and therefore hangs the debugger. I tested the toString method in the main line code and it hung the main thread (i.e. this is not a debugger specific issue).
Here is the stack trace for my thread that hit the breakpoint (on a line that was just trying to test a boolean attribute of my class):
Intellij provides a way to work around for my issue. It allows you to override how the debugger renders the class:
If your issue comes back I suggest taking a thread dump (inside or outside of the IDE) and see what your thread is doing.
In most cases, it would be because of the watches that you add while debugging.
Clear the watch statements that would result in recursive execution of same statements as in the code.
Always keep the watches clean before debugging.
It happened to me once (on version 2020.3.3) and "Invalidate Caches" and restart solved it.
The fix that worked for me was to remove method breakpoints. That made it superfast.
Ive been debugging a project in eclipse. I inserted a breakpoint on a while statement. All was working fine, I was monitoring the variable increments. I tried to change the test class, but forgot I was still running the program, a message popped up and asked a question (I can't remember the exact phrasing) and I clicked terminate. But now when I run the debugger, it runs through the program and gives me the following
<terminated, exit value: 0>
But it doesn't allow me to step through the program. I tried "skip all breakpoints" but that isn't the answer.. It has something to do with the pop up message I'm pretty sure.
Many Thanks for your help
Probably the debugger skips all breakpoints.
Hit the search button in the top right corner
Type skip all breakpoints
Click the result.
Debugger shall be working from now on.
I had the same issue earlier, I have found the answer on youtube :)
Since upgrading Eclipse (Galileo build 20090920-1017), hover in debug no longer displays a variable's value. Instead, hover behaves as if I were in normal Java perspective:
alt text http://michaelzanussi.com/wp-content/uploads/2009/11/debug_hover.png
I've tried cleaning the project, re-importing it, etc., all to no avail. Anything I'm missing here?
I went to Window - Preferences - Java - Editor - Hovers, hit "Restore Defaults" and "Apply" and that fixed it for me, even though nothing actually changed in the settings...
Go to Window - Preferences - Java - Editor - Hovers.
Is "Combined Hover" selected? Uncheck it; apply; close the window; restart debugging session; go back; check it again; apply.
If the above doesn't help, you can check "Variable Values" option and specify a modifier key for it. Not as convenient as "combined", but should work.
I had this problem too once, I "just" had to restart eclipse, after that the hover mechanism worked again.
The problem was "fixed" by renaming the package.
For whatever reason, this refactoring triggered something in Eclipse, and immediately I was able to view variable values during debugging. Also, when I go back into Preferences under Hovers, I can now see the "Variable Values" option.
I had a similar issue and when I came across this question. My problem was that windows hover time was set to 20s or so (you can test if this is your problem by putting the mouse on a mistake and waiting for a min or so). The registry key "MouseHoverTime" was set to a large value of 200000 ms (normally 400). Fix it by going to start -> run -> "regedit" -> HKEY_CURRENT_USER\Control Panel\Mouse double click "MouseHoverTime" and setting it back to 400.
I think this had been done on my computer a while back to prevent hover popups in another program. Anyway, sorry that my answer doesn't directly apply to this question, but I'm hoping it'll help somebody like me that comes across this thread with a similar issue.
For C++ project, please add -ggdb -0g to the compiler option. Hope this solution can help eveyry C++ programer face with the same issue.