Does IntelliJ or VSCode have the ability to set breakpoints that do not halt execution, instead taking a snapshot of stack/vars that you can view? - debugging

I'm currently on a team developing a Slack bot, we've begun the classic console.log debugging strategy and our log output is already getting extremely bloated. A team lead mentioned breakpoints and I decided it would probably be a good idea to start using them but there is a problem:
Slack bots are sometimes responding to requests in a time-sensitive manner. For instance, when opening a modal you only have 3 seconds following a user action to open the modal, clearly any breakpoint that halts execution before the modal is opened would cause problems.
Thinking about it, it seems like something that /should/ be possible. When reaching the breakpoint simply take the stack/vars that would be displayed and store/display them without halting execution. Unfortunately, 90% of the time I think "this should exist", it doesn't.

Well, I guess I could just google it huh?
IntelliJ - Tracepoint
VSCode - Logpoint

Related

LUIS testing freezing, becoming unserponsive

I've been trying to use batch testing to test my luis app and have been experiencing an annoying bug. Basically the LUIS app page will become unresponsive while the batch testing window is open.
The most similar issue I've seen can be found here: LUIS web interface crashed after import JSON file for Batch Testing or Import App, with no answer yet.
My problem is also slightly different by the looks of it.
Experimenting has yielded the following results:
I can upload, test and view the results of 1 batch successfully sometimes. Sometimes the page will become unresponsive while I am looking at the results.
If I have successfully viewed the batch, but then close the batch testing window without deleting the batch, the next time I open the window the whole site will become unresponsive.
Recently opening the "Inspect" tab on the single utterance testing window has also begun making the page unresponsive.
I can submit images if needed, but the pages seem more or less the same after the bug has occurred, they simply stop working. Pressing buttons does nothing and I need to refresh the page if I want to get back to the bot's Dashboard/Build/Publish/Settings page.
The app has 18 intents, 12 entities, and a couple hundred utterances. I have tested it on a collaborator account and the bugs seems to occur there too. Not sure what other info might be relevant.
If anyone has experienced similar issues and can help I'd appreciate it. Being able to use the built in Batch Testing feature would be very useful.

Visual Studio delays when Start Without Debugging on a console application

Recently my Visual Studio started to experience a delay before the program Starts Without Debugging.
This happens only when the following are met:
Console application
Start Without Debugging
There has been any change in the editor window from the last time program run.
After pressing Ctrl+F5 console application window opens and the cursor is active, but the execution is delayed.
The delay seems to be consistent in length (7-10 seconds), and not depend on the size of the code. I have checked two different installations of VS (2013 and 2015) on the same computer and the problem persists.
I have also checked that this delay occurs even for an empty Main().
There is a possibility that I have enabled some kind of an option/function in VS that causes this very specific delay, but I am not sure when this issue started occurring so I cannot trace back the change.
What could be the reason for this delay?
I will be grateful for help in this matter.
I made many attempts to diagnose the issue of the delay and one of the times that I pressed ctrl + F5 I have spotted a window opening in the background.
(It was definitely not visible everytime i tried to run without debugging).
It turns out that a functionality of Avira anti-virus had been scanning the code before it run for the first time. That is why when I made no changes to the code there was no delay.
Avira "Protection Cloud" is the name of the functionality responsible for the delays.
Link to Avira page about it and how to disable it: https://www.avira.com/en/support-for-home-knowledgebase-detail/kbid/1514
Sometimes if I have multiple editting windows open, this slows starting and stopping the debugger. Close all but those you are interested in and try again.

Windbg break-in takes very long time

I want to capture a stacktrace of an application which sometimes stops responding for few minutes.
When the application stops responding, the windows desktop also stops responding to mouse clicks, although some other already running applications are working fine at that time (for example windbg works fine, ProcessExplorer refreshes its screen, but does not respond to mouse events).
While the application is non responsive, it is actually taking about 80% of one CPU core. That is why I would like to get a stacktrace.
The misbehaving application usually takes about 2-3 minutes to do its strange job or if Ctrl+Esc is pressed it becomes responsive immediately (and the start menu opens of course...)
I have WinDbg attached to the misbehaving application and when I issue the Break command, the break-in does not happen until the application starts to respond again.
From what I understand the break-in actually creates a remote thread which pretty soon calls DbgBreakPoint.
What could be preventing debugger's thread from executing?
EDIT:
First of all thanks for your help!
I was also thinking that this might be caused by a bad device driver or something that installs a system wide hook somewhere.
I was thinking to enable kernel debugging and get a stack trace from the kernel for the offending thread or enable manual bluescreen trigger to produce a dump and look at that afterwards.
Process Explorer and Process Monitor does not reveal anything interesting. They also become unusable when the bug is triggered (updating their windows but not responsive to mouse or keyboard).
EDIT2:
Background info:
App uses QT, OpenGL and also DirectSound and runs on Windows 7 SP1 x64
I am currently suspecting something with the graphics part.
The strange thing is that if a system-wide lock is taken (like GDI Lock), this would prevent drawing of other Windows, but that does not happen. WinDbg on same machine works fine. ProcessExplorer updates but does not receive mouse clicks, Desktop updates but no mouse clicks.
I currently have a kernel debugger attached...
EDIT3
ETW was most useful for debugging. It turns out that Qt's main event processing loop goes crazy. PeekMessage and MsgWaitForMultipleObjectsEx (with 0 timeout) gets called in a tight loop. That is where the high CPU usage comes from.
It looks like the App is generating/getting loads of messages at that time. But it is not easy to see what the messages are (or I don't know how to access function parameters in ETW). Using a debugger also does not help much but, with a breakpoint in the QT's event loop leads me to believe that WM_TIMER messages are the culprit.
Given that the desktop also misbehaves during this time, it sounds like your app isn't necessarily misbehaving but merely aggravating a bug elsewhere (e.g., in a device driver or some crummy anti-malware code that has injected itself into other processes). Stack traces from your app may or may not be very revealing.
If the problem is easily reproducible, I'd set a breakpoint somewhere in the "middle" of the app and see if the problem happens before or after that. Then move the breakpoint until you find the last instruction your app executes before things go bonkers. Figuring out what your app does that triggers this behavior may give a clue as what's going on.
Another option is to try using some system-wide debugging tools. First, I'd peak in the Event Viewer to see if there are suspicious error or warning events posting in proximity to the moment the machine goes haywire. Then I'd try a tool like Sysinternal's Process Monitor or Process Explorer to get a better view of what's happening. You might also try ETW to capture a system-wide trace of what's happening on the system that you can study after the fact. (ETW can be hard to use, so check out Bruce Dawson's UIforETW.)
Use ETW to find the cause. Install the Windows Performance Toolkit (part of the Win10 v1511 SDK: https://go.microsoft.com/fwlink/p/?LinkID=698771 which is the last version that works in Win7), run WPRUI.exe, select CPU Usage and click on Start.
After you captured the hang, click on Save. Wait until WPRUI is finished, open the ETL in WPA, setup and load debug symbols in WPA.
Drag & Drop the CPU Usage (Precise) graph to analyse pane and look for WAIT (µs) max for your process to see that long hang and expand the stack to see where it happens.

How to find out more about Application Hang event?

If a VB6 app is causing an Application Hang event to appear in the Event Viewer, how can I find out more about why the application is hanging?
Does an Application Hang event mean that the app has frozen and crashed, or just that it temporarily hangs?
All I get in the event log for this event is:
Hanging application [MyAppName].exe, version [MyAppVersionNo], hang module hungapp, version 0.0.0.0, hang address 0x00000000.
That is not enough and I want to be able to find out more about why it is hanging. What code changes or other steps need to be taken to cause the app to provide more details in the event log?
I recommend using the Windows Performance Toolkit. The best version to use is in the Windows Assessment & Deployment Kit, http://www.microsoft.com/download/en/details.aspx?id=28997
Once it's installed, what you do is start up Windows Performance Recorder (WPR) and click the Start button to begin recording. Next, reproduce the problem with your app. Then go back to WPR and press the Save button. Next, load up Windows Performance Analyzer and open that *.ETL file that was generated. Then you want to go to System Activity section in the Graph Explorer, expand it, and find the UI Delays graph (or it might be the first graph parked on System Activity). Double click on it to get the detailed version in an Analysis tab.
Once you find the UI delay you're interested in, you can add another graph such as CPU Usage (Sampled) from the Processing node in Graph Explorer. When the two graphs are in the same Analysis tab, their scrolling and selection will be synchronized. So you can click on the UI delay event and it will also highlight the corresponding range in CPU Usage.
The Application Hang event means that Windows has decided that the application is unresponsive. Since the event is generated by the operating system and not the application, your options for getting additional information in the event are extremely limited.
This is what seems to be available on an Application Hang event:
Message: Hanging application %1, version %2, hang module %3, version %4, hang address 0x%5.
From:
http://www.microsoft.com/technet/support/ee/transform.aspx?ProdName=Windows+Operating+System&ProdVer=5.2&EvtID=1002&EvtSrc=Application+Hang&LCID=1033
If you believe the cause of the event is something that your application does (as opposed to something in the environment where the application is running), then instead of trying to pass info to the hang event, you should raise the level of log info to debug mode and look in your application's log file to see what it is doing just prior to becoming unresponsive.
If you lack logging information, or a logging framework in your application, then that is where you should be focusing your efforts. The upside is that you will benefit from better logging in the future as well. Use a logging framework however, so you can disable debug level logging in a production environment, when everything is running smoothly.
I would approach this by reviewing the code in the module that Windows has determined has hung, the name of which was written to the event log. Attempting to get more detail in the hang event will not be possible because when Windows has determined the app is unresponsive, it is too late.
Into the module that is hanging I would add multiple calls to DoEvents as well as logging status messages directly into the EventLog. Adding a logging framework at this point would introduce complexity and involve either a database or file access in which to store the logs.
Windows thinks the app has hung because it has stopped responding to messages. Unfortunately, implementing a second thread in your VB6 app is not trivial, unlike .NET. Never-the-less, adding another thread would keep the app responsive, but then you would likely still be left with answering the question, "why is the code taking so long to execute?"
Getting information from windows event perspective will not help. Try to have tracing in your application which helps you to get the exact cause.

App crashes when being resumed

My wp7 app crashes when I come back from a task such as Map, Call or Web Browser. Infact, if i lock my phone and resume it again, still it crashes. Please tell me what could be the problem and how can I remove it?
There is a problem with you code.
Remove the application off the phone by starting a new emulator instance.
Open App.xaml.cs
Put a breakpoint in the method RootFrame_NavigationFailed and Application_UnhandledException
Now use the CallStack to find the root of the issue.
With no code posted (and in your case it could be ANYTHING in the project) you will be the best person to resolve your issue. If you can post a small reproduction on here we can take a look.
In application exit methods you probably should restore the data you dealt with last time before you quited

Resources