internal readonly IDataReader DataReader;
+ const string DesktopRuntimeModuleName = "clr";
+
private static readonly string s_coreclrModuleName;
private readonly AnalyzeContext _analyzeContext;
internal static bool IsRuntimeModule(ModuleInfo module)
{
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && IsModuleEqual(module, DesktopRuntimeModuleName)) {
+ return true;
+ }
return IsModuleEqual(module, s_coreclrModuleName);
}
<Options>
<Option Condition="$(OS) == Linux">
<SOSPath>$(InstallDir)/libsosplugin.so</SOSPath>
+ <DotNetDumpHost>$(RepoRootDir)/.dotnet/dotnet</DotNetDumpHost>
<DotNetDumpPath>$(RootBinDir)/bin/dotnet-dump/$(TargetConfiguration)/netcoreapp2.1/publish/dotnet-dump.dll</DotNetDumpPath>
<DebuggeeDumpOutputRootDir>$(DumpDir)/$(TestProduct)/$(RuntimeFrameworkVersion)/$(BuildProjectFramework)</DebuggeeDumpOutputRootDir>
<DebuggeeDumpInputRootDir>$(DebuggeeDumpOutputRootDir)</DebuggeeDumpInputRootDir>
<HostExe>$(RepoRootDir)\.dotnet\dotnet.exe</HostExe>
<HostArgs>--fx-version $(RuntimeFrameworkVersion)</HostArgs>
<RuntimeSymbolsPath>$(RepoRootDir)\.dotnet\shared\Microsoft.NETCore.App\$(RuntimeFrameworkVersion)</RuntimeSymbolsPath>
- <SOSPath>$(InstallDir)\sos.dll</SOSPath>
- <DotNetDumpPath>$(RootBinDir)/bin/dotnet-dump/$(TargetConfiguration)/netcoreapp2.1/publish/dotnet-dump.dll</DotNetDumpPath>
</Option>
<!--
Desktop Runtime (debuggees cli built)
<FrameworkDirPath Condition="$(TargetArchitecture) == x64">$(WinDir)\Microsoft.Net\Framework64\v4.0.30319\</FrameworkDirPath>
<FrameworkDirPath Condition="$(TargetArchitecture) != x64">$(WinDir)\Microsoft.Net\Framework\v4.0.30319\</FrameworkDirPath>
<RuntimeSymbolsPath>$(FrameworkDirPath)</RuntimeSymbolsPath>
- <SOSPath>$(FrameworkDirPath)\sos.dll</SOSPath>
</Option>
</Options>
+ <SOSPath>$(InstallDir)\sos.dll</SOSPath>
+ <DotNetDumpHost>$(RepoRootDir)\.dotnet\dotnet.exe</DotNetDumpHost>
+ <DotNetDumpPath>$(RootBinDir)\bin\dotnet-dump\$(TargetConfiguration)\netcoreapp2.1\publish\dotnet-dump.dll</DotNetDumpPath>
<DebuggeeDumpOutputRootDir>$(DumpDir)\$(TestProduct)\$(RuntimeFrameworkVersion)\$(BuildProjectFramework)</DebuggeeDumpOutputRootDir>
<DebuggeeDumpInputRootDir>$(DebuggeeDumpOutputRootDir)</DebuggeeDumpInputRootDir>
</Configuration>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp1.1;netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp1.1;netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp1.1;netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp1.1;netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp1.1;netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp1.1;netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp1.1;netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
<DefineConstants Condition="'$(TargetFramework)' == 'net462'">$(DefineConstants);FULL_CLR</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp1.1;netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
</Project>
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp1.1;netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
</Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework>
- <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp1.1;netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
+ <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
}
}
- // With the dotnet-dump analyze tool
- if (information.TestConfiguration.DotNetDumpPath() != null)
+ // Using the dotnet-dump analyze tool if the path exists in the config file. Don't test dotnet-dump on triage dumps when running on desktop CLR.
+ if (information.TestConfiguration.DotNetDumpPath() != null && (information.TestConfiguration.IsNETCore || information.DumpType != SOSRunner.DumpType.Triage))
{
using (SOSRunner runner = await SOSRunner.StartDebugger(information, SOSRunner.DebuggerAction.LoadDumpWithDotNetDump))
{
ITestOutputHelper dotnetDumpOutputHelper = new IndentedTestOutputHelper(outputHelper, " ");
try
{
- if (string.IsNullOrWhiteSpace(config.HostExe) || string.IsNullOrWhiteSpace(config.DotNetDumpPath()))
+ if (string.IsNullOrWhiteSpace(config.DotNetDumpHost()) || string.IsNullOrWhiteSpace(config.DotNetDumpPath()))
{
- throw new SkipTestException("dotnet-dump collect needs HostExe and DotNetDumpPath config variables");
+ throw new SkipTestException("dotnet-dump collect needs DotNetDumpHost and DotNetDumpPath config variables");
}
// Wait until the debuggee gets started. It needs time to spin up before generating the core dump.
dotnetDumpArguments.Append(config.DotNetDumpPath());
dotnetDumpArguments.AppendFormat(" collect --process-id {0} --output %DUMP_NAME%", processRunner.ProcessId);
- ProcessRunner dotnetDumpRunner = new ProcessRunner(config.HostExe, ReplaceVariables(variables, dotnetDumpArguments.ToString())).
+ ProcessRunner dotnetDumpRunner = new ProcessRunner(config.DotNetDumpHost(), ReplaceVariables(variables, dotnetDumpArguments.ToString())).
WithLog(new TestRunner.TestLogger(dotnetDumpOutputHelper)).
WithTimeout(TimeSpan.FromMinutes(5)).
WithExpectedExitCode(0);
// Turn off warnings that can happen in the middle of a command's output
initialCommands.Add(".outmask- 0x244");
initialCommands.Add("!sym quiet");
+
+ // Turn on source/line numbers
+ initialCommands.Add(".lines");
break;
case NativeDebugger.Lldb:
{
throw new ArgumentException($"{action} not supported for dotnet-dump testing");
}
- if (string.IsNullOrWhiteSpace(config.HostExe))
+ if (string.IsNullOrWhiteSpace(config.DotNetDumpHost()))
{
- throw new ArgumentException("No HostExe in configuration");
+ throw new ArgumentException("No DotNetDumpHost in configuration");
}
initialCommands.Add("setsymbolserver -directory %DEBUG_ROOT%");
arguments.Append(debuggerPath);
arguments.Append(@" analyze %DUMP_NAME%");
- debuggerPath = config.HostExe;
+ debuggerPath = config.DotNetDumpHost();
break;
}
}
else if (line.StartsWith("IFDEF:"))
{
- string define = line.Substring("IFDEF:".Length);
+ string define = line.Substring("IFDEF:".Length).Trim();
activeDefines.Add(define, true);
isActiveDefineRegionEnabled = IsActiveDefineRegionEnabled(activeDefines, enabledDefines);
}
else if (line.StartsWith("!IFDEF:"))
{
- string define = line.Substring("!IFDEF:".Length);
+ string define = line.Substring("!IFDEF:".Length).Trim();
activeDefines.Add(define, false);
isActiveDefineRegionEnabled = IsActiveDefineRegionEnabled(activeDefines, enabledDefines);
}
else if (line.StartsWith("ENDIF:"))
{
- string define = line.Substring("ENDIF:".Length);
+ string define = line.Substring("ENDIF:".Length).Trim();
if (!activeDefines.Last().Key.Equals(define))
{
throw new Exception("Mismatched IFDEF/ENDIF. IFDEF: " + activeDefines.Last().Key + " ENDIF: " + define);
switch (Debugger)
{
case NativeDebugger.Cdb:
- commands.Add($".unload sos.dll");
+ if (_config.IsDesktop)
+ {
+ // Force the desktop sos to be loaded and then unload it.
+ commands.Add(".cordll -l");
+ commands.Add(".unload sos");
+ }
commands.Add($".load {sosPath}");
- commands.Add(".lines");
commands.Add(".reload");
+ commands.Add(".chain");
if (sosHostRuntime != null)
{
commands.Add($"!SetHostRuntime {sosHostRuntime}");
{
defines.Add("ALPINE");
}
+ // This is a special "OR" of two conditions. Add this is easier than changing the parser to support "OR".
+ if (_config.IsNETCore || Debugger == NativeDebugger.DotNetDump)
+ {
+ defines.Add("NETCORE_OR_DOTNETDUMP");
+ }
return defines;
}
return TestConfiguration.MakeCanonicalPath(gdbPath);
}
+ public static string DotNetDumpHost(this TestConfiguration config)
+ {
+ string dotnetDumpHost = config.GetValue("DotNetDumpHost");
+ return TestConfiguration.MakeCanonicalPath(dotnetDumpHost);
+ }
+
public static string DotNetDumpPath(this TestConfiguration config)
{
string dotnetDumpPath = config.GetValue("DotNetDumpPath");
# Divide By Zero debugging scenario
-# 1) load the executable
+# 1) Load the executable
# 2) Run the executable and wait for it to crash
# 3) Take a dump of the executable.
# 4) Open the dump and compare the output
#
# Commands Verified: GCWhere, GCRoot, DumpObj, DumpHeap, DumpStackObjects
#
-# 1) load sos
-# 2) run to the first debug break
-# 3) dump stack objects to get the address of GCWhere!temp
+# 1) Run to the first debug break
+# 2) Load sos
+# 3) Dump stack objects to get the address of GCWhere!temp
# 4) Run various commands on the address, verify Gen0
-# 5) run to the second debug break
+# 5) Run to the second debug break
# 6) Run various commands on the address, verify Gen1
-# 7) run to the third debug break
+# 7) Run to the third debug break
# 8) Run various commands on the address, verify Gen2
-# 9) run to the fourth debug break
+# 9) Run to the fourth debug break
#10) Run various commands on the address, verify it is still Gen2
-#11) let the program run to completion
-
-LOADSOS
+#11) Let the program run to completion
# Continue to the DebugBreak
CONTINUE
VERIFY:Break instruction exception - code 80000003
ENDIF:CDB
+LOADSOS
+
SOSCOMMAND:DumpStackObjects
VERIFY:<HEXVAL>\s+<HEXVAL>\s+System.IO.StringWriter\s+
LOADSOS
# Verify that bpmd works
-IFDEF:PROJECTK
IFDEF:LIVE
!IFDEF:MAJOR_RUNTIME_VERSION_1
+IFDEF:DESKTOP
+SOSCOMMAND:bpmd NestedExceptionTest.exe NestedExceptionTest.Program.Main
+ENDIF:DESKTOP
+!IFDEF:DESKTOP
SOSCOMMAND:bpmd NestedExceptionTest.dll NestedExceptionTest.Program.Main
+ENDIF:DESKTOP
CONTINUE
+
+# Unloads desktop sos and reloads new SOS
+IFDEF:DESKTOP
+LOADSOS
+ENDIF:DESKTOP
+
SOSCOMMAND:ClrStack
VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+NestedExceptionTest\.Program\.Main(\(.*\))?\s*
VERIFY:\[.*[\\|/]Debuggees[\\|/](dotnet.+[\\|/])?[Nn]ested[Ee]xception[Tt]est[\\|/][Nn]ested[Ee]xception[Tt]est\.cs @ 8\s*\]\s*
ENDIF:MAJOR_RUNTIME_VERSION_1
ENDIF:LIVE
-ENDIF:PROJECTK
CONTINUE
VERIFY:StackTrace \(generated\):
VERIFY:\s+SP\s+IP\s+Function\s+
VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+[Nn]ested[Ee]xception[Tt]est.*!NestedExceptionTest\.Program\.Main(\(.*\))?\+0x<HEXVAL>\s*
-# Desktop sos has a bug that prevents the line number/source file info from being printed.
-IFDEF:PROJECTK
VERIFY:\[.*[\\|/]Debuggees[\\|/](dotnet.+[\\|/])?[Nn]ested[Ee]xception[Tt]est[\\|/][Nn]ested[Ee]xception[Tt]est\.cs @ 8\s*\]\s*
-ENDIF:PROJECTK
VERIFY:(StackTraceString: <none>\s+)?
VERIFY:HResult:\s+80131509\s+
VERIFY:There are nested exceptions on this thread. Run with -nested for details
VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.*
VERIFY:\s+Child\s+SP\s+IP\s+Call Site\s+
VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+NestedExceptionTest\.Program\.Main(\(.*\))?\s*
-# Desktop sos has a bug that prevents the line number/source file info from being printed.
-IFDEF:PROJECTK
VERIFY:\[.*[\\|/]Debuggees[\\|/](dotnet.+[\\|/])?[Nn]ested[Ee]xception[Tt]est[\\|/][Nn]ested[Ee]xception[Tt]est\.cs @ 8\s*\]\s*
-ENDIF:PROJECTK
\ No newline at end of file
LOADSOS
# Verify that bpmd works
-IFDEF:PROJECTK
IFDEF:LIVE
!IFDEF:MAJOR_RUNTIME_VERSION_1
+IFDEF:DESKTOP
+SOSCOMMAND:bpmd SymbolTestApp.exe SymbolTestApp.Program.Main
+ENDIF:DESKTOP
+!IFDEF:DESKTOP
SOSCOMMAND:bpmd SymbolTestApp.dll SymbolTestApp.Program.Main
+ENDIF:DESKTOP
+
CONTINUE
+
+# Unloads desktop sos and reloads new SOS
+IFDEF:DESKTOP
+LOADSOS
+ENDIF:DESKTOP
+
SOSCOMMAND:ClrStack
VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+SymbolTestApp\.Program\.Main\(.*\)\s+\[(?i:.*[\\|/]SymbolTestApp\.cs) @ 16\]\s*
SOSCOMMAND:bpmd SymbolTestApp.cs:29
+IFDEF:DESKTOP
+SOSCOMMAND:bpmd SymbolTestApp.exe SymbolTestApp.Program.Foo4
+ENDIF:DESKTOP
+!IFDEF:DESKTOP
SOSCOMMAND:bpmd SymbolTestApp.dll SymbolTestApp.Program.Foo4
+ENDIF:DESKTOP
+IFDEF:PROJECTK
CONTINUE
SOSCOMMAND:ClrStack
VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+SymbolTestApp\.Program\.Main\(.*\)\s+\[(?i:.*[\\|/]SymbolTestApp\.cs) @ 16\]\s*
+ENDIF:PROJECTK
CONTINUE
SOSCOMMAND:ClrStack
+IFDEF:DESKTOP
+VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+SymbolTestApp\.Program\.Foo2\(.*\)\s+\[(?i:.*[\\|/]SymbolTestApp\.cs) @ 29\]\s*
+ENDIF:DESKTOP
+!IFDEF:DESKTOP
VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+SymbolTestApp\.Program\.Foo2\(.*\)\s+\[(?i:.*[\\|/]SymbolTestApp\.cs) @ 28\]\s*
+ENDIF:DESKTOP
CONTINUE
SOSCOMMAND:ClrStack
ENDIF:MAJOR_RUNTIME_VERSION_1
ENDIF:LIVE
-ENDIF:PROJECTK
CONTINUE
-IFDEF:PROJECTK
SOSCOMMAND:SetSymbolServer -ms
!IFDEF:DOTNETDUMP
SOSCOMMAND:SetHostRuntime
ENDIF:DOTNETDUMP
-ENDIF:PROJECTK
IFDEF:DOTNETDUMP
COMMAND:clrmodules
VERIFY:\s*Name:\s+.*(System\.Private\.CoreLib(\.ni)?\.dll|mscorlib.dll)\s+
SOSCOMMAND:DumpModule <POUT>\s+Module Name\s+(<HEXVAL>)\s+.*<POUT>
-!IFDEF:DESKTOP
VERIFY:\s*PEFile:\s+<HEXVAL>\s+
VERIFY:\s*ModuleId:\s+<HEXVAL>\s+
-ENDIF:DESKTOP
VERIFY:\s*LoaderHeap:\s+<HEXVAL>\s+
VERIFY:\s*TypeDefToMethodTableMap:\s+<HEXVAL>\s+
# Reflection debugging scenario
-# 1) load the executable
+# 1) Load the executable
# 2) Run the executable and wait for it to crash
# 3) Take a dump of the executable.
# 4) Open the dump and compare the output
VERIFY:InnerException:\s+System\.Exception, Use !PrintException <HEXVAL> to see more\.\s+
VERIFY:StackTrace \(generated\):\s+
VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+[Rr]eflection[Tt]est.*!(\$0_)?RefLoader\.Loader\.Main(\(\))?\+0x<HEXVAL>\s*
-# Desktop sos has a bug that prevents the line number/source file info from being printed.
-IFDEF:PROJECTK
VERIFY:[.*[\\|/]Debuggees[\\|/](dotnet.+[\\|/])?[Rr]eflection[Tt]est[\\|/][Rr]eflection[Tt]est\.cs @ 32\s*\]
-ENDIF:PROJECTK
VERIFY:(StackTraceString: <none>\s+)?
VERIFY:HResult:\s+80131604
VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.*
VERIFY:\s+Child\s+SP\s+IP\s+Call Site\s+
VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+(\*\*\* WARNING: Unable to verify checksum for ReflectionTest.exe\s*)?RefLoader\.Loader\.Main(\(\))?\s*
-# Desktop sos has a bug that prevents the line number/source file info from being printed.
-IFDEF:PROJECTK
VERIFY:[.*[\\|/]Debuggees[\\|/](dotnet.+[\\|/])?[Rr]eflection[Tt]est[\\|/][Rr]eflection[Tt]est\.cs @ 32\s*\]
-ENDIF:PROJECTK
\ No newline at end of file
VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.*
VERIFY:\s+Child\s+SP\s+IP\s+Call Site\s+
VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+(\*\*\* WARNING: Unable to verify checksum for SimpleThrow.exe\s*)?UserObject\.UseObject.*\s+
-# Desktop sos has a bug that prevents the line number/source file info from being printed.
-IFDEF:PROJECTK
VERIFY:[.*[\\|/]Debuggees[\\|/](dotnet.+[\\|/])?SimpleThrow[\\|/]UserObject\.cs @ 18\s*\]
-ENDIF:PROJECTK
VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+Simple\.Main\(\)\s+
-IFDEF:PROJECTK
VERIFY:[.*[\\|/]Debuggees[\\|/](dotnet.+[\\|/])?SimpleThrow[\\|/]SimpleThrow\.cs @ 9\s*\]
-ENDIF:PROJECTK
\ No newline at end of file
LOADSOS
# Verify that bpmd works
-IFDEF:PROJECTK
IFDEF:LIVE
!IFDEF:MAJOR_RUNTIME_VERSION_1
+IFDEF:DESKTOP
+SOSCOMMAND:bpmd SymbolTestApp.exe SymbolTestApp.Program.Main
+ENDIF:DESKTOP
+!IFDEF:DESKTOP
SOSCOMMAND:bpmd SymbolTestApp.dll SymbolTestApp.Program.Main
+ENDIF:DESKTOP
CONTINUE
+
+# Unloads desktop sos and reloads new SOS
+IFDEF:DESKTOP
+LOADSOS
+ENDIF:DESKTOP
+
SOSCOMMAND:ClrStack
VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+SymbolTestApp\.Program\.Main\(.*\)\s+\[(?i:.*[\\|/]SymbolTestApp\.cs) @ 16\]\s*
SOSCOMMAND:bpmd SymbolTestApp.cs:29
+IFDEF:DESKTOP
+SOSCOMMAND:bpmd SymbolTestApp.exe SymbolTestApp.Program.Foo4
+ENDIF:DESKTOP
+!IFDEF:DESKTOP
SOSCOMMAND:bpmd SymbolTestApp.dll SymbolTestApp.Program.Foo4
+ENDIF:DESKTOP
+!IFDEF:DESKTOP
CONTINUE
SOSCOMMAND:ClrStack
VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+SymbolTestApp\.Program\.Main\(.*\)\s+\[(?i:.*[\\|/]SymbolTestApp\.cs) @ 16\]\s*
+ENDIF:DESKTOP
CONTINUE
SOSCOMMAND:ClrStack
-VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+SymbolTestApp\.Program\.Foo2\(.*\)\s+\[(?i:.*[\\|/]SymbolTestApp\.cs) @ 28\]\s*
+VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+SymbolTestApp\.Program\.Foo2\(.*\)\s+\[(?i:.*[\\|/]SymbolTestApp\.cs) @ (28|29)\]\s*
CONTINUE
SOSCOMMAND:ClrStack
ENDIF:MAJOR_RUNTIME_VERSION_1
ENDIF:LIVE
-ENDIF:PROJECTK
CONTINUE
-IFDEF:PROJECTK
SOSCOMMAND:SetSymbolServer -ms
!IFDEF:DOTNETDUMP
SOSCOMMAND:SetHostRuntime
ENDIF:DOTNETDUMP
-ENDIF:PROJECTK
# Verify that ClrStack with no options works
SOSCOMMAND:SetSymbolServer -ms
VERIFY:\s+<DECVAL>.<DECVAL>.<DECVAL>.<DECVAL>.*
# Verify that ClrStack with managed/native mixed works
-IFDEF:PROJECTK
SOSCOMMAND:ClrStack -f
VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.*
VERIFY:\s+Child\s+SP\s+IP\s+Call Site\s+
VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+SymbolTestApp\.(dll|exe)!SymbolTestApp\.Program\.Foo2\(.*\)\s+\+\s+<DECVAL>\s+\[(?i:.*[\\|/]SymbolTestApp\.cs) @ 29\]\s*
VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+SymbolTestApp\.(dll|exe)!SymbolTestApp\.Program\.Foo1\(.*\)\s+\+\s+<DECVAL>\s+\[(?i:.*[\\|/]SymbolTestApp\.cs) @ 24\]\s*
VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+SymbolTestApp\.(dll|exe)!SymbolTestApp\.Program\.Main\(.*\)\s+\+\s+<DECVAL>\s+\[(?i:.*[\\|/]SymbolTestApp\.cs) @ 19\]\s*
-ENDIF:PROJECTK
# Verify that ClrStack all option works (locals/params)
-IFDEF:PROJECTK
SOSCOMMAND:ClrStack -a
VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.*
VERIFY:\s+Child\s+SP\s+IP\s+Call Site\s+
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+SymbolTestApp\.Program\.Foo2\(.*\)\s+\[(?i:.*[\\|/]SymbolTestApp\.cs) @ 29\]\s*
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+SymbolTestApp\.Program\.Foo1\(.*\)\s+\[(?i:.*[\\|/]SymbolTestApp\.cs) @ 24\]\s*
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+SymbolTestApp\.Program\.Main\(.*\)\s+\[(?i:.*[\\|/]SymbolTestApp\.cs) @ 19\]\s*
-ENDIF:PROJECTK
# Verify that ClrStack displays registers
-IFDEF:PROJECTK
SOSCOMMAND:ClrStack -r
VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.*
VERIFY:\s+Child\s+SP\s+IP\s+Call Site\s+
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+SymbolTestApp\.Program\.Foo1\(.*\)\s+\[(?i:.*[\\|/]SymbolTestApp\.cs) @ 24\]\s*
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+SymbolTestApp\.Program\.Main\(.*\)\s+\[(?i:.*[\\|/]SymbolTestApp\.cs) @ 19\]\s*
-ENDIF:PROJECTK
+
+# There seems no way to get -i to work on desktop under cdb. It does work under dotnet-dump because of the module mapping.
+IFDEF:NETCORE_OR_DOTNETDUMP
# Verify that ClrStack with the ICorDebug options works
-IFDEF:PROJECTK
SOSCOMMAND:ClrStack -i
VERIFY:.*\s+Dumping managed stack and managed variables using ICorDebug.\s+
VERIFY:.*\s+Child\s+SP\s+IP\s+Call Site\s+
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+\[DEFAULT\] I4 SymbolTestApp\.Program\.Foo1\(.*\)\s+\(.*\)\s+
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+\[DEFAULT\] Void SymbolTestApp\.Program\.Main\(.*\)\s+\(.*\)\s+
VERIFY:.*\s+Stack walk complete.\s+
-ENDIF:PROJECTK
+
+ENDIF:NETCORE_OR_DOTNETDUMP
# Issue: https://github.com/dotnet/diagnostics/issues/504
!IFDEF:ALPINE
+# There seems no way to get -i to work on desktop under cdb. It does work under dotnet-dump because of the module mapping.
+IFDEF:NETCORE_OR_DOTNETDUMP
+
# Verify that ClrStack with the ICorDebug options and all option (locals/params) works
-IFDEF:PROJECTK
SOSCOMMAND:ClrStack -i -a
VERIFY:.*\s+Dumping managed stack and managed variables using ICorDebug.\s+
VERIFY:.*\s+Child\s+SP\s+IP\s+Call Site\s+
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+\[DEFAULT\] I4 SymbolTestApp\.Program\.Foo1\(.*\)\s+\(.*\)\s+
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+\[DEFAULT\] Void SymbolTestApp\.Program\.Main\(.*\)\s+\(.*\)\s+
VERIFY:.*\s+Stack walk complete.\s+
-ENDIF:PROJECTK
+
+ENDIF:NETCORE_OR_DOTNETDUMP
# Verify DumpStackObjects works
-IFDEF:PROJECTK
SOSCOMMAND:DumpStackObjects
VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.*
VERIFY:\s+([R|E])*SP/REG\s+Object\s+Name\s+
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+System\.String.*
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+System\.String\[\].*
-ENDIF:PROJECTK
# Verify DumpStackObjects -verify works
-IFDEF:PROJECTK
SOSCOMMAND:DumpStackObjects -verify
VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.*
VERIFY:\s+([R|E])*SP/REG\s+Object\s+Name\s+
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+System\.String.*
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+System\.String\[\].*
-ENDIF:PROJECTK
ENDIF:ALPINE
!IFDEF:DOTNETDUMP
!IFDEF:ARM
-IFDEF:PROJECTK
# Verify DumpStack works
SOSCOMMAND:DumpStack
VERIFY:.*Child(-SP|EBP|FP)\s+RetAddr\s+Caller, Callee\s+
VERIFY:(.*\s+<HEXVAL>\s+<HEXVAL>\s+\(MethodDesc\s+<HEXVAL>\s+(\+\s*0x<HEXVAL>\s+)?SymbolTestApp\.Program\.Foo4\(System\.String\)\),\s+calling.*\s+)|(.*\s+<HEXVAL>\s+<HEXVAL>\s+\(MethodDesc\s+<HEXVAL>\s+(\+\s*0x<HEXVAL>\s+)?SymbolTestApp\.Program\.Foo2\(Int32, System\.String\)\),\s+calling.*\s+)
-ENDIF:PROJECTK
ENDIF:ARM
ENDIF:DOTNETDUMP
# Verify that DumpIL works (depends on the IP2MD right above)
SOSCOMMAND:DumpIL <POUT>\s*MethodDesc:\s+(<HEXVAL>)\s*<POUT>
+IFDEF:DESKTOP
+VERIFY:.*IL_<HEXVAL>: call class \[mscorlib\]System\.Reflection\.Assembly System\.Reflection\.Assembly::Load\(uint8\[\],uint8\[\]\)
+ENDIF:DESKTOP
!IFDEF:DESKTOP
VERIFY:.*IL_<HEXVAL>: callvirt class \[System\.(Runtime|Reflection)\]System\.Reflection\.Assembly System\.Runtime\.Loader\.AssemblyLoadContext::LoadFromStream\(class \[System\.(Runtime|IO)\]System\.IO\.Stream,class \[System\.(Runtime|IO)\]System\.IO\.Stream\)
ENDIF:DESKTOP
-IFDEF:DESKTOP
-# Disable until the new SOS supports desktop clr
-# VERIFY:.*IL_<HEXVAL>: call class \[System.Runtime\]System\.Reflection\.Assembly System\.Reflection\.Assembly::Load\(uint8\[\],uint8\[\]\)
-ENDIF:DESKTOP
!IFDEF:DOTNETDUMP
-IFDEF:PROJECTK
# Verify that "u" works (depends on the IP2MD here)
SOSCOMMAND:ClrStack
VERIFY:\s+Begin\s+<HEXVAL>,\s+size\s+<HEXVAL>\s+
VERIFY:\s+(?i:.*[\\|/]SymbolTestApp\.cs) @ (50|54):\s+
-ENDIF:PROJECTK
ENDIF:DOTNETDUMP
# Verify that Name2EE works
-IFDEF:PROJECTK
SOSCOMMAND:Name2EE *!SymbolTestApp.Program.Foo4
VERIFY:\s*Module:\s+\s+<HEXVAL>\s+
VERIFY:\s+Assembly:\s+(?i:SymbolTestApp).*\s+
VERIFY:\s+Name:\s+SymbolTestApp\.Program\.Foo4\(System\.String\)\s+
VERIFY:\s+JITTED Code Address:\s+<HEXVAL>\s+
-ENDIF:PROJECTK
# Verify that Threads (clrthreads) works
IFDEF:DOTNETDUMP
ENDIF:64BIT
# 2) Verifying that ClrStack with managed/native mixed works
-IFDEF:PROJECTK
SOSCOMMAND:SetSymbolServer -ms -loadsymbols
!IFDEF:DOTNETDUMP
SOSCOMMAND:SetHostRuntime
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+(?i:NestedExceptionTest.*)!NestedExceptionTest\.Program\.Main\(.*\)\s+\+\s+<DECVAL>\s+\[(?i:.*[\\|/]NestedExceptionTest\.cs) @ 13\s*\]\s+
ENDIF:64BIT
SOSCOMMAND:SetSymbolServer -disable
-ENDIF:PROJECTK
# 3) Verifying that ClrStack all option works (locals/params)
-IFDEF:PROJECTK
SOSCOMMAND:ClrStack -a
VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.*
VERIFY:\s+Child\s+SP\s+IP\s+Call Site\s+
VERIFY:\s+LOCALS:\s+
VERIFY:\s+0x<HEXVAL> = 0x<HEXVAL>\s+
ENDIF:64BIT
-ENDIF:PROJECTK
# 4) Verifying that ClrStack displays registers
-IFDEF:PROJECTK
SOSCOMMAND:ClrStack -r
VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.*
VERIFY:\s+Child\s+SP\s+IP\s+Call Site\s+
VERIFY:\s+eax=<HEXVAL>\s+ebx=<HEXVAL>\s+ecx=<HEXVAL>\s+
ENDIF:X86
ENDIF:64BIT
-ENDIF:PROJECTK
+
+# There seems no way to get -i to work on desktop under cdb. It does work under dotnet-dump because of the module mapping.
+IFDEF:NETCORE_OR_DOTNETDUMP
# Issue: https://github.com/dotnet/diagnostics/issues/504
!IFDEF:ALPINE
# 5) Verifying that ClrStack with the ICorDebug options works
-IFDEF:PROJECTK
SOSCOMMAND:ClrStack -i
VERIFY:.*\s+Dumping managed stack and managed variables using ICorDebug.\s+
VERIFY:.*\s+Child\s+SP\s+IP\s+Call Site\s+
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+\[DEFAULT\] Void NestedExceptionTest\.Program\.Main\(.*\)\s+\(.*\)\s+
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+\[DEFAULT\] Void NestedExceptionTest\.Program\.Main\(.*\)\s+\(.*\)\s+
VERIFY:.*\s+Stack walk complete.\s+
-ENDIF:PROJECTK
# 6) Verifying that ClrStack with the ICorDebug options and all option (locals/params) works
-IFDEF:PROJECTK
SOSCOMMAND:ClrStack -i -a
VERIFY:.*\s+Dumping managed stack and managed variables using ICorDebug.\s+
VERIFY:.*\s+Child\s+SP\s+IP\s+Call Site\s+
VERIFY:\s+\+ System.FormatException ex @ 0x<HEXVAL>\s+
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+\[DEFAULT\] Void NestedExceptionTest\.Program\.Main\(.*\)\s+\(.*\)\s+
VERIFY:.*\s+Stack walk complete.\s+
-ENDIF:PROJECTK
ENDIF:ALPINE
+ENDIF:NETCORE_OR_DOTNETDUMP
# 7) Verify DumpStackObjects works
-IFDEF:PROJECTK
SOSCOMMAND:DumpStackObjects
VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.*
VERIFY:\s+([R|E])*SP/REG\s+Object\s+Name\s+
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+System\.FormatException\s+
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+System\.InvalidOperationException\s+
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+System\.String.*
-ENDIF:PROJECTK
# 8) Verify DumpStackObjects -verify works
-IFDEF:PROJECTK
SOSCOMMAND:DumpStackObjects -verify
VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.*
VERIFY:\s+([R|E])*SP/REG\s+Object\s+Name\s+
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+System\.FormatException\s+
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+System\.InvalidOperationException\s+
VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+System\.String.*
-ENDIF:PROJECTK
!IFDEF:DOTNETDUMP
!IFDEF:ARM
VERIFY:StackTrace \(generated\):\s+
VERIFY:\s+SP\s+IP\s+Function\s+
VERIFY:\s+<HEXVAL>\s+<HEXVAL>.+RandomTest(::|\.)RandomUserTask\.<\.ctor>.+\+0x<HEXVAL>\s*
-# Desktop sos has a bug that prevents the line number/source file info from being printed. Fixed in ProjectK.
!IFDEF:DESKTOP
!IFDEF:TRIAGE_DUMP
VERIFY:[.+[\\|/]Debuggees[\\|/](dotnet.+[\\|/])?[Tt]ask[Nn]ested[Ee]xception[\\|/][Rr]andom[Uu]ser[Ll]ibrary[\\|/][Rr]andom[Uu]ser[Tt]ask\.cs @ (16|23)\]
VERIFY:StackTrace \(generated\):\s+
VERIFY:\s+SP\s+IP\s+Function\s+
VERIFY:\s+<HEXVAL>\s+<HEXVAL>.+RandomTest(::|\.)RandomUserTask\.InnerException(\(\))?\+0x<HEXVAL>\s*
-# Desktop sos has a bug that prevents the line number/source file info from being printed. Fixed in ProjectK.
!IFDEF:DESKTOP
!IFDEF:TRIAGE_DUMP
VERIFY:[.+[\\|/]Debuggees[\\|/](dotnet.+[\\|/])?[Tt]ask[Nn]ested[Ee]xception[\\|/][Rr]andom[Uu]ser[Ll]ibrary[\\|/][Rr]andom[Uu]ser[Tt]ask\.cs @ 34\]
!IFDEF:TRIAGE_DUMP
VERIFY:[.+[\\|/]Debuggees[\\|/](dotnet.+[\\|/])?[Tt]ask[Nn]ested[Ee]xception[\\|/][Rr]andom[Uu]ser[Ll]ibrary[\\|/][Rr]andom[Uu]ser[Tt]ask\.cs @ 19\]
ENDIF:TRIAGE_DUMP
-ENDIF:DESKTOP
\ No newline at end of file
+ENDIF:DESKTOP
{
HRESULT handleEventStatus = DEBUG_STATUS_NO_CHANGE;
- if (ModuleName != NULL && _stricmp(ModuleName, MAIN_CLR_MODULE_NAME_A) == 0)
+ if (ModuleName != NULL)
{
- if (g_breakOnRuntimeModuleLoad)
- {
- g_breakOnRuntimeModuleLoad = false;
- HandleRuntimeLoadedNotification(m_pDebugClient);
- }
- // if we don't want the JIT to optimize, we should also disable optimized NGEN images
- if (!g_fAllowJitOptimization)
- {
- ExtQuery(m_pDebugClient);
+ bool isNetCore = _stricmp(ModuleName, NETCORE_RUNTIME_MODULE_NAME_A) == 0;
+ bool isDesktop = _stricmp(ModuleName, DESKTOP_RUNTIME_MODULE_NAME_A) == 0;
- // If we aren't successful SetNGENCompilerFlags will print relevant error messages
- // and then we need to stop the debugger so the user can intervene if desired
- if (FAILED(SetNGENCompilerFlags(CORDEBUG_JIT_DISABLE_OPTIMIZATION)))
+ if (isNetCore || isDesktop)
+ {
+ if (g_breakOnRuntimeModuleLoad)
+ {
+ g_breakOnRuntimeModuleLoad = false;
+ HandleRuntimeLoadedNotification(m_pDebugClient);
+ }
+ // if we don't want the JIT to optimize, we should also disable optimized NGEN images
+ if (!g_fAllowJitOptimization)
{
- handleEventStatus = DEBUG_STATUS_BREAK;
+ ExtQuery(m_pDebugClient);
+
+ // If we aren't successful SetNGENCompilerFlags will print relevant error messages
+ // and then we need to stop the debugger so the user can intervene if desired
+ if (FAILED(SetNGENCompilerFlags(CORDEBUG_JIT_DISABLE_OPTIMIZATION)))
+ {
+ handleEventStatus = DEBUG_STATUS_BREAK;
+ }
+ ExtRelease();
}
- ExtRelease();
}
}
inline void EENotLoadedMessage(HRESULT Status)
{
- ExtOut("Failed to find runtime module (%s), 0x%08x\n", MAKEDLLNAME_A("coreclr"), Status);
+ ExtOut("Failed to find runtime module (%s), 0x%08x\n", GetRuntimeDllName(), Status);
ExtOut("Extension commands need it in order to have something to do.\n");
}
ExtOut("Failed to load data access module, 0x%08x\n", Status);
#ifndef FEATURE_PAL
ExtOut("Verify that 1) you have a recent build of the debugger (6.2.14 or newer)\n");
- ExtOut(" 2) the file mscordaccore.dll that matches your version of coreclr.dll is\n");
+ ExtOut(" 2) the file %s that matches your version of %s is\n", GetDacDllName(), GetRuntimeDllName());
ExtOut(" in the version directory or on the symbol path\n");
ExtOut(" 3) or, if you are debugging a dump file, verify that the file \n");
- ExtOut(" mscordaccore_<arch>_<arch>_<version>.dll is on your symbol path.\n");
+ ExtOut(" %s_<arch>_<arch>_<version>.dll is on your symbol path.\n", GetDacModuleName());
ExtOut(" 4) you are debugging on supported cross platform architecture as \n");
ExtOut(" the dump file. For example, an ARM dump file must be debugged\n");
ExtOut(" on an X86 or an ARM machine; an AMD64 dump file must be\n");
ExtOut(" debugged on an AMD64 machine.\n");
ExtOut("\n");
ExtOut("You can also run the debugger command .cordll to control the debugger's\n");
- ExtOut("load of mscordaccore.dll. .cordll -ve -u -l will do a verbose reload.\n");
+ ExtOut("load of %s.dll. .cordll -ve -u -l will do a verbose reload.\n", GetDacDllName());
ExtOut("If that succeeds, the SOS command should work on retry.\n");
ExtOut("\n");
ExtOut("If you are debugging a minidump, you need to make sure that your executable\n");
- ExtOut("path is pointing to coreclr.dll as well.\n");
+ ExtOut("path is pointing to %s as well.\n", GetRuntimeDllName());
#else // FEATURE_PAL
if (Status == CORDBG_E_MISSING_DEBUGGER_EXPORTS)
{
- ExtOut("You can run the debugger command 'setclrpath' to control the load of %s.\n", MAKEDLLNAME_A("mscordaccore"));
+ ExtOut("You can run the debugger command 'setclrpath' to control the load of %s.\n", GetDacDllName());
ExtOut("If that succeeds, the SOS command should work on retry.\n");
}
else
{
- ExtOut("Can not load or initialize %s. The target runtime may not be initialized.\n", MAKEDLLNAME_A("mscordaccore"));
+ ExtOut("Can not load or initialize %s. The target runtime may not be initialized.\n", GetDacDllName());
}
#endif // FEATURE_PAL
}
INIT_API_NOEE() \
if ((Status = CheckEEDll()) != S_OK) \
{ \
- ExtOut("Failed to find runtime module (%s), 0x%08x\n", MAKEDLLNAME_A("coreclr"), Status); \
+ ExtOut("Failed to find runtime module (%s), 0x%08x\n", GetRuntimeDllName(), Status); \
ExtOut("Some functionality may be impaired\n"); \
} \
else if ((Status = LoadClrDebugDll()) != S_OK) \
{ \
- ExtOut("Failed to load data access module (%s), 0x%08x\n", MAKEDLLNAME_A("mscordaccore"), Status); \
+ ExtOut("Failed to load data access module (%s), 0x%08x\n", GetDacDllName(), Status); \
ExtOut("Some functionality may be impaired\n"); \
} \
else \
#endif // FEATURE_PAL
/**********************************************************************\
- * Returns the coreclr module/runtime directory of the target.
+ * Returns the runtime module/runtime directory of the target.
\**********************************************************************/
-HRESULT GetCoreClrDirectory(std::string& coreClrDirectory)
+HRESULT GetRuntimeDirectory(std::string& runtimeDirectory)
{
#ifdef FEATURE_PAL
LPCSTR directory = g_ExtServices->GetCoreClrDirectory();
if (directory == NULL)
{
- ExtErr("Error: Runtime module (%s) not loaded yet\n", MAKEDLLNAME_A("coreclr"));
+ ExtErr("Error: Runtime module (%s) not loaded yet\n", NETCORE_RUNTIME_DLL_NAME_A);
return E_FAIL;
}
- if (!GetAbsolutePath(directory, coreClrDirectory))
+ if (!GetAbsolutePath(directory, runtimeDirectory))
{
ExtDbgOut("Error: Runtime directory %s doesn't exist\n", directory);
return E_FAIL;
HRESULT Status = GetRuntimeModuleInfo(&index, NULL);
if (FAILED(Status))
{
- ExtErr("Error: Runtime module (%s) not loaded yet\n", MAKEDLLNAME_A("coreclr"));
+ ExtErr("Error: Runtime module (%s) not loaded yet\n", GetRuntimeDllName());
return Status;
}
ArrayHolder<char> szModuleName = new char[MAX_LONGPATH + 1];
Status = g_ExtSymbols->GetModuleNames(index, 0, szModuleName, MAX_LONGPATH, NULL, NULL, 0, NULL, NULL, 0, NULL);
if (FAILED(Status))
{
- ExtErr("Error: Failed to get coreclr module name\n");
+ ExtErr("Error: Failed to get runtime module name\n");
return Status;
}
if (GetFileAttributesA(szModuleName) == INVALID_FILE_ATTRIBUTES)
ExtDbgOut("Error: Runtime module %s doesn't exist %08x\n", szModuleName, Status);
return Status;
}
- coreClrDirectory = szModuleName;
+ runtimeDirectory = szModuleName;
// Parse off the module name to get just the path
- size_t lastSlash = coreClrDirectory.rfind(DIRECTORY_SEPARATOR_CHAR_A);
+ size_t lastSlash = runtimeDirectory.rfind(DIRECTORY_SEPARATOR_CHAR_A);
if (lastSlash == std::string::npos)
{
ExtDbgOut("Error: Runtime module %s has no directory separator\n", szModuleName);
return E_FAIL;
}
- coreClrDirectory.assign(coreClrDirectory, 0, lastSlash);
+ runtimeDirectory.assign(runtimeDirectory, 0, lastSlash);
#endif
return S_OK;
}
/**********************************************************************\
- * Returns the coreclr module/runtime directory of the target.
+ * Returns the runtime module/runtime directory of the target.
\**********************************************************************/
-HRESULT GetCoreClrDirectory(LPWSTR modulePath, int modulePathSize)
+HRESULT GetRuntimeDirectory(LPWSTR modulePath, int modulePathSize)
{
- std::string coreclrDirectory;
- HRESULT hr = GetCoreClrDirectory(coreclrDirectory);
+ std::string runtimeDirectory;
+ HRESULT hr = GetRuntimeDirectory(runtimeDirectory);
if (FAILED(hr))
{
return hr;
}
- int length = MultiByteToWideChar(CP_ACP, 0, coreclrDirectory.c_str(), -1, modulePath, modulePathSize);
+ int length = MultiByteToWideChar(CP_ACP, 0, runtimeDirectory.c_str(), -1, modulePath, modulePathSize);
if (0 >= length)
{
- ExtErr("MultiByteToWideChar(coreclrDirectory) failed. Last error = 0x%x\n", GetLastError());
+ ExtErr("MultiByteToWideChar(runtimeDirectory) failed. Last error = 0x%x\n", GetLastError());
return HRESULT_FROM_WIN32(GetLastError());
}
return S_OK;
if (!FindDotNetVersion(3, 1, hostRuntimeDirectory))
{
// If an installed runtime can not be found, use the target coreclr version
- HRESULT hr = GetCoreClrDirectory(hostRuntimeDirectory);
+ HRESULT hr = GetRuntimeDirectory(hostRuntimeDirectory);
if (FAILED(hr))
{
return hr;
hostRuntimeDirectory.assign(g_hostRuntimeDirectory);
coreClrPath.assign(g_hostRuntimeDirectory);
coreClrPath.append(DIRECTORY_SEPARATOR_STR_A);
- coreClrPath.append(MAIN_CLR_DLL_NAME_A);
+ coreClrPath.append(NETCORE_RUNTIME_DLL_NAME_A);
return S_OK;
}
-#ifndef FEATURE_PAL
-/**********************************************************************\
- * Returns the path to the runtime directory to use for hosting.
-\**********************************************************************/
-LPCSTR
-GetHostRuntimeDirectory()
-{
- std::string hostRuntimeDirectory;
- std::string coreClrPath;
-
- HRESULT Status = GetHostRuntime(coreClrPath, hostRuntimeDirectory);
- if (FAILED(Status))
- {
- return nullptr;
- }
- return hostRuntimeDirectory.c_str();
-}
-#endif // FEATURE_PAL
-
//
// Returns the unique temporary directory for this instnace of SOS
//
if (g_dacFilePath == nullptr)
{
std::string dacModulePath;
- HRESULT hr = GetCoreClrDirectory(dacModulePath);
+ HRESULT hr = GetRuntimeDirectory(dacModulePath);
if (SUCCEEDED(hr))
{
dacModulePath.append(DIRECTORY_SEPARATOR_STR_A);
- dacModulePath.append(MAKEDLLNAME_A("mscordaccore"));
+ dacModulePath.append(GetDacDllName());
#ifdef FEATURE_PAL
// If DAC file exists in the runtime directory
if (access(dacModulePath.c_str(), F_OK) == 0)
if (tmpPath != nullptr)
{
std::string dacSymLink(tmpPath);
- dacSymLink.append(MAKEDLLNAME_A("mscordaccore"));
+ dacSymLink.append(NETCORE_DAC_DLL_NAME_A);
int error = symlink(dacModulePath.c_str(), dacSymLink.c_str());
if (error == 0)
if (g_dbiFilePath == nullptr)
{
std::string dbiModulePath;
- HRESULT hr = GetCoreClrDirectory(dbiModulePath);
+ HRESULT hr = GetRuntimeDirectory(dbiModulePath);
if (SUCCEEDED(hr))
{
dbiModulePath.append(DIRECTORY_SEPARATOR_STR_A);
- dbiModulePath.append(MAKEDLLNAME_A("mscordbi"));
+ dbiModulePath.append(NET_DBI_DLL_NAME_A);
#ifdef FEATURE_PAL
// If DBI file exists in the runtime directory
if (access(dbiModulePath.c_str(), F_OK) == 0)
//
static void SymbolFileCallback(void* param, const char* moduleFileName, const char* symbolFilePath)
{
- if (strcmp(moduleFileName, MAIN_CLR_DLL_NAME_A) == 0) {
+ if (strcmp(moduleFileName, GetRuntimeDllName()) == 0) {
return;
}
- if (strcmp(moduleFileName, MAKEDLLNAME_A("mscordaccore")) == 0) {
+ if (strcmp(moduleFileName, GetDacDllName()) == 0) {
if (g_dacFilePath == nullptr) {
g_dacFilePath = _strdup(symbolFilePath);
}
return;
}
- if (strcmp(moduleFileName, MAKEDLLNAME_A("mscordbi")) == 0) {
+ if (strcmp(moduleFileName, NET_DBI_DLL_NAME_A) == 0) {
if (g_dbiFilePath == nullptr) {
g_dbiFilePath = _strdup(symbolFilePath);
}
return E_FAIL;
}
- DacpGetModuleData moduleData;
- hr = moduleData.Request(pModule);
+ ArrayHolder<WCHAR> pModuleName = new WCHAR[MAX_LONGPATH + 1];
+ ULONG32 nameLen = 0;
+ hr = pModule->GetFileName(MAX_LONGPATH, &nameLen, pModuleName);
if (FAILED(hr))
{
- ExtOut("LoadSymbols moduleData.Request FAILED 0x%08x\n", hr);
+ ExtOut("LoadSymbols: IXCLRDataModule->GetFileName FAILED 0x%08x\n", hr);
return hr;
}
- ArrayHolder<WCHAR> pModuleName = new WCHAR[MAX_LONGPATH + 1];
- ULONG32 nameLen = 0;
- hr = pModule->GetFileName(MAX_LONGPATH, &nameLen, pModuleName);
+ DacpGetModuleData moduleData;
+ hr = moduleData.Request(pModule);
if (FAILED(hr))
{
- ExtOut("LoadSymbols: IXCLRDataModule->GetFileName FAILED 0x%08x\n", hr);
+#ifdef FEATURE_PAL
+ ExtOut("LoadSymbols moduleData.Request FAILED 0x%08x\n", hr);
return hr;
+#else
+ ULONG64 modBase;
+ hr = GetClrModuleImages(pModule, CLRDATA_MODULE_PE_FILE, &modBase);
+ if (FAILED(hr))
+ {
+ ExtOut("LoadSymbols GetClrModuleImages FAILED 0x%08x\n", hr);
+ return hr;
+ }
+ hr = LoadSymbolsForWindowsPDB(pMD, modBase, pModuleName, FALSE);
+ if (SUCCEEDED(hr))
+ {
+ return hr;
+ }
+ moduleData.LoadedPEAddress = modBase;
+ moduleData.IsFileLayout = TRUE;
+#endif
}
#ifndef FEATURE_PAL
extern LPCSTR g_tmpPath;
extern SOSNetCoreCallbacks g_SOSNetCoreCallbacks;
-extern HRESULT GetCoreClrDirectory(LPWSTR modulePath, int modulePathSize);
-extern HRESULT GetCoreClrDirectory(std::string& coreClrDirectory);
+extern HRESULT GetRuntimeDirectory(std::string& runtimeDirectory);
+extern HRESULT GetRuntimeDirectory(LPWSTR modulePath, int modulePathSize);
extern LPCSTR GetDacFilePath();
extern LPCSTR GetDbiFilePath();
extern BOOL IsHostingInitialized();
gchandleleaks=GCHandleLeaks
Gchandleleaks=GCHandleLeaks
GCHandleleaks=GCHandleLeaks
- HandleCLRN
+ SOSHandleCLRN
MinidumpMode
minidumpmode=MinidumpMode
Minidumpmode=MinidumpMode
#include <memory>
#include <functional>
-BOOL CallStatus;
BOOL ControlC = FALSE;
-
-IMetaDataDispenserEx *pDisp = NULL;
WCHAR g_mdName[mdNameLen];
#ifndef FEATURE_PAL
*/
STDMETHODIMP OnCodeGenerated(IXCLRDataMethodInstance* method)
{
+#ifndef FEATURE_PAL
+ // This is only needed for desktop runtime because OnCodeGenerated2
+ // isn't supported by the desktop DAC.
+ if (g_isDesktopRuntime)
+ {
+ // Some method has been generated, make a breakpoint and remove it.
+ ULONG32 len = mdNameLen;
+ LPWSTR szModuleName = (LPWSTR)alloca(mdNameLen * sizeof(WCHAR));
+ if (method->GetName(0, mdNameLen, &len, g_mdName) == S_OK)
+ {
+ ToRelease<IXCLRDataModule> pMod;
+ HRESULT hr = method->GetTokenAndScope(NULL, &pMod);
+ if (SUCCEEDED(hr))
+ {
+ len = mdNameLen;
+ if (pMod->GetName(mdNameLen, &len, szModuleName) == S_OK)
+ {
+ ExtOut("JITTED %S!%S\n", szModuleName, g_mdName);
+
+ // Add breakpoint, perhaps delete pending breakpoint
+ DacpGetModuleAddress dgma;
+ if (SUCCEEDED(dgma.Request(pMod)))
+ {
+ g_bpoints.Update(TO_TADDR(dgma.ModulePtr), FALSE);
+ }
+ else
+ {
+ ExtOut("Failed to request module address.\n");
+ }
+ }
+ }
+ }
+ }
+#endif
m_dbgStatus = DEBUG_STATUS_GO_HANDLED;
return S_OK;
}
#ifndef FEATURE_PAL
-DECLARE_API(HandleCLRN)
+DECLARE_API(SOSHandleCLRN)
{
INIT_API();
MINIDUMP_NOT_SUPPORTED();
{
INIT_API();
EnableModuleLoadUnloadCallbacks();
- return g_ExtControl->Execute(DEBUG_EXECUTE_NOT_LOGGED, "sxe -c \"!HandleCLRN\" clrn", 0);
+ return g_ExtControl->Execute(DEBUG_EXECUTE_NOT_LOGGED, "sxe -c \"!SOSHandleCLRN\" clrn", 0);
}
#else // FEATURE_PAL
}
else /* We were given a MethodDesc already */
{
- // if we've got an explicit MD, then we better have CLR and mscordacwks loaded
+ // if we've got an explicit MD, then we better have runtime and dac loaded
INIT_API_EE()
INIT_API_DAC();
{
ExtOut("Adding pending breakpoints...\n");
#ifndef FEATURE_PAL
- Status = g_ExtControl->Execute(DEBUG_EXECUTE_NOT_LOGGED, "sxe -c \"!HandleCLRN\" clrn", 0);
+ Status = g_ExtControl->Execute(DEBUG_EXECUTE_NOT_LOGGED, "sxe -c \"!SOSHandleCLRN\" clrn", 0);
#else
Status = g_ExtServices->SetExceptionCallback(HandleExceptionNotification);
#endif // FEATURE_PAL
return E_FAIL;
#else
// Try to find stress log symbols
- DWORD_PTR dwAddr = GetValueFromExpression(MAIN_CLR_MODULE_NAME_A "!StressLog::theLog");
+ DWORD_PTR dwAddr = GetValueFromExpression("StressLog::theLog");
StressLogAddress = dwAddr;
#endif
}
if (*args != 0)
fileName = args;
- DWORD_PTR dwAddr = GetValueFromExpression(MAIN_CLR_MODULE_NAME_A "!SVR::gc_log_buffer");
+ DWORD_PTR dwAddr = GetValueFromExpression("SVR::gc_log_buffer");
moveN (dwAddr, dwAddr);
if (dwAddr == 0)
{
- dwAddr = GetValueFromExpression(MAIN_CLR_MODULE_NAME_A "!WKS::gc_log_buffer");
+ dwAddr = GetValueFromExpression("WKS::gc_log_buffer");
moveN (dwAddr, dwAddr);
if (dwAddr == 0)
{
if (fIsServerGC)
{
- dwAddr = GetValueFromExpression(MAIN_CLR_MODULE_NAME_A "!SVR::gc_config_log_buffer");
- dwAddrOffset = GetValueFromExpression(MAIN_CLR_MODULE_NAME_A "!SVR::gc_config_log_buffer_offset");
+ dwAddr = GetValueFromExpression("SVR::gc_config_log_buffer");
+ dwAddrOffset = GetValueFromExpression("SVR::gc_config_log_buffer_offset");
}
else
{
- dwAddr = GetValueFromExpression(MAIN_CLR_MODULE_NAME_A "!WKS::gc_config_log_buffer");
- dwAddrOffset = GetValueFromExpression(MAIN_CLR_MODULE_NAME_A "!WKS::gc_config_log_buffer_offset");
+ dwAddr = GetValueFromExpression("WKS::gc_config_log_buffer");
+ dwAddrOffset = GetValueFromExpression("WKS::gc_config_log_buffer_offset");
}
moveN (dwAddr, dwAddr);
if (g_hostRuntimeDirectory != nullptr) {
ExtOut("Host runtime path: %s\n", g_hostRuntimeDirectory);
}
- std::string coreclrDirectory;
- if (SUCCEEDED(GetCoreClrDirectory(coreclrDirectory))) {
- ExtOut("Runtime path: %s\n", coreclrDirectory.c_str());
+ std::string runtimeDirectory;
+ if (SUCCEEDED(GetRuntimeDirectory(runtimeDirectory))) {
+ ExtOut("Runtime path: %s\n", runtimeDirectory.c_str());
}
DisplaySymbolStore();
GcEvtArgs gea = { GC_MARK_END, { ((gen == -1) ? 7 : (1 << gen)) } };
idp2->SetGcNotification(gea);
// ... and register the notification handler
- g_ExtControl->Execute(DEBUG_EXECUTE_NOT_LOGGED, "sxe -c \"!HandleCLRN\" clrn", 0);
+ g_ExtControl->Execute(DEBUG_EXECUTE_NOT_LOGGED, "sxe -c \"!SOSHandleCLRN\" clrn", 0);
// the above notification is removed in CNotification::OnGcEvent()
}
else
if (LoadClrDebugDll() != S_OK)
{
// Try to find stress log symbols
- DWORD_PTR dwAddr = GetValueFromExpression(MAIN_CLR_MODULE_NAME_A "!StressLog::theLog");
+ DWORD_PTR dwAddr = GetValueFromExpression("StressLog::theLog");
StressLogAddress = dwAddr;
g_bDacBroken = TRUE;
}
else
{
g_fAllowJitOptimization = FALSE;
- g_ExtControl->Execute(DEBUG_EXECUTE_NOT_LOGGED, "sxe -c \"!HandleCLRN\" clrn", 0);
+ g_ExtControl->Execute(DEBUG_EXECUTE_NOT_LOGGED, "sxe -c \"!SOSHandleCLRN\" clrn", 0);
ExtOut("JIT optimization will be suppressed\n");
}
{"-directory", &searchDirectory.data, COSTRING, TRUE},
{"-ms", &msdl, COBOOL, FALSE},
{"-log", &logging, COBOOL, FALSE},
-#ifdef FEATURE_PAL
{"-loadsymbols", &loadNative, COBOOL, FALSE},
+#ifdef FEATURE_PAL
{"-sympath", &windowsSymbolPath.data, COSTRING, TRUE},
#else
{"-mi", &symweb, COBOOL, FALSE},
#define plug_skew SIZEOF_OBJHEADER
#define min_obj_size (sizeof(BYTE*)+plug_skew+sizeof(size_t))
-extern BOOL CallStatus;
-
-
#ifndef NT_SUCCESS
#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
#endif
\**********************************************************************/
DWORD_PTR GetValueFromExpression(___in __in_z const char *const instr)
{
+ std::string symbol;
+ symbol.append(GetRuntimeModuleName());
+ symbol.append("!");
+ symbol.append(instr);
+
ULONG64 dwAddr;
- const char *str = instr;
+ const char* str = symbol.c_str();
char name[256];
dwAddr = 0;
ExtOut("SOS Error: Out of memory\n");
}
+// This is set as a side-effect of CheckEEDll()/GetRuntimeModuleInfo().
+bool g_isDesktopRuntime = false;
+
HRESULT GetRuntimeModuleInfo(PULONG moduleIndex, PULONG64 moduleBase)
{
-#ifdef FEATURE_PAL
- return g_ExtSymbols->GetModuleByModuleName(MAIN_CLR_DLL_NAME_A, 0, moduleIndex, moduleBase);
-#else
- return g_ExtSymbols->GetModuleByModuleName(MAIN_CLR_MODULE_NAME_A, 0, moduleIndex, moduleBase);
+ g_isDesktopRuntime = false;
+ HRESULT hr = g_ExtSymbols->GetModuleByModuleName(NETCORE_RUNTIME_MODULE_NAME_A, 0, moduleIndex, moduleBase);
+#ifndef FEATURE_PAL
+ if (FAILED(hr)) {
+ hr = g_ExtSymbols->GetModuleByModuleName(DESKTOP_RUNTIME_MODULE_NAME_A, 0, moduleIndex, moduleBase);
+ g_isDesktopRuntime = SUCCEEDED(hr);
+ }
#endif
+ return hr;
}
HRESULT CheckEEDll()
{
if (params.SymbolType == SymDeferred)
{
- g_ExtSymbols->Reload("/f " MAIN_CLR_DLL_NAME_A);
+ std::string reloadCommand;
+ reloadCommand.append("/f ");
+ reloadCommand.append(GetRuntimeDllName());
+ g_ExtSymbols->Reload(reloadCommand.c_str());
g_ExtSymbols->GetModuleParameters(1, &g_moduleInfo[MSCORWKS].baseAddr, 0, ¶ms);
}
if (params.SymbolType == SymPdb || params.SymbolType == SymDia)
}
if (g_moduleInfo[MSCORWKS].baseAddr != 0 && g_moduleInfo[MSCORWKS].hasPdb == FALSE)
{
- ExtOut("PDB symbol for coreclr.dll not loaded\n");
+ ExtOut("PDB symbol for %s not loaded\n", GetRuntimeDllName());
}
#endif // FEATURE_PAL
}
// >sxe ld:clr
// >g
// ...
- // ModLoad: coreclr.dll
+ // ModLoad: runtime dll
// >!bpmd Foo.dll Foo.Bar
// we will correctly give the answer that whatever module you were looking for, it isn't loaded yet
return NULL;
}
+#ifndef FEATURE_PAL
+
+/**********************************************************************\
+* Routine Description: *
+* *
+* Retrieve module base associated with the IXCLRDataModule *
+* instance passed in, and the extent type requested. *
+* *
+\**********************************************************************/
+HRESULT GetClrModuleImages(__in IXCLRDataModule* module, __in CLRDataModuleExtentType desiredType, __out PULONG64 firstAdd)
+{
+ CLRDATA_ENUM enumExtents;
+ HRESULT hr;
+
+ _ASSERTE(firstAdd != nullptr);
+ *firstAdd = 0;
+
+ if (FAILED(hr = module->StartEnumExtents(&enumExtents)))
+ {
+ return hr;
+ }
+ CLRDATA_MODULE_EXTENT extent;
+ while (module->EnumExtent(&enumExtents, &extent) == S_OK)
+ {
+ if ((desiredType == CLRDATA_MODULE_OTHER) || (desiredType == extent.type))
+ {
+ ULONG64 modBase;
+ if (FAILED(hr = g_ExtSymbols->GetModuleByOffset(extent.base, 0, nullptr, &modBase)))
+ {
+ break;
+ }
+ *firstAdd = modBase;
+ hr = S_OK;
+ break;
+ }
+ }
+ module->EndEnumExtents(enumExtents);
+ return hr;
+}
+
+#endif // FEATURE_PAL
+
/**********************************************************************\
* Routine Description: *
* *
\**********************************************************************/
HRESULT GetModuleFromAddress(___in CLRDATA_ADDRESS peAddress, ___out IXCLRDataModule** ppModule)
{
- HRESULT hr = E_FAIL;
*ppModule = nullptr;
int numModule;
for (int i = 0; i < numModule; i++)
{
ToRelease<IXCLRDataModule> module;
- hr = g_sos->GetModule(moduleList[i], &module);
+ HRESULT hr = g_sos->GetModule(moduleList[i], &module);
if (FAILED(hr)) {
- break;
+ return hr;
}
ULONG32 flags;
if ((hr = module->GetFlags(&flags)) != S_OK) {
continue;
}
DacpGetModuleData moduleData;
- HRESULT hr = moduleData.Request(module);
+ hr = moduleData.Request(module);
if (FAILED(hr)) {
- break;
+#ifdef FEATURE_PAL
+ return hr;
+#else
+ hr = GetClrModuleImages(module, CLRDATA_MODULE_PE_FILE, &moduleData.LoadedPEAddress);
+ if (FAILED(hr))
+ {
+ return hr;
+ }
+#endif
}
if (peAddress == moduleData.LoadedPEAddress)
{
*ppModule = module.Detach();
- break;
+ return S_OK;
}
}
}
- return hr;
+ return E_INVALIDARG;
}
/**********************************************************************\
// 2.x version
void DumpTieredNativeCodeAddressInfo_2x(struct DacpTieredVersionData_2x * pTieredVersionData, const UINT cTieredVersionData)
{
+ ExtOut("Code Version History:\n");
+
for(int i = cTieredVersionData - 1; i >= 0; --i)
{
const char *descriptor = NULL;
if (!(Options & SYMOPT_LOAD_LINES))
{
g_ExtSymbols->AddSymbolOptions(SYMOPT_LOAD_LINES);
-
if (SUCCEEDED(g_ExtSymbols->GetModuleByModuleName(MSCOREE_SHIM_A, 0, NULL, NULL)))
- g_ExtSymbols->Reload("/f " MSCOREE_SHIM_A);
-
+ {
+ g_ExtSymbols->Reload("/f" MSCOREE_SHIM_A);
+ }
EEFLAVOR flavor = GetEEFlavor();
if (flavor == MSCORWKS)
- g_ExtSymbols->Reload("/f " MAIN_CLR_DLL_NAME_A);
+ {
+ std::string reloadCommand;
+ reloadCommand.append("/f ");
+ reloadCommand.append(GetRuntimeDllName());
+ g_ExtSymbols->Reload(reloadCommand.c_str());
+ }
}
// reload mscoree.pdb and clrjit.pdb to get line info
BOOL GetEEVersion(VS_FIXEDFILEINFO* pFileInfo, char* fileVersionBuffer, int fileVersionBufferSizeInBytes)
{
_ASSERTE(pFileInfo);
- if (g_ExtSymbols2 == nullptr) {
- return FALSE;
- }
+ _ASSERTE(g_ExtSymbols2 != nullptr);
+
ModuleInfo moduleInfo = g_moduleInfo[GetEEFlavor()];
_ASSERTE(moduleInfo.index != DEBUG_ANY_ID);
#endif // FEATURE_PAL
//---------------------------------------------------------------------------------------
-// Provides a way for the public CLR debugging interface to find the appropriate
-// mscordbi.dll, DAC, etc.
+// Provides a way for the public CLR debugging interface to find the appropriate mscordbi.dll, DAC, etc.
class SOSLibraryProvider : public ICLRDebuggingLibraryProvider, ICLRDebuggingLibraryProvider2
{
public:
{
const char* filePath = nullptr;
- if (_wcsncmp(pwszFileName, MAKEDLLNAME_W(CORECLR_DAC_MODULE_NAME_W), _wcslen(MAKEDLLNAME_W(CORECLR_DAC_MODULE_NAME_W))) == 0)
+ if (_wcsncmp(pwszFileName, GetDacDllNameW(), _wcslen(GetDacDllNameW())) == 0)
{
filePath = GetDacFilePath();
}
- else if (_wcsncmp(pwszFileName, MAKEDLLNAME_W(MAIN_DBI_MODULE_NAME_W), _wcslen(MAKEDLLNAME_W(MAIN_DBI_MODULE_NAME_W))) == 0)
+ else if (_wcsncmp(pwszFileName, NET_DBI_DLL_NAME_W, _wcslen(NET_DBI_DLL_NAME_W)) == 0)
{
filePath = GetDbiFilePath();
}
}
else
{
- HRESULT hr = GetCoreClrDirectory(modulePath, MAX_LONGPATH);
+ HRESULT hr = GetRuntimeDirectory(modulePath, MAX_LONGPATH);
if (FAILED(hr))
{
return hr;
return S_OK;
}
- // Called by the shim to locate and load mscordaccore and mscordbi
+ // Called by the shim to locate and load dac and dbi
// Parameters:
// pwszFileName - the name of the file to load
// dwTimestamp - the expected timestamp of the file
}
}
#endif
- return g_ExtData->ReadVirtual(address, pBuffer, request, (PULONG) pcbRead);
+ HRESULT hr = g_ExtData->ReadVirtual(address, pBuffer, request, (PULONG) pcbRead);
+ if (FAILED(hr))
+ {
+ ExtDbgOut("SOSDataTarget::ReadVirtual FAILED %08x address %p size %08x\n", hr, address, request);
+ }
+ return hr;
}
virtual HRESULT STDMETHODCALLTYPE GetThreadContext(
GUID skuId = CLR_ID_ONECORE_CLR;
#else
GUID skuId = CLR_ID_CORECLR;
+#endif
+#ifndef FEATURE_PAL
+ if (g_isDesktopRuntime)
+ {
+ skuId = CLR_ID_V4_DESKTOP;
+ }
#endif
CLRDebuggingImpl* pDebuggingImpl = new CLRDebuggingImpl(skuId);
hr = pDebuggingImpl->QueryInterface(IID_ICLRDebugging, (LPVOID *)&pClrDebugging);
int *mWidths;
Alignment *mAlignments;
};
-
+
+#ifndef FEATURE_PAL
+HRESULT GetClrModuleImages(__in IXCLRDataModule* module, __in CLRDataModuleExtentType desiredType, __out PULONG64 firstAdd);
+#endif
HRESULT GetMethodDefinitionsFromName(DWORD_PTR ModulePtr, IXCLRDataModule* mod, const char* name, IXCLRDataMethodDefinition **ppMethodDefinitions, int numMethods, int *numMethodsNeeded);
HRESULT GetMethodDescsFromName(DWORD_PTR ModulePtr, IXCLRDataModule* mod, const char* name, DWORD_PTR **pOut, int *numMethodDescs);
T* m_ptr;
};
+// SOS's runtime, dac and dbi module name defines. *MODULE* is just the
+// module name on Windows, *DLL* has the .dll extension. On Linux/MacOS,
+// *MODULE* and *DLL* are the same.
+
+#ifdef FEATURE_PAL
+
+#define NETCORE_RUNTIME_MODULE_NAME_W MAKEDLLNAME_W(W("coreclr"))
+#define NETCORE_RUNTIME_MODULE_NAME_A MAKEDLLNAME_A("coreclr")
+#define NETCORE_RUNTIME_DLL_NAME_W NETCORE_RUNTIME_MODULE_NAME_W
+#define NETCORE_RUNTIME_DLL_NAME_A NETCORE_RUNTIME_MODULE_NAME_A
+
+#define NETCORE_DAC_MODULE_NAME_W MAKEDLLNAME_W(W("mscordaccore"))
+#define NETCORE_DAC_MODULE_NAME_A MAKEDLLNAME_A("mscordaccore")
+#define NETCORE_DAC_DLL_NAME_W NETCORE_DAC_MODULE_NAME_W
+#define NETCORE_DAC_DLL_NAME_A NETCORE_DAC_MODULE_NAME_A
+
+#define NET_DBI_MODULE_NAME_W MAKEDLLNAME_W(W("mscordbi"))
+#define NET_DBI_MODULE_NAME_A MAKEDLLNAME_A("mscordbi")
+#define NET_DBI_DLL_NAME_W NET_DBI_MODULE_NAME_W
+#define NET_DBI_DLL_NAME_A NET_DBI_MODULE_NAME_A
+
+#else
+
+#define NETCORE_RUNTIME_MODULE_NAME_W W("coreclr")
+#define NETCORE_RUNTIME_MODULE_NAME_A "coreclr"
+#define NETCORE_RUNTIME_DLL_NAME_W MAKEDLLNAME_W(NETCORE_RUNTIME_MODULE_NAME_W)
+#define NETCORE_RUNTIME_DLL_NAME_A MAKEDLLNAME_A(NETCORE_RUNTIME_MODULE_NAME_A)
+
+#define NETCORE_DAC_MODULE_NAME_W W("mscordaccore")
+#define NETCORE_DAC_MODULE_NAME_A "mscordaccore"
+#define NETCORE_DAC_DLL_NAME_W MAKEDLLNAME_W(NETCORE_DAC_MODULE_NAME_W)
+#define NETCORE_DAC_DLL_NAME_A MAKEDLLNAME_A(NETCORE_DAC_MODULE_NAME_A)
+
+#define NET_DBI_MODULE_NAME_W W("mscordbi")
+#define NET_DBI_MODULE_NAME_A "mscordbi"
+#define NET_DBI_DLL_NAME_W MAKEDLLNAME_W(W("mscordbi"))
+#define NET_DBI_DLL_NAME_A MAKEDLLNAME_A("mscordbi")
+
+#endif // FEATURE_PAL
+
+#define DESKTOP_RUNTIME_MODULE_NAME_W W("clr")
+#define DESKTOP_RUNTIME_MODULE_NAME_A "clr"
+#define DESKTOP_RUNTIME_DLL_NAME_W MAKEDLLNAME_W(DESKTOP_RUNTIME_MODULE_NAME_W)
+#define DESKTOP_RUNTIME_DLL_NAME_A MAKEDLLNAME_A(DESKTOP_RUNTIME_MODULE_NAME_A)
+
+#define DESKTOP_DAC_MODULE_NAME_W W("mscordacwks")
+#define DESKTOP_DAC_MODULE_NAME_A "mscordacwks"
+#define DESKTOP_DAC_DLL_NAME_W MAKEDLLNAME_W(W("mscordacwks"))
+#define DESKTOP_DAC_DLL_NAME_A MAKEDLLNAME_A("mscordacwks")
+
+// This is set as a side-effect of CheckEEDll()/GetRuntimeModuleInfo().
+extern bool g_isDesktopRuntime;
+
+inline const char* GetRuntimeModuleName()
+{
+ return g_isDesktopRuntime ? DESKTOP_RUNTIME_MODULE_NAME_A : NETCORE_RUNTIME_MODULE_NAME_A;
+}
+
+inline const char* GetRuntimeDllName()
+{
+ return g_isDesktopRuntime ? DESKTOP_RUNTIME_DLL_NAME_A : NETCORE_RUNTIME_DLL_NAME_A;
+}
+
+inline const char* GetDacModuleName()
+{
+ return g_isDesktopRuntime ? DESKTOP_DAC_MODULE_NAME_A : NETCORE_DAC_MODULE_NAME_A;
+}
+
+inline const char* GetDacDllName()
+{
+ return g_isDesktopRuntime ? DESKTOP_DAC_DLL_NAME_A : NETCORE_DAC_DLL_NAME_A;
+}
+
+inline const WCHAR* GetDacModuleNameW()
+{
+ return g_isDesktopRuntime ? DESKTOP_DAC_MODULE_NAME_W : NETCORE_DAC_MODULE_NAME_W;
+}
+
+inline const WCHAR* GetDacDllNameW()
+{
+ return g_isDesktopRuntime ? DESKTOP_DAC_DLL_NAME_W : NETCORE_DAC_DLL_NAME_W;
+}
+
struct ModuleInfo
{
ULONG64 baseAddr;
ULONG index;
BOOL hasPdb;
};
+
extern ModuleInfo g_moduleInfo[];
BOOL InitializeHeapData();
UnderlyingType m_val;
};
-struct ImageInfo
-{
- ULONG64 modBase;
-};
-
// Helper class used in ClrStackFromPublicInterface() to keep track of explicit EE Frames
// (i.e., "internal frames") on the stack. Call Init() with the appropriate
// ICorDebugThread3, and this class will initialize itself with the set of internal
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
- <TargetFrameworks>netcoreapp1.1;netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
+ <TargetFrameworks>netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
</Project>
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using Microsoft.Win32.SafeHandles;
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
-using Microsoft.Win32.SafeHandles;
namespace Microsoft.Diagnostics.Tools.Dump
{
NativeMethods.MINIDUMP_TYPE.MiniDumpWithThreadInfo |
NativeMethods.MINIDUMP_TYPE.MiniDumpWithTokenInformation;
- // Dump the process!
- if (!NativeMethods.MiniDumpWriteDump(process.Handle, (uint)process.Id, stream.SafeFileHandle, dumpType, ref exceptionInfo, IntPtr.Zero, IntPtr.Zero))
+ // Retry the write dump on ERROR_PARTIAL_COPY
+ for (int i = 0; i < 5; i++)
{
- int err = Marshal.GetHRForLastWin32Error();
- Marshal.ThrowExceptionForHR(err);
+ // Dump the process!
+ if (NativeMethods.MiniDumpWriteDump(process.Handle, (uint)process.Id, stream.SafeFileHandle, dumpType, ref exceptionInfo, IntPtr.Zero, IntPtr.Zero))
+ {
+ break;
+ }
+ else
+ {
+ int err = Marshal.GetHRForLastWin32Error();
+ if (err != NativeMethods.ERROR_PARTIAL_COPY)
+ {
+ Marshal.ThrowExceptionForHR(err);
+ }
+ }
}
}
});
private static class NativeMethods
{
- [DllImport("Dbghelp.dll")]
+ public const int ERROR_PARTIAL_COPY = unchecked((int)0x8007012b);
+
+ [DllImport("Dbghelp.dll", SetLastError = true)]
public static extern bool MiniDumpWriteDump(IntPtr hProcess, uint ProcessId, SafeFileHandle hFile, MINIDUMP_TYPE DumpType, ref MINIDUMP_EXCEPTION_INFORMATION ExceptionParam, IntPtr UserStreamParam, IntPtr CallbackParam);
[StructLayout(LayoutKind.Sequential, Pack = 4)]
#define INVALID_TASK_ID 0x0
#define MAX_CONNECTION_NAME MAX_PATH
-
-#define MAIN_CLR_MODULE_NAME_W W("coreclr")
-#define MAIN_CLR_MODULE_NAME_A "coreclr"
-
-#define MAIN_CLR_DLL_NAME_W MAKEDLLNAME_W(MAIN_CLR_MODULE_NAME_W)
-#define MAIN_CLR_DLL_NAME_A MAKEDLLNAME_A(MAIN_CLR_MODULE_NAME_A)
-
-
-#define MSCOREE_SHIM_W MAIN_CLR_DLL_NAME_W
-#define MSCOREE_SHIM_A MAIN_CLR_DLL_NAME_A
+#define MSCOREE_SHIM_W L"mscoree.dll"
+#define MSCOREE_SHIM_A "mscoree.dll"
#define SWITCHOUT_HANDLE_VALUE ((HANDLE)(LONG_PTR)-2)