Skip to content

Enable mixed call stacks when debuggee loads a mono-2.0* dynamic libr… #7

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 1 commit into from
Jan 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UnityMixedCallstack.vsdconfigxml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<NoFilter/>
<Interface Name="IDkmCallStackFilter"/>
<Interface Name="IDkmLoadCompleteNotification"/>
<Interface Name="IDkmModuleInstanceLoadNotification"/>
</InterfaceGroup>
</Implements>
</Class>
Expand Down
22 changes: 8 additions & 14 deletions UnityMixedCallstackFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@

namespace UnityMixedCallstack
{
public class UnityMixedCallstackFilter : IDkmCallStackFilter, IDkmLoadCompleteNotification
public class UnityMixedCallstackFilter : IDkmCallStackFilter, IDkmLoadCompleteNotification, IDkmModuleInstanceLoadNotification
{
private static List<Range> _rangesSortedByIp = new List<Range>();
private static FuzzyRangeComparer _comparer = new FuzzyRangeComparer();
private static bool _enabled = true;
private static bool _enabled;
private static IVsOutputWindowPane _debugPane;
private static string _currentFile;
private static FileStream _fileStream;
private static StreamReader _fileStreamReader;

public void OnLoadComplete(DkmProcess process, DkmWorkList workList, DkmEventDescriptor eventDescriptor)
Copy link

Choose a reason for hiding this comment

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

Future Cleanup: We could probably remove this window stuff, unless we're planning on logging things to the output window.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about it, but I see we log other info there as well.

{
_enabled = true;
DisposeStreams();

if (_debugPane == null)
Expand All @@ -32,14 +31,6 @@ public void OnLoadComplete(DkmProcess process, DkmWorkList workList, DkmEventDes
Guid debugPaneGuid = VSConstants.GUID_OutWindowDebugPane;
outWindow.GetPane(ref debugPaneGuid, out _debugPane);
}

var env = Environment.GetEnvironmentVariable("UNITY_MIXED_CALLSTACK");
if (env == null || env == "0") // plugin not enabled
{
_debugPane.OutputString("Warning: To use the UnityMixedCallstack plugin please set the environment variable UNITY_MIXED_CALLSTACK=1 and relaunch Unity and Visual Studio\n");
_debugPane.Activate();
_enabled = false;
}
}

public DkmStackWalkFrame[] FilterNextFrame(DkmStackContext stackContext, DkmStackWalkFrame input)
Expand All @@ -53,9 +44,6 @@ public DkmStackWalkFrame[] FilterNextFrame(DkmStackContext stackContext, DkmStac
if (input.InstructionAddress.ModuleInstance != null && input.InstructionAddress.ModuleInstance.Module != null) // code in existing module
return new[] { input };

if (!stackContext.Thread.IsMainThread) // error case
return new[] { input };

if (!_enabled) // environment variable not set
return new[] { input };

Expand Down Expand Up @@ -190,5 +178,11 @@ private static bool TryGetDescriptionForIp(ulong ip, out string name)
name = _rangesSortedByIp[index].Name;
return true;
}

public void OnModuleInstanceLoad(DkmModuleInstance moduleInstance, DkmWorkList workList, DkmEventDescriptorS eventDescriptor)
{
if (moduleInstance.Name.Contains("mono-2.0"))
_enabled = true;
}
}
}
2 changes: 1 addition & 1 deletion source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="UnityMixedCallstack.mderoy.1bc395e8-c1ea-4a2d-8a37-19e7f0c302b9" Version="2.1" Language="en-US" Publisher="Jb Evain, Michael DeRoy, Jonathan Chambers" />
<Identity Id="UnityMixedCallstack.mderoy.1bc395e8-c1ea-4a2d-8a37-19e7f0c302b9" Version="2.2" Language="en-US" Publisher="Jb Evain, Michael DeRoy, Jonathan Chambers" />
<DisplayName>Unity Mixed Callstack</DisplayName>
<Description xml:space="preserve">Visual Studio native debugger extension to help debug native applications using Mono. Originally developed by Jb Evain, Updated for Unity by Michael DeRoy and Jonathan Chambers</Description>
</Metadata>
Expand Down