Add SOS installer called dotnet-sos (temporary).
authorMike McLaughlin <mikem@microsoft.com>
Sat, 12 Jan 2019 01:39:47 +0000 (17:39 -0800)
committerMike McLaughlin <mikem@microsoft.com>
Fri, 25 Jan 2019 00:43:14 +0000 (16:43 -0800)
Added SOS binaries to dotnet-sos tool package.

Automatically search for installed .NET Core runtime.

Create a symlink to the DAC in a temp directory where libcoreclrtraceptprovider.so
doesn't exist so it doesn't get loaded by the DAC causing a LTTng-UST exception. To
workaround issue #https://github.com/dotnet/coreclr/issues/20205.

Add temporary file clean up on SOS exit for both the above symlink
and the native symbol downloader code.

Fix various problems in the "clrstack -i" command that trash memory
and fail the tests that have been enabled in this change.

Update dotnet-sos package files.

Update to 2.1.503 SDK/2.1.7 runtime.

Test against 2.2 instead of 2.0

Merge "Fix SOS GCInfo for Arm/Arm64" PR #22188 from coreclr SOS.

Push test logs on public ci

38 files changed:
README.md
diagnostics.sln
documentation/sos-debugging-extension.md
eng/Build-Native.cmd
eng/Versions.props
eng/build-native.sh
eng/build.yml
eng/install-test-runtimes.ps1
eng/install-test-runtimes.sh
global.json
src/Directory.Build.props
src/SOS/SOS.InstallHelper/InstallHelper.cs [new file with mode: 0644]
src/SOS/SOS.InstallHelper/SOS.InstallHelper.csproj [new file with mode: 0644]
src/SOS/SOS.NETCore/SOS.NETCore.csproj
src/SOS/SOS.NETCore/SymbolReader.cs
src/SOS/SOS.NETCore/Tracer.cs
src/SOS/SOS.UnitTests/ConfigFiles/Unix/Debugger.Tests.Config.txt
src/SOS/SOS.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt
src/SOS/SOS.UnitTests/Scripts/StackAndOtherTests.script
src/SOS/SOS.UnitTests/Scripts/StackTests.script
src/SOS/Strike/exts.cpp
src/SOS/Strike/hostcoreclr.cpp
src/SOS/Strike/hostcoreclr.h
src/SOS/Strike/metadata.cpp
src/SOS/Strike/sosdocs.txt
src/SOS/Strike/sosdocsunix.txt
src/SOS/Strike/strike.cpp
src/SOS/Strike/util.cpp
src/SOS/Strike/util.h
src/SOS/gcdump/gcdumpnonx86.cpp
src/Tools/dotnet-analyze/dotnet-analyze.csproj
src/Tools/dotnet-dump/dotnet-dump.csproj
src/Tools/dotnet-sos/Program.cs [new file with mode: 0644]
src/Tools/dotnet-sos/dotnet-sos.csproj [new file with mode: 0644]
src/inc/palclr.h
src/pal/inc/pal.h
src/pal/inc/palprivate.h [deleted file]
src/pal/src/include/pal/palinternal.h

index c9953615893ae89de639f7e9e42bb8cb4985e278..05ca6b345eec0e7f49f3b39670c9047358b0ce11 100644 (file)
--- a/README.md
+++ b/README.md
@@ -89,6 +89,10 @@ Symbol server support - The `setsymbolserver` command enables downloading the sy
     
     (lldb) setsymbolserver -ms
 
+Before executing the "bt" command to dump native frames to load the native symbols (for live debugging only):
+
+    (lldb) loadsymbols
+
 ## Useful Links
 
 * [The LLDB Debugger](http://lldb.llvm.org/index.html) - More information about lldb.
@@ -100,7 +104,7 @@ Symbol server support - The `setsymbolserver` command enables downloading the sy
 
 ## Build Status
 
-[![Build Status](https://dnceng.visualstudio.com/public/_apis/build/status/dotnet/diagnostics/public-ci?branchName=master)](https://dnceng.visualstudio.com/public/_build/latest?definitionId=72&branchName=master)
+[![Build Status](https://dnceng.visualstudio.com/public/_apis/build/status/dotnet/diagnostics/diagnostics-public-ci?branchName=master)](https://dnceng.visualstudio.com/public/_build/latest?definitionId=72&branchName=master)
 
 [//]: # (End current test results)
 
index 324aba897f3014837ca3b5163c357e3b599b76d1..03b8f947348c1ff004962434b8e01c19097ffac4 100644 (file)
@@ -35,6 +35,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "debugshim", "src\SOS\debugs
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gcdump", "src\SOS\gcdump\gcdump.vcxproj", "{20EBC3C4-917C-402D-B778-9A6E3742BF5A}"
 EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SOS.InstallHelper", "src\SOS\SOS.InstallHelper\SOS.InstallHelper.csproj", "{1F012743-941B-4915-8C55-02097894CF3F}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-sos", "src\Tools\dotnet-sos\dotnet-sos.csproj", "{41351955-16D5-48D7-AF4C-AF25F5FB2E78}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Checked|Any CPU = Checked|Any CPU
@@ -509,6 +513,86 @@ Global
                {20EBC3C4-917C-402D-B778-9A6E3742BF5A}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
                {20EBC3C4-917C-402D-B778-9A6E3742BF5A}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
                {20EBC3C4-917C-402D-B778-9A6E3742BF5A}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|x64
+               {1F012743-941B-4915-8C55-02097894CF3F}.Checked|Any CPU.ActiveCfg = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Checked|Any CPU.Build.0 = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Checked|ARM.ActiveCfg = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Checked|ARM.Build.0 = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Checked|ARM64.ActiveCfg = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Checked|ARM64.Build.0 = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Checked|x64.ActiveCfg = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Checked|x64.Build.0 = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Checked|x86.ActiveCfg = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Checked|x86.Build.0 = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Debug|ARM.ActiveCfg = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Debug|ARM.Build.0 = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Debug|ARM64.Build.0 = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Debug|x64.ActiveCfg = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Debug|x64.Build.0 = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Debug|x86.ActiveCfg = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Debug|x86.Build.0 = Debug|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Release|Any CPU.Build.0 = Release|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Release|ARM.ActiveCfg = Release|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Release|ARM.Build.0 = Release|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Release|ARM64.ActiveCfg = Release|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Release|ARM64.Build.0 = Release|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Release|x64.ActiveCfg = Release|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Release|x64.Build.0 = Release|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Release|x86.ActiveCfg = Release|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.Release|x86.Build.0 = Release|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.RelWithDebInfo|ARM.ActiveCfg = Release|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.RelWithDebInfo|ARM.Build.0 = Release|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.RelWithDebInfo|ARM64.ActiveCfg = Release|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.RelWithDebInfo|ARM64.Build.0 = Release|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU
+               {1F012743-941B-4915-8C55-02097894CF3F}.RelWithDebInfo|x86.Build.0 = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Checked|Any CPU.ActiveCfg = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Checked|Any CPU.Build.0 = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Checked|ARM.ActiveCfg = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Checked|ARM.Build.0 = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Checked|ARM64.ActiveCfg = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Checked|ARM64.Build.0 = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Checked|x64.ActiveCfg = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Checked|x64.Build.0 = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Checked|x86.ActiveCfg = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Checked|x86.Build.0 = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Debug|ARM.ActiveCfg = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Debug|ARM.Build.0 = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Debug|ARM64.Build.0 = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Debug|x64.ActiveCfg = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Debug|x64.Build.0 = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Debug|x86.ActiveCfg = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Debug|x86.Build.0 = Debug|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Release|Any CPU.Build.0 = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Release|ARM.ActiveCfg = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Release|ARM.Build.0 = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Release|ARM64.ActiveCfg = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Release|ARM64.Build.0 = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Release|x64.ActiveCfg = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Release|x64.Build.0 = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Release|x86.ActiveCfg = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.Release|x86.Build.0 = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.RelWithDebInfo|ARM.ActiveCfg = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.RelWithDebInfo|ARM.Build.0 = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.RelWithDebInfo|ARM64.ActiveCfg = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.RelWithDebInfo|ARM64.Build.0 = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78}.RelWithDebInfo|x86.Build.0 = Release|Any CPU
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
@@ -529,6 +613,8 @@ Global
                {A9A7C879-C320-3327-BB84-16E1322E17AE} = {41638A4C-0DAF-47ED-A774-ECBBAC0315D7}
                {6A94C5FE-8706-3505-834E-DA16242F3864} = {41638A4C-0DAF-47ED-A774-ECBBAC0315D7}
                {20EBC3C4-917C-402D-B778-9A6E3742BF5A} = {41638A4C-0DAF-47ED-A774-ECBBAC0315D7}
+               {1F012743-941B-4915-8C55-02097894CF3F} = {41638A4C-0DAF-47ED-A774-ECBBAC0315D7}
+               {41351955-16D5-48D7-AF4C-AF25F5FB2E78} = {B62728C8-1267-4043-B46F-5537BBAEC692}
        EndGlobalSection
        GlobalSection(ExtensibilityGlobals) = postSolution
                SolutionGuid = {46465737-C938-44FC-BE1A-4CE139EBB5E0}
index 041da8a6965aa304d5af089d4d59356ebd6965b5..a44f88e59219c0d5a43af2de829d1bf212b05702 100644 (file)
@@ -110,7 +110,7 @@ importance. Shortcut names for popular functions are listed in parenthesis. Type
 |**PrintException** [**-nested**] [**-lines**] [\<*Exception object address*>]<br /><br /> -or-<br /><br /> **PE** [**-nested**] [\<*Exception object address*>]|Displays and formats fields of any object derived from the <xref:System.Exception> class at the specified address. If you do not specify an address, the **PrintException** command displays the last exception thrown on the current thread.<br /><br /> The **-nested** option displays details about nested exception objects.<br /><br /> The **-lines** option displays source information, if available.<br /><br /> You can use this command to format and view the `_stackTrace` field, which is a binary array.|
 |**SyncBlk** [**-all** &#124; \<*syncblk number*>]|Displays the specified `SyncBlock` structure or all `SyncBlock` structures.  If you do not pass any arguments, the **SyncBlk** command displays the `SyncBlock` structure corresponding to objects that are owned by a thread.<br /><br /> A `SyncBlock` structure is a container for extra information that does not need to be created for every object. It can hold COM interop data, hash codes, and locking information for thread-safe operations.|
 |**SOSFlush**|Flushes an internal SOS cache.|
-|**SetSymbolServer** [**-ms**] [**-disable**] [**-log**] [**-cache** \<cache-path>] [**-loadsymbols**] [\<symbol-server-URL>]|Enables the symbol server downloading support.<br/><br/>The **-ms** option enables downloading from the public Microsoft symbol server.<br/><br/>The **-disable** option turns on the symbol download support.<br/><br/>The **-cache** \<cache-path> option specifies a symbol cache directory. The default is $HOME/.sos/symbolcache if not specified.<br/><br/>The **-log** option enables symbol download logging.<br/><br/>The **-loadsymbols** option attempts to download the native .NET Core symbols for the runtime.|
+|**SetSymbolServer** [**-ms**] [**-disable**] [**-log**] [**-cache** \<cache-path>] [**-loadsymbols**] [\<symbol-server-URL>]|Enables the symbol server downloading support.<br/><br/>The **-ms** option enables downloading from the public Microsoft symbol server.<br/><br/>The **-disable** option turns on the symbol download support.<br/><br/>The **-cache** \<cache-path> option specifies a symbol cache directory. The default is $HOME/.dotnet/symbolcache if not specified.<br/><br/>The **-log** option enables symbol download logging.<br/><br/>The **-loadsymbols** option attempts to download the native .NET Core symbols for the runtime.|
 |**Token2EE** \<*module name*> \<*token*>|Turns the specified metadata token in the specified module into a `MethodTable` structure or `MethodDesc` structure.<br /><br /> You can pass `*` for the module name parameter to find what that token maps to in every loaded managed module. You can also pass the debugger's name for a module, such as `mscorlib` or `image00400000`.|
 |**Threads** (**clrthreads**) [**-live**] [**-special**]|Displays all managed threads in the process.<br /><br /> The **Threads** command displays the debugger shorthand ID, the CLR thread ID, and the operating system thread ID.  Additionally, the **Threads** command displays a Domain column that indicates the application domain in which a thread is executing, an APT column that displays the COM apartment mode, and an Exception column that displays the last exception thrown in the thread.<br /><br /> The **-live** option displays threads associated with a live thread.<br /><br /> The **-special** option displays all special threads created by the CLR. Special threads include garbage collection threads (in concurrent and server garbage collection), debugger helper threads, finalizer threads, <xref:System.AppDomain> unload threads, and thread pool timer threads.|
 |**ThreadState \<** *State value field* **>**|Displays the state of the thread. The `value` parameter is the value of the `State` field in the **Threads** report output.|
index 65d8578a95e20c28544c584d0b50d08cc94994fd..a810a095ba93b1bb90c6b7e7401e40274ce2ed0d 100644 (file)
@@ -172,13 +172,13 @@ if not exist "%__DotNetCli%" (
     echo %__MsgPrefix%Assertion failed: dotnet cli not found at path "%__DotNetCli%"
     exit /b 1
 )
-set __MSBuildPath=%__ProjectDir%\.dotnet\sdk\2.1.401\MSBuild.dll
+set __MSBuildPath=%__ProjectDir%\.dotnet\sdk\2.1.503\MSBuild.dll
 if not exist "%__MSBuildPath%" (
     echo %__MsgPrefix%Assertion failed: dotnet cli sdk not found at path "%__MSBuildPath%"
     exit /b 1
 )
 
-set __DotNetRuntimeVersion=2.1.3
+set __DotNetRuntimeVersion=2.1.7
 
 REM =========================================================================================
 REM ===
index 76afd41f17a21e18c9172a15fe65e98185565cc4..588379b525c4fd804bb9541e0471d0b62feebbc4 100644 (file)
@@ -19,7 +19,7 @@
     <MicrosoftWin32PrimitivesVersion>4.3.0</MicrosoftWin32PrimitivesVersion>
 
     <!-- Other libs -->
-    <MicrosoftSymbolStoreVersion>1.0.0-dev-63604-01</MicrosoftSymbolStoreVersion>
+    <MicrosoftSymbolStoreVersion>1.0.0-dev-63716-01</MicrosoftSymbolStoreVersion>
   </PropertyGroup>
 
   <PropertyGroup>
index dca44b57b854fd937a7405797cb6c5ac7d2cef7b..deb6c858c6120e9e3f83004069fdfc0589294d8a 100755 (executable)
@@ -285,8 +285,8 @@ __ResultsDir=$__RootBinDir/TestResults/$__BuildType
 __PackagesBinDir=$__RootBinDir/packages/$__BuildType/Shipping
 __ExtraCmakeArgs="-DCLR_MANAGED_BINARY_DIR=$__RootBinDir/bin -DCLR_BUILD_TYPE=$__BuildType"
 __DotNetCli=$__ProjectRoot/.dotnet/dotnet
-__MSBuildPath=$__ProjectRoot/.dotnet/sdk/2.1.401/MSBuild.dll
-__DotNetRuntimeVersion=2.1.3
+__MSBuildPath=$__ProjectRoot/.dotnet/sdk/2.1.503/MSBuild.dll
+__DotNetRuntimeVersion=2.1.7
 
 if [ ! -e $__DotNetCli ]; then
    echo "dotnet cli not installed $__DotNetCli"
index fa582628e6ff720011c68715908f03b19942ebff..1191f4b6e723a15ecfaef60bf6d70a92705ebc57 100644 (file)
@@ -135,20 +135,20 @@ phases:
           artifactName: $(_PhaseName)_$(Agent.JobName)
         condition: and(succeeded(), ne(variables['_PublishArtifacts'], ''))
 
-      - task: CopyFiles@2
-        displayName: Gather Build Logs
-        inputs:
-          sourceFolder: '$(Build.SourcesDirectory)/artifacts'
-          contents: '?(log|TestResults)/**'
-          targetFolder: '$(Build.StagingDirectory)/BuildLogs'
-        continueOnError: true
-        condition: always()
+    - task: CopyFiles@2
+      displayName: Gather Build Logs
+      inputs:
+        sourceFolder: '$(Build.SourcesDirectory)/artifacts'
+        contents: '?(log|TestResults)/**'
+        targetFolder: '$(Build.StagingDirectory)/BuildLogs'
+      continueOnError: true
+      condition: always()
 
-      - task: PublishBuildArtifacts@1
-        displayName: Publish Logs to VSTS
-        inputs:
-          PathtoPublish: '$(Build.StagingDirectory)/BuildLogs'
-          PublishLocation: Container
-          ArtifactName: Logs_$(_PhaseName)_$(Agent.JobName)
-        continueOnError: true
-        condition: always()
+    - task: PublishBuildArtifacts@1
+      displayName: Publish Logs to VSTS
+      inputs:
+        PathtoPublish: '$(Build.StagingDirectory)/BuildLogs'
+        PublishLocation: Container
+        ArtifactName: Logs_$(_PhaseName)_$(Agent.JobName)
+      continueOnError: true
+      condition: always()
index 20e7a33c550520d6badd94a85d91cbdac29190c8..42bf6d3d98dc5d0ed630d2000a1b4398e5742fb5 100644 (file)
@@ -12,16 +12,16 @@ param(
 Set-StrictMode -Version Latest
 $ErrorActionPreference="Stop"
 
-$RuntimeVersion11="1.1.9"
-$RuntimeVersion20="2.0.9"
+$RuntimeVersion11="1.1.10"
+$RuntimeVersion22="2.2.1"
 $DailyTestText="true"
 
-# Install the other versions of .NET Core runtime we are going to test. 1.1.x, 2.0.x, 2.1.x (installed with the CLI)
+# Install the other versions of .NET Core runtime we are going to test. 1.1.x, 2.1.x (installed with the CLI), 2.2.x
 # and latest. Only install the latest master for daily jobs and leave the RuntimeVersion* config properties blank.
 if (!$DailyTest) {
     $DailyTestText="false"
     . $DotNetDir\dotnet-install.ps1 -Version $RuntimeVersion11 -Architecture $BuildArch -SkipNonVersionedFiles -Runtime dotnet -InstallDir $DotNetDir
-    . $DotNetDir\dotnet-install.ps1 -Version $RuntimeVersion20 -Architecture $BuildArch -SkipNonVersionedFiles -Runtime dotnet -InstallDir $DotNetDir
+    . $DotNetDir\dotnet-install.ps1 -Version $RuntimeVersion22 -Architecture $BuildArch -SkipNonVersionedFiles -Runtime dotnet -InstallDir $DotNetDir
 }
 
 . $DotNetDir\dotnet-install.ps1 -Channel $Branch -Version latest -Architecture $BuildArch -SkipNonVersionedFiles -Runtime dotnet -InstallDir $DotNetDir
@@ -43,8 +43,8 @@ if (Test-Path $VersionFile) {
     '<Configuration>
 <DailyTest>' + $DailyTestText  +'</DailyTest>
 <RuntimeVersion11>' + $RuntimeVersion11 + '</RuntimeVersion11>
-<RuntimeVersion20>' + $RuntimeVersion20 + '</RuntimeVersion20>
 <RuntimeVersion21>' + $RuntimeVersion21 + '</RuntimeVersion21>
+<RuntimeVersion22>' + $RuntimeVersion22 + '</RuntimeVersion22>
 <RuntimeVersionLatest>' + $RuntimeVersionLatest + '</RuntimeVersionLatest>
 </Configuration>' | Set-Content $ConfigFile
 
index 2edf1b0f38840b8a63660876df78faa0d3bcb165..41151ac8ace77a69a3b142c04c490733f9b040f0 100755 (executable)
@@ -9,8 +9,8 @@ daily_test=0
 branch="master"
 uncached_feed="https://dotnetcli.blob.core.windows.net/dotnet"
 
-runtime_version_11="1.1.9"
-runtime_version_20="2.0.9"
+runtime_version_11="1.1.10"
+runtime_version_22="2.2.1"
 runtime_version_21=
 
 while [ $# -ne 0 ]; do
@@ -48,12 +48,12 @@ done
 
 daily_test_text="true"
 
-# Install the other versions of .NET Core runtime we are going to test. 1.1.x, 2.0.x, 2.1.x (installed with the CLI)
+# Install the other versions of .NET Core runtime we are going to test. 1.1.x, 2.1.x (installed with the CLI), 2.2.x
 # and latest. Only install the latest master for daily jobs and leave the RuntimeVersion* config properties blank.
 if [ $daily_test == 0 ]; then
     daily_test_text="false"
     bash "$dotnet_dir/dotnet-install.sh" --version "$runtime_version_11" --architecture "$build_arch" --skip-non-versioned-files --runtime dotnet --install-dir "$dotnet_dir"
-    bash "$dotnet_dir/dotnet-install.sh" --version "$runtime_version_20" --architecture "$build_arch" --skip-non-versioned-files --runtime dotnet --install-dir "$dotnet_dir"
+    bash "$dotnet_dir/dotnet-install.sh" --version "$runtime_version_22" --architecture "$build_arch" --skip-non-versioned-files --runtime dotnet --install-dir "$dotnet_dir"
 fi
 
 bash "$dotnet_dir/dotnet-install.sh" --channel $branch --version latest --architecture "$build_arch" --skip-non-versioned-files --runtime dotnet --install-dir "$dotnet_dir"
@@ -78,8 +78,8 @@ if [ -f "$version_file" ]; then
     echo "<Configuration>
 <DailyTest>$daily_test_text</DailyTest>
 <RuntimeVersion11>$runtime_version_11</RuntimeVersion11>
-<RuntimeVersion20>$runtime_version_20</RuntimeVersion20>
 <RuntimeVersion21>$runtime_version_21</RuntimeVersion21>
+<RuntimeVersion22>$runtime_version_22</RuntimeVersion22>
 <RuntimeVersionLatest>$runtime_version_latest</RuntimeVersionLatest>
 </Configuration>" > $config_file
 
index a4abdd6309b7fbd48951a07b73395149b477cc21..0ae51c08c4f548669c20c17c35bc64812378a760 100644 (file)
@@ -1,6 +1,6 @@
 {
   "tools": {
-    "dotnet": "2.1.401"
+    "dotnet": "2.1.503"
   },
   "msbuild-sdks": {
     "Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.18516.5"
index 24999e271197bfe09a4e2be3f5326c5520d66446..62a7d0052fda14844af332c4721198935316d137 100644 (file)
@@ -12,7 +12,7 @@
     <!--
       Tools and packages produced by this repository support infrastructure and are not shipping on NuGet or via any other official channel.
     -->
-    <IsShipping>false</IsShipping>
+    <IsShipping>true</IsShipping>
     <NoPackageAnalysis>true</NoPackageAnalysis>
   </PropertyGroup>
 
     <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
   </PropertyGroup>
 
-  <PropertyGroup Condition="'$(TargetFramework)' == 'net45'">
+  <PropertyGroup Condition="'$(TargetFramework)' == 'net461'">
     <DebugType>full</DebugType>
   </PropertyGroup>
 
-  <PropertyGroup Condition="'$(TargetFramework)' != 'net45'">
+  <PropertyGroup Condition="'$(TargetFramework)' != 'net461'">
     <DebugType>portable</DebugType>
   </PropertyGroup>
 </Project>
diff --git a/src/SOS/SOS.InstallHelper/InstallHelper.cs b/src/SOS/SOS.InstallHelper/InstallHelper.cs
new file mode 100644 (file)
index 0000000..6d20caf
--- /dev/null
@@ -0,0 +1,172 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+namespace SOS.InstallHelper
+{
+    /// <summary>
+    /// Functions to install and configure SOS from the package containing this code.
+    /// </summary>
+    public sealed class InstallHelper
+    {
+        /// <summary>
+        /// Well known location to install SOS. Defaults to $HOME/.dotnet/sos on xplat and %USERPROFILE%/.dotnet/sos on Windows.
+        /// </summary>
+        public string InstallLocation { get; set; }
+
+        /// <summary>
+        /// On Linux/MacOS, the location of the lldb ".lldbinit" file. Defaults to $HOME/.lldbinit.
+        /// </summary>
+        public string LLDBInitFile { get; set; }
+
+        /// <summary>
+        /// If true, enable the symbol server support when configuring lldb.
+        /// </summary>
+        public bool EnableSymbolServer { get; set; } = true;
+
+        /// <summary>
+        /// The source path from which SOS is installed. Default is OS/architecture (RID) named directory in the same directory as this assembly.
+        /// </summary>
+        public string SOSSourcePath { get; set; }
+
+        /// <summary>
+        /// Create an instance of the installer.
+        /// </summary>
+        /// <exception cref="PlatformNotSupportedException">unknown operating system</exception>
+        public InstallHelper()
+        {
+            string home = null;
+            string os = null;
+
+            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) 
+            {
+                home = Environment.GetEnvironmentVariable("USERPROFILE");
+                os = "win";
+            }
+            else
+            {
+                home = Environment.GetEnvironmentVariable("HOME");
+                LLDBInitFile = Path.Combine(home, ".lldbinit");
+
+                if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
+                    os = "osx";
+                }
+                else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) {
+                    os = "linux";
+                }
+            }
+            if (os == null) {
+                throw new PlatformNotSupportedException($"Unsupported operating system {RuntimeInformation.OSDescription}");
+            }
+            Debug.Assert(!string.IsNullOrEmpty(home));
+            InstallLocation = Path.GetFullPath(Path.Combine(home, ".dotnet", "sos"));
+
+            string architecture = RuntimeInformation.OSArchitecture.ToString().ToLowerInvariant();
+            string rid = os + "-" + architecture;
+            SOSSourcePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), rid);
+        }
+
+        /// <summary>
+        /// Install SOS to well known location (InstallLocation).
+        /// </summary>
+        /// <exception cref="ArgumentException"></exception>
+        /// <exception cref="PlatformNotSupportedException">SOS not found for OS/architecture</exception>
+        public void Install()
+        {
+            Debug.Assert(!string.IsNullOrEmpty(InstallLocation));
+            Debug.Assert(!string.IsNullOrEmpty(SOSSourcePath));
+            if (!Directory.Exists(SOSSourcePath)) {
+                throw new PlatformNotSupportedException($"Operating system or architecture not supported: installing from {SOSSourcePath}");
+            }
+            Directory.CreateDirectory(InstallLocation);
+            foreach (string file in Directory.EnumerateFiles(SOSSourcePath))
+            {
+                string destinationFile = Path.Combine(InstallLocation, Path.GetFileName(file));
+                File.Copy(file, destinationFile, overwrite: true);
+            }
+        }
+
+        /// <summary>
+        /// Uninstalls and removes the SOS configuration.
+        /// </summary>
+        public void Uninstall()
+        {
+            if (!string.IsNullOrEmpty(LLDBInitFile)) {
+                Configure(remove: true);
+            }
+            if (Directory.Exists(InstallLocation))
+            {
+                foreach (string file in Directory.EnumerateFiles(InstallLocation))
+                {
+                    File.Delete(file);
+                }
+                Directory.Delete(InstallLocation);
+            }
+        }
+
+        const string InitFileStart = "#START - ADDED BY SOS INSTALLER";
+        const string InitFileEnd = "#END - ADDED BY SOS INSTALLER";
+
+        /// <summary>
+        /// Configure lldb to load SOS.
+        /// </summary>
+        /// <param name="remove">if true, remove the configuration from the init file</param>
+        /// <exception cref="ArgumentException"></exception>
+        public void Configure(bool remove = false)
+        {
+            if (string.IsNullOrEmpty(LLDBInitFile)) {
+                throw new ArgumentException("No lldb configuration file");
+            }
+
+            // Remove the start/end marker from an existing .lldbinit file
+            var lines = new List<string>();
+            if (File.Exists(LLDBInitFile))
+            {
+                bool markerFound = false;
+                foreach (string line in File.ReadAllLines(LLDBInitFile))
+                {
+                    if (line.Contains(InitFileEnd)) {
+                        markerFound = false;
+                        continue;
+                    }
+                    if (!markerFound) {
+                        if (line.Contains(InitFileStart)) {
+                            markerFound = true;
+                            continue;
+                        }
+                        lines.Add(line);
+                    }
+                }
+                if (markerFound) {
+                    throw new ArgumentException(".lldbinit file end marker not found");
+                }
+            }
+
+            // If configure (not remove), add the plugin load, etc. configuration between the start/end markers.
+            if (!remove)
+            {
+                lines.Add(InitFileStart);
+                string plugin = Path.Combine(InstallLocation, "libsosplugin");
+                string extension = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? ".dylib" : ".so";
+                lines.Add($"plugin load {plugin}{extension}");
+
+                if (EnableSymbolServer) {
+                    lines.Add(string.Format("setsymbolserver -ms"));
+                }
+                lines.Add(InitFileEnd);
+            }
+
+            // If there is anything to write, write the lldb init file
+            if (lines.Count > 0) {
+                File.WriteAllLines(LLDBInitFile, lines.ToArray());
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/SOS/SOS.InstallHelper/SOS.InstallHelper.csproj b/src/SOS/SOS.InstallHelper/SOS.InstallHelper.csproj
new file mode 100644 (file)
index 0000000..89203e3
--- /dev/null
@@ -0,0 +1,12 @@
+<!-- Copyright (c)  Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information. -->
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <TargetFramework>netstandard2.0</TargetFramework>
+    <AssemblyName>SOS.InstallHelper</AssemblyName>
+    <NoWarn>;1591;1701</NoWarn>
+    <Description>Diagnostic SOS Install Helper</Description>
+    <PackageReleaseNotes>$(Description)</PackageReleaseNotes>
+    <PackageTags>SOS</PackageTags>
+    <DebugSymbols>true</DebugSymbols>
+  </PropertyGroup>
+</Project>
index a4d723675802c9b6851c1bfb71377414a2e61e54..a0f80a208e3da7f62b5690a1db899977dc121a8b 100644 (file)
@@ -5,72 +5,11 @@
     <AssemblyName>SOS.NETCore</AssemblyName>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <NoWarn>;1591;1701</NoWarn>
-    <IsPackable>true</IsPackable>
-    <IsPublishable>true</IsPublishable>
     <Description>.NET Core SOS</Description>
-    <PackageId>SOS</PackageId>
-    <PackageReleaseNotes>$(Description)</PackageReleaseNotes>
-    <PackageTags>SOS</PackageTags>
-    <IncludeBuildOutput>false</IncludeBuildOutput>
-    <SOSNETCoreBinaries>$(ArtifactsBinDir)\SOS.NETCore\$(Configuration)\netcoreapp2.0\publish\*.dll</SOSNETCoreBinaries>
   </PropertyGroup>
   
   <ItemGroup>
     <PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" />
     <PackageReference Include="Microsoft.SymbolStore" Version="$(MicrosoftSymbolStoreVersion)" />
   </ItemGroup>
-
-  <ItemGroup>
-    <_PackageFiles Include="$(SOSNETCoreBinaries)">
-      <BuildAction>None</BuildAction>
-      <PackagePath>tools/win-x64</PackagePath>
-    </_PackageFiles>
-    <_PackageFiles Include="$(ArtifactsBinDir)\Windows_NT.x64.$(Configuration)\sos.dll">
-      <BuildAction>None</BuildAction>
-      <PackagePath>tools/win-x64</PackagePath>
-    </_PackageFiles>
-
-    <_PackageFiles Include="$(SOSNETCoreBinaries)">
-      <BuildAction>None</BuildAction>
-      <PackagePath>tools/win-x86</PackagePath>
-    </_PackageFiles>
-    <_PackageFiles Include="$(ArtifactsBinDir)\Windows_NT.x86.$(Configuration)\sos.dll">
-      <BuildAction>None</BuildAction>
-      <PackagePath>tools/win-x86</PackagePath>
-    </_PackageFiles>
-
-    <_PackageFiles Include="$(SOSNETCoreBinaries)">
-      <BuildAction>None</BuildAction>
-      <PackagePath>tools/linux-x64</PackagePath>
-    </_PackageFiles>
-    <_PackageFiles Include="$(ArtifactsBinDir)\Linux.x64.$(Configuration)\libsosplugin.so">
-      <BuildAction>None</BuildAction>
-      <PackagePath>tools/linux-x64</PackagePath>
-    </_PackageFiles>
-    <_PackageFiles Include="$(ArtifactsBinDir)\Linux.x64.$(Configuration)\libsos.so">
-      <BuildAction>None</BuildAction>
-      <PackagePath>tools/linux-x64</PackagePath>
-    </_PackageFiles>
-    <_PackageFiles Include="$(ArtifactsBinDir)\Linux.x64.$(Configuration)\sosdocsunix.txt">
-      <BuildAction>None</BuildAction>
-      <PackagePath>tools/linux-x64</PackagePath>
-    </_PackageFiles>
-
-    <_PackageFiles Include="$(SOSNETCoreBinaries)">
-      <BuildAction>None</BuildAction>
-      <PackagePath>tools/osx-x64</PackagePath>
-    </_PackageFiles>
-    <_PackageFiles Include="$(ArtifactsBinDir)\OSX.x64.$(Configuration)\libsosplugin.dylib">
-      <BuildAction>None</BuildAction>
-      <PackagePath>tools/osx-x64</PackagePath>
-    </_PackageFiles>
-    <_PackageFiles Include="$(ArtifactsBinDir)\OSX.x64.$(Configuration)\libsos.dylib">
-      <BuildAction>None</BuildAction>
-      <PackagePath>tools/osx-x64</PackagePath>
-    </_PackageFiles>
-    <_PackageFiles Include="$(ArtifactsBinDir)\OSX.x64.$(Configuration)\sosdocsunix.txt">
-      <BuildAction>None</BuildAction>
-      <PackagePath>tools/osx-x64</PackagePath>
-    </_PackageFiles>
-  </ItemGroup>
 </Project>
index d5d1e25b451cb368e225b9a1b154f4085e3fecc3..4681c43f591ee169edb2de6f0f7e61e11604412b 100644 (file)
@@ -165,7 +165,6 @@ namespace SOS
 
         static SymbolStore s_symbolStore = null;
         static bool s_symbolCacheAdded = false;
-        static string s_tempDirectory = null;
         static ITracer s_tracer = null;
 
         /// <summary>
@@ -204,6 +203,30 @@ namespace SOS
             return true;
         }
 
+        /// <summary>
+        /// Displays the symbol server and cache configuration
+        /// </summary>
+        internal static void DisplaySymbolStore()
+        {
+            if (s_tracer != null)
+            {
+                SymbolStore symbolStore = s_symbolStore;
+                while (symbolStore != null)
+                {
+                    if (symbolStore is CacheSymbolStore cache) {
+                        s_tracer.WriteLine("Cache: {0}", cache.CacheDirectory);
+                    }
+                    else if (symbolStore is HttpSymbolStore http)  {
+                        s_tracer.WriteLine("Server: {0}", http.Uri);
+                    }
+                    else {
+                        s_tracer.WriteLine("Unknown symbol store");
+                    }
+                    symbolStore = symbolStore.BackingStore;
+                }
+            }
+        }
+
         /// <summary>
         /// This function disables any symbol downloading support.
         /// </summary>
@@ -224,7 +247,7 @@ namespace SOS
         /// <param name="address">module base address</param>
         /// <param name="size">module size</param>
         /// <param name="readMemory">read memory callback delegate</param>
-        internal static void LoadNativeSymbols(SymbolFileCallback callback, IntPtr parameter, string moduleDirectory, string moduleFileName, 
+        internal static void LoadNativeSymbols(SymbolFileCallback callback, IntPtr parameter, string tempDirectory, string moduleDirectory, string moduleFileName, 
             ulong address, int size, ReadMemoryDelegate readMemory)
         {
             if (s_symbolStore != null)
@@ -265,21 +288,27 @@ namespace SOS
                             {
                                 if (file != null)
                                 {
-                                    string downloadFileName = file.FileName;
-
-                                    // If the downloaded doesn't already exists on disk in the cache, then write it to a temporary location.
-                                    if (!File.Exists(downloadFileName))
+                                    try
                                     {
-                                        downloadFileName = Path.Combine(GetTempDirectory(), symbolFileName);
+                                        string downloadFileName = file.FileName;
 
-                                        using (Stream destinationStream = File.OpenWrite(downloadFileName))
+                                        // If the downloaded doesn't already exists on disk in the cache, then write it to a temporary location.
+                                        if (!File.Exists(downloadFileName))
                                         {
-                                            file.Stream.CopyTo(destinationStream);
+                                            downloadFileName = Path.Combine(tempDirectory, symbolFileName);
+
+                                            using (Stream destinationStream = File.OpenWrite(downloadFileName)) {
+                                                file.Stream.CopyTo(destinationStream);
+                                            }
+                                            s_tracer.WriteLine("Downloaded symbol file {0}", key.FullPathName);
                                         }
-                                        s_tracer.WriteLine("Downloaded symbol file {0}", key.FullPathName);
+                                        s_tracer.Information("{0}: {1}", symbolFileName, downloadFileName);
+                                        callback(parameter, symbolFileName, downloadFileName);
+                                    }
+                                    catch (Exception ex) when (ex is UnauthorizedAccessException || ex is DirectoryNotFoundException)
+                                    {
+                                        s_tracer.Error("{0}", ex.Message);
                                     }
-                                    s_tracer.Information("{0}: {1}", symbolFileName, downloadFileName);
-                                    callback(parameter, symbolFileName, downloadFileName);
                                 }
                             }
                         }
@@ -859,6 +888,10 @@ namespace SOS
                     Debug.Assert(codeViewEntry.MinorVersion == ImageDebugDirectory.PortablePDBMinorVersion);
                     SymbolStoreKey key = PortablePDBFileKeyGenerator.GetKey(pdbPath, data.Guid);
                     pdbStream = GetSymbolStoreFile(key)?.Stream;
+                    if (pdbStream == null)
+                    {
+                        return null;
+                    }
                 }
 
                 provider = MetadataReaderProvider.FromPortablePdbStream(pdbStream);
@@ -983,7 +1016,8 @@ namespace SOS
                             break;
 
                         default:
-                            return false;
+                            // Directory path search (currently ignored)
+                            break;
                     }
 
                     // Add the symbol stores to the chain
@@ -1054,34 +1088,14 @@ namespace SOS
 
         private static string GetDefaultSymbolCache()
         {
-            var sb = new StringBuilder();
-
-            string environmentVar;
-            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
-            {
-                environmentVar = "ProgramData";
-            }
-            else
-            {
-                environmentVar = "HOME";
-            }
-            string userPath = Environment.GetEnvironmentVariable(environmentVar);
-            sb.Append(userPath);
-            sb.Append(Path.DirectorySeparatorChar);
-
             if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
             {
-                sb.Append("dbg");
-                sb.Append(Path.DirectorySeparatorChar);
-                sb.Append("sym");
+                return Path.Combine(Path.GetTempPath(), "SymbolCache");
             }
             else
             {
-                sb.Append(".dotnet");
-                sb.Append(Path.DirectorySeparatorChar);
-                sb.Append("symbolcache");
+                return Path.Combine(Environment.GetEnvironmentVariable("HOME"), ".dotnet", "symbolcache");
             }
-            return sb.ToString();
         }
 
         /// <summary>
@@ -1105,19 +1119,6 @@ namespace SOS
             }
         }
 
-        /// <summary>
-        /// Create/return a temporary directory.
-        /// </summary>
-        private static string GetTempDirectory()
-        {
-            if (s_tempDirectory == null)
-            {
-                s_tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
-                Directory.CreateDirectory(s_tempDirectory);
-            }
-            return s_tempDirectory;
-        }
-
         /// <summary>
         /// Quick fix for Path.GetFileName which incorrectly handles Windows-style paths on Linux
         /// </summary>
index 330f954add896710393b375c5c8027f65c8e456a..894598cc16544e89b94525872cb9948d141015f2 100644 (file)
@@ -1,4 +1,6 @@
-// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
 
 using System;
 
index d86aefd107118085a6b616ca60095700ff64b735..a5c35194a2e762eae749502b5e97dfdf5b2832ca 100644 (file)
       <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion>
     </Option>
     <Option Condition="'$(DailyTest)' != 'true'">
-      <BuildProjectMicrosoftNetCoreAppVersion>$(RuntimeVersion21)</BuildProjectMicrosoftNetCoreAppVersion>
+      <!-- Build the debuggee for 2.1 but run it on 2.2 -->
       <BuildProjectFramework>netcoreapp2.1</BuildProjectFramework>
-      <RuntimeFrameworkVersion>$(RuntimeVersion21)</RuntimeFrameworkVersion>
+      <BuildProjectMicrosoftNetCoreAppVersion>$(RuntimeVersion22)</BuildProjectMicrosoftNetCoreAppVersion>
+      <RuntimeFrameworkVersion>$(RuntimeVersion22)</RuntimeFrameworkVersion>
     </Option>
     <Option Condition="'$(DailyTest)' != 'true'">
-      <BuildProjectMicrosoftNetCoreAppVersion>$(RuntimeVersion20)</BuildProjectMicrosoftNetCoreAppVersion>
-      <BuildProjectFramework>netcoreapp2.0</BuildProjectFramework>
-      <RuntimeFrameworkVersion>$(RuntimeVersion20)</RuntimeFrameworkVersion>
+      <BuildProjectFramework>netcoreapp2.1</BuildProjectFramework>
+      <BuildProjectMicrosoftNetCoreAppVersion>$(RuntimeVersion21)</BuildProjectMicrosoftNetCoreAppVersion>
+      <RuntimeFrameworkVersion>$(RuntimeVersion21)</RuntimeFrameworkVersion>
     </Option>
     <Option Condition="Exists('$(RepoRootDir)/.dotnet/shared/Microsoft.NETCore.App/$(RuntimeVersion11)')">
-      <BuildProjectMicrosoftNetCoreAppVersion>$(RuntimeVersion11)</BuildProjectMicrosoftNetCoreAppVersion>
       <BuildProjectFramework>netcoreapp1.1</BuildProjectFramework>
+      <BuildProjectMicrosoftNetCoreAppVersion>$(RuntimeVersion11)</BuildProjectMicrosoftNetCoreAppVersion>
       <RuntimeFrameworkVersion>$(RuntimeVersion11)</RuntimeFrameworkVersion>
       <!-- createdump doesn't exists in 1.1 -->
       <GenerateDumpWithGDB>true</GenerateDumpWithGDB>
       <!-- SOS needs at least 2.0 to run. The default without this is to use the runtime being debuggged to host SOS.NETCore -->
-      <SOSHostRuntime>$(RepoRootDir)/.dotnet/shared/Microsoft.NETCore.App/$(RuntimeVersion20)</SOSHostRuntime>
+      <SOSHostRuntime>$(RepoRootDir)/.dotnet/shared/Microsoft.NETCore.App/$(RuntimeVersion21)</SOSHostRuntime>
     </Option>
   </Options>
 
index 2eaf15b2b141caaf13d1f68e25f3bb480eef9a2e..3ccab463bf17f5d88cc4ea6092cd1193a3d237c8 100644 (file)
       <Options>
         <Option>
           <!-- Build the debuggee for 2.1 but run it on latest -->
-          <BuildProjectMicrosoftNetCoreAppVersion>$(RuntimeVersion21)</BuildProjectMicrosoftNetCoreAppVersion>
           <BuildProjectFramework>netcoreapp2.1</BuildProjectFramework>
+          <BuildProjectMicrosoftNetCoreAppVersion>$(RuntimeVersion21)</BuildProjectMicrosoftNetCoreAppVersion>
           <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion>
         </Option>
         <Option Condition="'$(DailyTest)' != 'true'">
-          <BuildProjectMicrosoftNetCoreAppVersion>$(RuntimeVersion21)</BuildProjectMicrosoftNetCoreAppVersion>
+          <!-- Build the debuggee for 2.1 but run it on 2.2 -->
           <BuildProjectFramework>netcoreapp2.1</BuildProjectFramework>
-          <RuntimeFrameworkVersion>$(RuntimeVersion21)</RuntimeFrameworkVersion>
+          <BuildProjectMicrosoftNetCoreAppVersion>$(RuntimeVersion22)</BuildProjectMicrosoftNetCoreAppVersion>
+          <RuntimeFrameworkVersion>$(RuntimeVersion22)</RuntimeFrameworkVersion>
         </Option>
         <Option Condition="'$(DailyTest)' != 'true'">
-          <BuildProjectMicrosoftNetCoreAppVersion>$(RuntimeVersion20)</BuildProjectMicrosoftNetCoreAppVersion>
-          <BuildProjectFramework>netcoreapp2.0</BuildProjectFramework>
-          <RuntimeFrameworkVersion>$(RuntimeVersion20)</RuntimeFrameworkVersion>
+          <BuildProjectFramework>netcoreapp2.1</BuildProjectFramework>
+          <BuildProjectMicrosoftNetCoreAppVersion>$(RuntimeVersion21)</BuildProjectMicrosoftNetCoreAppVersion>
+          <RuntimeFrameworkVersion>$(RuntimeVersion21)</RuntimeFrameworkVersion>
         </Option>
         <Option Condition="'$(DailyTest)' != 'true'">
-          <BuildProjectMicrosoftNetCoreAppVersion>$(RuntimeVersion11)</BuildProjectMicrosoftNetCoreAppVersion>
           <BuildProjectFramework>netcoreapp1.1</BuildProjectFramework>
+          <BuildProjectMicrosoftNetCoreAppVersion>$(RuntimeVersion11)</BuildProjectMicrosoftNetCoreAppVersion>
           <RuntimeFrameworkVersion>$(RuntimeVersion11)</RuntimeFrameworkVersion>
           <!-- SOS needs at least 2.0 to run. The default without this is to use the runtime being debuggged to host SOS.NETCore -->
-          <SOSHostRuntime>$(RepoRootDir)\.dotnet\shared\Microsoft.NETCore.App\$(RuntimeVersion20)</SOSHostRuntime>
+          <SOSHostRuntime>$(RepoRootDir)\.dotnet\shared\Microsoft.NETCore.App\$(RuntimeVersion21)</SOSHostRuntime>
         </Option>
       </Options>
       <HostExe>$(RepoRootDir)\.dotnet\dotnet.exe</HostExe>
index b180edd7c41e7ccb409c2a102c0af12aa5261ff3..5382109ba0fe37f4741f3ff7ef4a3f8512c8693d 100644 (file)
@@ -10,6 +10,8 @@ CONTINUE
 ENDIF:LIVE
 
 # Verify that ClrStack with no options works
+SOSCOMMAND:SetSymbolServer -ms
+SOSCOMMAND:SetHostRuntime
 SOSCOMMAND:ClrStack
 VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.*
 VERIFY:\s+Child\s+SP\s+IP\s+Call Site\s+
@@ -17,6 +19,7 @@ VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>.*\s+SymbolTestApp\.Program\.Foo4\(System\.String
 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*
+SOSCOMMAND:SetSymbolServer -disable
 
 # Verify that ClrStack with managed/native mixed works
 IFDEF:PROJECTK
@@ -59,9 +62,6 @@ VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+SymbolTestApp\.Program\.Foo1\(.*\)\s+\[(?i:.*[
 VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+SymbolTestApp\.Program\.Main\(.*\)\s+\[(?i:.*[\\|/]SymbolTestApp\.cs) @ 19\]\s*
 ENDIF:PROJECTK
 
-# Disable ClrStack -i until coreclr issue #17259
-IFDEF:DESKTOP
-
 # Verify that ClrStack with the ICorDebug options works
 SOSCOMMAND:ClrStack -i
 IFDEF:PROJECTK
@@ -92,8 +92,6 @@ VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+\[DEFAULT\] Void SymbolTestApp\.Program\.Main\
 VERIFY:.*\s+Stack walk complete.\s+
 ENDIF:PROJECTK
 
-ENDIF:DESKTOP
-
 # Verify DumpStackObjects works
 IFDEF:PROJECTK
 SOSCOMMAND:DumpStackObjects
index 595dc9e9b687949ba8430d548557ef2048a7cab3..f79d76514bcca4249f3510e6a6bff92419c65483 100644 (file)
@@ -18,6 +18,8 @@ ENDIF:64BIT
 
 # 2) Verifying that ClrStack with managed/native mixed works
 IFDEF:PROJECTK
+SOSCOMMAND:SetSymbolServer -ms -loadsymbols
+SOSCOMMAND:SetHostRuntime
 SOSCOMMAND:ClrStack -f
 VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.*
 VERIFY:\s+Child\s+SP\s+IP\s+Call Site\s+
@@ -25,6 +27,7 @@ VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+(?i:NestedExceptionTest.*)!NestedExceptionTest
 IFDEF:64BIT
 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)
@@ -61,9 +64,6 @@ VERIFY:\s+[r|e]ax=<HEXVAL>\s+[r|e]bx=<HEXVAL>\s+[r|e]cx=<HEXVAL>\s+
 ENDIF:64BIT
 ENDIF:PROJECTK
 
-# Disable ClrStack -i until coreclr issue #17259
-IFDEF:DESKTOP
-
 # 5) Verifying that ClrStack with the ICorDebug options works
 SOSCOMMAND:ClrStack -i
 VERIFY:.*\s+Dumping managed stack and managed variables using ICorDebug.\s+
@@ -88,8 +88,6 @@ VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+\[DEFAULT\] Void NestedExceptionTest\.Program\
 VERIFY:.*\s+Stack walk complete.\s+
 ENDIF:PROJECTK
 
-ENDIF:DESKTOP
-
 # 7) Verify DumpStackObjects works
 IFDEF:PROJECTK
 SOSCOMMAND:DumpStackObjects
index 4f5d97dc33e591e5617e92143f59bd2fbb8ecf51..b14be2e6b2c8f8822045e2c0bc523ffab93df6d4 100644 (file)
@@ -14,6 +14,8 @@
 
 #define VER_PRODUCTVERSION_W        (0x0100)
 
+extern void SOSShutdown();
+
 //
 // globals
 //
@@ -256,6 +258,7 @@ DebugExtensionInitialize(PULONG Version, PULONG Flags)
     ExtRelease();
     
     OnUnloadTask::Register(CleanupEventCallbacks);
+    OnUnloadTask::Register(SOSShutdown);
     g_pCallbacksClient = DebugClient;
     EventCallbacks* pCallbacksObj = new EventCallbacks(DebugClient);
     IDebugEventCallbacks* pCallbacks = NULL;
index 306411554807c363c742eb1576e21b58b4f84651..4ff608ac248f50685b133c9f5f47dc6b075e4140 100644 (file)
@@ -45,6 +45,7 @@ static bool g_symbolStoreInitialized = false;
 LPCSTR g_hostRuntimeDirectory = nullptr;
 LPCSTR g_dacFilePath = nullptr;
 LPCSTR g_dbiFilePath = nullptr;
+LPCSTR g_tmpPath = nullptr;
 SOSNetCoreCallbacks g_SOSNetCoreCallbacks;
 
 #ifdef FEATURE_PAL
@@ -53,7 +54,10 @@ SOSNetCoreCallbacks g_SOSNetCoreCallbacks;
 #define TPALIST_SEPARATOR_STR_A ";"
 #endif
 
-void AddFilesFromDirectoryToTpaList(const char* directory, std::string& tpaList)
+//
+// Build the TPA list of assemblies for the runtime hosting api.
+//
+static void AddFilesFromDirectoryToTpaList(const char* directory, std::string& tpaList)
 {
     const char * const tpaExtensions[] = {
         "*.ni.dll",      // Probe for .ni.dll first so that it's preferred if ni and il coexist in the same dir
@@ -82,9 +86,8 @@ void AddFilesFromDirectoryToTpaList(const char* directory, std::string& tpaList)
         {
             do
             {
-                if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+                if ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
                 {
-
                     std::string filename(data.cFileName);
                     size_t extPos = filename.length() - extLength;
                     std::string filenameWithoutExt(filename.substr(0, extPos));
@@ -117,7 +120,7 @@ void AddFilesFromDirectoryToTpaList(const char* directory, std::string& tpaList)
 #define symlinkEntrypointExecutable "/proc/curproc/exe"
 #endif
 
-bool GetAbsolutePath(const char* path, std::string& absolutePath)
+static bool GetAbsolutePath(const char* path, std::string& absolutePath)
 {
     bool result = false;
 
@@ -134,7 +137,7 @@ bool GetAbsolutePath(const char* path, std::string& absolutePath)
     return result;
 }
 
-bool GetEntrypointExecutableAbsolutePath(std::string& entrypointExecutable)
+static bool GetEntrypointExecutableAbsolutePath(std::string& entrypointExecutable)
 {
     bool result = false;
     
@@ -204,7 +207,7 @@ bool GetEntrypointExecutableAbsolutePath(std::string& entrypointExecutable)
 
 #else // FEATURE_PAL
 
-bool GetEntrypointExecutableAbsolutePath(std::string& entrypointExecutable)
+static bool GetEntrypointExecutableAbsolutePath(std::string& entrypointExecutable)
 {
     ArrayHolder<char> hostPath = new char[MAX_LONGPATH+1];
     if (::GetModuleFileName(NULL, hostPath, MAX_LONGPATH) == 0)
@@ -220,6 +223,9 @@ bool GetEntrypointExecutableAbsolutePath(std::string& entrypointExecutable)
 
 #endif // FEATURE_PAL
 
+/**********************************************************************\
+ * Returns the coreclr module/runtime directory of the target.
+\**********************************************************************/
 HRESULT GetCoreClrDirectory(std::string& coreClrDirectory)
 {
 #ifdef FEATURE_PAL
@@ -263,16 +269,124 @@ HRESULT GetCoreClrDirectory(std::string& coreClrDirectory)
     return S_OK;
 }
 
+//
+// Searches the runtime directory for a .NET Core runtime version
+//
+static bool FindDotNetVersion(int majorFilter, int minorFilter, std::string& hostRuntimeDirectory)
+{
+    std::string directory(hostRuntimeDirectory);
+    directory.append("*");
+    std::string versionFound;
+
+    WIN32_FIND_DATAA data;
+    HANDLE findHandle = FindFirstFileA(directory.c_str(), &data);
+
+    if (findHandle != INVALID_HANDLE_VALUE) 
+    {
+        int highestRevision = 0;
+        do
+        {
+            if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+            {
+                int major = 0;
+                int minor = 0;
+                int revision = 0;
+                if (sscanf_s(data.cFileName, "%d.%d.%d", &major, &minor, &revision) == 3)
+                {
+                    if (major == majorFilter && minor == minorFilter)
+                    {
+                        if (revision >= highestRevision)
+                        {
+                            highestRevision = revision;
+                            versionFound.assign(data.cFileName);
+                        }
+                    }
+                }
+            }
+        } 
+        while (0 != FindNextFileA(findHandle, &data));
+
+        FindClose(findHandle);
+    }
+
+    if (versionFound.length() > 0)
+    {
+        hostRuntimeDirectory.append(versionFound);
+        return true;
+    }
+
+    return false;
+}
+
+#ifdef FEATURE_PAL
+const char *g_linuxPaths[] = {
+//  "/rh-dotnet22/root/usr/bin/dotnet/shared/Microsoft.NETCore.App",
+    "/rh-dotnet21/root/usr/bin/dotnet/shared/Microsoft.NETCore.App",
+    "/rh-dotnet20/root/usr/bin/dotnet/shared/Microsoft.NETCore.App",
+    "/usr/share/dotnet/shared/Microsoft.NETCore.App",
+};
+#endif
+
+/**********************************************************************\
+ * Returns the path to the coreclr to use for hosting and it's
+ * directory. Attempts to use the best installed version of the 
+ * runtime, otherwise it defaults to the target's runtime version.
+\**********************************************************************/
 HRESULT GetHostRuntime(std::string& coreClrPath, std::string& hostRuntimeDirectory)
 {
     // If the hosting runtime isn't already set, use the runtime we are debugging
     if (g_hostRuntimeDirectory == nullptr)
     {
-        HRESULT hr = GetCoreClrDirectory(hostRuntimeDirectory);
-        if (FAILED(hr))
+#ifdef FEATURE_PAL
+#if defined(__APPLE__)
+        hostRuntimeDirectory.assign("/usr/local/share/dotnet/shared/Microsoft.NETCore.App");
+#elif defined (__FreeBSD__) || defined(__NetBSD__)
+        ExtErr("FreeBSD or NetBSD not supported\n");
+        return E_FAIL;
+#else
+        // Start with the possible RHEL's locations, then the regular Linux path
+        for (int i = 0; i < _countof(g_linuxPaths); i++)
+        {
+            hostRuntimeDirectory.assign(g_linuxPaths[i]);
+            if (access(hostRuntimeDirectory.c_str(), F_OK) == 0)
+            {
+                break;
+            }
+        }
+#endif
+#else
+        ArrayHolder<CHAR> programFiles = new CHAR[MAX_LONGPATH];
+        if (GetEnvironmentVariableA("PROGRAMFILES", programFiles, MAX_LONGPATH) == 0)
         {
-            return hr;
+            ExtErr("PROGRAMFILES environment variable not found\n");
+            return E_FAIL;
         }
+        hostRuntimeDirectory.assign(programFiles);
+        hostRuntimeDirectory.append("\\dotnet\\shared\\Microsoft.NETCore.App");
+#endif
+        hostRuntimeDirectory.append(DIRECTORY_SEPARATOR_STR_A);
+
+        // First attempt find the highest 2.1.x version. We want to start with the LTS
+        // and only use the higher versions if it isn't installed.
+        if (!FindDotNetVersion(2, 1, hostRuntimeDirectory))
+        {
+            // Find highest 2.2.x version
+            if (!FindDotNetVersion(2, 2, hostRuntimeDirectory))
+            {
+                // Find highest 3.0.x version
+                if (!FindDotNetVersion(3, 0, hostRuntimeDirectory))
+                {
+                    // If an installed runtime can not be found, use the target coreclr version
+                    HRESULT hr = GetCoreClrDirectory(hostRuntimeDirectory);
+                    if (FAILED(hr))
+                    {
+                        return hr;
+                    }
+                }
+            }
+        }
+
+        // Save away the runtime version we are going to use to host the SOS managed code
         g_hostRuntimeDirectory = _strdup(hostRuntimeDirectory.c_str());
     }
     hostRuntimeDirectory.assign(g_hostRuntimeDirectory);
@@ -282,6 +396,71 @@ HRESULT GetHostRuntime(std::string& coreClrPath, std::string& hostRuntimeDirecto
     return S_OK;
 }
 
+//
+// Returns the unique temporary directory for this instnace of SOS
+//
+static LPCSTR GetTempDirectory()
+{
+    if (g_tmpPath == nullptr)
+    {
+        char tmpPath[MAX_LONGPATH];
+        if (::GetTempPathA(MAX_LONGPATH, tmpPath) == 0)
+        {
+            strcpy_s(tmpPath, MAX_LONGPATH, ".");
+            strcat_s(tmpPath, MAX_LONGPATH, DIRECTORY_SEPARATOR_STR_A);
+        }
+        char pidstr[128];
+        sprintf_s(pidstr, _countof(pidstr), "%d", GetCurrentProcessId());
+        strcat_s(tmpPath, MAX_LONGPATH, pidstr);
+        strcat_s(tmpPath, MAX_LONGPATH, DIRECTORY_SEPARATOR_STR_A);
+
+        CreateDirectoryA(tmpPath, NULL);
+        g_tmpPath = _strdup(tmpPath);
+    }
+    return g_tmpPath;
+}
+
+/**********************************************************************\
+ * Clean up the temporary directory files and DAC symlink.
+\**********************************************************************/
+#ifdef FEATURE_PAL
+__attribute__((destructor)) 
+#endif
+void SOSShutdown()
+{
+    LPCSTR tmpPath = (LPCSTR)InterlockedExchangePointer((PVOID *)&g_tmpPath, nullptr);
+    if (tmpPath != nullptr)
+    {
+        std::string directory(tmpPath);
+        directory.append("*");
+
+        WIN32_FIND_DATAA data;
+        HANDLE findHandle = FindFirstFileA(directory.c_str(), &data);
+
+        if (findHandle != INVALID_HANDLE_VALUE) 
+        {
+            do
+            {
+                if ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
+                {
+                    std::string file(tmpPath);
+                    file.append(data.cFileName);
+                    DeleteFileA(file.c_str());
+                }
+            } 
+            while (0 != FindNextFileA(findHandle, &data));
+
+            FindClose(findHandle);
+        }
+
+        RemoveDirectoryA(tmpPath);
+        free((void*)tmpPath);
+    }
+}
+
+/**********************************************************************\
+ * Returns the DAC module path to the rest of SOS.
+\**********************************************************************/
 LPCSTR GetDacFilePath()
 {
     // If the DAC path hasn't been set by the symbol download support, use the one in the runtime directory.
@@ -296,13 +475,41 @@ LPCSTR GetDacFilePath()
 #ifdef FEATURE_PAL
             // if DAC file exists
             if (access(dacModulePath.c_str(), F_OK) == 0)
+#endif
+            {
+#if defined(__linux__)
+                // We are creating a symlink to the DAC in a temp directory
+                // where libcoreclrtraceptprovider.so doesn't exist so it 
+                // doesn't get loaded by the DAC causing a LTTng-UST exception.
+                //
+                // Issue #https://github.com/dotnet/coreclr/issues/20205
+                LPCSTR tmpPath = GetTempDirectory();
+                if (tmpPath != nullptr) 
+                {
+                    std::string dacSymLink(tmpPath);
+                    dacSymLink.append(MAKEDLLNAME_A("mscordaccore"));
+
+                    int error = symlink(dacModulePath.c_str(), dacSymLink.c_str());
+                    if (error == 0)
+                    {
+                        dacModulePath.assign(dacSymLink);
+                    }
+                    else
+                    {
+                        ExtErr("symlink(%s, %s) FAILED %s\n", dacModulePath.c_str(), dacSymLink.c_str(), strerror(errno));
+                    }
+                }
 #endif
                 g_dacFilePath = _strdup(dacModulePath.c_str());
+            }
         }
     }
     return g_dacFilePath;
 }
 
+/**********************************************************************\
+ * Returns the DBI module path to the rest of SOS.
+\**********************************************************************/
 LPCSTR GetDbiFilePath()
 {
     if (g_dbiFilePath == nullptr)
@@ -323,11 +530,18 @@ LPCSTR GetDbiFilePath()
     return g_dbiFilePath;
 }
 
+/**********************************************************************\
+ * Returns true if the host runtime has already been initialized.
+\**********************************************************************/
 BOOL IsHostingInitialized()
 {
     return g_hostingInitialized;
 }
 
+/**********************************************************************\
+ * Initializes the host coreclr runtime and gets the managed entry 
+ * points delegates.
+\**********************************************************************/
 HRESULT InitializeHosting()
 {
     if (g_hostingInitialized)
@@ -442,6 +656,7 @@ HRESULT InitializeHosting()
     }
 
     IfFailRet(createDelegate(hostHandle, domainId, SymbolReaderDllName, SymbolReaderClassName, "InitializeSymbolStore", (void **)&g_SOSNetCoreCallbacks.InitializeSymbolStoreDelegate));
+    IfFailRet(createDelegate(hostHandle, domainId, SymbolReaderDllName, SymbolReaderClassName, "DisplaySymbolStore", (void **)&g_SOSNetCoreCallbacks.DisplaySymbolStoreDelegate));
     IfFailRet(createDelegate(hostHandle, domainId, SymbolReaderDllName, SymbolReaderClassName, "DisableSymbolStore", (void **)&g_SOSNetCoreCallbacks.DisableSymbolStoreDelegate));
     IfFailRet(createDelegate(hostHandle, domainId, SymbolReaderDllName, SymbolReaderClassName, "LoadNativeSymbols", (void **)&g_SOSNetCoreCallbacks.LoadNativeSymbolsDelegate));
     IfFailRet(createDelegate(hostHandle, domainId, SymbolReaderDllName, SymbolReaderClassName, "LoadSymbolsForModule", (void **)&g_SOSNetCoreCallbacks.LoadSymbolsForModuleDelegate));
@@ -454,6 +669,9 @@ HRESULT InitializeHosting()
     return Status;
 }
 
+/**********************************************************************\
+ * Public entry point to set the managed callbacks (unused).
+\**********************************************************************/
 extern "C" void InitializeSymbolReaderCallbacks(SOSNetCoreCallbacks sosNetCoreCallbacks)
 {
     g_SOSNetCoreCallbacks = sosNetCoreCallbacks;
@@ -461,7 +679,7 @@ extern "C" void InitializeSymbolReaderCallbacks(SOSNetCoreCallbacks sosNetCoreCa
 }
 
 //
-// Pass to managed helper code to read in-memory PEs/PDBs
+// Pass to managed helper code to read in-memory PEs/PDBs.
 // Returns the number of bytes read.
 //
 static int ReadMemoryForSymbols(ULONG64 address, uint8_t *buffer, int cb)
@@ -476,6 +694,9 @@ static int ReadMemoryForSymbols(ULONG64 address, uint8_t *buffer, int cb)
 
 #ifdef FEATURE_PAL
 
+//
+// Symbol downloader callback
+//
 static void SymbolFileCallback(void* param, const char* moduleFileName, const char* symbolFileName)
 {
     if (strcmp(moduleFileName, MAIN_CLR_DLL_NAME_A) == 0) {
@@ -501,15 +722,21 @@ static void SymbolFileCallback(void* param, const char* moduleFileName, const ch
     }
 }
 
+//
+// Enumerate native module callback
+//
 static void LoadNativeSymbolsCallback(void* param, const char* moduleDirectory, const char* moduleFileName, ULONG64 moduleAddress, int moduleSize)
 {
     _ASSERTE(g_hostingInitialized);
     _ASSERTE(g_SOSNetCoreCallbacks.LoadNativeSymbolsDelegate != nullptr);
-    g_SOSNetCoreCallbacks.LoadNativeSymbolsDelegate(SymbolFileCallback, param, moduleDirectory, moduleFileName, moduleAddress, moduleSize, ReadMemoryForSymbols);
+    g_SOSNetCoreCallbacks.LoadNativeSymbolsDelegate(SymbolFileCallback, param, GetTempDirectory(), moduleDirectory, moduleFileName, moduleAddress, moduleSize, ReadMemoryForSymbols);
 }
 
 #endif
 
+/**********************************************************************\
+ * Setup and initialize the symbol server support.
+\**********************************************************************/
 HRESULT InitializeSymbolStore(BOOL logging, BOOL msdl, BOOL symweb, const char* symbolServer, const char* cacheDirectory)
 {
     HRESULT Status = S_OK;
@@ -525,6 +752,11 @@ HRESULT InitializeSymbolStore(BOOL logging, BOOL msdl, BOOL symweb, const char*
     return S_OK;
 }
 
+/**********************************************************************\
+ * Enumerate the native modules and attempt to download the symbols
+ * for them. Depends on the lldb callback to enumerate modules. Not
+ * necessary on dbgeng because it already downloads native symbols.
+\**********************************************************************/
 HRESULT LoadNativeSymbols()
 {
     HRESULT Status = S_OK;
@@ -542,6 +774,21 @@ HRESULT LoadNativeSymbols()
     return Status;
 }
 
+/**********************************************************************\
+ * Displays the symbol server and cache status.
+\**********************************************************************/
+void DisplaySymbolStore()
+{
+    if (g_symbolStoreInitialized)
+    {
+        _ASSERTE(g_SOSNetCoreCallbacks.DisplaySymbolStoreDelegate != nullptr);
+        g_SOSNetCoreCallbacks.DisplaySymbolStoreDelegate();
+    }
+}
+
+/**********************************************************************\
+ * Turns off the symbol server support.
+\**********************************************************************/
 void DisableSymbolStore()
 {
     if (g_symbolStoreInitialized)
@@ -553,14 +800,15 @@ void DisableSymbolStore()
     }
 }
 
+/**********************************************************************\
+ * Load symbols for an ICorDebugModule. Used by "clrstack -i".
+\**********************************************************************/
 HRESULT SymbolReader::LoadSymbols(___in IMetaDataImport* pMD, ___in ICorDebugModule* pModule)
 {
     HRESULT Status = S_OK;
+
     BOOL isDynamic = FALSE;
-    BOOL isInMemory = FALSE;
     IfFailRet(pModule->IsDynamic(&isDynamic));
-    IfFailRet(pModule->IsInMemory(&isInMemory));
-
     if (isDynamic)
     {
         // Dynamic and in memory assemblies are a special case which we will ignore for now
@@ -569,23 +817,17 @@ HRESULT SymbolReader::LoadSymbols(___in IMetaDataImport* pMD, ___in ICorDebugMod
     }
 
     ULONG64 peAddress = 0;
-    ULONG32 peSize = 0;
     IfFailRet(pModule->GetBaseAddress(&peAddress));
-    IfFailRet(pModule->GetSize(&peSize));
 
-    ULONG32 len = 0; 
-    WCHAR moduleName[MAX_LONGPATH];
-    IfFailRet(pModule->GetName(_countof(moduleName), &len, moduleName));
+    IXCLRDataModule* pClrModule;
+    IfFailRet(GetModuleFromAddress(peAddress, &pClrModule));
 
-#ifndef FEATURE_PAL
-    if (SUCCEEDED(LoadSymbolsForWindowsPDB(pMD, peAddress, moduleName, isInMemory)))
-    {
-        return S_OK;
-    }
-#endif // FEATURE_PAL
-    return LoadSymbolsForPortablePDB(moduleName, isInMemory, isInMemory, peAddress, peSize, 0, 0);
+    return LoadSymbols(pMD, pClrModule);
 }
 
+/**********************************************************************\
+ * Load symbols for a module.
+\**********************************************************************/
 HRESULT SymbolReader::LoadSymbols(___in IMetaDataImport* pMD, ___in IXCLRDataModule* pModule)
 {
     ULONG32 flags;
@@ -640,6 +882,9 @@ HRESULT SymbolReader::LoadSymbols(___in IMetaDataImport* pMD, ___in IXCLRDataMod
 
 #ifndef FEATURE_PAL
 
+/**********************************************************************\
+ * Attempts to load Windows PDBs on Windows.
+\**********************************************************************/
 HRESULT SymbolReader::LoadSymbolsForWindowsPDB(___in IMetaDataImport* pMD, ___in ULONG64 peAddress, __in_z WCHAR* pModuleName, ___in BOOL isFileLayout)
 {
     HRESULT Status = S_OK;
@@ -650,7 +895,6 @@ HRESULT SymbolReader::LoadSymbolsForWindowsPDB(___in IMetaDataImport* pMD, ___in
     IfFailRet(CoInitialize(NULL));
 
     // We now need a binder object that will take the module and return a 
-    // reader object
     ToRelease<ISymUnmanagedBinder3> pSymBinder;
     if (FAILED(Status = CreateInstanceCustom(CLSID_CorSymBinder_SxS, 
                         IID_ISymUnmanagedBinder3, 
@@ -711,6 +955,9 @@ HRESULT SymbolReader::LoadSymbolsForWindowsPDB(___in IMetaDataImport* pMD, ___in
 
 #endif // FEATURE_PAL
 
+/**********************************************************************\
+ * Attempts to load a portable or embeded PDB. Both Windows and xplat.
+\**********************************************************************/
 HRESULT SymbolReader::LoadSymbolsForPortablePDB(__in_z WCHAR* pModuleName, ___in BOOL isInMemory, ___in BOOL isFileLayout,
     ___in ULONG64 peAddress, ___in ULONG64 peSize, ___in ULONG64 inMemoryPdbAddress, ___in ULONG64 inMemoryPdbSize)
 {
@@ -762,6 +1009,9 @@ HRESULT SymbolReader::LoadSymbolsForPortablePDB(__in_z WCHAR* pModuleName, ___in
     return Status;
 }
 
+/**********************************************************************\
+ * Return the source/line number info for method/il offset.
+\**********************************************************************/
 HRESULT SymbolReader::GetLineByILOffset(___in mdMethodDef methodToken, ___in ULONG64 ilOffset,
     ___out ULONG *pLinenum, __out_ecount(cchFileName) WCHAR* pwszFileName, ___in ULONG cchFileName)
 {
@@ -940,6 +1190,9 @@ HRESULT SymbolReader::GetNamedLocalVariable(___in ISymUnmanagedScope * pScope, _
     return E_FAIL;
 }
 
+/**********************************************************************\
+ * Returns the name of the local variable from a PDB. 
+\**********************************************************************/
 HRESULT SymbolReader::GetNamedLocalVariable(___in ICorDebugFrame * pFrame, ___in ULONG localIndex, __out_ecount(paramNameLen) WCHAR* paramName, 
     ___in ULONG paramNameLen, ___out ICorDebugValue** ppValue)
 {
@@ -964,7 +1217,10 @@ HRESULT SymbolReader::GetNamedLocalVariable(___in ICorDebugFrame * pFrame, ___in
     return GetNamedLocalVariable(NULL, pILFrame, methodDef, localIndex, paramName, paramNameLen, ppValue);
 }
 
-HRESULT SymbolReader::ResolveSequencePoint(__in_z WCHAR* pFilename, ___in ULONG32 lineNumber, ___in TADDR mod, ___out mdMethodDef* pToken, ___out ULONG32* pIlOffset)
+/**********************************************************************\
+ * Returns the sequence point to bind breakpoints.
+\**********************************************************************/
+HRESULT SymbolReader::ResolveSequencePoint(__in_z WCHAR* pFilename, ___in ULONG32 lineNumber, ___out mdMethodDef* pToken, ___out ULONG32* pIlOffset)
 {
     HRESULT Status = S_OK;
 
index 70f2a7e8c61909d8634e9a1ce4001e01521527ab..e757830f5d78fa6926e9fce641a3cfa20e590146 100644 (file)
@@ -18,8 +18,9 @@ typedef  int (*ReadMemoryDelegate)(ULONG64, uint8_t*, int);
 typedef void (*SymbolFileCallbackDelegate)(void*, const char* moduleFileName, const char* symbolFileName);
 
 typedef  BOOL (*InitializeSymbolStoreDelegate)(BOOL, BOOL, BOOL, const char*, const char*, const char*);
+typedef  void (*DisplaySymbolStoreDelegate)();
 typedef  void (*DisableSymbolStoreDelegate)();
-typedef  void (*LoadNativeSymbolsDelegate)(SymbolFileCallbackDelegate, void*, const char*, const char*, ULONG64, int, ReadMemoryDelegate);
+typedef  void (*LoadNativeSymbolsDelegate)(SymbolFileCallbackDelegate, void*, const char*, const char*, const char*, ULONG64, int, ReadMemoryDelegate);
 typedef  PVOID (*LoadSymbolsForModuleDelegate)(const char*, BOOL, ULONG64, int, ULONG64, int, ReadMemoryDelegate);
 typedef  void (*DisposeDelegate)(PVOID);
 typedef  BOOL (*ResolveSequencePointDelegate)(PVOID, const char*, unsigned int, unsigned int*, unsigned int*);
@@ -29,6 +30,7 @@ typedef  BOOL (*GetLineByILOffsetDelegate)(PVOID, mdMethodDef, ULONG64, ULONG *,
 struct SOSNetCoreCallbacks
 {
     InitializeSymbolStoreDelegate InitializeSymbolStoreDelegate;
+    DisplaySymbolStoreDelegate DisplaySymbolStoreDelegate;
     DisableSymbolStoreDelegate DisableSymbolStoreDelegate;
     LoadNativeSymbolsDelegate LoadNativeSymbolsDelegate;
     LoadSymbolsForModuleDelegate LoadSymbolsForModuleDelegate;
@@ -48,6 +50,7 @@ extern BOOL IsHostingInitialized();
 extern HRESULT InitializeHosting();
 extern HRESULT InitializeSymbolStore(BOOL logging, BOOL msdl, BOOL symweb, const char* symbolServer, const char* cacheDirectory);
 extern HRESULT LoadNativeSymbols();
+extern void DisplaySymbolStore();
 extern void DisableSymbolStore();
 
 class SymbolReader
@@ -93,7 +96,7 @@ public:
     HRESULT LoadSymbols(___in IMetaDataImport* pMD, ___in IXCLRDataModule* pModule);
     HRESULT GetLineByILOffset(___in mdMethodDef MethodToken, ___in ULONG64 IlOffset, ___out ULONG *pLinenum, __out_ecount(cchFileName) WCHAR* pwszFileName, ___in ULONG cchFileName);
     HRESULT GetNamedLocalVariable(___in ICorDebugFrame * pFrame, ___in ULONG localIndex, __out_ecount(paramNameLen) WCHAR* paramName, ___in ULONG paramNameLen, ___out ICorDebugValue** ppValue);
-    HRESULT ResolveSequencePoint(__in_z WCHAR* pFilename, ___in ULONG32 lineNumber, ___in TADDR mod, ___out mdMethodDef* ___out pToken, ___out ULONG32* pIlOffset);
+    HRESULT ResolveSequencePoint(__in_z WCHAR* pFilename, ___in ULONG32 lineNumber, ___out mdMethodDef* ___out pToken, ___out ULONG32* pIlOffset);
 };
 
 HRESULT
index 8502aaa45b0cfa45b4a451b2b5665b858375f5c8..77bccd52ec9092541f7b47bdaab22d04e31797df 100644 (file)
@@ -18,7 +18,6 @@
 *                                                                      *
 \**********************************************************************/
 // Caller should guard against exception
-// !!! mdName should have at least mdNameLen WCHAR
 static HRESULT NameForTypeDef_s(mdTypeDef tkTypeDef, IMetaDataImport *pImport,
                               __out_ecount (capacity_mdName) WCHAR *mdName, size_t capacity_mdName)
 {
@@ -26,7 +25,7 @@ static HRESULT NameForTypeDef_s(mdTypeDef tkTypeDef, IMetaDataImport *pImport,
     ULONG nameLen;
     
     HRESULT hr = pImport->GetTypeDefProps(tkTypeDef, mdName,
-                                          mdNameLen, &nameLen,
+                                          (ULONG)capacity_mdName, &nameLen,
                                           &flags, NULL);
     if (hr != S_OK) {
         return hr;
@@ -42,54 +41,23 @@ static HRESULT NameForTypeDef_s(mdTypeDef tkTypeDef, IMetaDataImport *pImport,
     }
     WCHAR *name = (WCHAR*)_alloca((nameLen+1)*sizeof(WCHAR));
     wcscpy_s (name, nameLen+1, mdName);
-    hr = NameForTypeDef_s(tkEnclosingClass,pImport,mdName, capacity_mdName);
+    hr = NameForTypeDef_s(tkEnclosingClass, pImport, mdName, capacity_mdName);
     if (hr != S_OK) {
         return hr;
     }
     size_t Len = _wcslen (mdName);
-    if (Len < mdNameLen-2) {
+    if (Len < capacity_mdName - 2) {
         mdName[Len++] = L'+';
         mdName[Len] = L'\0';
     }
-    Len = mdNameLen-1 - Len;
+    Len = capacity_mdName - 1 - Len;
     if (Len > nameLen) {
         Len = nameLen;
     }
-    wcsncat_s (mdName,capacity_mdName,name,Len);
+    wcsncat_s (mdName, capacity_mdName, name, Len);
     return hr;
 }
 
-/**********************************************************************\
-* Routine Description:                                                 *
-*                                                                      *
-*    This function is called to find the name of a TypeDef using       *  
-*    metadata API.                                                     *
-*                                                                      *
-\**********************************************************************/
-// Caller should guard against exception
-// !!! mdName should have at least mdNameLen WCHAR
-/*
-static HRESULT NameForTypeDefNew(mdTypeDef tkTypeDef, IMDInternalImport *pImport,
-                              WCHAR *mdName)
-{
-    DWORD flags;
-    ULONG nameLen;
-    char *name = (char *)_alloca((mdNameLen+1)*sizeof(char));
-    char *namesp = (char *)_alloca((mdNameLen+1)*sizeof(char));
-    
-    HRESULT hr = pImport->GetNameOfTypeDef(tkTypeDef, name, namesp);
-    if (FAILED(hr))
-    {
-        return hr;
-    }
-
-    strcpy (namesp, ".");
-    strcpy (namesp, name);
-    MultiByteToWideChar (CP_ACP,0,namesp,-1,mdName,mdNameLen);
-    return hr;
-}
-*/
-
 /**********************************************************************\
 * Routine Description:                                                 *
 *                                                                      *
index c46ed5e6a8dbebe2d77b696ff91228dd927e44d9..2f3e165c57a76b383c233cad9535356465130ccc 100644 (file)
@@ -2585,9 +2585,11 @@ code that runs as part of SOS in the debugger (cdb/windbg). The runtime needs
 to be at least version 2.0.0 or greater. If there are spaces in directory, it
 needs to be single-quoted (').
 
-The default is to use the same runtime (coreclr.dll) being debugged. Use this
-command when the runtime being debugged isn't working to run the SOS code or
-if the version is less than 2.0.0.
+Normally, SOS attempts to find an installed .NET Core runtime to run its
+managed code automatically but this command is available if it fails. The
+default is to use the same runtime (coreclr.dll) being debugged. Use this
+command if the default runtime being debugged isn't working enough to run
+the SOS code or if the version is less than 2.0.0.
 
 If you received the following error message when running a SOS command, use
 this command to set the path to 2.0.0 or greater .NET Core runtime.
@@ -2608,7 +2610,7 @@ SetSymbolServer [-ms] [-mi] [-disable] [-log] [-cache <cache-path>] [<symbol-ser
 -ms - Use the public Microsoft symbol server.
 -mi - Use the internal symweb symbol server.
 -disable - Disable symbol download support.
--cache - Specific a symbol cache directory. The default is $HOME/.sos/symbolcache if not specified.
+-cache - Specific a symbol cache directory. The default is %TEMP%\SymbolCache if not specified.
 -log - Enable symbol download logging.
 <symbol-server-URL> - Symbol server URL.
 
index 9c4a134b13ea268eb2e23644563f655e799842b9..3015584362c0a0889e4630c417301cd2a9b36118 100644 (file)
@@ -1844,14 +1844,16 @@ cleanup the previous resources.
 COMMAND: sethostruntime.
 SetHostRuntime <runtime-directory>
 
-This command sets the path to the .NET Core runtime to use to host the managed
+This command sets the path to the .NET Core runtime to use to host the managed 
 code that runs as part of SOS in the debugger (lldb). The runtime needs
 to be at least version 2.0.0 or greater. If there are spaces in directory, it
 needs to be single-quoted (').
 
-The default is to use the same runtime (libcoreclr) being debugged. Use this
-command when the runtime being debugged isn't working enough to run the SOS 
-code or if the version is less than 2.0.0.
+Normally, SOS attempts to find an installed .NET Core runtime to run its
+managed code automatically but this command is available if it fails. The
+default is to use the same runtime (libcoreclr) being debugged. Use this
+command if the default runtime being debugged isn't working enough to run
+the SOS code or if the version is less than 2.0.0.
 
 If you received the following error message when running a SOS command, use
 this command to set the path to 2.0.0 or greater .NET Core runtime.
@@ -1872,7 +1874,7 @@ SetSymbolServer [-ms] [-disable] [-log] [-cache <cache-path>] [-loadsymbols] [<s
 
 -ms - Use the public Microsoft symbol server.
 -disable - Disable symbol download support.
--cache - Specific a symbol cache directory. The default is $HOME/.sos/symbolcache if not specified.
+-cache - Specific a symbol cache directory. The default is $HOME/.dotnet/symbolcache if not specified.
 -log - Enable symbol download logging.
 -loadsymbols - Attempts to download the native .NET Core symbols for the runtime
 <symbol-server-URL> - Symbol server URL.
index bd2584dddb5ef54dd5b2733f04c4c228f3db489d..c700346e45de2714dc51826e3a401253663d81d4 100644 (file)
@@ -7152,7 +7152,7 @@ public:
 
         mdMethodDef methodDef;
         ULONG32 ilOffset;
-        if(FAILED(Status = pSymbolReader->ResolveSequencePoint(pFilename, lineNumber, mod, &methodDef, &ilOffset)))
+        if(FAILED(Status = pSymbolReader->ResolveSequencePoint(pFilename, lineNumber, &methodDef, &ilOffset)))
         {
             return S_FALSE; // not binding in a module is typical
         }
@@ -7992,7 +7992,7 @@ DECLARE_API(bpmd)
                     // if we have symbols then get the function name so we can lookup the MethodDescs
                     mdMethodDef methodDefToken;
                     ULONG32 ilOffset;
-                    if(SUCCEEDED(symbolReader.ResolveSequencePoint(Filename, lineNumber, moduleList[iModule], &methodDefToken, &ilOffset)))
+                    if(SUCCEEDED(symbolReader.ResolveSequencePoint(Filename, lineNumber, &methodDefToken, &ilOffset)))
                     {
                         ToRelease<IXCLRDataMethodDefinition> pMethodDef = NULL;
                         if (SUCCEEDED(ModDef->GetMethodDefinitionByToken(methodDefToken, &pMethodDef)))
@@ -12682,21 +12682,24 @@ public:
                 break;
             }
             
-            CROSS_PLATFORM_CONTEXT context;
+            // This is a workaround for a problem in the MacOS DAC/DBI PAL. The exception
+            // handling is enabled for DLLs and not passing them on to the OS causing an 
+            // fatal fault. Putting this struct in the heap works around this fault.
+            ArrayHolder<CROSS_PLATFORM_CONTEXT> context = new CROSS_PLATFORM_CONTEXT[1];
             ULONG32 cbContextActual;
-            if ((Status=pStackWalk->GetContext(
+            if ((Status = pStackWalk->GetContext(
                 DT_CONTEXT_FULL, 
-                sizeof(context),
+                sizeof(CROSS_PLATFORM_CONTEXT),
                 &cbContextActual,
-                (BYTE *)&context))!=S_OK)
+                (BYTE *)context.GetPtr())) != S_OK)
             {
                 ExtOut("GetFrameContext failed: %lx\n",Status);
                 break;
             }
 
             // First find the info for the Frame object, if the current frame has an associated clr!Frame.
-            CLRDATA_ADDRESS sp = GetSP(context);
-            CLRDATA_ADDRESS ip = GetIP(context);
+            CLRDATA_ADDRESS sp = GetSP(*context.GetPtr());
+            CLRDATA_ADDRESS ip = GetIP(*context.GetPtr());
 
             ToRelease<ICorDebugFrame> pFrame;
             IfFailRet(pStackWalk->GetFrame(&pFrame));
@@ -12765,7 +12768,7 @@ public:
                 IfFailRet(pFunction->GetModule(&pModule));
                 IfFailRet(pFunction->GetToken(&methodDef));
 
-                WCHAR wszModuleName[100];
+                WCHAR wszModuleName[MAX_LONGPATH];
                 ULONG32 cchModuleNameActual;
                 IfFailRet(pModule->GetName(_countof(wszModuleName), &cchModuleNameActual, wszModuleName));
 
@@ -15468,13 +15471,14 @@ DECLARE_API(SetSymbolServer)
             ExtOut("Symbol cache path: %s\n", symbolCache.data);
         }
     }
-
-#ifdef FEATURE_PAL
-    if (loadNative)
+    else if (loadNative)
     {
         Status = LoadNativeSymbols();
     }
-#endif
+    else
+    {
+        DisplaySymbolStore();
+    }
 
     return Status;
 }
index cfe1159c8397bbf580bd13fdc54bdb413bb0e2b3..74feb7903dd1b47f50579e8b42818977378a591e 100644 (file)
@@ -2560,6 +2560,44 @@ Failure:
     return NULL;
 }
 
+/**********************************************************************\
+* Routine Description:                                                 *
+*                                                                      *
+*    Find the IXCLRDataModule instance for the base address.           *
+*                                                                      *
+\**********************************************************************/
+HRESULT GetModuleFromAddress(___in CLRDATA_ADDRESS peAddress, ___out IXCLRDataModule** ppModule)
+{
+    HRESULT hr = E_FAIL;
+    *ppModule = nullptr;
+
+    int numModule;
+    ArrayHolder<DWORD_PTR> moduleList = ModuleFromName(NULL, &numModule);
+    if (moduleList != nullptr)
+    {
+        for (int i = 0; i < numModule; i++)
+        {
+            ToRelease<IXCLRDataModule> module;
+            hr = g_sos->GetModule(moduleList[i], &module);
+            if (FAILED(hr)) {
+                break;
+            }
+            DacpGetModuleData moduleData;
+            HRESULT hr = moduleData.Request(module);
+            if (FAILED(hr)) {
+                break;
+            }
+            if (peAddress == moduleData.LoadedPEAddress)
+            {
+                *ppModule = module.Detach();
+                break;
+            }
+        }
+    }
+
+    return hr;
+}
+
 /**********************************************************************\
 * Routine Description:                                                 *
 *                                                                      *
index 883cd722ce8ec6d7784258679a0f22f8adfc6ad9..9660e009a79bed4be824df3086ef6fd413a38371 100644 (file)
@@ -1865,6 +1865,7 @@ BOOL TryGetMethodDescriptorForDelegate(CLRDATA_ADDRESS delegateAddr, CLRDATA_ADD
  *      ArrayHolder class.
  */
 DWORD_PTR *ModuleFromName(__in_opt LPSTR name, int *numModules);
+HRESULT GetModuleFromAddress(___in CLRDATA_ADDRESS peAddress, ___out IXCLRDataModule** ppModule);
 void GetInfoFromName(DWORD_PTR ModuleAddr, const char* name);
 void GetInfoFromModule (DWORD_PTR ModuleAddr, ULONG token, DWORD_PTR *ret=NULL);
 
index 766b15423a2dd89dd3e7436d6d51aa8fac24956d..7635037649ee1f8b2c678549f9d9300db9c21681 100644 (file)
@@ -285,7 +285,11 @@ size_t      GCDump::DumpGCTable(PTR_CBYTE      gcInfoBlock,
                                                   | DECODE_GENERICS_INST_CONTEXT
                                                   | DECODE_GC_LIFETIMES
                                                   | DECODE_PROLOG_LENGTH
-                                                  | DECODE_RETURN_KIND),
+                                                  | DECODE_RETURN_KIND
+#if defined(_TARGET_ARM_) || defined(_TARGET_ARM64_)
+                                                  | DECODE_HAS_TAILCALLS
+#endif
+                                                 ),
                              0);
 
     if (NO_SECURITY_OBJECT != hdrdecoder.GetSecurityObjectStackSlot() ||
index 4d6db4befa532174c55f2670b7fc93ff7eb454c4..ec801f8b37542456cac134b0c01e242807ff46ea 100644 (file)
@@ -1,17 +1,23 @@
 ï»¿<Project Sdk="Microsoft.NET.Sdk">
-
   <PropertyGroup>
     <OutputType>Exe</OutputType>
-
-    <!-- Target .NET Core 2.1 so it will run on LTS -->
     <TargetFramework>netcoreapp2.1</TargetFramework>
-
-    <RootNamespace>Microsoft.Diagnostics.Tools.Analyze</RootNamespace>
-
+    <RuntimeFrameworkVersion>2.1.0</RuntimeFrameworkVersion>
     <!-- Don't pack until ship engineering is done. Currently causing the official job to fail.
     <IsPackable>true</IsPackable>
     <PackAsTool>true</PackAsTool>
     -->
+    <PackAsToolShimRuntimeIdentifiers>win-x64;win-x86;osx-x64</PackAsToolShimRuntimeIdentifiers>
+    <!-- The package version needs to be hard coded as a stable version so "dotnet tool install -g dotnet-analyze" works -->
+    <Version>1.0.0</Version>
+    <PackageVersion>1.0.0</PackageVersion>
+    <ToolCommandName>dotnet-analyze</ToolCommandName>
+    <RootNamespace>Microsoft.Diagnostics.Tools.Analyze</RootNamespace>
+    <Description>Diagnostic analyze tool</Description>
+    <PackageTags>Diagnostic</PackageTags>
+    <PackageReleaseNotes>$(Description)</PackageReleaseNotes>
+    <!-- Need to put the shims here to sign -->
+    <PackagedShimOutputRootDirectory>$(OutputPath)</PackagedShimOutputRootDirectory>
   </PropertyGroup>
 
   <ItemGroup>
index 75a08525d90b39b54eb54aaa4a8c58e1e3a64365..b8453cade2e67a0ddfd0b4a6a069228624ee15e3 100644 (file)
@@ -1,15 +1,15 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
     <OutputType>Exe</OutputType>
-
     <!-- Target .NET Core 2.1 so it will run on LTS -->
     <TargetFramework>netcoreapp2.1</TargetFramework>
-
     <RootNamespace>Microsoft.Diagnostics.Tools.Dump</RootNamespace>
 
+    <!-- Don't pack until ship engineering is done. Currently causing the official job to fail.
     <IsPackable>true</IsPackable>
     <PackAsTool>true</PackAsTool>
+    -->
   </PropertyGroup>
 
   <ItemGroup>
diff --git a/src/Tools/dotnet-sos/Program.cs b/src/Tools/dotnet-sos/Program.cs
new file mode 100644 (file)
index 0000000..cb0753d
--- /dev/null
@@ -0,0 +1,64 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using McMaster.Extensions.CommandLineUtils;
+using SOS.InstallHelper;
+using System;
+using System.Threading.Tasks;
+
+namespace Microsoft.Diagnostics.Tools.SOS
+{
+    [Command(Name = "dotnet-analyze", Description = "Install and configure SOS")]
+    internal class Program
+    {
+        [Option("--install", Description = "Install and configure SOS.")]
+        public bool InstallSOS { get; set; }
+
+        [Option("--uninstall", Description = "Uninstall SOS.")]
+        public bool UninstallSOS { get; set; }
+
+        public int OnExecute(IConsole console, CommandLineApplication app)
+        {
+            if (InstallSOS || UninstallSOS)
+            {
+                var sosInstaller = new InstallHelper();
+                try
+                {
+                    if (UninstallSOS)
+                    {
+                        console.WriteLine("Uninstalling SOS from {0}", sosInstaller.InstallLocation);
+                        sosInstaller.Uninstall();
+                    }
+                    else 
+                    {
+                        console.WriteLine("Installing SOS to {0}", sosInstaller.InstallLocation);
+                        sosInstaller.Install();
+
+                        if (sosInstaller.LLDBInitFile != null) {
+                            console.WriteLine("Configuring LLDB {0}", sosInstaller.LLDBInitFile);
+                            sosInstaller.Configure();
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                    console.Error.WriteLine(ex.Message);
+                    return 1;
+                }
+            }
+            return 0;
+        }
+
+        private static int Main(string[] args)
+        {
+            try
+            {
+                return CommandLineApplication.Execute<Program>(args);
+            }
+            catch (OperationCanceledException)
+            {
+                return 0;
+            }
+        }
+    }
+}
diff --git a/src/Tools/dotnet-sos/dotnet-sos.csproj b/src/Tools/dotnet-sos/dotnet-sos.csproj
new file mode 100644 (file)
index 0000000..00f1271
--- /dev/null
@@ -0,0 +1,80 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>netcoreapp2.1</TargetFramework>
+    <RuntimeFrameworkVersion>2.1.0</RuntimeFrameworkVersion>
+    <IsPackable>true</IsPackable>
+    <PackAsTool>true</PackAsTool>
+    <PackAsToolShimRuntimeIdentifiers>win-x64;win-x86;osx-x64</PackAsToolShimRuntimeIdentifiers>
+    <!-- The package version needs to be hard coded as a stable version so "dotnet tool install -g dotnet-sos" works -->
+    <Version>1.0.0</Version>
+    <PackageVersion>1.0.0</PackageVersion>
+    <ToolCommandName>dotnet-sos</ToolCommandName>
+    <RootNamespace>Microsoft.Diagnostics.Tools.SOS</RootNamespace>
+    <Description>Diagnostic SOS installer</Description>
+    <PackageTags>Diagnostic</PackageTags>
+    <PackageReleaseNotes>$(Description)</PackageReleaseNotes>
+    <!-- Need to put the shims here to sign -->
+    <PackagedShimOutputRootDirectory>$(OutputPath)</PackagedShimOutputRootDirectory>
+    <SOSNETCoreBinaries>$(ArtifactsBinDir)\SOS.NETCore\$(Configuration)\netcoreapp2.0\publish\*.dll</SOSNETCoreBinaries>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.2.5" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\..\SOS\SOS.InstallHelper\SOS.InstallHelper.csproj" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <_PackageFiles Include="$(SOSNETCoreBinaries)">
+      <BuildAction>None</BuildAction>
+      <PackagePath>tools/netcoreapp2.1/any/win-x64</PackagePath>
+    </_PackageFiles>
+    <_PackageFiles Include="$(ArtifactsBinDir)\Windows_NT.x64.$(Configuration)\sos.dll">
+      <BuildAction>None</BuildAction>
+      <PackagePath>tools/netcoreapp2.1/any/win-x64</PackagePath>
+    </_PackageFiles>
+    <_PackageFiles Include="$(SOSNETCoreBinaries)">
+      <BuildAction>None</BuildAction>
+      <PackagePath>tools/netcoreapp2.1/any/win-x86</PackagePath>
+    </_PackageFiles>
+    <_PackageFiles Include="$(ArtifactsBinDir)\Windows_NT.x86.$(Configuration)\sos.dll">
+      <BuildAction>None</BuildAction>
+      <PackagePath>tools/netcoreapp2.1/any/win-x86</PackagePath>
+    </_PackageFiles>
+    <_PackageFiles Include="$(SOSNETCoreBinaries)">
+      <BuildAction>None</BuildAction>
+      <PackagePath>tools/netcoreapp2.1/any/linux-x64</PackagePath>
+    </_PackageFiles>
+    <_PackageFiles Include="$(ArtifactsBinDir)\Linux.x64.$(Configuration)\libsosplugin.so">
+      <BuildAction>None</BuildAction>
+      <PackagePath>tools/netcoreapp2.1/any/linux-x64</PackagePath>
+    </_PackageFiles>
+    <_PackageFiles Include="$(ArtifactsBinDir)\Linux.x64.$(Configuration)\libsos.so">
+      <BuildAction>None</BuildAction>
+      <PackagePath>tools/netcoreapp2.1/any/linux-x64</PackagePath>
+    </_PackageFiles>
+    <_PackageFiles Include="$(ArtifactsBinDir)\Linux.x64.$(Configuration)\sosdocsunix.txt">
+      <BuildAction>None</BuildAction>
+      <PackagePath>tools/netcoreapp2.1/any/linux-x64</PackagePath>
+    </_PackageFiles>
+    <_PackageFiles Include="$(SOSNETCoreBinaries)">
+      <BuildAction>None</BuildAction>
+      <PackagePath>tools/netcoreapp2.1/any/osx-x64</PackagePath>
+    </_PackageFiles>
+    <_PackageFiles Include="$(ArtifactsBinDir)\OSX.x64.$(Configuration)\libsosplugin.dylib">
+      <BuildAction>None</BuildAction>
+      <PackagePath>tools/netcoreapp2.1/any/osx-x64</PackagePath>
+    </_PackageFiles>
+    <_PackageFiles Include="$(ArtifactsBinDir)\OSX.x64.$(Configuration)\libsos.dylib">
+      <BuildAction>None</BuildAction>
+      <PackagePath>tools/netcoreapp2.1/any/osx-x64</PackagePath>
+    </_PackageFiles>
+    <_PackageFiles Include="$(ArtifactsBinDir)\OSX.x64.$(Configuration)\sosdocsunix.txt">
+      <BuildAction>None</BuildAction>
+      <PackagePath>tools/netcoreapp2.1/any/osx-x64</PackagePath>
+    </_PackageFiles>
+  </ItemGroup>
+</Project>
index dabe86f3d36a6ec807e97d381e33441fe0a338c7..7a47b886c4898c88e84d23e0e2a25a00e8773754 100644 (file)
 #endif
 
 #if !defined(MAX_LONGPATH)
-#define MAX_LONGPATH   260 /* max. length of full pathname */
+#define MAX_LONGPATH    1024        /* max. length of full pathname */
 #endif
 #if !defined(MAX_PATH_FNAME)
-#define MAX_PATH_FNAME   MAX_PATH /* max. length of full pathname */
+#define MAX_PATH_FNAME  MAX_PATH    /* max. length of full pathname */
 #endif
 
 #define __clr_reserved __reserved
index e4e5275ac90e1a0f4cfa7067efeeea9b7f4c862e..e0fe3cb496cbbe5aee37af05e2a367870e24a498 100644 (file)
@@ -442,15 +442,23 @@ CharNextExA(
 #define IDYES                   6
 #define IDNO                    7
 
+PALIMPORT
+int
+PALAPI
+MessageBoxA(
+    IN LPVOID hWnd,  // NOTE: diff from winuser.h
+    IN LPCSTR lpText,
+    IN LPCSTR lpCaption,
+    IN UINT uType);
 
 PALIMPORT
 int
 PALAPI
 MessageBoxW(
-        IN LPVOID hWnd,  // NOTE: diff from winuser.h
-        IN LPCWSTR lpText,
-        IN LPCWSTR lpCaption,
-        IN UINT uType);
+    IN LPVOID hWnd,  // NOTE: diff from winuser.h
+    IN LPCWSTR lpText,
+    IN LPCWSTR lpCaption,
+    IN UINT uType);
 
 
 #ifdef UNICODE
@@ -515,18 +523,29 @@ typedef struct _SECURITY_ATTRIBUTES {
 
 #define INVALID_SET_FILE_POINTER   ((DWORD)-1)
 
+PALIMPORT
+HANDLE
+PALAPI
+CreateFileA(
+    IN LPCSTR lpFileName,
+    IN DWORD dwDesiredAccess,
+    IN DWORD dwShareMode,
+    IN LPSECURITY_ATTRIBUTES lpSecurityAttributes,
+    IN DWORD dwCreationDisposition,
+    IN DWORD dwFlagsAndAttributes,
+    IN HANDLE hTemplateFile);
 
 PALIMPORT
 HANDLE
 PALAPI
 CreateFileW(
-        IN LPCWSTR lpFileName,
-        IN DWORD dwDesiredAccess,
-        IN DWORD dwShareMode,
-        IN LPSECURITY_ATTRIBUTES lpSecurityAttributes,
-        IN DWORD dwCreationDisposition,
-        IN DWORD dwFlagsAndAttributes,
-        IN HANDLE hTemplateFile);
+    IN LPCWSTR lpFileName,
+    IN DWORD dwDesiredAccess,
+    IN DWORD dwShareMode,
+    IN LPSECURITY_ATTRIBUTES lpSecurityAttributes,
+    IN DWORD dwCreationDisposition,
+    IN DWORD dwFlagsAndAttributes,
+    IN HANDLE hTemplateFile);
 
 #ifdef UNICODE
 #define CreateFile CreateFileW
@@ -535,6 +554,17 @@ CreateFileW(
 #endif
 
 
+PALIMPORT
+DWORD
+PALAPI
+SearchPathA(
+    IN LPCSTR lpPath,
+    IN LPCSTR lpFileName,
+    IN LPCSTR lpExtension,
+    IN DWORD nBufferLength,
+    OUT LPSTR lpBuffer,
+    OUT LPSTR *lpFilePart);
+
 PALIMPORT
 DWORD
 PALAPI
@@ -544,8 +574,8 @@ SearchPathW(
     IN LPCWSTR lpExtension,
     IN DWORD nBufferLength,
     OUT LPWSTR lpBuffer,
-    OUT LPWSTR *lpFilePart
-    );
+    OUT LPWSTR *lpFilePart);
+
 #ifdef UNICODE
 #define SearchPath  SearchPathW
 #else
@@ -553,14 +583,21 @@ SearchPathW(
 #endif // !UNICODE
 
 
+PALIMPORT
+BOOL
+PALAPI
+CopyFileA(
+    IN LPCSTR lpExistingFileName,
+    IN LPCSTR lpNewFileName,
+    IN BOOL bFailIfExists);
 
 PALIMPORT
 BOOL
 PALAPI
 CopyFileW(
-      IN LPCWSTR lpExistingFileName,
-      IN LPCWSTR lpNewFileName,
-      IN BOOL bFailIfExists);
+    IN LPCWSTR lpExistingFileName,
+    IN LPCWSTR lpNewFileName,
+    IN BOOL bFailIfExists);
 
 #ifdef UNICODE
 #define CopyFile CopyFileW
@@ -569,11 +606,17 @@ CopyFileW(
 #endif
 
 
+PALIMPORT
+BOOL
+PALAPI
+DeleteFileA(
+    IN LPCSTR lpFileName);
+
 PALIMPORT
 BOOL
 PALAPI
 DeleteFileW(
-        IN LPCWSTR lpFileName);
+    IN LPCWSTR lpFileName);
 
 #ifdef UNICODE
 #define DeleteFile DeleteFileW
@@ -582,18 +625,24 @@ DeleteFileW(
 #endif
 
 
-
 #define MOVEFILE_REPLACE_EXISTING      0x00000001
 #define MOVEFILE_COPY_ALLOWED          0x00000002
 
+PALIMPORT
+BOOL
+PALAPI
+MoveFileExA(
+    IN LPCSTR lpExistingFileName,
+    IN LPCSTR lpNewFileName,
+    IN DWORD dwFlags);
 
 PALIMPORT
 BOOL
 PALAPI
 MoveFileExW(
-        IN LPCWSTR lpExistingFileName,
-        IN LPCWSTR lpNewFileName,
-        IN DWORD dwFlags);
+    IN LPCWSTR lpExistingFileName,
+    IN LPCWSTR lpNewFileName,
+    IN DWORD dwFlags);
 
 #ifdef UNICODE
 #define MoveFileEx MoveFileExW
@@ -601,12 +650,20 @@ MoveFileExW(
 #define MoveFileEx MoveFileExA
 #endif
 
+
+PALIMPORT
+BOOL
+PALAPI
+CreateDirectoryA(
+    IN LPCSTR lpPathName,
+    IN LPSECURITY_ATTRIBUTES lpSecurityAttributes);
+
 PALIMPORT
 BOOL
 PALAPI
 CreateDirectoryW(
-         IN LPCWSTR lpPathName,
-         IN LPSECURITY_ATTRIBUTES lpSecurityAttributes);
+    IN LPCWSTR lpPathName,
+    IN LPSECURITY_ATTRIBUTES lpSecurityAttributes);
 
 #ifdef UNICODE
 #define CreateDirectory CreateDirectoryW
@@ -614,11 +671,18 @@ CreateDirectoryW(
 #define CreateDirectory CreateDirectoryA
 #endif
 
+
+PALIMPORT
+BOOL
+PALAPI
+RemoveDirectoryA(
+    IN LPCSTR lpPathName);
+
 PALIMPORT
 BOOL
 PALAPI
 RemoveDirectoryW(
-         IN LPCWSTR lpPathName);
+    IN LPCWSTR lpPathName);
 
 #ifdef UNICODE
 #define RemoveDirectory RemoveDirectoryW
@@ -675,12 +739,19 @@ typedef PWIN32_FIND_DATAA PWIN32_FIND_DATA;
 typedef LPWIN32_FIND_DATAA LPWIN32_FIND_DATA;
 #endif
 
+PALIMPORT
+HANDLE
+PALAPI
+FindFirstFileA(
+    IN LPCSTR lpFileName,
+    OUT LPWIN32_FIND_DATAA lpFindFileData);
+
 PALIMPORT
 HANDLE
 PALAPI
 FindFirstFileW(
-           IN LPCWSTR lpFileName,
-           OUT LPWIN32_FIND_DATAW lpFindFileData);
+    IN LPCWSTR lpFileName,
+    OUT LPWIN32_FIND_DATAW lpFindFileData);
 
 #ifdef UNICODE
 #define FindFirstFile FindFirstFileW
@@ -688,12 +759,20 @@ FindFirstFileW(
 #define FindFirstFile FindFirstFileA
 #endif
 
+
+PALIMPORT
+BOOL
+PALAPI
+FindNextFileA(
+    IN HANDLE hFindFile,
+    OUT LPWIN32_FIND_DATAA lpFindFileData);
+
 PALIMPORT
 BOOL
 PALAPI
 FindNextFileW(
-          IN HANDLE hFindFile,
-          OUT LPWIN32_FIND_DATAW lpFindFileData);
+    IN HANDLE hFindFile,
+    OUT LPWIN32_FIND_DATAW lpFindFileData);
 
 #ifdef UNICODE
 #define FindNextFile FindNextFileW
@@ -701,17 +780,25 @@ FindNextFileW(
 #define FindNextFile FindNextFileA
 #endif
 
+
 PALIMPORT
 BOOL
 PALAPI
 FindClose(
       IN OUT HANDLE hFindFile);
 
+
+PALIMPORT
+DWORD
+PALAPI
+GetFileAttributesA(
+    IN LPCSTR lpFileName);
+
 PALIMPORT
 DWORD
 PALAPI
 GetFileAttributesW(
-           IN LPCWSTR lpFileName);
+    IN LPCWSTR lpFileName);
 
 #ifdef UNICODE
 #define GetFileAttributes GetFileAttributesW
@@ -719,6 +806,7 @@ GetFileAttributesW(
 #define GetFileAttributes GetFileAttributesA
 #endif
 
+
 typedef enum _GET_FILEEX_INFO_LEVELS {
   GetFileExInfoStandard
 } GET_FILEEX_INFO_LEVELS;
@@ -749,14 +837,21 @@ PALIMPORT
 BOOL
 PALAPI
 GetFileAttributesExW(
-             IN LPCWSTR lpFileName,
-             IN GET_FILEEX_INFO_LEVELS fInfoLevelId,
-             OUT LPVOID lpFileInformation);
+    IN LPCWSTR lpFileName,
+    IN GET_FILEEX_INFO_LEVELS fInfoLevelId,
+    OUT LPVOID lpFileInformation);
 
 #ifdef UNICODE
 #define GetFileAttributesEx GetFileAttributesExW
 #endif
 
+PALIMPORT
+BOOL
+PALAPI
+SetFileAttributesA(
+    IN LPCSTR lpFileName,
+    IN DWORD dwFileAttributes);
+
 PALIMPORT
 BOOL
 PALAPI
@@ -770,6 +865,7 @@ SetFileAttributesW(
 #define SetFileAttributes SetFileAttributesA
 #endif
 
+
 typedef struct _OVERLAPPED {
     ULONG_PTR Internal;
     ULONG_PTR InternalHigh;
@@ -880,37 +976,44 @@ PALIMPORT
 VOID
 PALAPI
 GetSystemTime(
-          OUT LPSYSTEMTIME lpSystemTime);
+    OUT LPSYSTEMTIME lpSystemTime);
 
 PALIMPORT
 BOOL
 PALAPI
 FileTimeToSystemTime(
-            IN CONST FILETIME *lpFileTime,
-            OUT LPSYSTEMTIME lpSystemTime);
-
-
+    IN CONST FILETIME *lpFileTime,
+    OUT LPSYSTEMTIME lpSystemTime);
 
 PALIMPORT
 BOOL
 PALAPI
 FlushFileBuffers(
-         IN HANDLE hFile);
+    IN HANDLE hFile);
 
 PALIMPORT
 UINT
 PALAPI
 GetConsoleOutputCP(
-           VOID);
+    VOID);
+
+PALIMPORT
+DWORD
+PALAPI
+GetFullPathNameA(
+    IN LPCSTR lpFileName,
+    IN DWORD nBufferLength,
+    OUT LPSTR lpBuffer,
+    OUT LPSTR *lpFilePart);
 
 PALIMPORT
 DWORD
 PALAPI
 GetFullPathNameW(
-         IN LPCWSTR lpFileName,
-         IN DWORD nBufferLength,
-         OUT LPWSTR lpBuffer,
-         OUT LPWSTR *lpFilePart);
+    IN LPCWSTR lpFileName,
+    IN DWORD nBufferLength,
+    OUT LPWSTR lpBuffer,
+    OUT LPWSTR *lpFilePart);
 
 #ifdef UNICODE
 #define GetFullPathName GetFullPathNameW
@@ -918,13 +1021,14 @@ GetFullPathNameW(
 #define GetFullPathName GetFullPathNameA
 #endif
 
+
 PALIMPORT
 DWORD
 PALAPI
 GetLongPathNameW(
-         IN LPCWSTR lpszShortPath,
-                 OUT LPWSTR lpszLongPath,
-         IN DWORD cchBuffer);
+    IN LPCWSTR lpszShortPath,
+    OUT LPWSTR lpszLongPath,
+    IN DWORD cchBuffer);
 
 #ifdef UNICODE
 #define GetLongPathName GetLongPathNameW
@@ -934,23 +1038,32 @@ PALIMPORT
 DWORD
 PALAPI
 GetShortPathNameW(
-         IN LPCWSTR lpszLongPath,
-                 OUT LPWSTR lpszShortPath,
-         IN DWORD cchBuffer);
+    IN LPCWSTR lpszLongPath,
+    OUT LPWSTR lpszShortPath,
+    IN DWORD cchBuffer);
 
 #ifdef UNICODE
 #define GetShortPathName GetShortPathNameW
 #endif
 
 
+PALIMPORT
+UINT
+PALAPI
+GetTempFileNameA(
+    IN LPCSTR lpPathName,
+    IN LPCSTR lpPrefixString,
+    IN UINT uUnique,
+    OUT LPSTR lpTempFileName);
+
 PALIMPORT
 UINT
 PALAPI
 GetTempFileNameW(
-         IN LPCWSTR lpPathName,
-         IN LPCWSTR lpPrefixString,
-         IN UINT uUnique,
-         OUT LPWSTR lpTempFileName);
+    IN LPCWSTR lpPathName,
+    IN LPCWSTR lpPrefixString,
+    IN UINT uUnique,
+    OUT LPWSTR lpTempFileName);
 
 #ifdef UNICODE
 #define GetTempFileName GetTempFileNameW
@@ -958,12 +1071,20 @@ GetTempFileNameW(
 #define GetTempFileName GetTempFileNameA
 #endif
 
+
+PALIMPORT
+DWORD
+PALAPI
+GetTempPathA(
+    IN DWORD nBufferLength,
+    OUT LPSTR lpBuffer);
+
 PALIMPORT
 DWORD
 PALAPI
 GetTempPathW(
-         IN DWORD nBufferLength,
-         OUT LPWSTR lpBuffer);
+    IN DWORD nBufferLength,
+    OUT LPWSTR lpBuffer);
 
 #ifdef UNICODE
 #define GetTempPath GetTempPathW
@@ -971,12 +1092,20 @@ GetTempPathW(
 #define GetTempPath GetTempPathA
 #endif
 
+
+PALIMPORT
+DWORD
+PALAPI
+GetCurrentDirectoryA(
+    IN DWORD nBufferLength,
+    OUT LPSTR lpBuffer);
+
 PALIMPORT
 DWORD
 PALAPI
 GetCurrentDirectoryW(
-             IN DWORD nBufferLength,
-             OUT LPWSTR lpBuffer);
+    IN DWORD nBufferLength,
+    OUT LPWSTR lpBuffer);
 
 #ifdef UNICODE
 #define GetCurrentDirectory GetCurrentDirectoryW
@@ -984,11 +1113,18 @@ GetCurrentDirectoryW(
 #define GetCurrentDirectory GetCurrentDirectoryA
 #endif
 
+
+PALIMPORT
+BOOL
+PALAPI
+SetCurrentDirectoryA(
+    IN LPCSTR lpPathName);
+
 PALIMPORT
 BOOL
 PALAPI
 SetCurrentDirectoryW(
-            IN LPCWSTR lpPathName);
+    IN LPCWSTR lpPathName);
 
 
 #ifdef UNICODE
@@ -1001,19 +1137,19 @@ PALIMPORT
 DWORD
 PALAPI
 GetCurrentProcessId(
-            VOID);
+    VOID);
 
 PALIMPORT
 DWORD
 PALAPI
 GetCurrentSessionId(
-            VOID);
+    VOID);
 
 PALIMPORT
 DWORD
 PALAPI
 GetCurrentThreadId(
-           VOID);
+   VOID);
 
 #define STARTF_USESTDHANDLES       0x00000100
 
@@ -1915,16 +2051,27 @@ SetErrorMode(
 #define MEM_WRITE_WATCH                 0x200000
 #define MEM_RESERVE_EXECUTABLE          0x40000000 // reserve memory using executable memory allocator
 
+PALIMPORT
+HANDLE
+PALAPI
+CreateFileMappingA(
+    IN HANDLE hFile,
+    IN LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
+    IN DWORD flProtect,
+    IN DWORD dwMaximumSizeHigh,
+    IN DWORD dwMaximumSizeLow,
+    IN LPCSTR lpName);
+
 PALIMPORT
 HANDLE
 PALAPI
 CreateFileMappingW(
-           IN HANDLE hFile,
-           IN LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
-           IN DWORD flProtect,
-           IN DWORD dwMaxmimumSizeHigh,
-           IN DWORD dwMaximumSizeLow,
-           IN LPCWSTR lpName);
+    IN HANDLE hFile,
+    IN LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
+    IN DWORD flProtect,
+    IN DWORD dwMaxmimumSizeHigh,
+    IN DWORD dwMaximumSizeLow,
+    IN LPCWSTR lpName);
 
 #ifdef UNICODE
 #define CreateFileMapping CreateFileMappingW
@@ -1932,6 +2079,7 @@ CreateFileMappingW(
 #define CreateFileMapping CreateFileMappingA
 #endif
 
+
 #define SECTION_QUERY       0x0001
 #define SECTION_MAP_WRITE   0x0002
 #define SECTION_MAP_READ    0x0004
@@ -1945,10 +2093,18 @@ CreateFileMappingW(
 PALIMPORT
 HANDLE
 PALAPI
-OpenFileMappingW(
+OpenFileMappingA(
          IN DWORD dwDesiredAccess,
          IN BOOL bInheritHandle,
-         IN LPCWSTR lpName);
+         IN LPCSTR lpName);
+
+PALIMPORT
+HANDLE
+PALAPI
+OpenFileMappingW(
+    IN DWORD dwDesiredAccess,
+    IN BOOL bInheritHandle,
+    IN LPCWSTR lpName);
 
 #ifdef UNICODE
 #define OpenFileMapping OpenFileMappingW
@@ -1956,38 +2112,54 @@ OpenFileMappingW(
 #define OpenFileMapping OpenFileMappingA
 #endif
 
+
 PALIMPORT
 LPVOID
 PALAPI
 MapViewOfFile(
-          IN HANDLE hFileMappingObject,
-          IN DWORD dwDesiredAccess,
-          IN DWORD dwFileOffsetHigh,
-          IN DWORD dwFileOffsetLow,
-          IN SIZE_T dwNumberOfBytesToMap);
+    IN HANDLE hFileMappingObject,
+    IN DWORD dwDesiredAccess,
+    IN DWORD dwFileOffsetHigh,
+    IN DWORD dwFileOffsetLow,
+    IN SIZE_T dwNumberOfBytesToMap);
 
 PALIMPORT
 LPVOID
 PALAPI
 MapViewOfFileEx(
-          IN HANDLE hFileMappingObject,
-          IN DWORD dwDesiredAccess,
-          IN DWORD dwFileOffsetHigh,
-          IN DWORD dwFileOffsetLow,
-          IN SIZE_T dwNumberOfBytesToMap,
-          IN LPVOID lpBaseAddress);
+    IN HANDLE hFileMappingObject,
+    IN DWORD dwDesiredAccess,
+    IN DWORD dwFileOffsetHigh,
+    IN DWORD dwFileOffsetLow,
+    IN SIZE_T dwNumberOfBytesToMap,
+    IN LPVOID lpBaseAddress);
 
 PALIMPORT
 BOOL
 PALAPI
 UnmapViewOfFile(
-        IN LPCVOID lpBaseAddress);
+    IN LPCVOID lpBaseAddress);
+
+
+PALIMPORT
+HMODULE
+PALAPI
+LoadLibraryA(
+    IN LPCSTR lpLibFileName);
+
+PALIMPORT
+HMODULE
+PALAPI
+LoadLibraryExA(
+    IN LPCSTR lpLibFileName,
+    IN /*Reserved*/ HANDLE hFile,
+    IN DWORD dwFlags);
 
 PALIMPORT
 HMODULE
 PALAPI
 LoadLibraryW(
-        IN LPCWSTR lpLibFileName);
+    IN LPCWSTR lpLibFileName);
 
 PALIMPORT
 HMODULE
@@ -2026,6 +2198,15 @@ PALAPI
 DisableThreadLibraryCalls(
     IN HMODULE hLibModule);
 
+
+PALIMPORT
+DWORD
+PALAPI
+GetModuleFileNameA(
+    IN HMODULE hModule,
+    OUT LPSTR lpFileName,
+    IN DWORD nSize);
+
 PALIMPORT
 DWORD
 PALAPI
@@ -2040,6 +2221,7 @@ GetModuleFileNameW(
 #define GetModuleFileName GetModuleFileNameA
 #endif
 
+
 PALIMPORT
 DWORD
 PALAPI
@@ -2408,7 +2590,7 @@ PALIMPORT
 VOID
 PALAPI
 DebugBreak(
-       VOID);
+    VOID);
 
 PALIMPORT
 int
@@ -2428,13 +2610,21 @@ lstrlenW(
 #define lstrlen lstrlenA
 #endif
 
+PALIMPORT
+DWORD
+PALAPI
+GetEnvironmentVariableA(
+    IN LPCSTR lpName,
+    OUT LPSTR lpBuffer,
+    IN DWORD nSize);
+
 PALIMPORT
 DWORD
 PALAPI
 GetEnvironmentVariableW(
-            IN LPCWSTR lpName,
-            OUT LPWSTR lpBuffer,
-            IN DWORD nSize);
+    IN LPCWSTR lpName,
+    OUT LPWSTR lpBuffer,
+    IN DWORD nSize);
 
 #ifdef UNICODE
 #define GetEnvironmentVariable GetEnvironmentVariableW
@@ -2442,12 +2632,20 @@ GetEnvironmentVariableW(
 #define GetEnvironmentVariable GetEnvironmentVariableA
 #endif
 
+
+PALIMPORT
+BOOL
+PALAPI
+SetEnvironmentVariableA(
+    IN LPCSTR lpName,
+    IN LPCSTR lpValue);
+
 PALIMPORT
 BOOL
 PALAPI
 SetEnvironmentVariableW(
-            IN LPCWSTR lpName,
-            IN LPCWSTR lpValue);
+    IN LPCWSTR lpName,
+    IN LPCWSTR lpValue);
 
 #ifdef UNICODE
 #define SetEnvironmentVariable SetEnvironmentVariableW
@@ -2455,11 +2653,17 @@ SetEnvironmentVariableW(
 #define SetEnvironmentVariable SetEnvironmentVariableA
 #endif
 
+PALIMPORT
+LPSTR
+PALAPI
+GetEnvironmentStringsA(
+    VOID);
+
 PALIMPORT
 LPWSTR
 PALAPI
 GetEnvironmentStringsW(
-               VOID);
+    VOID);
 
 #ifdef UNICODE
 #define GetEnvironmentStrings GetEnvironmentStringsW
@@ -2467,11 +2671,18 @@ GetEnvironmentStringsW(
 #define GetEnvironmentStrings GetEnvironmentStringsA
 #endif
 
+
+PALIMPORT
+BOOL
+PALAPI
+FreeEnvironmentStringsA(
+    IN LPSTR);
+
 PALIMPORT
 BOOL
 PALAPI
 FreeEnvironmentStringsW(
-            IN LPWSTR);
+    IN LPWSTR);
 
 #ifdef UNICODE
 #define FreeEnvironmentStrings FreeEnvironmentStringsW
@@ -2479,22 +2690,24 @@ FreeEnvironmentStringsW(
 #define FreeEnvironmentStrings FreeEnvironmentStringsA
 #endif
 
+
 PALIMPORT
 BOOL
 PALAPI
 CloseHandle(
-        IN OUT HANDLE hObject);
+    IN OUT HANDLE hObject);
 
 PALIMPORT
 DWORD
 PALAPI
 GetTickCount(
-         VOID);
+    VOID);
 
 PALIMPORT
 ULONGLONG
 PALAPI
-GetTickCount64(VOID);
+GetTickCount64(
+    VOID);
 
 PALIMPORT
 BOOL
@@ -2518,8 +2731,7 @@ PAL_nanosleep(
 
 #ifndef FEATURE_PAL_SXS
 
-typedef LONG (PALAPI *PTOP_LEVEL_EXCEPTION_FILTER)(
-                           struct _EXCEPTION_POINTERS *ExceptionInfo);
+typedef LONG (PALAPI *PTOP_LEVEL_EXCEPTION_FILTER)(struct _EXCEPTION_POINTERS *ExceptionInfo);
 typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
 
 PALIMPORT
@@ -3145,10 +3357,6 @@ CreatePipe(
     IN DWORD nSize
     );
 
-#if defined FEATURE_PAL_ANSI
-#include "palprivate.h"
-#endif //FEATURE_PAL_ANSI
-
 /******************* C Runtime Entrypoints *******************************/
 
 /* Some C runtime functions needs to be reimplemented by the PAL.
diff --git a/src/pal/inc/palprivate.h b/src/pal/inc/palprivate.h
deleted file mode 100644 (file)
index be79f8c..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-#ifndef __PAL_PRIVATE_H__
-#define __PAL_PRIVATE_H__
-
-#ifdef  __cplusplus
-extern "C" {
-#endif
-
-PALIMPORT
-int
-PALAPI
-MessageBoxA(
-        IN LPVOID hWnd,  // NOTE: diff from winuser.h
-        IN LPCSTR lpText,
-        IN LPCSTR lpCaption,
-        IN UINT uType);
-
-
-PALIMPORT
-HANDLE
-PALAPI
-CreateFileA(
-        IN LPCSTR lpFileName,
-        IN DWORD dwDesiredAccess,
-        IN DWORD dwShareMode,
-        IN LPSECURITY_ATTRIBUTES lpSecurityAttributes,
-        IN DWORD dwCreationDisposition,
-        IN DWORD dwFlagsAndAttributes,
-        IN HANDLE hTemplateFile);
-
-PALIMPORT
-DWORD
-PALAPI
-SearchPathA(
-    IN LPCSTR lpPath,
-    IN LPCSTR lpFileName,
-    IN LPCSTR lpExtension,
-    IN DWORD nBufferLength,
-    OUT LPSTR lpBuffer,
-    OUT LPSTR *lpFilePart
-    );
-
-PALIMPORT
-BOOL
-PALAPI
-CopyFileA(
-      IN LPCSTR lpExistingFileName,
-      IN LPCSTR lpNewFileName,
-      IN BOOL bFailIfExists);
-
-
-PALIMPORT
-BOOL
-PALAPI
-DeleteFileA(
-        IN LPCSTR lpFileName);
-
-PALIMPORT
-BOOL
-PALAPI
-MoveFileExA(
-        IN LPCSTR lpExistingFileName,
-        IN LPCSTR lpNewFileName,
-        IN DWORD dwFlags);
-
-PALIMPORT
-BOOL
-PALAPI
-CreateDirectoryA(
-         IN LPCSTR lpPathName,
-         IN LPSECURITY_ATTRIBUTES lpSecurityAttributes);
-
-PALIMPORT
-HANDLE
-PALAPI
-FindFirstFileA(
-           IN LPCSTR lpFileName,
-           OUT LPWIN32_FIND_DATAA lpFindFileData);
-
-PALIMPORT
-BOOL
-PALAPI
-FindNextFileA(
-          IN HANDLE hFindFile,
-          OUT LPWIN32_FIND_DATAA lpFindFileData);
-
-PALIMPORT
-DWORD
-PALAPI
-GetFileAttributesA(
-           IN LPCSTR lpFileName);
-
-PALIMPORT
-BOOL
-PALAPI
-SetFileAttributesA(
-           IN LPCSTR lpFileName,
-           IN DWORD dwFileAttributes);
-
-PALIMPORT
-DWORD
-PALAPI
-GetFullPathNameA(
-         IN LPCSTR lpFileName,
-         IN DWORD nBufferLength,
-         OUT LPSTR lpBuffer,
-         OUT LPSTR *lpFilePart);
-
-PALIMPORT
-UINT
-PALAPI
-GetTempFileNameA(
-         IN LPCSTR lpPathName,
-         IN LPCSTR lpPrefixString,
-         IN UINT uUnique,
-         OUT LPSTR lpTempFileName);
-
-PALIMPORT
-DWORD
-PALAPI
-GetTempPathA(
-         IN DWORD nBufferLength,
-         OUT LPSTR lpBuffer);
-
-PALIMPORT
-DWORD
-PALAPI
-GetCurrentDirectoryA(
-             IN DWORD nBufferLength,
-             OUT LPSTR lpBuffer);
-
-PALIMPORT
-BOOL
-PALAPI
-SetCurrentDirectoryA(
-            IN LPCSTR lpPathName);
-
-PALIMPORT
-HANDLE
-PALAPI
-CreateFileMappingA(
-           IN HANDLE hFile,
-           IN LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
-           IN DWORD flProtect,
-           IN DWORD dwMaximumSizeHigh,
-           IN DWORD dwMaximumSizeLow,
-           IN LPCSTR lpName);
-
-PALIMPORT
-HANDLE
-PALAPI
-OpenFileMappingA(
-         IN DWORD dwDesiredAccess,
-         IN BOOL bInheritHandle,
-         IN LPCSTR lpName);
-
-PALIMPORT
-HMODULE
-PALAPI
-LoadLibraryA(
-        IN LPCSTR lpLibFileName);
-
-PALIMPORT
-HMODULE
-PALAPI
-LoadLibraryExA(
-        IN LPCSTR lpLibFileName,
-        IN /*Reserved*/ HANDLE hFile,
-        IN DWORD dwFlags);
-
-PALIMPORT
-DWORD
-PALAPI
-GetModuleFileNameA(
-    IN HMODULE hModule,
-    OUT LPSTR lpFileName,
-    IN DWORD nSize);
-
-
-PALIMPORT
-LPSTR
-PALAPI
-GetEnvironmentStringsA(
-               VOID);
-
-PALIMPORT
-BOOL
-PALAPI
-SetEnvironmentVariableA(
-            IN LPCSTR lpName,
-            IN LPCSTR lpValue);
-
-PALIMPORT
-DWORD
-PALAPI
-GetEnvironmentVariableA(
-            IN LPCSTR lpName,
-            OUT LPSTR lpBuffer,
-            IN DWORD nSize);
-
-PALIMPORT
-BOOL
-PALAPI
-FreeEnvironmentStringsA(
-            IN LPSTR);
-
-PALIMPORT
-BOOL
-PALAPI
-RemoveDirectoryA(
-                 IN LPCSTR lpPathName);
-
-#ifdef  __cplusplus
-}
-#endif
-
-#endif// __PAL_PRIVATE_H__
index aac1f73505afc8fd7b24b468d771b455982eb9c8..95ff40f274264f28eabd7dddb5a6b3b0637c43fd 100644 (file)
@@ -331,8 +331,6 @@ function_name() to call the system's implementation
 #define FILE PAL_FILE
 
 #include "pal.h"
-#include "palprivate.h"
-
 #include "mbusafecrt.h"
 
 #ifdef _VAC_