Skip to content

Fix for vscode-powershell #837 callstack missing line info. #508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 11, 2017

Conversation

rkeithhill
Copy link
Contributor

This PR addresses two bugs. First the missing line info was due to use passing back null when we didn't have end line/col info. The protocol claims that should work. But when I changed the end line/col to reflect the same values as the start line/col (assuming the end values were null - not set) then the callstack started to display the line info. It is a bit weird but the very first frame in some cases contains a col other than 0.

The second bug was that the call stack was getting duplicated. I implemented the new stackTraceRequest for paging stack frames back to VSCode and now that bug is fixed.

I tried to implement StackFrame.PresentationHint == "subtle" for script outside the initial working directory. Do you have a better way to get the workspaceRoot path in the debugger? I had to cache the working dir when SetWorkingDirectory() gets called. And when you attach to a process, there isn't a way to set the "cwd".

Finally, I ran into one bug I'll file later that has to do with the base of the call stack sometimes showing " 1". If you click on that you get an error telling you can't be opened.

This PR addresses two bugs.  First the missing line info was due to use passing back null when we didn't have end line/col info.  The protocol claims that should work.  But when I changed the end line/col to reflect the same values as the start line/col (assuming the end values were null - not set) then the callstack started to display the line info.  It is  a bit weird but the very first frame in some cases contains a col other than 0.

The second bug was that the call stack was getting duplicated.  I implemented the new stackTraceRequest for paging stack frames back to VSCode and now that bug is fixed.

I tried to implement StackFrame.PresentationHint == "subtle" for script outside the initial working directory.  Do you have a better way to get the workspaceRoot path in the debugger?  I had to cache the working dir when SetWorkingDirectory() gets called.  And when you attach to a process, there isn't a way to set the "cwd".

Finally, I ran into one bug I'll file later that has to do with the base of the call stack sometimes showing "<ScriptBlock> <No File> 1".  If you click on that you get an error telling you <No File> can't be opened.
@rkeithhill rkeithhill added this to the June 2017 milestone Jun 11, 2017
@@ -43,7 +63,7 @@ public class StackFrameDetails
/// <summary>
/// Gets the line number of the script where the stack frame occurred.
/// </summary>
public int EndLineNumber { get; internal set; }
public int? EndLineNumber { get; internal set; }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that Get-PSCallStack doesn't return any info about end line/col it seems like these values should be nullable (even though I'm setting them to startLine / 0 respectively).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it's clearer if the contract is that those values may not be populated.

@daviwil
Copy link
Contributor

daviwil commented Jun 11, 2017

Looks like there are a couple missing XML comments causing the build to fail:

Debugging\StackFrameDetails.cs(11,17): error CS1591: Missing XML comment for publicly visible type or member 'StackFramePresentationHint' [C:\projects\powershelleditorservices\src\PowerShellEditorServices\PowerShellEditorServices.csproj]
Debugging\StackFrameDetails.cs(115,20): error CS1573: Parameter 'workspaceRootPath' has no matching param tag in the XML comment for 'StackFrameDetails.Create(PSObject, VariableContainerDetails, VariableContainerDetails, string)' (but other parameters do) [C:\projects\powershelleditorservices\src\PowerShellEditorServices\PowerShellEditorServices.csproj]

string moduleId = string.Empty;
var presentationHint = StackFramePresentationHint.Normal;

var invocationInfo = callStackFrameObject.Properties["InvocationInfo"].Value as InvocationInfo;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested this with remote debugging? Sometimes these objects come back as a weird serialized type that will cause issues.

/// Gets the working directory path the PowerShell context was inititially set when the debugger launches.
/// This path is used to determine whether a script in the call stack is an "external" script.
/// </summary>
public string InitialWorkingDirectory { get; private set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now, we'll come up with a better way to get the workspace path soon.

@daviwil
Copy link
Contributor

daviwil commented Jun 11, 2017

Thanks for implementing the new stack frame behavior too! Feel free to merge after the XML comment issues are fixed.

@daviwil daviwil modified the milestones: June 2017, 1.3.2 Jun 11, 2017
…area better.

Handle possibilty of there not being a InvocationInfo property on a PSObject.
@rkeithhill rkeithhill force-pushed the rkeithhill/fix-callstack-missing-line-info branch from 0b77e6f to 792787b Compare June 11, 2017 23:29
@daviwil
Copy link
Contributor

daviwil commented Jun 11, 2017

Thanks man!

@daviwil daviwil merged commit 9a9e2b8 into master Jun 11, 2017
@daviwil daviwil deleted the rkeithhill/fix-callstack-missing-line-info branch June 11, 2017 23:43
@daviwil
Copy link
Contributor

daviwil commented Jun 11, 2017

Fixes PowerShell/vscode-powershell#837

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants