Skip to content

Commit 4606aab

Browse files
authored
Merge pull request Unity-Technologies#7 from joncham/non-env-var-enable
Enable mixed call stacks when debuggee loads a mono-2.0* dynamic libr…
2 parents ca7e42e + e95777a commit 4606aab

3 files changed

+10
-15
lines changed

UnityMixedCallstack.vsdconfigxml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<NoFilter/>
1313
<Interface Name="IDkmCallStackFilter"/>
1414
<Interface Name="IDkmLoadCompleteNotification"/>
15+
<Interface Name="IDkmModuleInstanceLoadNotification"/>
1516
</InterfaceGroup>
1617
</Implements>
1718
</Class>

UnityMixedCallstackFilter.cs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@
1111

1212
namespace UnityMixedCallstack
1313
{
14-
public class UnityMixedCallstackFilter : IDkmCallStackFilter, IDkmLoadCompleteNotification
14+
public class UnityMixedCallstackFilter : IDkmCallStackFilter, IDkmLoadCompleteNotification, IDkmModuleInstanceLoadNotification
1515
{
1616
private static List<Range> _rangesSortedByIp = new List<Range>();
1717
private static FuzzyRangeComparer _comparer = new FuzzyRangeComparer();
18-
private static bool _enabled = true;
18+
private static bool _enabled;
1919
private static IVsOutputWindowPane _debugPane;
2020
private static string _currentFile;
2121
private static FileStream _fileStream;
2222
private static StreamReader _fileStreamReader;
2323

2424
public void OnLoadComplete(DkmProcess process, DkmWorkList workList, DkmEventDescriptor eventDescriptor)
2525
{
26-
_enabled = true;
2726
DisposeStreams();
2827

2928
if (_debugPane == null)
@@ -32,14 +31,6 @@ public void OnLoadComplete(DkmProcess process, DkmWorkList workList, DkmEventDes
3231
Guid debugPaneGuid = VSConstants.GUID_OutWindowDebugPane;
3332
outWindow.GetPane(ref debugPaneGuid, out _debugPane);
3433
}
35-
36-
var env = Environment.GetEnvironmentVariable("UNITY_MIXED_CALLSTACK");
37-
if (env == null || env == "0") // plugin not enabled
38-
{
39-
_debugPane.OutputString("Warning: To use the UnityMixedCallstack plugin please set the environment variable UNITY_MIXED_CALLSTACK=1 and relaunch Unity and Visual Studio\n");
40-
_debugPane.Activate();
41-
_enabled = false;
42-
}
4334
}
4435

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

56-
if (!stackContext.Thread.IsMainThread) // error case
57-
return new[] { input };
58-
5947
if (!_enabled) // environment variable not set
6048
return new[] { input };
6149

@@ -190,5 +178,11 @@ private static bool TryGetDescriptionForIp(ulong ip, out string name)
190178
name = _rangesSortedByIp[index].Name;
191179
return true;
192180
}
181+
182+
public void OnModuleInstanceLoad(DkmModuleInstance moduleInstance, DkmWorkList workList, DkmEventDescriptorS eventDescriptor)
183+
{
184+
if (moduleInstance.Name.Contains("mono-2.0"))
185+
_enabled = true;
186+
}
193187
}
194188
}

source.extension.vsixmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<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">
33
<Metadata>
4-
<Identity Id="UnityMixedCallstack.mderoy.1bc395e8-c1ea-4a2d-8a37-19e7f0c302b9" Version="2.1" Language="en-US" Publisher="Jb Evain, Michael DeRoy, Jonathan Chambers" />
4+
<Identity Id="UnityMixedCallstack.mderoy.1bc395e8-c1ea-4a2d-8a37-19e7f0c302b9" Version="2.2" Language="en-US" Publisher="Jb Evain, Michael DeRoy, Jonathan Chambers" />
55
<DisplayName>Unity Mixed Callstack</DisplayName>
66
<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>
77
</Metadata>

0 commit comments

Comments
 (0)