VS Code / Dart - Variable inspector shows error string - flutter

When trying to inspect variables for a Flutter project in VSCode, it is often the case the inspector shows nothing of use. For instance, below we have a variable x of some type. There are no runtime errors but when setting a breakpoint, the inspector simply shows the following for the value of x.
<function errorString(error) {>
The meaning of this is elusory since there is no related output in the debugging console. The breakpoints are being set within calls to Futures returning functions but it's hit and miss as to why most, but not all, variables cannot be inspected.
What do these error strings mean?
How can the root cause be determined (think stack traces in VS Pro)?
Why do they only show in break points but don't seem to affect runtime output?
How can the actual resolved state of the variable be inspected?

This was a bug in the Dart VS Code extension that has now been resolved:
https://github.com/Dart-Code/Dart-Code/issues/3840
Now the proper error message should be shown instead of the implementation of a function.

Related

VS code Dlang: can't change build config

I am giving D a shot with the VS code extension code-d. Everything works fine, except that I can't switch configuration, arch type or build type. If I try to do any of these things, I receive the following output message in code-d & serve-d:
{"code":-32602,"data":null,"message":"`params` MUST be an object (named arguments) or array (positional arguments), other types are not allowed by spec"}
At this point, I only have a hello world project, as described in the code-d documentation. Am I missing something?
There is a workaround for this. You can use user tasks in vs code. Create user tasks in vs code for each of your build configuration. Then install this extension (https://github.com/actboy168/vscode-tasks). This will pick each of your task and display it in the task bar of vs code. So you only need a mouse click.

Show the value of the property and not just the type

In our dear VS Code when we hover in any variable the vscode by default shows the type of this variable, when it is an object, it shows the structure of the object.
e.g:
I would like to know if in addition to showing the type or structure it is possible to show the value of the properties.
If this is not possible in the vscode itself, is there any extension that does something like this?
The closest you can get to what you want (show variables value), is to add the variable in the debug window to the watch list. In debug mode, when you hit a breakpoint, your watch will evaluate the value at the current time (whether its been set, or not etc.) and will output what it is in that window for you.
See below:

Scala: Setting programatically a break-point to be recognized by IntelliJ

In Visual Studio / C# I can easily set programatically a break-point. Is there any similar feature available for IntelliJ/Scala-Plugin and the Scala language ?
To clarify: In C# you can call an API function
System.Diagnostics.Debugger.Break();
and then the Debugger in VS stops like with any breakpoint, set in the IDE.
I am not aware of such a feature, but in any programming environment you can get away with an adhoc solution: just define a method debugBreak, add a breakpoint to it and then use that. By example:
def debugBreak() {
println("Breakpoint hit!") // Manually set a breakpoint here
}
//.... then somwhere in your code base
if (<<some condition>>) {
debugBreak
}
That's it. Everytime the condition is met, the debugger will stop and you just need to go up the stack one frame.
As an aside, most of the time a better and simpler soluttion is to just set a conditional breakpoint in IntelliJ (essentially pasting your condition expression in the "condition" field). See https://www.jetbrains.com/idea/help/configuring-breakpoints.html.
However sometimes IntelliJ is unable to evaluate your expression, so in those cases the adhoc solution described above is a useful substitute.

Eclipse debug can't find fields

I'm using the Eclipse debugger and can't inspect/watch field values or results of field.method() calls. I've encountered the problem in both Juno and now in Indigo. At first I could resolve the issue by wiping out my .metadata and rebuilding, but now the problem occurs even with a fresh build.
A specific error: I create a Deflater object deflater = new Deflater();,
set some input deflater.setInput(buffer, 0, bufferPosition);,
then try to inspect functionality by highlighting a section of code deflater.needsInput()
and doing a right-click->Inspect. The error reads: "Cannot find the field deflater for the object apps.TestCore$Tests (id=27)".
The error only occurs when the field belongs to an inner class (In this case "Tests"); when the variable is local or the class is not an inner class, everything seems to be working. Hovering over the variable "deflater" shows the contents drill-down just like it should. Highlighting "deflater" and doing an Inspect gives the error, and using the Expressions view to inspect the variable/call methods on the variable gives the same error.
Please help; this is making my debugging life very difficult, as I have to use println() for anything more complex than a hover inspection can provide.
This is not remote debugging - just local to my system.

How to evaluate/watch a variable or method whilst debugging in XCode

I come from a Delphi and .Net background and have just started iPhone development. I just came across a problem whilst debugging.
I had the following code:
if ([displayText rangeOfString:#"."].location != NSNotFound) .....etc
I wanted to evaluate this whilst I was debugging but could not work out how to do it. I found the Expressions window and entered the below but nothing happened:
[displayText rangeOfString:#"."].location
As I'm used to Delphi & .Net (and I know XCode is a different product) its very easy to stick in variables, methods etc into a watch window and then see the result but I cannot see how to do this in XCode. Please can you tell me how I evaluate things whilst debugging??
Thanks
In your case, what you would do is at the debugger is type:
p (NSRange)[displayText rangeOfString:#"."]
You can print out the value of objects with po, but things like C structures have to be printed out with "p" and you have to cast the return types from ObjC calls to the correct struct type.
Also, just putting this in the Expressions window should result in a value:
(NSRange)[displayText rangeOfString:#"."]
In both cases you will see the whole NSRange struct, with location and length.
You can watch variables by going in the debugging drop down in the main menu on top and selecting watch variable. You can also right click and you should see the option "watch variable." Alternatively you can hover your mouse over the desired variable while stepping through your code to see its value at that time