Step request in VS Code extension not rendering correctly - visual-studio-code

I am working on an extension/debugger and I am having a problem with step debugging. I have implemented the nextRequest method in my debug adapter and it calls my internal debugger to initiate the step request, then returns the response. I have an event handler that gets notified when the step request is processed and this in turn sends a StoppedEvent of type step to VS Code.
The problem I have is that VS Code reacts to the StoppedEvent by requesting the threads and the stack frames, but it does not render the "stopped" indicator (yellow arrow) at all, so the user has no visual indication that the step succeeded (other than the yellow arrow from the breakpoint disappearing). I'm thinking VS Code may not be getting the right file or line number, but I checked that these are set correctly in the frames I return in the response to stackTraceRequest. I'm not sure what I'm missing here.

This was my mistake. The paths sent were being computed slightly differently form the paths sent at breakpoint events, which is why it worked for breakpoints but not for step events.

Related

Navigate To at start up simulation

When I run the model, I want my model to go to the viewarea of the simulation parameters in the agent of this user interface. So at the simulation and java actions I added this by the next code (also a screenshot is added at the bottom):
root.uI_startUP.SimulationParameters.navigateTo();
The strange thing is when I run the model for the first time, he goes for like 1 second to this view area, but then automatically returns to the main agent. When I stop the model and restart it again (and keep the run window open), this problem is not happening and it is staying in the good user-interface agent view area.
What could be the reason behind this? and how can this be solved.
Added later:
At the moment I fixed it by creating an event which is triggered by the variable start==true, and after that navigates to the interface and sets this value to false. see figure below
This works, and seems to be a solution.
But I'm still curious why the first method is not working..
Seems to be the code in "Initial experiment setup" that messes here.
Remove both code snippets and only call uI_startUP.SimulationParameters.navigateTo() on the "On startup" of Main.
This is how you should do it anyway :)

Way to update user while code is executing?

I'm creating a SwiftUI multiplatform app in XCode and I have a section of my code that hangs. I want to update the user so they know what's happening and are willing to wait. I originally planned to have an alert with text that changed and then planned to have a Text element that updated. In both cases this isn't shown until after the code executes and as such only shows the final message (normally the success done message unless an error made it end sooner).
Is there anyway I can have a visible message to the user through an alert or SwiftUI element that is updated right away and thus will be helpful?
The fact that the alert isn't even shown until after the code executes is bad and incorrect. This suggests that you are doing something lengthy on the main thread, and that is an absolute no-no. You are freezing the interface and you risk the WatchDog process crashing your app before the user's very eyes. If something takes time, do it in the background.

Issue with setting AutomationElement value

I have an issue with setting value of AutomationElement by using method ValuePattern.SetValue().
Everything works just fine until some dialog appears. When the dialog appears the code execution got stuck. No exception is thrown. After the dialog is confirmed, the code exection continues. Bellow is a sample of the code:
BasePattern basePattern = null;
ValuePattern valuePattern = null;
AutomationElement elementA = Window.GetElement(SearchCriteria.ByText(propertyName));
object patternObjectA = null;
elementA.TryGetCurrentPattern(ValuePattern.Pattern, out patternObjectA);
basePattern = (BasePattern)patternObjectA;
valuePattern = (ValuePattern)patternObjectA;
valuePattern.SetValue(optionToSet);
// Window.GetElement() is a method from TestStack.White framework
// The code execution got stuck on the last line until the dialog is confirmed
Is there any other way to set AutomationElement value?
Is somehow possible to avoid of getting stuck by dialog?
I'll by grateful for any help.
Thanks advance.
It could be that this dialog is not supporting UI Automation correctly or that you simply target the wrong element.
To verify that you may use Inspect.exe from Microsoft or similiar tools.
If it works, check if you really target the correct component with your code again.
If it does not work and:
if you are able to change the application
you can change the so called AutomationPeer of the UI component - here is a link for more infos
Or simply use another UI component that supports UI Automation correctly.
if you are not able to change the application, and also do not need to run in background, parallel, etc.. you might just focus the component (call setFocus() onto the AutomationElement, or expand it (via IsExpandCollapsePatternAvailable or simulated MouseClick onto the components coordinates)) and then use the SendKeys.SendWait("test") method.
EDIT: There is one more thing you should have a look at, and I wonder why I didn't mentioned it in the first place: Register to UI Automation Events
For example you could register a callback for the Structure change event type, and check if the dialog you talk about appeared.
If so --> click the confirmed button of the dialog.
Probably you will have to synchronize your execution, so that every further action in the UI Automation script waits until the registered callback got executed and the confirmed button got clicked.

utilReplaceInResponse not showing changes in the browser

Working in FiddlerScript, I've got some changes being made in the OnBeforeResponse method that used to work on a different machine (now long gone) but aren't working for me now. I've boiled it down to the following basic example.
On the fiddler sandbox page, I'm trying to replace the word per item with the words per item URL: http://webdbg.com/sandbox/shop/
Fiddler script file modified from the original to have two new lines. 1 to decode the session and 1 to replace in the response as per all examples I've seen and what used to work for me.
static function OnBeforeResponse(oSession: Session) {
oSession.utilDecodeResponse(); //Added this.
oSession.utilReplaceInResponse("per item", "per item"); //Added this
if (m_Hide304s && oSession.responseCode == 304) {
oSession["ui-hide"] = "true";
}
}
After saving the above fiddlerscript file and refreshing the page, I'm not seeing the replaces show in the browser. If I look in the Fiddler inspector, I am seeing the replaces. This means that the OnBeforeResponse is indeed being called at some point and the utilReplaceInResponse is also executing.
Additional oddity, if I put breakpoints after all responses (Fiddler -> Rules -> Automatic Breakpoints -> After Responses) and refresh the page, the response hits the breakpoint as expected and I click Run to Completion and the browser does show the replacement. So: No breakpoint, page doesn't show replacements in the rendered page. With breakpoint and simply running to completion, the page does show the replacements.
Why isn't the page showing the changes in the browser even though it shows them in the Fiddler inspector, or if I have a breakpoint set?
.
SOLUTION Had the Stream option selected in the main toolbar - deselected that and it works as expected.
.
Environment: Fiddler v2.4.5.3 - 64-bit AMD64, VM: 114.00mb, WS: 132.00mb .NET 2.0.50727.5472 WinNT 6.1.7601 SP1
Seen on both IE9 and Chrome31
Solved myself.
I had the Stream option enabled in the toolbar. (Doh!) De-select that and the replacement in the OnBeforeResponse works as expected.
It may be a new Fiddler version feature, but I had to add the following line to get my find/replace to work:
oSession.utilDecodeResponse();

Xcode/iPhone -- break when the next event enters my code?

I am working on a large (>30k lines) event-driven app. I have a sequence of inputs that produces a bug. What I want to do is to break as soon as the final input enters my code.
Is there a general way to do that?
I understand that for any specific sequence of inputs, I can find out where that last input is going to enter my code, then set a breakpoint there. What I would like to do is take out the step of "find out where that last input enters my code." In other words, I am running the app in the simulator, and I want to set a flag somewhere that says "break the next time you are going to enter non-system Objective C code." Then I send the event that causes the problem.
I understand what you are asking, but have you tried using an Exception Breakpoint? This will basically act like an auto-inserted breakpoint on the piece of code that throws the exception. If that doesn't work for you, try a symbolic breakpoint
If you want to intercept UI events, you can try subclassing UIWindow and overriding its sendEvent: method, then setting this class as the class of the UIWindow object in your main XIB file. sendEvent: will be called each time the user generates a touch event. Unfortunately, at this point you cannot yet know which UI object will finally consume the event (read: which event handler code will be ultimately called) since that depends on the actual state of the responder chain. But anyway, you can use this method to inject events into the system.