From 4aad6faf4f0c6af538ffd694b6b32d114d24a5f6 Mon Sep 17 00:00:00 2001 From: Juan Hoyos <juan.s.hoyos@outlook.com> Date: Tue, 20 Sep 2022 20:56:36 -0700 Subject: [PATCH] Merge main into release/stable (#3332) * Update dependencies from https://github.com/dotnet/aspnetcore build 20220608.3 (#3108) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/aspnetcore build 20220609.17 (#3109) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/aspnetcore build 20220610.8 (#3110) [main] Update dependencies from dotnet/aspnetcore * [main] Update dependencies from dotnet/symstore (#3106) [main] Update dependencies from dotnet/symstore * Changes needed for clrmd 2.1 (#3094) * Changes needed for clrmd 2.1 Remove VersionData and convert to System.Version. Not sure why I didn't use System.Version before. Add DbgEng Interop classes from Microsoft.Diagnostics.Runtime.Utilities. CLRMD 2.1 has removed that assembly * Update CLRMD version to latest * Update CLRMD version * Disable DebugServices.UnitTests TestDbgEng tests because of problems loading dbgeng.dll * Update comment with issue * Update dependencies from https://github.com/dotnet/aspnetcore build 20220611.4 (#3112) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/microsoft/clrmd build 20220608.1 (#3113) [main] Update dependencies from microsoft/clrmd * Update dependencies from https://github.com/dotnet/arcade build 20220613.1 (#3115) [main] Update dependencies from dotnet/arcade * Update dependencies from https://github.com/dotnet/installer build 20220610.12 (#3116) [main] Update dependencies from dotnet/installer * Update dependencies from https://github.com/dotnet/aspnetcore build 20220612.4 (#3117) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/aspnetcore build 20220613.13 (#3119) [main] Update dependencies from dotnet/aspnetcore * Pin the Microsoft.Extensions.Logging version so that source-build does not pick up latest (#3121) * Fix PDBs in dbgshim packages (#3122) * [main] Update dependencies from microsoft/clrmd (#3124) * Update dependencies from https://github.com/microsoft/clrmd build 20220614.2 Microsoft.Diagnostics.Runtime From Version 2.1.330801 -> To Version 2.1.331402 * Fix build issue Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Mike McLaughlin <mikem@microsoft.com> * Update dependencies from https://github.com/microsoft/clrmd build 20220615.3 (#3128) [main] Update dependencies from microsoft/clrmd * Update dependencies from https://github.com/microsoft/clrmd build 20220617.1 (#3130) [main] Update dependencies from microsoft/clrmd * Update dependencies from https://github.com/dotnet/arcade build 20220616.2 (#3132) [main] Update dependencies from dotnet/arcade * Update dependencies from https://github.com/microsoft/clrmd build 20220620.2 (#3135) [main] Update dependencies from microsoft/clrmd * Update dependencies from https://github.com/dotnet/symstore build 20220620.1 (#3136) [main] Update dependencies from dotnet/symstore * DML formats array missing DML_IL entry (#3140) This was causing incorrect commands in markup for WinDBG scenarios. * Allow for runtimelab to build Microsoft.Diagnostics.NETCore.Client (#3139) * Update dependencies from https://github.com/dotnet/symstore build 20220622.1 (#3141) [main] Update dependencies from dotnet/symstore * Update dependencies from https://github.com/microsoft/clrmd build 20220623.2 (#3142) [main] Update dependencies from microsoft/clrmd * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220624.2 (#3144) [main] Update dependencies from dotnet/source-build-reference-packages * Update dependencies from https://github.com/dotnet/symstore build 20220627.1 (#3146) [main] Update dependencies from dotnet/symstore * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220627.1 (#3147) Microsoft.SourceBuild.Intermediate.source-build-reference-packages From Version 7.0.0-alpha.1.22324.2 -> To Version 7.0.0-alpha.1.22327.1 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Add help for command flag of dotnet-dump (#3151) * Add help for command flag of dotnet-dump * Update Program.cs * Update Program.cs * Update Program.cs * Update Program.cs * Update src/Tools/dotnet-dump/Program.cs Co-authored-by: Dan Moseley <danmose@microsoft.com> Co-authored-by: Dan Moseley <danmose@microsoft.com> * Add `.github/fabricbot.json` (#3149) Co-authored-by: msftbot[bot] <48340428+msftbot[bot]@users.noreply.github.com> * Fix dotnet dump command help typo (#3152) * Update dependencies from https://github.com/dotnet/symstore build 20220629.1 (#3154) [main] Update dependencies from dotnet/symstore * Fix usbmux to return any received data. (#3134) * Fix usbmux to return any received data. When receiving data from the other end in usbmux mode, we need to return any data we get, not wait to fill the input buffer. Otherwise any clients waiting for data will wait forever: in fact the initial handshake would fail to complete, because we wouldn't pass along the 28-byte success response because we were trying to fill the 1028-byte buffer with data. Also add some input validation to make sure we don't write data into random memory + take the requested offset into account when writing data into the output array. * Testing main, adding in net7.0 testing (#3127) Testing main, adding in net7.0 testing Add common test runner and project (CommonTestRunner) Disable 7.0 singlefile and aspnet tests until new test infra is in DotNetBuildDebuggeeTestStep.cs resilient against test environment Change TFM on .NET 7 for Unix as well Adjust ProcessInfo tests to account for full "managed" commandline Remove net5.0 testing Don't install 3.1 on arm64 Build and run tests on MacOS M1 https://github.com/dotnet/diagnostics/issues/2568 Reenable EventLogsPipeUnitTests and EventCounterTriggerTests https://github.com/dotnet/diagnostics/issues/2541 TestLogsAllCategoriesDefaultLevelFallback fails frequently https://github.com/dotnet/diagnostics/issues/2819 Diagnostics tests don't run on MacOS arm64 Fix x86 GCEventTest Don't dispose EventPipeSession in EventPipeSessionTests because they hang for 30secs during the dispose. Disable (setting COMPlus_EnableWriteXorExecute=0) W^E in SOSRunner so bpmd tests work on 7.0. Add --address option to modules command Update test SDK to version with SOS buffer fixes Made changes to SOS runner to use the local DAC via the runtime directory for single-file apps instead of depending on downloading it from the symbol server. Disable checking GCFreeSegment callbacks on 7.0 Add singlefile to test helper (like SOSRunner) log names Disable eeversion test on 7.0 * Update dependencies from https://github.com/dotnet/runtime build 20220701.8 (#3157) [main] Update dependencies from dotnet/runtime * [main] Update dependencies from dotnet/aspnetcore (#3156) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/runtime build 20220702.5 (#3158) [main] Update dependencies from dotnet/runtime * [main] Update dependencies from dotnet/installer (#3133) [main] Update dependencies from dotnet/installer - Merge branch 'main' into darc-main-b94fa457-eb37-496d-866f-cdcbfea0a05d * Update dependencies from https://github.com/dotnet/runtime build 20220704.1 (#3160) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/installer build 20220704.2 (#3159) [main] Update dependencies from dotnet/installer * [main] Update dependencies from dotnet/arcade (#3145) [main] Update dependencies from dotnet/arcade - Revert Microsoft.DotNet.RemoteExecutor version back to something that works with this repo * Update dependencies from https://github.com/dotnet/symstore build 20220704.1 (#3162) [main] Update dependencies from dotnet/symstore * Update dependencies from https://github.com/dotnet/runtime build 20220704.5 (#3163) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/aspnetcore build 20220704.2 (#3161) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/symstore build 20220705.1 (#3166) [main] Update dependencies from dotnet/symstore * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220705.3 (#3168) [main] Update dependencies from dotnet/source-build-reference-packages * Update dependencies from https://github.com/dotnet/aspnetcore build 20220705.19 (#3165) [main] Update dependencies from dotnet/aspnetcore * Fix symweb URL in symbol service (#3164) * Update dependencies from https://github.com/dotnet/runtime build 20220706.1 (#3167) [main] Update dependencies from dotnet/runtime * Change return value type from HResult to int to avoid crash on Linux x86 (#3129) * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220706.1 (#3173) [main] Update dependencies from dotnet/source-build-reference-packages * Update dependencies from https://github.com/dotnet/runtime build 20220706.9 (#3172) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/aspnetcore build 20220707.1 (#3171) [main] Update dependencies from dotnet/aspnetcore * Disable dumpstack/eestack tests on 7.0 runtimes (#3174) * Update dependencies from https://github.com/dotnet/runtime build 20220707.4 (#3177) [main] Update dependencies from dotnet/runtime * Disable more !dumpstack tests (#3178) * Update dependencies from https://github.com/dotnet/aspnetcore build 20220707.7 (#3176) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/aspnetcore build 20220708.6 (#3179) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/runtime build 20220708.7 (#3180) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/aspnetcore build 20220709.3 (#3181) [main] Update dependencies from dotnet/aspnetcore * [main] Update dependencies from dotnet/installer (#3183) [main] Update dependencies from dotnet/installer - Fix single-file runtime version * [main] Update dependencies from dotnet/arcade (#3182) [main] Update dependencies from dotnet/arcade - Revert remote executor version * Update dependencies from https://github.com/dotnet/aspnetcore build 20220711.9 (#3184) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/symstore build 20220711.1 (#3185) [main] Update dependencies from dotnet/symstore * Update dependencies from https://github.com/dotnet/runtime build 20220711.13 (#3186) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/aspnetcore build 20220712.16 (#3188) [main] Update dependencies from dotnet/aspnetcore * Change WarningsAsErrors elements to inherit (#3190) * [main] Update dependencies from dotnet/runtime (#3189) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220713.2 (#3194) [main] Update dependencies from dotnet/source-build-reference-packages * Update dependencies from https://github.com/dotnet/aspnetcore build 20220714.1 (#3193) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/aspnetcore build 20220714.5 (#3196) [main] Update dependencies from dotnet/aspnetcore * Expose token2ee (#3195) * Update dependencies from https://github.com/dotnet/runtime build 20220714.7 (#3197) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/aspnetcore build 20220715.7 (#3199) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/runtime build 20220715.6 (#3200) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220715.1 (#3201) [main] Update dependencies from dotnet/source-build-reference-packages * Update dependencies from https://github.com/dotnet/runtime build 20220716.5 (#3203) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/aspnetcore build 20220717.1 (#3202) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/runtime build 20220717.4 (#3207) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220717.1 (#3208) [main] Update dependencies from dotnet/source-build-reference-packages * Update dependencies from https://github.com/dotnet/aspnetcore build 20220717.2 (#3206) [main] Update dependencies from dotnet/aspnetcore * [main] Update dependencies from dotnet/installer (#3205) [main] Update dependencies from dotnet/installer - Fix single-file runtime version * [main] Update dependencies from dotnet/arcade (#3204) [main] Update dependencies from dotnet/arcade - Restore remote executor version * Add gchandles and objsize commands to lldb debugger extension (#3192) * GCHandles should work on all platforms, so remove the artificial constraint * Enable objsize in lldb and SOS debugger * Add gchandles command * It builds! ``` 000000011bf9fcd8 2190 332880 System.RuntimeType+RuntimeTypeCache 000000011badb120 131 1535936 System.Object[] Total 34402 objects Handles: Strong Handles: 3683 Pinned Handles: 6 Ref Count Handles: 10740 Weak Long Handles: 5316 Weak Short Handles: 9624 Dependent Handles: 5033 ``` * Fix code style * Update dependencies from https://github.com/dotnet/symstore build 20220718.1 (#3210) [main] Update dependencies from dotnet/symstore * Update dependencies from https://github.com/dotnet/aspnetcore build 20220718.7 (#3209) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220718.3 (#3212) [main] Update dependencies from dotnet/source-build-reference-packages * [main] Update dependencies from dotnet/runtime (#3211) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/aspnetcore build 20220719.9 (#3213) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/aspnetcore build 20220720.9 (#3215) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/aspnetcore build 20220721.13 (#3219) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220721.2 (#3220) [main] Update dependencies from dotnet/source-build-reference-packages * Update dependencies from https://github.com/dotnet/aspnetcore build 20220722.13 (#3223) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/aspnetcore build 20220723.2 (#3224) [main] Update dependencies from dotnet/aspnetcore * [main] Update dependencies from dotnet/arcade (#3225) [main] Update dependencies from dotnet/arcade - Revert Microsoft.RemoteExecutor version * [main] Update dependencies from dotnet/installer (#3226) [main] Update dependencies from dotnet/installer - Update 7.0 single-file runtime version * Remove stale gauges from dotnet-counters UI (#3221) dotnet-counters currently adds new metrics and tags that it discovers to the console UI but never removes anything, even if the data for those metrics/tags stops coming. For gauges the lack of data is meaningful because the user code explicitly chose not to provide a value when queried. This change removes metrics/tags from the UI if the gauge in the monitored process stops sending data. * Allow dotnet-sos install parameter to use --arch (#3227) This aligns us better with the usage in `dotnet tool install` * Update dependencies from https://github.com/dotnet/aspnetcore build 20220726.1 (#3228) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/symstore build 20220725.1 (#3229) [main] Update dependencies from dotnet/symstore * [main] Update dependencies from dotnet/aspnetcore (#3232) [main] Update dependencies from dotnet/aspnetcore * Update Newtonsoft usage (#3234) * Bump Netwonsoft JSON used in test * Move arcade to bar build ID: 143014 * Pin Microsoft.DotNet.RemoteExecutor * Update dependencies from https://github.com/dotnet/aspnetcore build 20220729.1 (#3237) [main] Update dependencies from dotnet/aspnetcore * [main] Update dependencies from dotnet/source-build-reference-packages (#3230) [main] Update dependencies from dotnet/source-build-reference-packages * [main] Update dependencies from dotnet/runtime (#3236) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/runtime build 20220721.1 (#3216) Microsoft.NETCore.App.Runtime.win-x64 , VS.Redist.Common.NetCore.SharedFramework.x64.7.0 From Version 7.0.0-rc.1.22369.9 -> To Version 7.0.0-rc.1.22371.1 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Mike McLaughlin <mikem@microsoft.com> * Enable more SOS commands for Linux/MacOS (#3233) Enable more SOS commands for Linux/MacOS Allows more SOS on Linux/MacOS and Linux core dumps on Windows under Windbg. Commands enabled for Linux/MacOS on lldb, windbg and dotnet-dump: DumpSig DumpSigElem DumpRuntimeTypes VerifyHeap AnalyzeOOM VerifyObj ListNearObj GCHeapStat ThreadPool EHInfo GCInfo ObjSize FindRoots Under dotnet-dump and lldb this commands are lowercase. Issue: https://github.com/dotnet/diagnostics/issues/3169 Fix invalid formatting char problems on Windows on a few of the commands. Fix dumpgcdata for server GCs Fix verifyheap failures Fix GCHeapTraverse for empty POH Co-authored-by: Andrew Au <andrewau@microsoft.com> * Update dependencies from https://github.com/dotnet/runtime build 20220730.1 (#3239) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220729.1 (#3240) [main] Update dependencies from dotnet/source-build-reference-packages * Update dependencies from https://github.com/dotnet/aspnetcore build 20220729.5 (#3238) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/aspnetcore build 20220730.2 (#3241) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220730.1 (#3243) [main] Update dependencies from dotnet/source-build-reference-packages * Update dependencies from https://github.com/dotnet/runtime build 20220730.3 (#3242) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/symstore build 20220731.1 (#3246) Microsoft.SymbolStore From Version 1.0.337501 -> To Version 1.0.338101 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * [main] Update dependencies from dotnet/runtime (#3247) [main] Update dependencies from dotnet/runtime - Update MacOS vm image from macOS-10.15 to macOS-latest - Stop using XCode 12 explicitly The queues will use a version greater than 12 now by default. * Update dependencies from https://github.com/dotnet/arcade build 20220729.10 (#3244) Microsoft.DotNet.Arcade.Sdk From Version 7.0.0-beta.22377.18 -> To Version 7.0.0-beta.22379.10 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * [main] Update dependencies from dotnet/installer (#3245) * Update dependencies from https://github.com/dotnet/installer build 20220731.2 Microsoft.Dotnet.Sdk.Internal From Version 7.0.100-rc.1.22374.1 -> To Version 7.0.100-rc.1.22381.2 * Update single-file runtime version Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Mike McLaughlin <mikem@microsoft.com> * Update dependencies from https://github.com/dotnet/symstore build 20220801.1 (#3250) [main] Update dependencies from dotnet/symstore * Update dependencies from https://github.com/dotnet/runtime build 20220801.9 (#3251) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/aspnetcore build 20220802.1 (#3249) Microsoft.AspNetCore.App.Ref , Microsoft.AspNetCore.App.Ref.Internal From Version 7.0.0-rc.1.22380.2 -> To Version 7.0.0-rc.1.22402.1 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/runtime build 20220802.10 (#3253) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/aspnetcore build 20220803.3 (#3252) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220802.1 (#3254) [main] Update dependencies from dotnet/source-build-reference-packages * [main] Update dependencies from dotnet/aspnetcore (#3256) * Update dependencies from https://github.com/dotnet/aspnetcore build 20220803.14 Microsoft.AspNetCore.App.Ref , Microsoft.AspNetCore.App.Ref.Internal From Version 7.0.0-rc.1.22403.3 -> To Version 7.0.0-rc.1.22403.14 * Disable EventCounterTriggerTests.EventCounterTriggerWithEventPipePipelineTest on Windows also Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Mike McLaughlin <mikem@microsoft.com> * [main] Update dependencies from dotnet/runtime (#3257) [main] Update dependencies from dotnet/runtime - Disable part of EventLogsPipelineUnitTests.TestLogsAllCategoriesDefaultLevelFallback - Disable EventLogsPipelineUnitTests.TestLogsAllCategoriesDefaultLevelFallback * Update dependencies from https://github.com/dotnet/aspnetcore build 20220804.15 (#3259) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220804.2 (#3261) [main] Update dependencies from dotnet/source-build-reference-packages * Update dependencies from https://github.com/dotnet/aspnetcore build 20220805.12 (#3263) [main] Update dependencies from dotnet/aspnetcore * [main] Update dependencies from dotnet/runtime (#3260) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220805.2 (#3264) [main] Update dependencies from dotnet/source-build-reference-packages * Update dependencies from https://github.com/dotnet/runtime build 20220806.5 (#3267) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/arcade build 20220805.6 (#3268) [main] Update dependencies from dotnet/arcade * Update dependencies from https://github.com/dotnet/runtime build 20220807.4 (#3270) [main] Update dependencies from dotnet/runtime * [main] Update dependencies from dotnet/installer (#3269) [main] Update dependencies from dotnet/installer - Update single-file runtime version - Changed wrong property * Make symbol store settings output more user friendly (#3271) * Update dependencies from https://github.com/dotnet/aspnetcore build 20220808.7 (#3272) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/symstore build 20220808.1 (#3273) [main] Update dependencies from dotnet/symstore * Update dependencies from https://github.com/dotnet/runtime build 20220808.9 (#3274) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220808.1 (#3275) [main] Update dependencies from dotnet/source-build-reference-packages * Allow `sos <cmd>` to be used consistently across all debuggers/hosts (#3266) * Allow sos <cmd> to be used consistently across all debuggers/hosts Issue https://github.com/dotnet/diagnostics/issues/2998 Renamed CommandPlatform to CommandFlags Add DAC EnumMemoryRegion `enummemory` test command Don't fail if datatarget's ReadVirtual is passed 0 size * Add ICLRDataEnumMemoryRegionsLoggingCallback callback to enummemory cmd * Update to 3.1.28/6.0.8 runtime versions * Update dependencies from https://github.com/dotnet/runtime build 20220810.1 (#3277) [main] Update dependencies from dotnet/runtime * Align TraceEvent Version with dotnet/runtime (#3191) * Align TraceEvent Version with dotnet/runtime * Update Graph NodeCount type * Bump TraceEvent Version to 3.0.3 * Update dependencies from https://github.com/dotnet/aspnetcore build 20220810.1 (#3276) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/aspnetcore build 20220810.20 (#3278) [main] Update dependencies from dotnet/aspnetcore * [main] Update dependencies from dotnet/runtime (#3279) [main] Update dependencies from dotnet/runtime - Fix failing DumpStack tests * Update dependencies from https://github.com/dotnet/aspnetcore build 20220812.1 (#3280) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/runtime build 20220813.1 (#3282) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/aspnetcore build 20220812.22 (#3281) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/runtime build 20220813.9 (#3284) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/aspnetcore build 20220813.3 (#3283) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/arcade build 20220811.2 (#3285) [main] Update dependencies from dotnet/arcade * Update dependencies from https://github.com/dotnet/aspnetcore build 20220814.2 (#3287) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/runtime build 20220814.6 (#3288) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/symstore build 20220815.1 (#3290) [main] Update dependencies from dotnet/symstore * Update dependencies from https://github.com/dotnet/aspnetcore build 20220815.25 (#3289) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/runtime build 20220815.13 (#3291) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/runtime build 20220816.3 (#3293) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220816.1 (#3294) [main] Update dependencies from dotnet/source-build-reference-packages * Update dependencies from https://github.com/dotnet/aspnetcore build 20220817.1 (#3292) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/aspnetcore build 20220817.17 (#3296) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/runtime build 20220817.9 (#3297) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/aspnetcore build 20220818.9 (#3299) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/arcade build 20220818.4 (#3300) [main] Update dependencies from dotnet/arcade * Update dependencies from https://github.com/dotnet/symstore build 20220819.1 (#3302) [main] Update dependencies from dotnet/symstore * Update dependencies from https://github.com/dotnet/aspnetcore build 20220819.22 (#3301) [main] Update dependencies from dotnet/aspnetcore * Update SOS for removal of unmanaged threadpool (#3303) * Update dependencies from https://github.com/dotnet/aspnetcore build 20220820.2 (#3304) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/runtime build 20220821.2 (#3307) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/arcade build 20220819.1 (#3306) [main] Update dependencies from dotnet/arcade * Update dependencies from https://github.com/dotnet/aspnetcore build 20220821.9 (#3305) [main] Update dependencies from dotnet/aspnetcore * Make ReversedDiagnosticsServer.Start method throw if address is in use (#3231) * Make ReversedDiagnosticsServer.Start method throw if address is in use * Test for correct error code on OSX Use SkippableFact instead of short-circuit * Update dependencies from https://github.com/dotnet/aspnetcore build 20220823.1 (#3309) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/symstore build 20220822.1 (#3310) Microsoft.SymbolStore From Version 1.0.341901 -> To Version 1.0.342201 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/runtime build 20220822.12 (#3311) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/aspnetcore build 20220823.16 (#3312) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/aspnetcore build 20220824.4 (#3314) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/runtime build 20220825.17 (#3316) [main] Update dependencies from dotnet/runtime * Installer update and fixed lldb's ReadVirtual to support partial reads (#3315) * Update dependencies from https://github.com/dotnet/installer build 20220814.7 Microsoft.Dotnet.Sdk.Internal From Version 7.0.100-rc.1.22407.1 -> To Version 7.0.100-rc.1.22414.7 * Update single-file 7.0 runtime version * Update dependencies from https://github.com/dotnet/installer build 20220819.24 Microsoft.Dotnet.Sdk.Internal From Version 7.0.100-rc.1.22407.1 -> To Version 7.0.100-rc.2.22419.24 * Fixed lldb's ReadVirtual to support partial reads Fixed the DumpRuntimeTypes command to build the GC heap info. It was looking up segments uninitialized. * Update dependencies from https://github.com/dotnet/runtime build 20220826.8 (#3320) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/aspnetcore build 20220826.21 (#3319) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/aspnetcore build 20220827.7 (#3321) [main] Update dependencies from dotnet/aspnetcore * Fix linux-musl-arm64 RID in dbgshim package (#3327) * [main] Update dependencies from dotnet/installer (#3323) * Update dependencies from https://github.com/dotnet/installer build 20220826.5 Microsoft.Dotnet.Sdk.Internal From Version 7.0.100-rc.2.22419.24 -> To Version 7.0.100-rc.2.22426.5 * Update single-file version Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Mike McLaughlin <mikem@microsoft.com> * Update dependencies from https://github.com/dotnet/arcade build 20220826.8 (#3322) Microsoft.DotNet.Arcade.Sdk From Version 7.0.0-beta.22419.1 -> To Version 7.0.0-beta.22426.8 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/aspnetcore build 20220829.3 (#3324) Microsoft.AspNetCore.App.Ref , Microsoft.AspNetCore.App.Ref.Internal From Version 7.0.0-rc.2.22427.7 -> To Version 7.0.0-rc.2.22429.3 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/runtime build 20220828.3 (#3325) Microsoft.NETCore.App.Runtime.win-x64 , VS.Redist.Common.NetCore.SharedFramework.x64.7.0 From Version 7.0.0-rc.2.22426.8 -> To Version 7.0.0-rc.2.22428.3 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Sync eng/native from runtime (#3318) * Workaround 7.0 msbuild bug hit in MacOS CI builds (#3328) * Update dependencies from https://github.com/dotnet/symstore build 20220829.1 (#3330) Microsoft.SymbolStore From Version 1.0.342201 -> To Version 1.0.342901 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * [main] Update dependencies from dotnet/aspnetcore (#3329) * Update dependencies from https://github.com/dotnet/aspnetcore build 20220829.7 Microsoft.AspNetCore.App.Ref , Microsoft.AspNetCore.App.Ref.Internal From Version 7.0.0-rc.2.22429.3 -> To Version 7.0.0-rc.2.22429.7 * Disable EventLogsPipelineUnitTests on Windows. Issue #2541 * Fix where the skip exception is thrown Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Mike McLaughlin <mikem@microsoft.com> * Bump Azure.Storage.Blobs in /eng/release/DiagnosticsReleaseTool (#3217) Bumps [Azure.Storage.Blobs](https://github.com/Azure/azure-sdk-for-net) from 12.9.1 to 12.13.0. - [Release notes](https://github.com/Azure/azure-sdk-for-net/releases) - [Commits](https://github.com/Azure/azure-sdk-for-net/compare/Azure.Storage.Blobs_12.9.1...Azure.Storage.Blobs_12.13.0) --- updated-dependencies: - dependency-name: Azure.Storage.Blobs dependency-type: direct:production ... Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/aspnetcore build 20220831.2 (#3334) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/runtime build 20220830.11 (#3335) [main] Update dependencies from dotnet/runtime * Update Ubuntu 16.04 images (#3336) * Update Ubuntu 16.04 images * Simplify documentation * Address CR feedback * Fix recursive issues for large Regions GC heap enumeration (#3333) * Fix recursive issues for large Regions GC heap enumeration * Ensure check interrupt in other calls of GC algorithms * Update dependencies from https://github.com/dotnet/runtime build 20220831.13 (#3340) Microsoft.NETCore.App.Runtime.win-x64 , VS.Redist.Common.NetCore.SharedFramework.x64.7.0 From Version 7.0.0-rc.2.22430.11 -> To Version 7.0.0-rc.2.22431.13 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/aspnetcore build 20220831.34 (#3339) Microsoft.AspNetCore.App.Ref , Microsoft.AspNetCore.App.Ref.Internal From Version 7.0.0-rc.2.22431.2 -> To Version 7.0.0-rc.2.22431.34 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update public pool names (#3338) * Revert "Update Ubuntu 16.04 images (#3336)" (#3342) This reverts commit b5bca688fed93a65806a4121d8c838c6aa853af7. * Update dependencies from https://github.com/dotnet/runtime build 20220901.11 (#3346) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/symstore build 20220901.1 (#3345) Microsoft.SymbolStore From Version 1.0.342901 -> To Version 1.0.345101 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/aspnetcore build 20220901.19 (#3344) Microsoft.AspNetCore.App.Ref , Microsoft.AspNetCore.App.Ref.Internal From Version 7.0.0-rc.2.22431.34 -> To Version 7.0.0-rc.2.22451.19 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/aspnetcore build 20220902.11 (#3347) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/runtime build 20220902.13 (#3348) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/installer build 20220904.1 (#3351) [main] Update dependencies from dotnet/installer * Update dependencies from https://github.com/dotnet/arcade build 20220902.1 (#3350) [main] Update dependencies from dotnet/arcade * Fix use of bitwise '&' with boolean operands in palrt (#3349) * Update dependencies from https://github.com/dotnet/symstore build 20220905.1 (#3352) [main] Update dependencies from dotnet/symstore * Fix debugging on UWP/.NET Core 1.0 (#3343) Need to check for the architecture named CLRDEBUGINFO (i.e. "CLRDEBUGINFOCORESYSAMD64", etc.) resource in coreclr.dll for the live debugging APIs. * Update dependencies from https://github.com/dotnet/aspnetcore build 20220906.19 (#3355) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220906.2 (#3357) [main] Update dependencies from dotnet/source-build-reference-packages * Misc SOS fixes and cleanup. (#3354) * Misc SOS fixes and cleanup. Use new EnumMemoryRegion flags. Update the clrdata.idl/clrdata.h/clrdata_i.cpp to the new DAC log message interface name. Change the name of the "enummemory" command to "enummem". Add memory region verify on the callback. Fix dumpobj/dumpruntimetypes with TypeDescs. Add memory usage stats to sosstatus. Fix issue https://github.com/dotnet/diagnostics/issues/3187. dotnet-dump analyze causes an Exception when console width is 0. Fix issue https://github.com/dotnet/diagnostics/issues/3120. Increase (remove) max heap segment. Finish https://github.com/dotnet/diagnostics/issues/3101. SOS should stop using HResult as a PInvoke return. * Update dependencies from https://github.com/dotnet/runtime build 20220906.11 (#3356) Microsoft.NETCore.App.Runtime.win-x64 , VS.Redist.Common.NetCore.SharedFramework.x64.7.0 From Version 7.0.0-rc.2.22452.13 -> To Version 7.0.0-rc.2.22456.11 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/aspnetcore build 20220907.29 (#3360) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/runtime build 20220908.21 (#3363) [main] Update dependencies from dotnet/runtime * Add console file logging (#3358) Add console file logging Added "logopen" and "logclose" commands to control console file logging. Added the IConsoleFileLoggingService and implementation to control the console file logging. Issue: https://github.com/dotnet/diagnostics/issues/3095 Add internal diagnostic logging to a file also. Added the IDiagnosticLoggingService and implementation to control internal diagnostic logging. Move Tracer.cs to Microsoft.Diagnostics.DebugService.Implementation. Add tests for logging commands * Update dependencies from https://github.com/dotnet/aspnetcore build 20220908.35 (#3362) Microsoft.AspNetCore.App.Ref , Microsoft.AspNetCore.App.Ref.Internal From Version 7.0.0-rc.2.22457.29 -> To Version 7.0.0-rc.2.22458.35 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Enable int overflow/underflow checking (#3361) Enable int overflow/underflow checking * Update dependencies from https://github.com/dotnet/aspnetcore build 20220910.2 (#3364) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/runtime build 20220909.15 (#3365) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/arcade build 20220906.4 (#3369) [main] Update dependencies from dotnet/arcade * Update dependencies from https://github.com/dotnet/runtime build 20220910.1 (#3368) Microsoft.NETCore.App.Runtime.win-x64 , VS.Redist.Common.NetCore.SharedFramework.x64.7.0 From Version 7.0.0-rc.2.22459.15 -> To Version 7.0.0-rc.2.22460.1 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/aspnetcore build 20220910.7 (#3367) [main] Update dependencies from dotnet/aspnetcore * Update CollectCommand.cs (#3371) Fix typo in comment * Update dependencies from https://github.com/dotnet/aspnetcore build 20220912.11 (#3373) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/runtime build 20220912.6 (#3374) [main] Update dependencies from dotnet/runtime * Fix SOS message context (#3375) * Fix SOS message context Issue: https://github.com/dotnet/diagnostics/issues/2978 * Update dependencies from https://github.com/dotnet/aspnetcore build 20220913.21 (#3377) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220913.2 (#3379) [main] Update dependencies from dotnet/source-build-reference-packages * Update dependencies from https://github.com/dotnet/runtime build 20220913.21 (#3378) [main] Update dependencies from dotnet/runtime * Fixed dotnet-counters rendering issues on console resizes (#3353) * Updated ConsoleWriter formatting * Fixed the issue of large fonts by using the fixed length of formatted values. * Should now only print the numerical values when the window width is less than 20 * Truncate the instruction string at the top of output based on the console width * Added fix for change in console height and multidimensional metrics. * Roll to Windows 2019 image to fix arm cross build (#3376) Roll back to Windows 2019 image to fix arm cross build * Fix stray help command (#3382) * Check CursorTop before changing CursorLeft to prevent ArgumentOutOfRangeException (#3372) * Catch ArgumentOutOfRangeException dotnet-dump analyze causes an Exception when console top is -1 * Check CursorTop before changing CursorLeft * Disable eestack/dumpstack testing on 7.0 (#3383) * Add linux-musl-arm SOS support (#3384) * Add linux-musl-arm SOS support Issue: https://github.com/dotnet/diagnostics/issues/1552 * Add linux-musl-arm to SOS/dotnet-dump packages * Add linux-musl-arm dbgshim to package * Update dependencies from https://github.com/dotnet/aspnetcore build 20220914.30 (#3385) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/runtime build 20220914.18 (#3386) [main] Update dependencies from dotnet/runtime * Remove support for SOS win-arm .NET Framework hosting (#3387) * Remove support for SOS win-arm .NET Framework hosting * Revert "Roll to Windows 2019 image to fix arm cross build (#3376)" This reverts commit d3a6215f659b6059fa2237427733aa6c3b04b807. * PR Feedback Co-authored-by: Mike McLaughlin <mikem@microsoft.com> Co-authored-by: Mike McLaughlin <mikem@microsoft.com> * Update dependencies from https://github.com/dotnet/runtime build 20220915.3 (#3390) [main] Update dependencies from dotnet/runtime * Update dependencies from https://github.com/dotnet/aspnetcore build 20220915.27 (#3389) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/aspnetcore build 20220916.18 (#3393) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/runtime build 20220916.6 (#3394) [main] Update dependencies from dotnet/runtime * Enable traverseheap command under lldb/dotnet-dump on all platforms (#3388) * [main] Update dependencies from dotnet/source-build-reference-packages (#3391) [main] Update dependencies from dotnet/source-build-reference-packages * Update dependencies from https://github.com/dotnet/arcade build 20220916.3 (#3396) [main] Update dependencies from dotnet/arcade * Update dependencies from https://github.com/dotnet/aspnetcore build 20220920.1 (#3397) [main] Update dependencies from dotnet/aspnetcore * Update dependencies from https://github.com/dotnet/runtime build 20220919.12 (#3398) [main] Update dependencies from dotnet/runtime * Fix overflow exception in Microsoft.Diagnostics.Monitoring (#3400) Issue: https://github.com/dotnet/diagnostics/issues/3392 Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Mike McLaughlin <mikem@microsoft.com> Co-authored-by: Michael Simons <msimons@microsoft.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Aaron Robinson <arobins@microsoft.com> Co-authored-by: Dan Moseley <danmose@microsoft.com> Co-authored-by: msftbot[bot] <48340428+msftbot[bot]@users.noreply.github.com> Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com> Co-authored-by: o-lek <72216713+o-lek@users.noreply.github.com> Co-authored-by: Levi Broderick <GrabYourPitchforks@users.noreply.github.com> Co-authored-by: Marius Ungureanu <therzok@gmail.com> Co-authored-by: Noah Falk <noahfalk@users.noreply.github.com> Co-authored-by: Andrew Au <andrewau@microsoft.com> Co-authored-by: Mitchell Hwang <16830051+mdh1418@users.noreply.github.com> Co-authored-by: Jan Kotas <jkotas@microsoft.com> Co-authored-by: Justin Anderson <jander-msft@users.noreply.github.com> Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Matt Galbraith <MattGal@users.noreply.github.com> Co-authored-by: Hyungju Lee <leee.lee@samsung.com> Co-authored-by: Daniel Ramos <111319334+dramos020@users.noreply.github.com> --- .github/fabricbot.json | 86 ++ Directory.Build.props | 1 + NuGet.config | 1 - diagnostics.sln | 93 +- diagnostics.yml | 37 +- documentation/sos-debugging-extension.md | 16 +- eng/CodeAnalysis.ruleset | 20 +- eng/InstallRuntimes.proj | 43 +- eng/Version.Details.xml | 40 +- eng/Versions.props | 43 +- eng/build.yml | 13 +- eng/common/SetupNugetSources.ps1 | 18 +- eng/common/SetupNugetSources.sh | 68 +- eng/common/build.sh | 17 +- eng/common/cross/arm/sources.list.focal | 11 + eng/common/cross/arm/sources.list.jammy | 11 + eng/common/cross/arm64/sources.list.focal | 11 + eng/common/cross/arm64/sources.list.jammy | 11 + eng/common/cross/build-rootfs.sh | 330 +++-- eng/common/cross/riscv64/sources.list.sid | 1 + eng/common/cross/toolchain.cmake | 98 +- eng/common/cross/x86/sources.list.focal | 11 + eng/common/cross/x86/sources.list.jammy | 11 + eng/common/generate-locproject.ps1 | 47 +- eng/common/generate-sbom-prep.ps1 | 2 + eng/common/generate-sbom-prep.sh | 12 + eng/common/init-tools-native.ps1 | 9 +- eng/common/native/init-compiler.sh | 2 +- eng/common/sdk-task.ps1 | 2 +- eng/common/sdl/NuGet.config | 5 + eng/common/sdl/sdl.ps1 | 38 + eng/common/templates/job/execute-sdl.yml | 6 +- eng/common/templates/job/job.yml | 37 +- eng/common/templates/job/onelocbuild.yml | 2 +- eng/common/templates/job/source-build.yml | 2 +- .../templates/job/source-index-stage1.yml | 8 +- eng/common/templates/jobs/jobs.yml | 2 +- .../templates/post-build/post-build.yml | 10 +- eng/common/templates/steps/execute-sdl.yml | 60 +- eng/common/templates/steps/send-to-helix.yml | 10 +- eng/common/tools.ps1 | 17 +- eng/common/tools.sh | 2 +- eng/native/build-commons.sh | 103 +- eng/native/configurecompiler.cmake | 88 +- eng/native/configureoptimization.cmake | 7 +- eng/native/configurepaths.cmake | 1 + eng/native/configureplatform.cmake | 59 +- eng/native/configuretools.cmake | 50 +- eng/native/functions.cmake | 36 +- eng/native/gen-buildsys.cmd | 2 - eng/native/gen-buildsys.sh | 25 +- eng/native/ijw/IJW.cmake | 82 ++ .../ijw/getRefPackFolderFromArtifacts.ps1 | 21 + eng/native/ijw/getRefPackFolderFromSdk.ps1 | 27 + eng/native/init-distro-rid.sh | 6 +- eng/native/init-os-and-arch.sh | 19 +- eng/native/init-vs-env.cmd | 9 +- eng/native/naming.props | 15 - eng/native/tryrun.cmake | 6 +- eng/prepare-release.yml | 10 +- .../DiagnosticsReleaseTool.csproj | 2 +- global.json | 18 +- src/Directory.Build.props | 5 +- .../CommandService.cs | 113 +- .../DataReader.cs | 208 ++++ .../DiagnosticLoggingService.cs | 166 +++ .../FileLoggingConsoleService.cs | 171 +++ .../ImageMappingMemoryService.cs | 8 +- .../MetadataMappingMemoryService.cs | 1 - .../Module.cs | 38 +- .../ModuleService.cs | 6 +- .../ModuleServiceFromDataReader.cs | 80 +- .../Runtime.cs | 117 +- .../RuntimeService.cs | 174 +-- .../SymbolService.cs | 14 +- .../Target.cs | 1 + .../TargetFromDataReader.cs | 19 +- .../Tracer.cs | 58 +- .../Utilities.cs | 98 +- .../CommandAttributes.cs | 13 +- .../IConsoleFileLoggingService.cs | 43 + .../IDiagnosticLoggingService.cs | 34 + .../IModule.cs | 2 +- .../VersionData.cs | 102 -- .../ClrModulesCommand.cs | 6 +- .../DumpAsyncCommand.cs | 2 +- .../Host/ConsoleLoggingCommand.cs | 46 + .../Host/LoggingCommand.cs | 62 +- .../Host/ModulesCommand.cs | 92 +- .../Host/RuntimesCommand.cs | 43 +- .../Host/SetSymbolServerCommand.cs | 7 +- .../Host/StatusCommand.cs | 3 + ...ft.Diagnostics.Monitoring.EventPipe.csproj | 2 +- .../DiagnosticsClient/DiagnosticsClient.cs | 3 +- .../DiagnosticsClient/EventPipeSession.cs | 9 +- .../DiagnosticsIpc/IpcAdvertise.cs | 12 +- .../DiagnosticsIpc/ProcessEnvironment.cs | 9 +- .../DiagnosticsIpc/ProcessInfo.cs | 5 +- .../IpcHelpers.cs | 3 +- ...icrosoft.Diagnostics.NETCore.Client.csproj | 8 +- .../ReversedDiagnosticsServer.cs | 41 +- .../ConsoleService.cs | 29 +- src/Microsoft.Diagnostics.Repl/ExitCommand.cs | 2 +- src/Microsoft.Diagnostics.Repl/HelpCommand.cs | 2 +- .../DotNetBuildDebuggeeTestStep.cs | 2 + .../IProcessLogger.cs | 1 + .../ProcessRunner.cs | 18 +- .../TestConfiguration.cs | 41 +- .../TestHost/TestDataReader.cs | 119 +- .../TestHost/TestDataWriter.cs | 6 +- .../TestOutputProcessLogger.cs | 24 +- .../TestRunner.cs | 2 +- src/SOS/CMakeLists.txt | 4 +- .../ConsoleServiceFromDebuggerServices.cs | 2 +- src/SOS/SOS.Extensions/DebuggerServices.cs | 49 +- src/SOS/SOS.Extensions/HostServices.cs | 69 +- .../ModuleServiceFromDebuggerServices.cs | 17 +- src/SOS/SOS.Extensions/RemoteMemoryService.cs | 4 +- src/SOS/SOS.Extensions/SOS.Extensions.csproj | 1 - .../TargetFromFromDebuggerServices.cs | 2 +- src/SOS/SOS.Hosting/Commands/SOSCommand.cs | 53 +- .../SOS.Hosting/CorDebugDataTargetWrapper.cs | 14 +- src/SOS/SOS.Hosting/DataTargetWrapper.cs | 80 +- .../{dbgeng => DbgEng}/DebugAdvanced.cs | 4 +- .../{dbgeng => DbgEng}/DebugClient.cs | 4 +- .../{dbgeng => DbgEng}/DebugControl.cs | 4 +- .../{dbgeng => DbgEng}/DebugDataSpaces.cs | 4 +- .../{dbgeng => DbgEng}/DebugRegisters.cs | 4 +- .../{dbgeng => DbgEng}/DebugSymbols.cs | 10 +- .../{dbgeng => DbgEng}/DebugSystemObjects.cs | 4 +- .../DbgEng/Interop/Enums/BusDataType.cs | 24 + .../DbgEng/Interop/Enums/CodePage.cs | 18 + .../Interop/Enums/DebugAddSynthMethod.cs | 14 + .../DbgEng/Interop/Enums/DebugAddSynthSym.cs | 14 + .../DbgEng/Interop/Enums/DebugAsmOpt.cs | 18 + .../DbgEng/Interop/Enums/DebugAttach.cs | 24 + .../Enums/DebugBreakpointAccessType.cs | 17 + .../Interop/Enums/DebugBreakpointFlag.cs | 18 + .../Interop/Enums/DebugBreakpointType.cs | 13 + .../DbgEng/Interop/Enums/DebugCds.cs | 17 + .../DbgEng/Interop/Enums/DebugCdsRefresh.cs | 31 + .../DbgEng/Interop/Enums/DebugCes.cs | 29 + .../Interop/Enums/DebugCesExecutionStatus.cs | 15 + .../DbgEng/Interop/Enums/DebugClass.cs | 14 + .../Interop/Enums/DebugClassQualifier.cs | 22 + .../Interop/Enums/DebugConnectSession.cs | 16 + .../Interop/Enums/DebugCreateProcess.cs | 16 + .../DbgEng/Interop/Enums/DebugCss.cs | 20 + .../DbgEng/Interop/Enums/DebugCurrent.cs | 18 + .../DbgEng/Interop/Enums/DebugData.cs | 16 + .../DbgEng/Interop/Enums/DebugDataSpace.cs | 17 + .../DbgEng/Interop/Enums/DebugDisasm.cs | 17 + .../DbgEng/Interop/Enums/DebugDump.cs | 19 + .../DbgEng/Interop/Enums/DebugDumpFile.cs | 12 + .../Interop/Enums/DebugECreateProcess.cs | 17 + .../DbgEng/Interop/Enums/DebugEIndex.cs | 14 + .../DbgEng/Interop/Enums/DebugEnd.cs | 15 + .../DbgEng/Interop/Enums/DebugEngOpt.cs | 35 + .../DbgEng/Interop/Enums/DebugEvent.cs | 27 + .../DbgEng/Interop/Enums/DebugExecute.cs | 17 + .../DbgEng/Interop/Enums/DebugExpr.cs | 12 + .../Enums/DebugFilterContinueOption.cs | 12 + .../DbgEng/Interop/Enums/DebugFilterEvent.cs | 20 + .../Interop/Enums/DebugFilterExecOption.cs | 15 + .../DbgEng/Interop/Enums/DebugFindSource.cs | 18 + .../DbgEng/Interop/Enums/DebugFormat.cs | 35 + .../DbgEng/Interop/Enums/DebugFrame.cs | 15 + .../DbgEng/Interop/Enums/DebugGetFnent.cs | 15 + .../DbgEng/Interop/Enums/DebugGetMod.cs | 16 + .../DbgEng/Interop/Enums/DebugGetProc.cs | 17 + .../Interop/Enums/DebugGetTextCompletions.cs | 20 + .../DbgEng/Interop/Enums/DebugGsel.cs | 19 + .../Interop/Enums/DebugHandleDataType.cs | 23 + .../DbgEng/Interop/Enums/DebugInterrupt.cs | 13 + .../DbgEng/Interop/Enums/DebugLevel.cs | 12 + .../DbgEng/Interop/Enums/DebugLog.cs | 17 + .../DbgEng/Interop/Enums/DebugManReset.cs | 15 + .../DbgEng/Interop/Enums/DebugManStr.cs | 16 + .../DbgEng/Interop/Enums/DebugManaged.cs | 16 + .../DbgEng/Interop/Enums/DebugModName.cs | 15 + .../DbgEng/Interop/Enums/DebugModule.cs | 21 + .../DbgEng/Interop/Enums/DebugOffsInfo.cs | 11 + .../DbgEng/Interop/Enums/DebugOutCb.cs | 13 + .../DbgEng/Interop/Enums/DebugOutCbf.cs | 16 + .../DbgEng/Interop/Enums/DebugOutCbi.cs | 17 + .../DbgEng/Interop/Enums/DebugOutCtl.cs | 24 + .../DbgEng/Interop/Enums/DebugOutSym.cs | 17 + .../DbgEng/Interop/Enums/DebugOutTextRepl.cs | 14 + .../DbgEng/Interop/Enums/DebugOutType.cs | 21 + .../DbgEng/Interop/Enums/DebugOutput.cs | 23 + .../Interop/Enums/DebugOutputSymbols.cs | 18 + .../DbgEng/Interop/Enums/DebugPhysical.cs | 14 + .../DbgEng/Interop/Enums/DebugProcDesc.cs | 20 + .../DbgEng/Interop/Enums/DebugProcess.cs | 16 + .../DbgEng/Interop/Enums/DebugRegSrc.cs | 13 + .../DbgEng/Interop/Enums/DebugRegister.cs | 14 + .../DbgEng/Interop/Enums/DebugRegisters.cs | 18 + .../DbgEng/Interop/Enums/DebugRequest.cs | 221 ++++ .../DbgEng/Interop/Enums/DebugScopeGroup.cs | 16 + .../DbgEng/Interop/Enums/DebugServers.cs | 13 + .../DbgEng/Interop/Enums/DebugSession.cs | 18 + .../DbgEng/Interop/Enums/DebugSource.cs | 14 + .../DbgEng/Interop/Enums/DebugSrcFile.cs | 12 + .../DbgEng/Interop/Enums/DebugStackcs.cs | 26 + .../DbgEng/Interop/Enums/DebugStatus.cs | 29 + .../DbgEng/Interop/Enums/DebugStatusFlags.cs | 24 + .../DbgEng/Interop/Enums/DebugSymInfo.cs | 14 + .../DbgEng/Interop/Enums/DebugSymType.cs | 18 + .../DbgEng/Interop/Enums/DebugSymbol.cs | 20 + .../DbgEng/Interop/Enums/DebugSysObjInfo.cs | 13 + .../DbgEng/Interop/Enums/DebugSysVerStr.cs | 12 + .../DbgEng/Interop/Enums/DebugTbInfo.cs | 21 + .../DbgEng/Interop/Enums/DebugTypeOpts.cs | 17 + .../DbgEng/Interop/Enums/DebugVSearch.cs | 12 + .../DbgEng/Interop/Enums/DebugVSource.cs | 14 + .../DbgEng/Interop/Enums/DebugValueType.cs | 23 + .../DbgEng/Interop/Enums/DebugWait.cs | 14 + .../Interop/Enums/ECreationDisposition.cs | 38 + .../DbgEng/Interop/Enums/EFileAccess.cs | 18 + .../DbgEng/Interop/Enums/EFileAttributes.cs | 38 + .../DbgEng/Interop/Enums/EFileShare.cs | 17 + .../DbgEng/Interop/Enums/ErrorLevel.cs | 13 + .../DbgEng/Interop/Enums/ExtTdop.cs | 30 + .../DbgEng/Interop/Enums/FormatMessage.cs | 19 + .../SOS.Hosting/DbgEng/Interop/Enums/IG.cs | 60 + .../DbgEng/Interop/Enums/ImageFileMachine.cs | 41 + .../DbgEng/Interop/Enums/InterfaceType.cs | 29 + .../SOS.Hosting/DbgEng/Interop/Enums/MEM.cs | 29 + .../Interop/Enums/ModuleArchitecture.cs | 15 + .../DbgEng/Interop/Enums/ModuleOrders.cs | 16 + .../SOS.Hosting/DbgEng/Interop/Enums/Paage.cs | 24 + .../SOS.Hosting/DbgEng/Interop/Enums/Sec.cs | 22 + .../DbgEng/Interop/Enums/SpfMoveMethod.cs | 13 + .../DbgEng/Interop/Enums/SymOpt.cs | 40 + .../DbgEng/Interop/Enums/SymTag.cs | 48 + .../SOS.Hosting/DbgEng/Interop/Enums/VsFF.cs | 19 + .../DbgEng/Interop/IDebugAdvanced.cs | 25 + .../DbgEng/Interop/IDebugAdvanced2.cs | 88 ++ .../DbgEng/Interop/IDebugAdvanced3.cs | 128 ++ .../DbgEng/Interop/IDebugBreakpoint.cs | 110 ++ .../DbgEng/Interop/IDebugBreakpoint2.cs | 132 ++ .../DbgEng/Interop/IDebugBreakpoint3.cs | 138 +++ .../DbgEng/Interop/IDebugClient.cs | 250 ++++ .../DbgEng/Interop/IDebugClient2.cs | 284 +++++ .../DbgEng/Interop/IDebugClient3.cs | 319 +++++ .../DbgEng/Interop/IDebugClient4.cs | 362 ++++++ .../DbgEng/Interop/IDebugClient5.cs | 533 +++++++++ .../DbgEng/Interop/IDebugClient6.cs | 539 +++++++++ .../DbgEng/Interop/IDebugControl.cs | 537 +++++++++ .../DbgEng/Interop/IDebugControl2.cs | 579 +++++++++ .../DbgEng/Interop/IDebugControl3.cs | 603 ++++++++++ .../DbgEng/Interop/IDebugControl4.cs | 1006 ++++++++++++++++ .../DbgEng/Interop/IDebugControl5.cs | 1053 ++++++++++++++++ .../DbgEng/Interop/IDebugControl6.cs | 1063 +++++++++++++++++ .../DbgEng/Interop/IDebugDataSpaces.cs | 336 ++++++ .../DbgEng/Interop/IDebugDataSpaces2.cs | 227 ++++ .../DbgEng/Interop/IDebugDataSpaces3.cs | 258 ++++ .../DbgEng/Interop/IDebugDataSpaces4.cs | 346 ++++++ .../DbgEng/Interop/IDebugEventCallbacks.cs | 95 ++ .../Interop/IDebugEventCallbacksWide.cs | 95 ++ .../Interop/IDebugEventContextCallbacks.cs | 117 ++ .../DbgEng/Interop/IDebugInputCallbacks.cs | 21 + .../DbgEng/Interop/IDebugOutputCallbacks.cs | 19 + .../DbgEng/Interop/IDebugOutputCallbacks2.cs | 37 + .../Interop/IDebugOutputCallbacksWide.cs | 19 + .../DbgEng/Interop/IDebugRegisters.cs | 74 ++ .../DbgEng/Interop/IDebugRegisters2.cs | 189 +++ .../DbgEng/Interop/IDebugSymbolGroup.cs | 70 ++ .../DbgEng/Interop/IDebugSymbolGroup2.cs | 146 +++ .../DbgEng/Interop/IDebugSymbols.cs | 332 +++++ .../DbgEng/Interop/IDebugSymbols2.cs | 387 ++++++ .../DbgEng/Interop/IDebugSymbols3.cs | 889 ++++++++++++++ .../DbgEng/Interop/IDebugSymbols4.cs | 958 +++++++++++++++ .../DbgEng/Interop/IDebugSymbols5.cs | 972 +++++++++++++++ .../DbgEng/Interop/IDebugSystemObjects.cs | 153 +++ .../DbgEng/Interop/IDebugSystemObjects2.cs | 177 +++ .../DbgEng/Interop/IDebugSystemObjects3.cs | 214 ++++ .../Structs/DebugBreakpointParameters.cs | 25 + .../Interop/Structs/DebugCachedSymbolInfo.cs | 18 + .../Structs/DebugCreateProcessOptions.cs | 17 + .../Interop/Structs/DebugEventContext.cs | 17 + .../Structs/DebugExceptionFilterParameters.cs | 19 + .../Structs/DebugGetTextCompletionsIn.cs | 18 + .../Structs/DebugGetTextCompletionsOut.cs | 19 + .../Interop/Structs/DebugHandleDataBasic.cs | 19 + .../Interop/Structs/DebugLastEventInfo.cs | 27 + .../Structs/DebugLastEventInfoBreakpoint.cs | 14 + .../Structs/DebugLastEventInfoException.cs | 15 + .../Structs/DebugLastEventInfoExitProcess.cs | 14 + .../Structs/DebugLastEventInfoExitThread.cs | 14 + .../Structs/DebugLastEventInfoLoadModule.cs | 14 + .../Structs/DebugLastEventInfoSystemError.cs | 15 + .../Structs/DebugLastEventInfoUnloadModule.cs | 14 + .../Interop/Structs/DebugModuleAndId.cs | 25 + .../Interop/Structs/DebugModuleParameters.cs | 25 + .../Interop/Structs/DebugOffsetRegion.cs | 15 + .../Structs/DebugReadUserMinidumpStream.cs | 20 + .../Structs/DebugRegisterDescription.cs | 20 + .../Structs/DebugSpecificFilterParameters.cs | 18 + .../DbgEng/Interop/Structs/DebugStackFrame.cs | 22 + .../Interop/Structs/DebugStackFrameEx.cs | 49 + .../Interop/Structs/DebugSymbolEntry.cs | 25 + .../Interop/Structs/DebugSymbolParameters.cs | 19 + .../Interop/Structs/DebugSymbolSourceEntry.cs | 29 + .../Structs/DebugThreadBasicInformation.cs | 23 + .../DbgEng/Interop/Structs/DebugTypedData.cs | 24 + .../DbgEng/Interop/Structs/DebugValue.cs | 55 + .../Interop/Structs/ExceptionRecord64.cs | 20 + .../DbgEng/Interop/Structs/ExtTypedData.cs | 51 + .../DbgEng/Interop/Structs/F128Parts64.cs | 17 + .../DbgEng/Interop/Structs/I64Parts32.cs | 17 + .../Interop/Structs/ImageCor20Header.cs | 44 + .../Structs/ImageCor20HeaderEntryPoint.cs | 17 + .../Interop/Structs/ImageDataDirectory.cs | 15 + .../DbgEng/Interop/Structs/ImageDosHeader.cs | 51 + .../DbgEng/Interop/Structs/ImageFileHeader.cs | 27 + .../Interop/Structs/ImageHlpModule64.cs | 125 ++ .../Interop/Structs/ImageImportDescriptor.cs | 29 + .../Interop/Structs/ImageNtHeaders32.cs | 19 + .../Interop/Structs/ImageNtHeaders64.cs | 19 + .../Interop/Structs/ImageOptionalHeader32.cs | 110 ++ .../Interop/Structs/ImageOptionalHeader64.cs | 108 ++ .../Interop/Structs/ImageThunkData32.cs | 21 + .../Interop/Structs/ImageThunkData64.cs | 21 + .../DbgEng/Interop/Structs/LandAndCodePage.cs | 17 + .../Structs/MemoryBasicInformation64.cs | 22 + .../DbgEng/Interop/Structs/Rect.cs | 17 + .../DbgEng/Interop/Structs/VsFixedFileInfo.cs | 26 + .../Structs/WdbgExtsClrDataInterface.cs | 24 + .../Interop/Structs/WdbgExtsThreadOsInfo.cs | 23 + .../Interop/Structs/WinDbgExtensionApis.cs | 26 + src/SOS/SOS.Hosting/HostWrapper.cs | 6 +- src/SOS/SOS.Hosting/LLDBServices.cs | 4 +- src/SOS/SOS.Hosting/RuntimeWrapper.cs | 10 +- src/SOS/SOS.Hosting/SOS.Hosting.csproj | 1 - src/SOS/SOS.Hosting/SOSHost.cs | 12 +- src/SOS/SOS.Hosting/SOSLibrary.cs | 2 +- src/SOS/SOS.Hosting/ServiceWrapper.cs | 2 +- .../SOS.Hosting/SymbolServiceExtensions.cs | 26 +- src/SOS/SOS.Hosting/TargetWrapper.cs | 4 +- .../Unix/Debugger.Tests.Config.txt | 49 +- .../Windows/Debugger.Tests.Config.txt | 51 +- .../Debuggees/DesktopClrHost/CMakeLists.txt | 2 +- .../Debuggees/Directory.Build.props | 2 +- .../Debuggees/WebApp3/WebApp3.csproj | 3 +- src/SOS/SOS.UnitTests/SOS.cs | 6 +- src/SOS/SOS.UnitTests/SOSRunner.cs | 67 +- .../Scripts/ConcurrentDictionaries.script | 3 + src/SOS/SOS.UnitTests/Scripts/DumpGen.script | 3 + src/SOS/SOS.UnitTests/Scripts/GCPOH.script | 7 + .../Scripts/NestedExceptionTest.script | 8 +- .../Scripts/OtherCommands.script | 24 +- .../SOS.UnitTests/Scripts/Reflection.script | 6 +- .../Scripts/StackAndOtherTests.script | 12 +- .../SOS.UnitTests/Scripts/StackTests.script | 12 +- .../Scripts/TaskNestedException.script | 8 +- src/SOS/SOS.UnitTests/Scripts/WebApp.script | 10 +- src/SOS/Strike/CMakeLists.txt | 4 +- src/SOS/Strike/Strike.vcxproj | 10 +- src/SOS/Strike/eeheap.cpp | 32 +- src/SOS/Strike/exts.cpp | 2 + src/SOS/Strike/gcroot.cpp | 38 +- src/SOS/Strike/sos.cpp | 50 +- src/SOS/Strike/sos.def | 2 + src/SOS/Strike/sos.h | 25 +- src/SOS/Strike/sos_unixexports.src | 17 +- src/SOS/Strike/sosdocsunix.txt | 426 ++++++- src/SOS/Strike/strike.cpp | 551 +++++---- src/SOS/Strike/util.cpp | 39 +- src/SOS/Strike/util.h | 11 +- src/SOS/extensions/CMakeLists.txt | 4 +- src/SOS/extensions/extensions.vcxproj | 8 +- src/SOS/extensions/hostcoreclr.cpp | 4 +- src/SOS/inc/hostservices.h | 10 +- src/SOS/lldbplugin/services.cpp | 146 ++- src/SOS/lldbplugin/services.h | 4 + src/SOS/lldbplugin/soscommand.cpp | 71 +- src/Tools/dotnet-counters/CounterMonitor.cs | 7 + .../dotnet-counters/Exporters/CSVExporter.cs | 2 + .../Exporters/ConsoleWriter.cs | 133 ++- .../Exporters/ICounterRenderer.cs | 1 + .../dotnet-counters/Exporters/JSONExporter.cs | 2 + .../USBMuxTcpClientRouterFactory.cs | 28 +- .../dotnet-dsrouter/dotnet-dsrouter.csproj | 4 +- src/Tools/dotnet-dump/Analyzer.cs | 42 +- .../dotnet-dump/Commands/ReadMemoryCommand.cs | 2 +- src/Tools/dotnet-dump/Commands/SOSCommand.cs | 60 + src/Tools/dotnet-dump/Program.cs | 2 +- .../dotnet-gcdump/DotNetHeapDump/Graph.cs | 45 +- src/Tools/dotnet-sos/Program.cs | 2 +- .../CommandLine/Commands/CollectCommand.cs | 2 +- src/dbgshim/dbgshim.cpp | 7 +- src/dbgshim/dbgshim.vcxproj | 8 +- src/dbgshim/debugshim.cpp | 37 +- src/dbgshim/debugshim.h | 25 + src/dbgshim/pkg/Directory.Build.props | 39 +- ...crosoft.Diagnostics.DbgShim.linux-arm.proj | 2 +- ...osoft.Diagnostics.DbgShim.linux-arm64.proj | 2 +- ....Diagnostics.DbgShim.linux-musl-arm64.proj | 4 +- ...ft.Diagnostics.DbgShim.linux-musl-x64.proj | 2 +- ...crosoft.Diagnostics.DbgShim.linux-x64.proj | 2 +- ...crosoft.Diagnostics.DbgShim.osx-arm64.proj | 2 +- ...Microsoft.Diagnostics.DbgShim.osx-x64.proj | 2 +- .../pkg/Microsoft.Diagnostics.DbgShim.props | 22 +- ...Microsoft.Diagnostics.DbgShim.win-arm.proj | 2 +- ...crosoft.Diagnostics.DbgShim.win-arm64.proj | 2 +- ...Microsoft.Diagnostics.DbgShim.win-x64.proj | 2 +- ...Microsoft.Diagnostics.DbgShim.win-x86.proj | 2 +- ...ft.diagnostics.dbgshim.linux-musl-arm.proj | 7 + src/shared/dbgutil/dbgutil.vcxproj | 8 +- src/shared/dbgutil/elfreader.cpp | 2 +- src/shared/gcdump/gcdump.vcxproj | 8 +- src/shared/inc/clrdata.idl | 15 + src/shared/inc/dumpcommon.h | 136 +++ src/shared/inc/gcdesc.h | 2 - src/shared/pal/prebuilt/idl/clrdata_i.cpp | 11 +- src/shared/pal/prebuilt/inc/clrdata.h | 187 ++- src/shared/palrt/bstr.cpp | 2 +- src/shared/utilcode/utilcode.vcxproj | 8 +- src/sos-packaging.props | 4 + .../CommonTestRunner/CommonTestRunner.csproj | 51 + .../Unix/Debugger.Tests.Config.txt | 54 + .../Windows/Debugger.Tests.Config.txt | 53 + .../DiagnosticPortsHelper.cs | 5 +- src/tests/CommonTestRunner/TestRunner.cs | 342 ++++++ .../Unix/Debugger.Tests.Config.txt | 16 +- .../Windows/Debugger.Tests.Config.txt | 13 +- src/tests/DbgShim.UnitTests/DbgShimAPI.cs | 34 +- src/tests/DbgShim.UnitTests/DebuggeeInfo.cs | 2 +- .../SimpleDebuggee/SimpleDebuggee.cs | 3 +- src/tests/DbgShim.UnitTests/ICLRDebugging.cs | 2 +- src/tests/DbgShim.UnitTests/ICorDebug.cs | 12 +- .../DbgShim.UnitTests/ICorDebugController.cs | 16 +- .../LibraryProviderWrapper.cs | 16 +- .../ManagedCallbackWrapper.cs | 68 +- src/tests/Directory.Build.props | 16 + .../EventPipeTracee/EventPipeTracee.csproj | 2 +- src/tests/EventPipeTracee/Program.cs | 70 +- .../ExitCodeTracee/ExitCodeTracee.csproj | 2 +- .../Windows/Debugger.Tests.Config.txt | 4 + .../DebugServicesTests.cs | 53 +- ...Diagnostics.DebugServices.UnitTests.csproj | 4 +- .../TestDbgEng.cs | 4 +- .../EventCounterPipelineUnitTests.cs | 27 +- .../EventCounterTriggerTests.cs | 30 +- .../EventLogsPipelineUnitTests.cs | 71 +- .../EventTracePipelineUnitTests.cs | 51 +- ...tics.Monitoring.EventPipe.UnitTests.csproj | 7 +- .../PipelineTestUtilities.cs | 61 +- ...ft.Diagnostics.Monitoring.UnitTests.csproj | 6 +- .../PipelineTests.cs | 4 - .../CommonHelper.cs | 42 - .../EventPipeSessionTests.cs | 111 +- .../GetProcessEnvironmentTests.cs | 34 +- .../GetProcessInfoTests.cs | 59 +- .../GetPublishedProcessesTests.cs | 94 +- ...iagnostics.NETCore.Client.UnitTests.csproj | 61 +- .../RemoteTestExecution.cs | 110 -- .../ReversedServerTests.cs | 164 ++- .../TestRunner.cs | 178 --- src/tests/StackTracee/Program.cs | 2 +- src/tests/StackTracee/StackTracee.csproj | 2 +- src/tests/Tracee/Program.cs | 47 +- src/tests/Tracee/Tracee.csproj | 2 +- .../DotnetCounters.UnitTests.csproj | 2 +- .../dotnet-stack/DotnetStack.UnitTests.csproj | 6 +- src/tests/dotnet-stack/StackTests.cs | 66 +- src/tests/dotnet-trace/ChildProcessTests.cs | 85 +- .../dotnet-trace/DotnetTrace.UnitTests.csproj | 9 +- .../eventpipe/EventPipe.UnitTests.csproj | 4 +- src/tests/eventpipe/GCEvents.cs | 16 +- src/tests/eventpipe/LoaderEvents.cs | 3 +- 472 files changed, 23638 insertions(+), 3154 deletions(-) create mode 100644 .github/fabricbot.json create mode 100644 eng/common/cross/arm/sources.list.focal create mode 100644 eng/common/cross/arm/sources.list.jammy create mode 100644 eng/common/cross/arm64/sources.list.focal create mode 100644 eng/common/cross/arm64/sources.list.jammy create mode 100644 eng/common/cross/riscv64/sources.list.sid create mode 100644 eng/common/cross/x86/sources.list.focal create mode 100644 eng/common/cross/x86/sources.list.jammy create mode 100644 eng/common/sdl/sdl.ps1 create mode 100644 eng/native/ijw/IJW.cmake create mode 100644 eng/native/ijw/getRefPackFolderFromArtifacts.ps1 create mode 100644 eng/native/ijw/getRefPackFolderFromSdk.ps1 create mode 100644 src/Microsoft.Diagnostics.DebugServices.Implementation/DataReader.cs create mode 100644 src/Microsoft.Diagnostics.DebugServices.Implementation/DiagnosticLoggingService.cs create mode 100644 src/Microsoft.Diagnostics.DebugServices.Implementation/FileLoggingConsoleService.cs rename src/{Microsoft.Diagnostics.DebugServices => Microsoft.Diagnostics.DebugServices.Implementation}/Tracer.cs (57%) create mode 100644 src/Microsoft.Diagnostics.DebugServices/IConsoleFileLoggingService.cs create mode 100644 src/Microsoft.Diagnostics.DebugServices/IDiagnosticLoggingService.cs delete mode 100644 src/Microsoft.Diagnostics.DebugServices/VersionData.cs create mode 100644 src/Microsoft.Diagnostics.ExtensionCommands/Host/ConsoleLoggingCommand.cs rename src/SOS/SOS.Hosting/{dbgeng => DbgEng}/DebugAdvanced.cs (94%) rename src/SOS/SOS.Hosting/{dbgeng => DbgEng}/DebugClient.cs (99%) rename src/SOS/SOS.Hosting/{dbgeng => DbgEng}/DebugControl.cs (99%) rename src/SOS/SOS.Hosting/{dbgeng => DbgEng}/DebugDataSpaces.cs (99%) rename src/SOS/SOS.Hosting/{dbgeng => DbgEng}/DebugRegisters.cs (98%) rename src/SOS/SOS.Hosting/{dbgeng => DbgEng}/DebugSymbols.cs (99%) rename src/SOS/SOS.Hosting/{dbgeng => DbgEng}/DebugSystemObjects.cs (99%) create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/BusDataType.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/CodePage.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugAddSynthMethod.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugAddSynthSym.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugAsmOpt.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugAttach.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugBreakpointAccessType.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugBreakpointFlag.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugBreakpointType.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCds.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCdsRefresh.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCes.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCesExecutionStatus.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugClass.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugClassQualifier.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugConnectSession.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCreateProcess.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCss.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCurrent.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugData.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugDataSpace.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugDisasm.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugDump.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugDumpFile.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugECreateProcess.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugEIndex.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugEnd.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugEngOpt.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugEvent.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugExecute.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugExpr.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFilterContinueOption.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFilterEvent.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFilterExecOption.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFindSource.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFormat.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFrame.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGetFnent.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGetMod.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGetProc.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGetTextCompletions.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGsel.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugHandleDataType.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugInterrupt.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugLevel.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugLog.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugManReset.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugManStr.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugManaged.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugModName.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugModule.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOffsInfo.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutCb.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutCbf.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutCbi.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutCtl.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutSym.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutTextRepl.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutType.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutput.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutputSymbols.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugPhysical.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugProcDesc.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugProcess.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugRegSrc.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugRegister.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugRegisters.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugRequest.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugScopeGroup.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugServers.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSession.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSource.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSrcFile.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugStackcs.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugStatus.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugStatusFlags.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSymInfo.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSymType.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSymbol.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSysObjInfo.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSysVerStr.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugTbInfo.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugTypeOpts.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugVSearch.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugVSource.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugValueType.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugWait.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ECreationDisposition.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/EFileAccess.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/EFileAttributes.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/EFileShare.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ErrorLevel.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ExtTdop.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/FormatMessage.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/IG.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ImageFileMachine.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/InterfaceType.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/MEM.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ModuleArchitecture.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ModuleOrders.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/Paage.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/Sec.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/SpfMoveMethod.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/SymOpt.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/SymTag.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Enums/VsFF.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugAdvanced.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugAdvanced2.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugAdvanced3.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugBreakpoint.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugBreakpoint2.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugBreakpoint3.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient2.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient3.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient4.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient5.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient6.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl2.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl3.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl4.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl5.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl6.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugDataSpaces.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugDataSpaces2.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugDataSpaces3.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugDataSpaces4.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugEventCallbacks.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugEventCallbacksWide.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugEventContextCallbacks.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugInputCallbacks.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugOutputCallbacks.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugOutputCallbacks2.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugOutputCallbacksWide.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugRegisters.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugRegisters2.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbolGroup.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbolGroup2.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols2.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols3.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols4.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols5.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSystemObjects.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSystemObjects2.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSystemObjects3.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugBreakpointParameters.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugCachedSymbolInfo.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugCreateProcessOptions.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugEventContext.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugExceptionFilterParameters.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugGetTextCompletionsIn.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugGetTextCompletionsOut.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugHandleDataBasic.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfo.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoBreakpoint.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoException.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoExitProcess.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoExitThread.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoLoadModule.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoSystemError.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoUnloadModule.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugModuleAndId.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugModuleParameters.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugOffsetRegion.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugReadUserMinidumpStream.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugRegisterDescription.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugSpecificFilterParameters.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugStackFrame.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugStackFrameEx.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugSymbolEntry.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugSymbolParameters.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugSymbolSourceEntry.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugThreadBasicInformation.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugTypedData.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugValue.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ExceptionRecord64.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ExtTypedData.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/F128Parts64.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/I64Parts32.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageCor20Header.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageCor20HeaderEntryPoint.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageDataDirectory.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageDosHeader.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageFileHeader.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageHlpModule64.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageImportDescriptor.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageNtHeaders32.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageNtHeaders64.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageOptionalHeader32.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageOptionalHeader64.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageThunkData32.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageThunkData64.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/LandAndCodePage.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/MemoryBasicInformation64.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/Rect.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/VsFixedFileInfo.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/WdbgExtsClrDataInterface.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/WdbgExtsThreadOsInfo.cs create mode 100644 src/SOS/SOS.Hosting/DbgEng/Interop/Structs/WinDbgExtensionApis.cs create mode 100644 src/Tools/dotnet-dump/Commands/SOSCommand.cs create mode 100644 src/dbgshim/pkg/microsoft.diagnostics.dbgshim.linux-musl-arm.proj create mode 100644 src/shared/inc/dumpcommon.h create mode 100644 src/tests/CommonTestRunner/CommonTestRunner.csproj create mode 100644 src/tests/CommonTestRunner/ConfigFiles/Unix/Debugger.Tests.Config.txt create mode 100644 src/tests/CommonTestRunner/ConfigFiles/Windows/Debugger.Tests.Config.txt rename src/tests/{Microsoft.Diagnostics.NETCore.Client => CommonTestRunner}/DiagnosticPortsHelper.cs (92%) create mode 100644 src/tests/CommonTestRunner/TestRunner.cs create mode 100644 src/tests/Directory.Build.props delete mode 100644 src/tests/Microsoft.Diagnostics.NETCore.Client/CommonHelper.cs delete mode 100644 src/tests/Microsoft.Diagnostics.NETCore.Client/RemoteTestExecution.cs delete mode 100644 src/tests/Microsoft.Diagnostics.NETCore.Client/TestRunner.cs diff --git a/.github/fabricbot.json b/.github/fabricbot.json new file mode 100644 index 0000000000..55572d732a --- /dev/null +++ b/.github/fabricbot.json @@ -0,0 +1,86 @@ +{ + "version": "1.0", + "tasks": [ + { + "taskType": "trigger", + "capabilityId": "AutoMerge", + "subCapability": "AutoMerge", + "version": "1.0", + "config": { + "taskName": "Automatically merge pull requests", + "label": "auto-merge", + "silentMode": false, + "minMinutesOpen": "1", + "mergeType": "squash", + "deleteBranches": true, + "allowAutoMergeInstructionsWithoutLabel": true, + "enforceDMPAsStatus": true, + "removeLabelOnPush": true, + "usePrDescriptionAsCommitMessage": false, + "conditionalMergeTypes": [], + "requireAllStatuses": true, + "requireSpecificCheckRuns": true, + "requireSpecificCheckRunsList": [ + "diagnostics-public-ci" + ], + "minimumNumberOfStatuses": 1, + "minimumNumberOfCheckRuns": 1, + "requireAllStatuses_exemptList": [ + "codecov", + "Dependabot", + "DotNet Maestro", + "DotNet Maestro - Int" + ] + }, + "id": "9xknvk-BFN" + }, + { + "taskType": "trigger", + "capabilityId": "IssueResponder", + "subCapability": "PullRequestResponder", + "version": "1.0", + "id": "DGPtO9UQd", + "config": { + "conditions": { + "operator": "and", + "operands": [ + { + "name": "isAction", + "parameters": { + "action": "opened" + } + }, + { + "name": "titleContains", + "parameters": { + "titlePattern": "Update dependencies" + } + }, + { + "name": "isActivitySender", + "parameters": { + "user": "dotnet-maestro[bot]" + } + } + ] + }, + "eventType": "pull_request", + "eventNames": [ + "pull_request", + "issues", + "project_card" + ], + "taskName": "Auto approve dependencies", + "actions": [ + { + "name": "approvePullRequest", + "parameters": { + "comment": "Automatically approving dependency update." + } + } + ] + } + } + ], + "userGroups": [] +} diff --git a/Directory.Build.props b/Directory.Build.props index d354b43f1d..801c9ed79e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -16,5 +16,6 @@ <RepositoryType>git</RepositoryType> <PackageLicenseExpression>MIT</PackageLicenseExpression> <EnableSourceControlManagerQueries>true</EnableSourceControlManagerQueries> + <GitHubRepositoryName>diagnostics</GitHubRepositoryName> </PropertyGroup> </Project> diff --git a/NuGet.config b/NuGet.config index 68ed20a984..de789f31f8 100644 --- a/NuGet.config +++ b/NuGet.config @@ -7,7 +7,6 @@ <clear /> <!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.--> <!-- Begin: Package sources from dotnet-aspnetcore --> - <add key="darc-pub-dotnet-aspnetcore-fac970d" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-aspnetcore-fac970de/nuget/v3/index.json" /> <!-- End: Package sources from dotnet-aspnetcore --> <!-- Begin: Package sources from dotnet-runtime --> <!-- End: Package sources from dotnet-runtime --> diff --git a/diagnostics.sln b/diagnostics.sln index 5f940760e0..1a0860f67d 100644 --- a/diagnostics.sln +++ b/diagnostics.sln @@ -1,7 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29019.234 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32519.111 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.TestHelpers", "src\Microsoft.Diagnostics.TestHelpers\Microsoft.Diagnostics.TestHelpers.csproj", "{730C1201-1848-4F1E-8C1F-6316FB886C35}" EndProject @@ -41,9 +41,6 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SOS.Symbol.Package", "src\SOS\SOS.Package\SOS.Symbol.Package.csproj", "{410394E0-7F4F-42D5-B5FA-30956F44ACBC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{03479E19-3F18-49A6-910A-F5041E27E7C0}" - ProjectSection(SolutionItems) = preProject - src\tests\eventpipe\EventPipe.UnitTests.csproj = src\tests\eventpipe\EventPipe.UnitTests.csproj - EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotnetTrace.UnitTests", "src\tests\dotnet-trace\DotnetTrace.UnitTests.csproj", "{AEDCCF5B-5AD0-4D64-BF73-5CF468E07D22}" EndProject @@ -173,8 +170,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "inc", "inc", "{41BDFD6D-D16 src\shared\inc\sstring.h = src\shared\inc\sstring.h src\shared\inc\sstring.inl = src\shared\inc\sstring.inl src\shared\inc\stacktrace.h = src\shared\inc\stacktrace.h - src\shared\inc\static_assert.h = src\shared\inc\static_assert.h src\shared\inc\staticcontract.h = src\shared\inc\staticcontract.h + src\shared\inc\static_assert.h = src\shared\inc\static_assert.h src\shared\inc\stdmacros.h = src\shared\inc\stdmacros.h src\shared\inc\stresslog.h = src\shared\inc\stresslog.h src\shared\inc\switches.h = src\shared\inc\switches.h @@ -265,6 +262,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "minipal", "minipal", "{795B EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DbgShim.UnitTests", "src\tests\DbgShim.UnitTests\DbgShim.UnitTests.csproj", "{DD60B7C4-BECC-4C7D-A53B-FCDD4C92B728}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommonTestRunner", "src\tests\CommonTestRunner\CommonTestRunner.csproj", "{DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotnetStack.UnitTests", "src\tests\dotnet-stack\DotnetStack.UnitTests.csproj", "{E8F133F8-4D20-475D-9D16-2BA236DAB65F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Checked|Any CPU = Checked|Any CPU @@ -1786,6 +1787,84 @@ Global {DD60B7C4-BECC-4C7D-A53B-FCDD4C92B728}.RelWithDebInfo|x64.Build.0 = Release|Any CPU {DD60B7C4-BECC-4C7D-A53B-FCDD4C92B728}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU {DD60B7C4-BECC-4C7D-A53B-FCDD4C92B728}.RelWithDebInfo|x86.Build.0 = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Checked|Any CPU.Build.0 = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Checked|ARM.ActiveCfg = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Checked|ARM.Build.0 = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Checked|ARM64.ActiveCfg = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Checked|ARM64.Build.0 = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Checked|x64.ActiveCfg = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Checked|x64.Build.0 = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Checked|x86.ActiveCfg = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Checked|x86.Build.0 = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Debug|ARM.ActiveCfg = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Debug|ARM.Build.0 = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Debug|ARM64.Build.0 = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Debug|x64.ActiveCfg = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Debug|x64.Build.0 = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Debug|x86.ActiveCfg = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Debug|x86.Build.0 = Debug|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Release|Any CPU.Build.0 = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Release|ARM.ActiveCfg = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Release|ARM.Build.0 = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Release|ARM64.ActiveCfg = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Release|ARM64.Build.0 = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Release|x64.ActiveCfg = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Release|x64.Build.0 = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Release|x86.ActiveCfg = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.Release|x86.Build.0 = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.RelWithDebInfo|ARM.ActiveCfg = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.RelWithDebInfo|ARM.Build.0 = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.RelWithDebInfo|ARM64.ActiveCfg = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.RelWithDebInfo|ARM64.Build.0 = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F}.RelWithDebInfo|x86.Build.0 = Release|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Checked|Any CPU.Build.0 = Debug|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Checked|ARM.ActiveCfg = Debug|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Checked|ARM.Build.0 = Debug|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Checked|ARM64.ActiveCfg = Debug|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Checked|ARM64.Build.0 = Debug|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Checked|x64.ActiveCfg = Debug|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Checked|x64.Build.0 = Debug|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Checked|x86.ActiveCfg = Debug|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Checked|x86.Build.0 = Debug|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Debug|ARM.ActiveCfg = Debug|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Debug|ARM.Build.0 = Debug|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Debug|ARM64.Build.0 = Debug|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Debug|x64.ActiveCfg = Debug|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Debug|x64.Build.0 = Debug|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Debug|x86.ActiveCfg = Debug|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Debug|x86.Build.0 = Debug|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Release|ARM.ActiveCfg = Release|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Release|ARM.Build.0 = Release|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Release|ARM64.ActiveCfg = Release|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Release|ARM64.Build.0 = Release|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Release|x64.ActiveCfg = Release|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Release|x64.Build.0 = Release|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Release|x86.ActiveCfg = Release|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.Release|x86.Build.0 = Release|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.RelWithDebInfo|ARM.ActiveCfg = Release|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.RelWithDebInfo|ARM.Build.0 = Release|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.RelWithDebInfo|ARM64.ActiveCfg = Release|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.RelWithDebInfo|ARM64.Build.0 = Release|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.RelWithDebInfo|x64.Build.0 = Release|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU + {E8F133F8-4D20-475D-9D16-2BA236DAB65F}.RelWithDebInfo|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1842,6 +1921,8 @@ Global {8C35FEF8-1101-38F6-ACD0-462A1EA53A7D} = {7852EDE4-93DF-4DB1-8A86-C521703811AF} {795B7A50-1B1F-406E-94E0-F9B35104EF22} = {7852EDE4-93DF-4DB1-8A86-C521703811AF} {DD60B7C4-BECC-4C7D-A53B-FCDD4C92B728} = {03479E19-3F18-49A6-910A-F5041E27E7C0} + {DFF48CB6-4504-41C6-A8F1-F4A3D316D49F} = {03479E19-3F18-49A6-910A-F5041E27E7C0} + {E8F133F8-4D20-475D-9D16-2BA236DAB65F} = {03479E19-3F18-49A6-910A-F5041E27E7C0} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {46465737-C938-44FC-BE1A-4CE139EBB5E0} diff --git a/diagnostics.yml b/diagnostics.yml index fc5301ec6e..28b5eeb015 100644 --- a/diagnostics.yml +++ b/diagnostics.yml @@ -173,7 +173,7 @@ stages: - template: /eng/build.yml parameters: - name: MacOS_cross + name: MacOS_arm64 osGroup: MacOS_cross crossbuild: true buildAndSkipTest: true @@ -191,7 +191,7 @@ stages: - ${{ if ne(variables['System.TeamProject'], 'public') }}: - template: /eng/build.yml parameters: - name: Linux_cross + name: Linux_arm osGroup: Linux dockerImage: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-20210719121212-8a8d3be crossrootfsDir: '/crossrootfs/arm' @@ -205,7 +205,7 @@ stages: - template: /eng/build.yml parameters: - name: Linux_cross64 + name: Linux_arm64 osGroup: Linux dockerImage: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-arm64-20210719121212-8a8d3be crossrootfsDir: '/crossrootfs/arm64' @@ -219,7 +219,22 @@ stages: - template: /eng/build.yml parameters: - name: Alpine_cross64 + name: Linux_musl_arm + osGroup: Linux + dockerImage: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-arm-alpine-20210923140502-78f7860 + crossrootfsDir: '/crossrootfs/arm' + artifactsTargetPath: bin/Linux-musl.arm.Release + buildAndSkipTest: true + strategy: + matrix: + Build_Release: + _BuildConfig: Release + _BuildArch: arm + _PublishArtifacts: bin/Linux.arm.Release + + - template: /eng/build.yml + parameters: + name: Linux_musl_arm64 osGroup: Linux dockerImage: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-arm64-alpine-20210923140502-78f7860 crossrootfsDir: '/crossrootfs/arm64' @@ -232,7 +247,6 @@ stages: _BuildArch: arm64 _PublishArtifacts: bin/Linux.arm64.Release - ############################ # # # Test only legs # @@ -316,14 +330,15 @@ stages: - CentOS_7 - Alpine3_13 - MacOS - - MacOS_cross - - Linux_cross - - Linux_cross64 - - Alpine_cross64 + - MacOS_arm64 + - Linux_arm + - Linux_arm64 + - Linux_musl_arm + - Linux_musl_arm64 condition: succeeded() pool: name: NetCore1ESPool-Svc-Internal - demands: ImageOverride -equals Build.Windows.10.Amd64.VS2019 + demands: ImageOverride -equals windows.vs2022.amd64 enablePublishUsingPipelines: true enableMicrobuild: true artifacts: @@ -376,7 +391,7 @@ stages: publishUsingPipelines: true pool: name: NetCore1ESPool-Svc-Internal - demands: ImageOverride -equals Build.windows.10.amd64.vs2019 + demands: ImageOverride -equals windows.vs2022.amd64 - ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: - template: /eng/common/templates/post-build/post-build.yml diff --git a/documentation/sos-debugging-extension.md b/documentation/sos-debugging-extension.md index cda591f82c..92ebe04472 100644 --- a/documentation/sos-debugging-extension.md +++ b/documentation/sos-debugging-extension.md @@ -39,18 +39,18 @@ importance. Shortcut names for popular functions are listed in parenthesis. Type DumpHeap (dumpheap) DumpStack (dumpstack) DumpVC EEStack (eestack) GCRoot (gcroot) CLRStack (clrstack) - PrintException (pe) GCInfo - EHInfo + ObjSize GCInfo + PrintException (pe) EHInfo bpmd (bpmd) Examining CLR data structures Diagnostic Utilities ----------------------------- ----------------------------- DumpDomain (dumpdomain) VerifyHeap - EEHeap (eeheap) FindAppDomain - Name2EE (name2ee) DumpLog (dumplog) - DumpMT (dumpmt) - DumpClass (dumpclass) - DumpMD (dumpmd) + EEHeap (eeheap) FindAppDomain + Name2EE (name2ee) GCHandles + DumpMT (dumpmt) DumpLog (dumplog) + DumpClass (dumpclass) SuppressJitOptimization + DumpMD (dumpmd) ThreadPool (threadpool) Token2EE DumpModule (dumpmodule) DumpAssembly @@ -98,6 +98,7 @@ importance. Shortcut names for popular functions are listed in parenthesis. Type |**EHInfo** [\<*MethodDesc address*>] [\<*Code address*>]|Displays the exception handling blocks in a specified method. This command displays the code addresses and offsets for the clause block (the `try` block) and the handler block (the `catch` block).| |**FAQ**|Displays frequently asked questions.| |**FindAppDomain** \<*Object address*>|Determines the application domain of an object at the specified address.| +|**GCHandles** [**-perdomain**]|Displays statistics about garbage collector handles in the process.<br /><br /> The **-perdomain** option arranges the statistics by application domain.<br /><br /> Use the **GCHandles** command to find memory leaks caused by garbage collector handle leaks. For example, a memory leak occurs when code retains a large array because a strong garbage collector handle still points to it, and the handle is discarded without freeing it.| |**GCInfo** \<*MethodDesc address*>\<*Code address*>|Displays data that indicates when registers or stack locations contain managed objects. If a garbage collection occurs, the collector must know the locations of references to objects so it can update them with new object pointer values.| |**GCRoot** [**-nostacks**] [**-all**] \<*Object address*>|Displays information about references (or roots) to an object at the specified address.<br /><br /> The **GCRoot** command examines the entire managed heap and the handle table for handles within other objects and handles on the stack. Each stack is then searched for pointers to objects, and the finalizer queue is also searched.<br /><br /> This command does not determine whether a stack root is valid or is discarded. Use the **clrstack** and **U** commands to disassemble the frame that the local or argument value belongs to in order to determine if the stack root is still in use.<br /><br /> The **-nostacks** option restricts the search to garbage collector handles and reachable objects.<br /><br /> The **-all** option forces all roots to be displayed instead of just the unique roots.| |**GCWhere** *\<object address>*|Displays the location and size in the garbage collection heap of the argument passed in. When the argument lies in the managed heap but is not a valid object address, the size is displayed as 0 (zero).| @@ -109,6 +110,7 @@ importance. Shortcut names for popular functions are listed in parenthesis. Type |**HistRoot** *\<root>*|Displays information related to both promotions and relocations of the specified root.<br /><br /> The root value can be used to track the movement of an object through the garbage collections.| |**IP2MD** (**ip2md**) \<*Code address*>|Displays the `MethodDesc` structure at the specified address in code that has been JIT-compiled.| |**Name2EE** (**name2ee**) \<*module name*> \<*type or method name*><br /><br /> -or-<br /><br /> **Name2EE** \<*module name*>**!**\<*type or method name*>|Displays the `MethodTable` structure and `EEClass` structure for the specified type or method in the specified module.<br /><br /> The specified module must be loaded in the process.<br /><br /> To get the proper type name you can browse the module by using the an IL reflection tool like Ildasm or ILSpy. You can also pass `*` as the module name parameter to search all loaded managed modules. The *module name* parameter can also be the debugger's name for a module, such as `mscorlib` or `image00400000`.<br /><br /> This command supports the Windows debugger syntax of <`module`>`!`<`type`>. The type must be fully qualified.| +|**ObjSize** [\<*Object address*>] | [**-aggregate**] [**-stat**]|Displays the size of the specified object. If you do not specify any parameters, the **ObjSize** command displays the size of all objects found on managed threads, displays all garbage collector handles in the process, and totals the size of any objects pointed to by those handles. The **ObjSize** command includes the size of all child objects in addition to the parent.<br /><br /> The **-aggregate** option can be used in conjunction with the **-stat** argument to get a detailed view of the types that are still rooted. By using **!dumpheap -stat** and **!objsize -aggregate -stat**, you can determine which objects are no longer rooted and diagnose various memory issues.| |**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** | \<*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.| diff --git a/eng/CodeAnalysis.ruleset b/eng/CodeAnalysis.ruleset index 6e46bfdde8..ebfe969709 100644 --- a/eng/CodeAnalysis.ruleset +++ b/eng/CodeAnalysis.ruleset @@ -1,10 +1,10 @@ -<RuleSet Name="Diagnostics Ruleset" - Description="Diagnostics Ruleset" - ToolsVersion="14.0"> - - <!-- Define all the analyzer rule actions for this repo. --> - <Include Path="CodeAnalysis.Repository.ruleset" Action="Default" /> - - <!-- This will override or define all rules needed values to be SDL compliant. --> - <Include Path="CodeAnalysis.Security.ruleset" Action="Default" /> -</RuleSet> +<?xml version="1.0" encoding="utf-8"?> +<RuleSet Name="Diagnostics Ruleset" Description="Diagnostics Ruleset" ToolsVersion="14.0"> + <!-- Define all the analyzer rule actions for this repo. --> + <Include Path="CodeAnalysis.Repository.ruleset" Action="Default" /> + <!-- This will override or define all rules needed values to be SDL compliant. --> + <Include Path="CodeAnalysis.Security.ruleset" Action="Default" /> + <Rules AnalyzerId="Microsoft.CodeQuality.Analyzers" RuleNamespace="Microsoft.CodeQuality.Analyzers"> + <Rule Id="CA1069" Action="None" /> + </Rules> +</RuleSet> \ No newline at end of file diff --git a/eng/InstallRuntimes.proj b/eng/InstallRuntimes.proj index c11cd5f6ac..eac7bdc378 100644 --- a/eng/InstallRuntimes.proj +++ b/eng/InstallRuntimes.proj @@ -15,16 +15,17 @@ $(MicrosoftDotnetSdkInternalVersion) - .NET SDK to use for testing - $(VSRedistCommonNetCoreSharedFrameworkx6460Version) - latest dotnet runtime package version (the version to install) - $(MicrosoftNETCoreAppRuntimewinx64Version) - latest dotnet runtime stable version (the version that actually is installed) + $(VSRedistCommonNetCoreSharedFrameworkx6470Version) - latest dotnet runtime package version (the version to install) + $(MicrosoftNETCoreAppRuntimewinx64Version) - latest dotnet runtime stable version (the version that actually is installed) - $(MicrosoftAspNetCoreAppRefInternalVersion) - latest dotnet aspnetcore package version (the version to install) - $(MicrosoftAspNetCoreAppRefVersion) - latest dotnet aspnetcore stable version (the version that actually is installed) + $(MicrosoftAspNetCoreAppRefInternalVersion) - latest dotnet aspnetcore package version (the version to install) + $(MicrosoftAspNetCoreAppRefVersion) - latest dotnet aspnetcore stable version (the version that actually is installed) - $(MicrosoftNETCoreApp50Version) $(MicrosoftAspNetCoreApp50Version) - 5.0 version - $(MicrosoftNETCoreApp31Version) $(MicrosoftAspNetCoreApp31Version) - 3.1 version + $(MicrosoftNETCoreApp60Version) $(MicrosoftAspNetCoreApp60Version) - 6.0 version + $(MicrosoftNETCoreApp31Version) $(MicrosoftAspNetCoreApp31Version) - 3.1 version - $(SingleFileRuntimeVersion) - The version of the runtime used to build single-file apps + $(SingleFileRuntimeLatestVersion) - The latest version of the runtime used to build single-file apps + $(SingleFileRuntime60Version) - The 6.0.x version of the runtime used to build single-file apps From Arcade: @@ -63,6 +64,11 @@ <RegeditCommand>regedit.exe</RegeditCommand> </PropertyGroup> + <PropertyGroup> + <Enable31Testing>true</Enable31Testing> + <Enable31Testing Condition="'$(BuildArch)' == 'arm64' and $([MSBuild]::IsOsPlatform(OSX))">false</Enable31Testing> + </PropertyGroup> + <Choose> <When Condition="$([MSBuild]::IsOsPlatform(Windows))"> <PropertyGroup> @@ -78,14 +84,14 @@ </Choose> <ItemGroup Condition="!$(InternalReleaseTesting) and !$(PrivateBuildTesting)"> - <TestVersions Include="Latest" RuntimeVersion="$(VSRedistCommonNetCoreSharedFrameworkx6460Version)" AspNetVersion="$(MicrosoftAspNetCoreAppRefInternalVersion)" /> - <TestVersions Include="50" RuntimeVersion="$(MicrosoftNETCoreApp50Version)" AspNetVersion="$(MicrosoftAspNetCoreApp50Version)" /> - <TestVersions Include="31" RuntimeVersion="$(MicrosoftNETCoreApp31Version)" AspNetVersion="$(MicrosoftAspNetCoreApp31Version)" /> + <TestVersions Include="Latest" RuntimeVersion="$(VSRedistCommonNetCoreSharedFrameworkx6470Version)" AspNetVersion="$(MicrosoftAspNetCoreAppRefInternalVersion)" /> + <TestVersions Include="60" RuntimeVersion="$(MicrosoftNETCoreApp60Version)" AspNetVersion="$(MicrosoftAspNetCoreApp60Version)" /> + <TestVersions Include="31" RuntimeVersion="$(MicrosoftNETCoreApp31Version)" AspNetVersion="$(MicrosoftAspNetCoreApp31Version)" Condition="$(Enable31Testing)" /> </ItemGroup> <!-- Local private build testing --> <ItemGroup Condition="$(PrivateBuildTesting)"> - <TestVersions Include="Latest" RuntimeVersion="$(VSRedistCommonNetCoreSharedFrameworkx6460Version)" AspNetVersion="$(MicrosoftAspNetCoreAppRefInternalVersion)" /> + <TestVersions Include="Latest" RuntimeVersion="$(VSRedistCommonNetCoreSharedFrameworkx6470Version)" AspNetVersion="$(MicrosoftAspNetCoreAppRefInternalVersion)" /> </ItemGroup> <!-- Internal service release testing --> @@ -147,11 +153,11 @@ Outputs="$(TestConfigFileName)"> <PropertyGroup Condition="'$(PrivateBuildTesting)' != 'true' AND '$(InternalReleaseTesting)' != 'true'"> - <RuntimeVersion31>$(MicrosoftNETCoreApp31Version)</RuntimeVersion31> - <AspNetCoreVersion31>$(MicrosoftAspNetCoreApp31Version)</AspNetCoreVersion31> + <RuntimeVersion31 Condition="$(Enable31Testing)">$(MicrosoftNETCoreApp31Version)</RuntimeVersion31> + <AspNetCoreVersion31 Condition="$(Enable31Testing)">$(MicrosoftAspNetCoreApp31Version)</AspNetCoreVersion31> - <RuntimeVersion50>$(MicrosoftNETCoreApp50Version)</RuntimeVersion50> - <AspNetCoreVersion50>$(MicrosoftAspNetCoreApp50Version)</AspNetCoreVersion50> + <RuntimeVersion60>$(MicrosoftNETCoreApp60Version)</RuntimeVersion60> + <AspNetCoreVersion60>$(MicrosoftAspNetCoreApp60Version)</AspNetCoreVersion60> </PropertyGroup> <PropertyGroup> @@ -170,13 +176,14 @@ <RuntimeVersion31>$(RuntimeVersion31)</RuntimeVersion31> <AspNetCoreVersion31>$(AspNetCoreVersion31)</AspNetCoreVersion31> - <RuntimeVersion50>$(RuntimeVersion50)</RuntimeVersion50> - <AspNetCoreVersion50>$(AspNetCoreVersion50)</AspNetCoreVersion50> + <RuntimeVersion60>$(RuntimeVersion60)</RuntimeVersion60> + <AspNetCoreVersion60>$(AspNetCoreVersion60)</AspNetCoreVersion60> <RuntimeVersionLatest>$(RuntimeVersionLatest)</RuntimeVersionLatest> <AspNetCoreVersionLatest>$(AspNetCoreVersionLatest)</AspNetCoreVersionLatest> - <SingleFileRuntimeVersion>$(SingleFileRuntimeVersion)</SingleFileRuntimeVersion> + <SingleFileRuntimeLatestVersion>$(SingleFileRuntimeLatestVersion)</SingleFileRuntimeLatestVersion> + <SingleFileRuntime60Version>$(SingleFileRuntime60Version)</SingleFileRuntime60Version> </Configuration> ]]> </TestConfigFileLines> diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index e29011c03d..ef060c4d03 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -1,52 +1,52 @@ <Dependencies> <ProductDependencies> - <Dependency Name="Microsoft.SymbolStore" Version="1.0.328001"> + <Dependency Name="Microsoft.SymbolStore" Version="1.0.345501"> <Uri>https://github.com/dotnet/symstore</Uri> - <Sha>1ff51a5afa61af820a14b3aa84b401d1a79bc783</Sha> + <Sha>ecc608c89f6de49a937e9d6f180141bbc1639092</Sha> </Dependency> - <Dependency Name="Microsoft.Diagnostics.Runtime" Version="2.0.325901"> + <Dependency Name="Microsoft.Diagnostics.Runtime" Version="2.2.332302"> <Uri>https://github.com/microsoft/clrmd</Uri> - <Sha>a64d9ac11086f28fbd4b2b2337c19be7826fbfa9</Sha> + <Sha>877b2d049d5ff5c5b4182606e397b6c92de090f6</Sha> </Dependency> <Dependency Name="Microsoft.Diagnostics.Runtime.Utilities" Version="2.0.325901"> <Uri>https://github.com/microsoft/clrmd</Uri> <Sha>a64d9ac11086f28fbd4b2b2337c19be7826fbfa9</Sha> </Dependency> - <Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="7.0.0-alpha.1.22270.1"> + <Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="8.0.0-alpha.1.22466.2"> <Uri>https://github.com/dotnet/source-build-reference-packages</Uri> - <Sha>3dbb19f76474f2f22749b2e64d34c15178381ffb</Sha> + <Sha>7024c140e5954ca2d27eb6dc0285b939407ddb42</Sha> <SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" /> </Dependency> </ProductDependencies> <ToolsetDependencies> - <Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="7.0.0-beta.22276.1"> + <Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.22466.3"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>b8b67b243ba93bf9b89390c85b4dee034d3c5609</Sha> + <Sha>bf47db2617320c82f94713d7b538f7bc0fa9d662</Sha> <SourceBuild RepoName="arcade" ManagedOnly="true" /> </Dependency> - <Dependency Name="Microsoft.DotNet.RemoteExecutor" Version="7.0.0-beta.22276.1"> + <Dependency Name="Microsoft.DotNet.RemoteExecutor" Version="7.0.0-beta.22316.2" Pinned="true"> <Uri>https://github.com/dotnet/arcade</Uri> - <Sha>b8b67b243ba93bf9b89390c85b4dee034d3c5609</Sha> + <Sha>ccfe6da198c5f05534863bbb1bff66e830e0c6ab</Sha> </Dependency> - <Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="6.0.106-servicing.22277.1"> + <Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="7.0.100-rc.2.22454.1"> <Uri>https://github.com/dotnet/installer</Uri> - <Sha>0632d08f8d604ed2a9ea697e88991b7f2ec68141</Sha> + <Sha>330dee39e5e4dcf765f4c41c76b94c8e4497e91c</Sha> </Dependency> - <Dependency Name="Microsoft.AspNetCore.App.Ref.Internal" Version="6.0.6-servicing.22262.8"> + <Dependency Name="Microsoft.AspNetCore.App.Ref.Internal" Version="7.0.0-rtm.22470.1"> <Uri>https://github.com/dotnet/aspnetcore</Uri> - <Sha>fac970ded3047f63328ff56f59a874bcabf18126</Sha> + <Sha>35c3d66a10dae85cf615da7cdc9e0f0de0d678bb</Sha> </Dependency> - <Dependency Name="Microsoft.AspNetCore.App.Ref" Version="6.0.6"> + <Dependency Name="Microsoft.AspNetCore.App.Ref" Version="7.0.0-rtm.22470.1"> <Uri>https://github.com/dotnet/aspnetcore</Uri> - <Sha>fac970ded3047f63328ff56f59a874bcabf18126</Sha> + <Sha>35c3d66a10dae85cf615da7cdc9e0f0de0d678bb</Sha> </Dependency> - <Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="6.0.5"> + <Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="7.0.0-rtm.22469.12"> <Uri>https://github.com/dotnet/runtime</Uri> - <Sha>a21b9a2dd4c31cf5bd37626562b7612faf21cee6</Sha> + <Sha>210804731c56d2fd4619ddefd801f2c93467ea58</Sha> </Dependency> - <Dependency Name="VS.Redist.Common.NetCore.SharedFramework.x64.6.0" Version="6.0.5-servicing.22213.11"> + <Dependency Name="VS.Redist.Common.NetCore.SharedFramework.x64.7.0" Version="7.0.0-rtm.22469.12"> <Uri>https://github.com/dotnet/runtime</Uri> - <Sha>a21b9a2dd4c31cf5bd37626562b7612faf21cee6</Sha> + <Sha>210804731c56d2fd4619ddefd801f2c93467ea58</Sha> </Dependency> </ToolsetDependencies> </Dependencies> diff --git a/eng/Versions.props b/eng/Versions.props index bb8fd3f44a..941842b51a 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -1,7 +1,7 @@ <Project> <PropertyGroup> <RepositoryUrl>https://github.com/dotnet/diagnostics</RepositoryUrl> - <PreReleaseVersionLabel /> + <PreReleaseVersionLabel>preview</PreReleaseVersionLabel> <VersionPrefix>6.0.0</VersionPrefix> <DotNetUseShippingVersions>true</DotNetUseShippingVersions> <AutoGenerateAssemblyVersion>true</AutoGenerateAssemblyVersion> @@ -15,23 +15,26 @@ <SkipPackagePublishingVersionChecks>true</SkipPackagePublishingVersionChecks> </PropertyGroup> <PropertyGroup> - <!-- The SDK runtime version used to build single-file apps (currently hardcoded) --> - <SingleFileRuntimeVersion>6.0.5</SingleFileRuntimeVersion> <!-- Latest symstore version updated by darc --> - <MicrosoftSymbolStoreVersion>1.0.328001</MicrosoftSymbolStoreVersion> - <!-- Runtime versions to test --> - <MicrosoftNETCoreApp31Version>3.1.18</MicrosoftNETCoreApp31Version> - <MicrosoftAspNetCoreApp31Version>$(MicrosoftNETCoreApp31Version)</MicrosoftAspNetCoreApp31Version> - <MicrosoftNETCoreApp50Version>5.0.9</MicrosoftNETCoreApp50Version> - <MicrosoftAspNetCoreApp50Version>$(MicrosoftNETCoreApp50Version)</MicrosoftAspNetCoreApp50Version> + <MicrosoftSymbolStoreVersion>1.0.345501</MicrosoftSymbolStoreVersion> <!-- Latest shared runtime version updated by darc --> - <VSRedistCommonNetCoreSharedFrameworkx6460Version>6.0.5-servicing.22213.11</VSRedistCommonNetCoreSharedFrameworkx6460Version> - <MicrosoftNETCoreAppRuntimewinx64Version>6.0.5</MicrosoftNETCoreAppRuntimewinx64Version> + <VSRedistCommonNetCoreSharedFrameworkx6470Version>7.0.0-rtm.22469.12</VSRedistCommonNetCoreSharedFrameworkx6470Version> + <MicrosoftNETCoreAppRuntimewinx64Version>7.0.0-rtm.22469.12</MicrosoftNETCoreAppRuntimewinx64Version> <!-- Latest shared aspnetcore version updated by darc --> - <MicrosoftAspNetCoreAppRefInternalVersion>6.0.6-servicing.22262.8</MicrosoftAspNetCoreAppRefInternalVersion> - <MicrosoftAspNetCoreAppRefVersion>6.0.6</MicrosoftAspNetCoreAppRefVersion> + <MicrosoftAspNetCoreAppRefInternalVersion>7.0.0-rtm.22470.1</MicrosoftAspNetCoreAppRefInternalVersion> + <MicrosoftAspNetCoreAppRefVersion>7.0.0-rtm.22470.1</MicrosoftAspNetCoreAppRefVersion> <!-- dotnet/installer: Testing version of the SDK. Needed for the signed & entitled host. --> - <MicrosoftDotnetSdkInternalVersion>6.0.106-servicing.22277.1</MicrosoftDotnetSdkInternalVersion> + <MicrosoftDotnetSdkInternalVersion>7.0.100-rc.2.22454.1</MicrosoftDotnetSdkInternalVersion> + </PropertyGroup> + <PropertyGroup> + <!-- Runtime versions to test --> + <MicrosoftNETCoreApp31Version>3.1.28</MicrosoftNETCoreApp31Version> + <MicrosoftAspNetCoreApp31Version>$(MicrosoftNETCoreApp31Version)</MicrosoftAspNetCoreApp31Version> + <MicrosoftNETCoreApp60Version>6.0.8</MicrosoftNETCoreApp60Version> + <MicrosoftAspNetCoreApp60Version>$(MicrosoftNETCoreApp60Version)</MicrosoftAspNetCoreApp60Version> + <!-- The SDK runtime version used to build single-file apps (currently hardcoded) --> + <SingleFileRuntime60Version>6.0.8</SingleFileRuntime60Version> + <SingleFileRuntimeLatestVersion>7.0.0-rc.1.22422.12</SingleFileRuntimeLatestVersion> </PropertyGroup> <PropertyGroup> <!-- Opt-in/out repo features --> @@ -44,11 +47,11 @@ <MicrosoftWin32PrimitivesVersion>4.3.0</MicrosoftWin32PrimitivesVersion> <!-- Other libs --> <MicrosoftBclAsyncInterfacesVersion>1.1.0</MicrosoftBclAsyncInterfacesVersion> - <MicrosoftDiagnosticsRuntimeVersion>2.0.325901</MicrosoftDiagnosticsRuntimeVersion> - <MicrosoftDiagnosticsRuntimeUtilitiesVersion>2.0.325901</MicrosoftDiagnosticsRuntimeUtilitiesVersion> + <MicrosoftDiagnosticsRuntimeVersion>2.2.332302</MicrosoftDiagnosticsRuntimeVersion> <MicrosoftDiaSymReaderNativePackageVersion>16.9.0-beta1.21055.5</MicrosoftDiaSymReaderNativePackageVersion> - <MicrosoftDiagnosticsTracingTraceEventVersion>2.0.64</MicrosoftDiagnosticsTracingTraceEventVersion> - <MicrosoftExtensionsLoggingVersion>2.1.1</MicrosoftExtensionsLoggingVersion> + <MicrosoftDiagnosticsTracingTraceEventVersion>3.0.3</MicrosoftDiagnosticsTracingTraceEventVersion> + <!-- Use pinned version to avoid picking up latest (which doesn't support netcoreapp3.1) during source-build --> + <MicrosoftExtensionsLoggingPinnedVersion>2.1.1</MicrosoftExtensionsLoggingPinnedVersion> <!-- Need version that understands UseAppFilters sentinel. --> <MicrosoftExtensionsLoggingEventSourceVersion>5.0.1</MicrosoftExtensionsLoggingEventSourceVersion> <SystemCommandLineVersion>2.0.0-beta1.20468.1</SystemCommandLineVersion> @@ -58,8 +61,8 @@ <SystemTextEncodingsWebVersion>4.7.2</SystemTextEncodingsWebVersion> <SystemTextJsonVersion>4.7.1</SystemTextJsonVersion> <XUnitAbstractionsVersion>2.0.3</XUnitAbstractionsVersion> - <MicrosoftDotNetRemoteExecutorVersion>7.0.0-beta.22276.1</MicrosoftDotNetRemoteExecutorVersion> + <MicrosoftDotNetRemoteExecutorVersion>7.0.0-beta.22316.2</MicrosoftDotNetRemoteExecutorVersion> <cdbsosversion>10.0.18362</cdbsosversion> - <NewtonSoftJsonVersion>12.0.2</NewtonSoftJsonVersion> + <NewtonSoftJsonVersion>13.0.1</NewtonSoftJsonVersion> </PropertyGroup> </Project> diff --git a/eng/build.yml b/eng/build.yml index 19e60fcdce..76de75d35b 100644 --- a/eng/build.yml +++ b/eng/build.yml @@ -34,7 +34,7 @@ jobs: pool: # Public Linux Build Pool ${{ if and(eq(parameters.osGroup, 'Linux'), eq(variables['System.TeamProject'], 'public')) }}: - name: NetCore1ESPool-Svc-Public + name: NetCore-Public demands: ImageOverride -equals Build.Ubuntu.1804.Amd64.Open # Official Build Linux Pool @@ -48,17 +48,17 @@ jobs: # Build OSX Pool (we don't have on-prem OSX BuildPool) ${{ if in(parameters.osGroup, 'MacOS', 'MacOS_cross') }}: - vmImage: macOS-10.15 + vmImage: macOS-latest # Official Build Windows Pool ${{ if and(eq(parameters.osGroup, 'Windows_NT'), ne(variables['System.TeamProject'], 'public')) }}: name: NetCore1ESPool-Svc-Internal - demands: ImageOverride -equals Build.Windows.10.Amd64.VS2019 + demands: ImageOverride -equals windows.vs2022.amd64 # Public Windows Build Pool ${{ if and(eq(parameters.osGroup, 'Windows_NT'), eq(variables['System.TeamProject'], 'public')) }}: - name: NetCore1ESPool-Svc-Public - demands: ImageOverride -equals Build.Windows.10.Amd64.VS2019.Open + name: NetCore-Public + demands: ImageOverride -equals windows.vs2022.amd64.open ${{ if and(ne(parameters.dockerImage, ''), ne(parameters.requiresCapPtraceContainer, 'true')) }}: container: ${{ parameters.dockerImage }} @@ -137,9 +137,6 @@ jobs: sourceFolder: $(Build.ArtifactStagingDirectory)/__download__/Build_$(_BuildConfig)/bin/Linux.$(_BuildArch).$(_BuildConfig) targetFolder: '$(Build.SourcesDirectory)/artifacts/bin/Linux.$(_BuildArch).$(_BuildConfig)' - - ${{ if eq(parameters.osGroup, 'MacOS_cross') }}: - - script: /bin/bash -c "sudo xcode-select -s /Applications/Xcode_12.2.app/Contents/Developer" - - script: $(_dockerEnv) $(_buildScript) -configuration $(_BuildConfig) -architecture $(_BuildArch) diff --git a/eng/common/SetupNugetSources.ps1 b/eng/common/SetupNugetSources.ps1 index 18823840b1..6e99723945 100644 --- a/eng/common/SetupNugetSources.ps1 +++ b/eng/common/SetupNugetSources.ps1 @@ -146,22 +146,22 @@ $userName = "dn-bot" # Insert credential nodes for Maestro's private feeds InsertMaestroPrivateFeedCredentials -Sources $sources -Creds $creds -Username $userName -Password $Password +# 3.1 uses a different feed url format so it's handled differently here $dotnet31Source = $sources.SelectSingleNode("add[@key='dotnet3.1']") if ($dotnet31Source -ne $null) { AddPackageSource -Sources $sources -SourceName "dotnet3.1-internal" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal/nuget/v2" -Creds $creds -Username $userName -Password $Password AddPackageSource -Sources $sources -SourceName "dotnet3.1-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal-transport/nuget/v2" -Creds $creds -Username $userName -Password $Password } -$dotnet5Source = $sources.SelectSingleNode("add[@key='dotnet5']") -if ($dotnet5Source -ne $null) { - AddPackageSource -Sources $sources -SourceName "dotnet5-internal" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet5-internal/nuget/v2" -Creds $creds -Username $userName -Password $Password - AddPackageSource -Sources $sources -SourceName "dotnet5-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet5-internal-transport/nuget/v2" -Creds $creds -Username $userName -Password $Password -} +$dotnetVersions = @('5','6','7') -$dotnet6Source = $sources.SelectSingleNode("add[@key='dotnet6']") -if ($dotnet6Source -ne $null) { - AddPackageSource -Sources $sources -SourceName "dotnet6-internal" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet6-internal/nuget/v2" -Creds $creds -Username $userName -Password $Password - AddPackageSource -Sources $sources -SourceName "dotnet6-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet6-internal-transport/nuget/v2" -Creds $creds -Username $userName -Password $Password +foreach ($dotnetVersion in $dotnetVersions) { + $feedPrefix = "dotnet" + $dotnetVersion; + $dotnetSource = $sources.SelectSingleNode("add[@key='$feedPrefix']") + if ($dotnetSource -ne $null) { + AddPackageSource -Sources $sources -SourceName "$feedPrefix-internal" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/$feedPrefix-internal/nuget/v2" -Creds $creds -Username $userName -Password $Password + AddPackageSource -Sources $sources -SourceName "$feedPrefix-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/$feedPrefix-internal-transport/nuget/v2" -Creds $creds -Username $userName -Password $Password + } } $doc.Save($filename) diff --git a/eng/common/SetupNugetSources.sh b/eng/common/SetupNugetSources.sh index ad3fb74fd2..8af7d899db 100644 --- a/eng/common/SetupNugetSources.sh +++ b/eng/common/SetupNugetSources.sh @@ -105,53 +105,33 @@ if [ "$?" == "0" ]; then PackageSources+=('dotnet3.1-internal-transport') fi -# Ensure dotnet5-internal and dotnet5-internal-transport are in the packageSources if the public dotnet5 feeds are present -grep -i "<add key=\"dotnet5\"" $ConfigFile -if [ "$?" == "0" ]; then - grep -i "<add key=\"dotnet5-internal\"" $ConfigFile - if [ "$?" != "0" ]; then - echo "Adding dotnet5-internal to the packageSources." - PackageSourcesNodeFooter="</packageSources>" - PackageSourceTemplate="${TB}<add key=\"dotnet5-internal\" value=\"https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet5-internal/nuget/v2\" />" - - sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile - fi - PackageSources+=('dotnet5-internal') - - grep -i "<add key=\"dotnet5-internal-transport\">" $ConfigFile - if [ "$?" != "0" ]; then - echo "Adding dotnet5-internal-transport to the packageSources." - PackageSourcesNodeFooter="</packageSources>" - PackageSourceTemplate="${TB}<add key=\"dotnet5-internal-transport\" value=\"https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet5-internal-transport/nuget/v2\" />" - - sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile - fi - PackageSources+=('dotnet5-internal-transport') -fi - -# Ensure dotnet6-internal and dotnet6-internal-transport are in the packageSources if the public dotnet6 feeds are present -grep -i "<add key=\"dotnet6\"" $ConfigFile -if [ "$?" == "0" ]; then - grep -i "<add key=\"dotnet6-internal\"" $ConfigFile - if [ "$?" != "0" ]; then - echo "Adding dotnet6-internal to the packageSources." - PackageSourcesNodeFooter="</packageSources>" - PackageSourceTemplate="${TB}<add key=\"dotnet6-internal\" value=\"https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet6-internal/nuget/v2\" />" +DotNetVersions=('5' '6' '7') + +for DotNetVersion in ${DotNetVersions[@]} ; do + FeedPrefix="dotnet${DotNetVersion}"; + grep -i "<add key=\"$FeedPrefix\"" $ConfigFile + if [ "$?" == "0" ]; then + grep -i "<add key=\"$FeedPrefix-internal\"" $ConfigFile + if [ "$?" != "0" ]; then + echo "Adding $FeedPrefix-internal to the packageSources." + PackageSourcesNodeFooter="</packageSources>" + PackageSourceTemplate="${TB}<add key=\"$FeedPrefix-internal\" value=\"https://pkgs.dev.azure.com/dnceng/internal/_packaging/$FeedPrefix-internal/nuget/v2\" />" + + sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile + fi + PackageSources+=("$FeedPrefix-internal") - sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile - fi - PackageSources+=('dotnet6-internal') + grep -i "<add key=\"$FeedPrefix-internal-transport\">" $ConfigFile + if [ "$?" != "0" ]; then + echo "Adding $FeedPrefix-internal-transport to the packageSources." + PackageSourcesNodeFooter="</packageSources>" + PackageSourceTemplate="${TB}<add key=\"$FeedPrefix-internal-transport\" value=\"https://pkgs.dev.azure.com/dnceng/internal/_packaging/$FeedPrefix-internal-transport/nuget/v2\" />" - grep -i "<add key=\"dotnet6-internal-transport\">" $ConfigFile - if [ "$?" != "0" ]; then - echo "Adding dotnet6-internal-transport to the packageSources." - PackageSourcesNodeFooter="</packageSources>" - PackageSourceTemplate="${TB}<add key=\"dotnet6-internal-transport\" value=\"https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet6-internal-transport/nuget/v2\" />" - - sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile + sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile + fi + PackageSources+=("$FeedPrefix-internal-transport") fi - PackageSources+=('dotnet6-internal-transport') -fi +done # I want things split line by line PrevIFS=$IFS diff --git a/eng/common/build.sh b/eng/common/build.sh index 55b298f16c..50af40cdd2 100755 --- a/eng/common/build.sh +++ b/eng/common/build.sh @@ -19,6 +19,9 @@ usage() echo "Actions:" echo " --restore Restore dependencies (short: -r)" echo " --build Build solution (short: -b)" + echo " --sourceBuild Source-build the solution (short: -sb)" + echo " Will additionally trigger the following actions: --restore, --build, --pack" + echo " If --configuration is not set explicitly, will also set it to 'Release'" echo " --rebuild Rebuild solution" echo " --test Run all unit tests in the solution (short: -t)" echo " --integrationTest Run all integration tests in the solution" @@ -55,6 +58,7 @@ scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" restore=false build=false +source_build=false rebuild=false test=false integration_test=false @@ -73,7 +77,7 @@ exclude_ci_binary_log=false pipelines_log=false projects='' -configuration='Debug' +configuration='' prepare_machine=false verbosity='minimal' runtime_source_feed='' @@ -119,6 +123,12 @@ while [[ $# > 0 ]]; do -pack) pack=true ;; + -sourcebuild|-sb) + build=true + source_build=true + restore=true + pack=true + ;; -test|-t) test=true ;; @@ -168,6 +178,10 @@ while [[ $# > 0 ]]; do shift done +if [[ -z "$configuration" ]]; then + if [[ "$source_build" = true ]]; then configuration="Release"; else configuration="Debug"; fi +fi + if [[ "$ci" == true ]]; then pipelines_log=true node_reuse=false @@ -205,6 +219,7 @@ function Build { /p:RepoRoot="$repo_root" \ /p:Restore=$restore \ /p:Build=$build \ + /p:ArcadeBuildFromSource=$source_build \ /p:Rebuild=$rebuild \ /p:Test=$test \ /p:Pack=$pack \ diff --git a/eng/common/cross/arm/sources.list.focal b/eng/common/cross/arm/sources.list.focal new file mode 100644 index 0000000000..4de2600c17 --- /dev/null +++ b/eng/common/cross/arm/sources.list.focal @@ -0,0 +1,11 @@ +deb http://ports.ubuntu.com/ubuntu-ports/ focal main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ focal main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted + +deb http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse diff --git a/eng/common/cross/arm/sources.list.jammy b/eng/common/cross/arm/sources.list.jammy new file mode 100644 index 0000000000..6bb0453029 --- /dev/null +++ b/eng/common/cross/arm/sources.list.jammy @@ -0,0 +1,11 @@ +deb http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted + +deb http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse diff --git a/eng/common/cross/arm64/sources.list.focal b/eng/common/cross/arm64/sources.list.focal new file mode 100644 index 0000000000..4de2600c17 --- /dev/null +++ b/eng/common/cross/arm64/sources.list.focal @@ -0,0 +1,11 @@ +deb http://ports.ubuntu.com/ubuntu-ports/ focal main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ focal main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted + +deb http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse diff --git a/eng/common/cross/arm64/sources.list.jammy b/eng/common/cross/arm64/sources.list.jammy new file mode 100644 index 0000000000..6bb0453029 --- /dev/null +++ b/eng/common/cross/arm64/sources.list.jammy @@ -0,0 +1,11 @@ +deb http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted + +deb http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse diff --git a/eng/common/cross/build-rootfs.sh b/eng/common/cross/build-rootfs.sh index 5a59dcff28..5680980fa2 100644 --- a/eng/common/cross/build-rootfs.sh +++ b/eng/common/cross/build-rootfs.sh @@ -5,22 +5,26 @@ set -e usage() { echo "Usage: $0 [BuildArch] [CodeName] [lldbx.y] [llvmx[.y]] [--skipunmount] --rootfsdir <directory>]" - echo "BuildArch can be: arm(default), armel, arm64, x86" + echo "BuildArch can be: arm(default), arm64, armel, armv6, ppc64le, riscv64, s390x, x64, x86" echo "CodeName - optional, Code name for Linux, can be: xenial(default), zesty, bionic, alpine, alpine3.13 or alpine3.14. If BuildArch is armel, LinuxCodeName is jessie(default) or tizen." echo " for FreeBSD can be: freebsd12, freebsd13" - echo " for illumos can be: illumos." + echo " for illumos can be: illumos" + echo " for Haiku can be: haiku." echo "lldbx.y - optional, LLDB version, can be: lldb3.9(default), lldb4.0, lldb5.0, lldb6.0 no-lldb. Ignored for alpine and FreeBSD" echo "llvmx[.y] - optional, LLVM version for LLVM related packages." echo "--skipunmount - optional, will skip the unmount of rootfs folder." echo "--use-mirror - optional, use mirror URL to fetch resources, when available." + echo "--jobs N - optional, restrict to N jobs." exit 1 } __CodeName=xenial __CrossDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -__InitialDir=$PWD __BuildArch=arm __AlpineArch=armv7 +__FreeBSDArch=arm +__FreeBSDMachineArch=armv7 +__IllumosArch=arm7 __QEMUArch=arm __UbuntuArch=armhf __UbuntuRepo="http://ports.ubuntu.com/" @@ -40,7 +44,7 @@ __AlpinePackages+=" libedit" # symlinks fixer __UbuntuPackages+=" symlinks" -# CoreCLR and CoreFX dependencies +# runtime dependencies __UbuntuPackages+=" libicu-dev" __UbuntuPackages+=" liblttng-ust-dev" __UbuntuPackages+=" libunwind8-dev" @@ -51,7 +55,7 @@ __AlpinePackages+=" libunwind-dev" __AlpinePackages+=" lttng-ust-dev" __AlpinePackages+=" compiler-rt-static" -# CoreFX dependencies +# runtime libraries' dependencies __UbuntuPackages+=" libcurl4-openssl-dev" __UbuntuPackages+=" libkrb5-dev" __UbuntuPackages+=" libssl-dev" @@ -72,26 +76,38 @@ __FreeBSDPackages+=" openssl" __FreeBSDPackages+=" krb5" __FreeBSDPackages+=" terminfo-db" -__IllumosPackages="icu-64.2nb2" -__IllumosPackages+=" mit-krb5-1.16.2nb4" -__IllumosPackages+=" openssl-1.1.1e" -__IllumosPackages+=" zlib-1.2.11" +__IllumosPackages="icu" +__IllumosPackages+=" mit-krb5" +__IllumosPackages+=" openssl" +__IllumosPackages+=" zlib" + +__HaikuPackages="gmp" +__HaikuPackages+=" gmp_devel" +__HaikuPackages+=" krb5" +__HaikuPackages+=" krb5_devel" +__HaikuPackages+=" libiconv" +__HaikuPackages+=" libiconv_devel" +__HaikuPackages+=" llvm12_libunwind" +__HaikuPackages+=" llvm12_libunwind_devel" +__HaikuPackages+=" mpfr" +__HaikuPackages+=" mpfr_devel" # ML.NET dependencies __UbuntuPackages+=" libomp5" __UbuntuPackages+=" libomp-dev" +__Keyring= __UseMirror=0 __UnprocessedBuildArgs= while :; do - if [ $# -le 0 ]; then + if [[ "$#" -le 0 ]]; then break fi - lowerI="$(echo $1 | tr "[:upper:]" "[:lower:]")" + lowerI="$(echo "$1" | tr "[:upper:]" "[:lower:]")" case $lowerI in - -?|-h|--help) + -\?|-h|--help) usage exit 1 ;; @@ -101,20 +117,13 @@ while :; do __AlpineArch=armv7 __QEMUArch=arm ;; - armv6) - __BuildArch=armv6 - __UbuntuArch=armhf - __QEMUArch=arm - __UbuntuRepo="http://raspbian.raspberrypi.org/raspbian/" - __CodeName=buster - __LLDB_Package="liblldb-6.0-dev" - __Keyring="/usr/share/keyrings/raspbian-archive-keyring.gpg" - ;; arm64) __BuildArch=arm64 __UbuntuArch=arm64 __AlpineArch=aarch64 __QEMUArch=aarch64 + __FreeBSDArch=arm64 + __FreeBSDMachineArch=aarch64 ;; armel) __BuildArch=armel @@ -122,6 +131,18 @@ while :; do __UbuntuRepo="http://ftp.debian.org/debian/" __CodeName=jessie ;; + armv6) + __BuildArch=armv6 + __UbuntuArch=armhf + __QEMUArch=arm + __UbuntuRepo="http://raspbian.raspberrypi.org/raspbian/" + __CodeName=buster + __LLDB_Package="liblldb-6.0-dev" + + if [[ -e "/usr/share/keyrings/raspbian-archive-keyring.gpg" ]]; then + __Keyring="--keyring /usr/share/keyrings/raspbian-archive-keyring.gpg" + fi + ;; ppc64le) __BuildArch=ppc64le __UbuntuArch=ppc64el @@ -131,6 +152,18 @@ while :; do __UbuntuPackages=$(echo ${__UbuntuPackages} | sed 's/ libomp5//') unset __LLDB_Package ;; + riscv64) + __BuildArch=riscv64 + __UbuntuArch=riscv64 + __UbuntuRepo="http://deb.debian.org/debian-ports" + __CodeName=sid + __UbuntuPackages=$(echo ${__UbuntuPackages} | sed 's/ libunwind8-dev//') + unset __LLDB_Package + + if [[ -e "/usr/share/keyrings/debian-ports-archive-keyring.gpg" ]]; then + __Keyring="--keyring /usr/share/keyrings/debian-ports-archive-keyring.gpg --include=debian-ports-archive-keyring" + fi + ;; s390x) __BuildArch=s390x __UbuntuArch=s390x @@ -140,56 +173,69 @@ while :; do __UbuntuPackages=$(echo ${__UbuntuPackages} | sed 's/ libomp5//') unset __LLDB_Package ;; + x64) + __BuildArch=x64 + __UbuntuArch=amd64 + __FreeBSDArch=amd64 + __FreeBSDMachineArch=amd64 + __illumosArch=x86_64 + __UbuntuRepo= + ;; x86) __BuildArch=x86 __UbuntuArch=i386 __UbuntuRepo="http://archive.ubuntu.com/ubuntu/" ;; - lldb3.6) - __LLDB_Package="lldb-3.6-dev" - ;; - lldb3.8) - __LLDB_Package="lldb-3.8-dev" - ;; - lldb3.9) - __LLDB_Package="liblldb-3.9-dev" - ;; - lldb4.0) - __LLDB_Package="liblldb-4.0-dev" - ;; - lldb5.0) - __LLDB_Package="liblldb-5.0-dev" - ;; - lldb6.0) - __LLDB_Package="liblldb-6.0-dev" + lldb*) + version="${lowerI/lldb/}" + parts=(${version//./ }) + + # for versions > 6.0, lldb has dropped the minor version + if [[ "${parts[0]}" -gt 6 ]]; then + version="${parts[0]}" + fi + + __LLDB_Package="liblldb-${version}-dev" ;; no-lldb) unset __LLDB_Package ;; llvm*) - version="$(echo "$lowerI" | tr -d '[:alpha:]-=')" + version="${lowerI/llvm/}" parts=(${version//./ }) __LLVM_MajorVersion="${parts[0]}" __LLVM_MinorVersion="${parts[1]}" + + # for versions > 6.0, llvm has dropped the minor version if [[ -z "$__LLVM_MinorVersion" && "$__LLVM_MajorVersion" -le 6 ]]; then __LLVM_MinorVersion=0; fi ;; xenial) # Ubuntu 16.04 - if [ "$__CodeName" != "jessie" ]; then + if [[ "$__CodeName" != "jessie" ]]; then __CodeName=xenial fi ;; zesty) # Ubuntu 17.04 - if [ "$__CodeName" != "jessie" ]; then + if [[ "$__CodeName" != "jessie" ]]; then __CodeName=zesty fi ;; bionic) # Ubuntu 18.04 - if [ "$__CodeName" != "jessie" ]; then + if [[ "$__CodeName" != "jessie" ]]; then __CodeName=bionic fi ;; + focal) # Ubuntu 20.04 + if [[ "$__CodeName" != "jessie" ]]; then + __CodeName=focal + fi + ;; + jammy) # Ubuntu 22.04 + if [[ "$__CodeName" != "jessie" ]]; then + __CodeName=jammy + fi + ;; jessie) # Debian 8 __CodeName=jessie __UbuntuRepo="http://ftp.debian.org/debian/" @@ -205,11 +251,6 @@ while :; do __LLDB_Package="liblldb-6.0-dev" ;; tizen) - if [ "$__BuildArch" != "arm" ] && [ "$__BuildArch" != "armel" ] && [ "$__BuildArch" != "arm64" ] && [ "$__BuildArch" != "x86" ] ; then - echo "Tizen is available only for arm, armel, arm64 and x86." - usage; - exit 1; - fi __CodeName= __UbuntuRepo= __Tizen=tizen @@ -228,18 +269,20 @@ while :; do ;; freebsd12) __CodeName=freebsd - __BuildArch=x64 __SkipUnmount=1 ;; freebsd13) __CodeName=freebsd __FreeBSDBase="13.0-RELEASE" __FreeBSDABI="13" - __BuildArch=x64 __SkipUnmount=1 ;; illumos) __CodeName=illumos + __SkipUnmount=1 + ;; + haiku) + __CodeName=haiku __BuildArch=x64 __SkipUnmount=1 ;; @@ -248,11 +291,15 @@ while :; do ;; --rootfsdir|-rootfsdir) shift - __RootfsDir=$1 + __RootfsDir="$1" ;; --use-mirror) __UseMirror=1 ;; + --use-jobs) + shift + MAXJOBS=$1 + ;; *) __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1" ;; @@ -261,81 +308,76 @@ while :; do shift done -if [ -e "$__Keyring" ]; then - __Keyring="--keyring=$__Keyring" -else - __Keyring="" -fi - -if [ "$__BuildArch" == "armel" ]; then +if [[ "$__BuildArch" == "armel" ]]; then __LLDB_Package="lldb-3.5-dev" fi + __UbuntuPackages+=" ${__LLDB_Package:-}" -if [ ! -z "$__LLVM_MajorVersion" ]; then +if [[ -n "$__LLVM_MajorVersion" ]]; then __UbuntuPackages+=" libclang-common-${__LLVM_MajorVersion}${__LLVM_MinorVersion:+.$__LLVM_MinorVersion}-dev" fi -if [ -z "$__RootfsDir" ] && [ ! -z "$ROOTFS_DIR" ]; then - __RootfsDir=$ROOTFS_DIR +if [[ -z "$__RootfsDir" && -n "$ROOTFS_DIR" ]]; then + __RootfsDir="$ROOTFS_DIR" fi -if [ -z "$__RootfsDir" ]; then +if [[ -z "$__RootfsDir" ]]; then __RootfsDir="$__CrossDir/../../../.tools/rootfs/$__BuildArch" fi -if [ -d "$__RootfsDir" ]; then - if [ $__SkipUnmount == 0 ]; then - umount $__RootfsDir/* || true +if [[ -d "$__RootfsDir" ]]; then + if [[ "$__SkipUnmount" == "0" ]]; then + umount "$__RootfsDir"/* || true fi - rm -rf $__RootfsDir + rm -rf "$__RootfsDir" fi -mkdir -p $__RootfsDir +mkdir -p "$__RootfsDir" __RootfsDir="$( cd "$__RootfsDir" && pwd )" if [[ "$__CodeName" == "alpine" ]]; then __ApkToolsVersion=2.9.1 - __ApkToolsDir=$(mktemp -d) - wget https://github.com/alpinelinux/apk-tools/releases/download/v$__ApkToolsVersion/apk-tools-$__ApkToolsVersion-x86_64-linux.tar.gz -P $__ApkToolsDir - tar -xf $__ApkToolsDir/apk-tools-$__ApkToolsVersion-x86_64-linux.tar.gz -C $__ApkToolsDir - mkdir -p $__RootfsDir/usr/bin - cp -v /usr/bin/qemu-$__QEMUArch-static $__RootfsDir/usr/bin - - $__ApkToolsDir/apk-tools-$__ApkToolsVersion/apk \ - -X http://dl-cdn.alpinelinux.org/alpine/v$__AlpineVersion/main \ - -X http://dl-cdn.alpinelinux.org/alpine/v$__AlpineVersion/community \ - -U --allow-untrusted --root $__RootfsDir --arch $__AlpineArch --initdb \ + __ApkToolsDir="$(mktemp -d)" + wget "https://github.com/alpinelinux/apk-tools/releases/download/v$__ApkToolsVersion/apk-tools-$__ApkToolsVersion-x86_64-linux.tar.gz" -P "$__ApkToolsDir" + tar -xf "$__ApkToolsDir/apk-tools-$__ApkToolsVersion-x86_64-linux.tar.gz" -C "$__ApkToolsDir" + mkdir -p "$__RootfsDir"/usr/bin + cp -v "/usr/bin/qemu-$__QEMUArch-static" "$__RootfsDir/usr/bin" + + "$__ApkToolsDir/apk-tools-$__ApkToolsVersion/apk" \ + -X "http://dl-cdn.alpinelinux.org/alpine/v$__AlpineVersion/main" \ + -X "http://dl-cdn.alpinelinux.org/alpine/v$__AlpineVersion/community" \ + -U --allow-untrusted --root "$__RootfsDir" --arch "$__AlpineArch" --initdb \ add $__AlpinePackages - rm -r $__ApkToolsDir + rm -r "$__ApkToolsDir" elif [[ "$__CodeName" == "freebsd" ]]; then - mkdir -p $__RootfsDir/usr/local/etc - JOBS="$(getconf _NPROCESSORS_ONLN)" - wget -O - https://download.freebsd.org/ftp/releases/amd64/${__FreeBSDBase}/base.txz | tar -C $__RootfsDir -Jxf - ./lib ./usr/lib ./usr/libdata ./usr/include ./usr/share/keys ./etc ./bin/freebsd-version - echo "ABI = \"FreeBSD:${__FreeBSDABI}:amd64\"; FINGERPRINTS = \"${__RootfsDir}/usr/share/keys\"; REPOS_DIR = [\"${__RootfsDir}/etc/pkg\"]; REPO_AUTOUPDATE = NO; RUN_SCRIPTS = NO;" > ${__RootfsDir}/usr/local/etc/pkg.conf - echo "FreeBSD: { url: "pkg+http://pkg.FreeBSD.org/\${ABI}/quarterly", mirror_type: \"srv\", signature_type: \"fingerprints\", fingerprints: \"${__RootfsDir}/usr/share/keys/pkg\", enabled: yes }" > ${__RootfsDir}/etc/pkg/FreeBSD.conf - mkdir -p $__RootfsDir/tmp + mkdir -p "$__RootfsDir"/usr/local/etc + JOBS=${MAXJOBS:="$(getconf _NPROCESSORS_ONLN)"} + wget -O - "https://download.freebsd.org/ftp/releases/${__FreeBSDArch}/${__FreeBSDMachineArch}/${__FreeBSDBase}/base.txz" | tar -C "$__RootfsDir" -Jxf - ./lib ./usr/lib ./usr/libdata ./usr/include ./usr/share/keys ./etc ./bin/freebsd-version + echo "ABI = \"FreeBSD:${__FreeBSDABI}:${__FreeBSDMachineArch}\"; FINGERPRINTS = \"${__RootfsDir}/usr/share/keys\"; REPOS_DIR = [\"${__RootfsDir}/etc/pkg\"]; REPO_AUTOUPDATE = NO; RUN_SCRIPTS = NO;" > "${__RootfsDir}"/usr/local/etc/pkg.conf + echo "FreeBSD: { url: \"pkg+http://pkg.FreeBSD.org/\${ABI}/quarterly\", mirror_type: \"srv\", signature_type: \"fingerprints\", fingerprints: \"${__RootfsDir}/usr/share/keys/pkg\", enabled: yes }" > "${__RootfsDir}"/etc/pkg/FreeBSD.conf + mkdir -p "$__RootfsDir"/tmp # get and build package manager - wget -O - https://github.com/freebsd/pkg/archive/${__FreeBSDPkg}.tar.gz | tar -C $__RootfsDir/tmp -zxf - - cd $__RootfsDir/tmp/pkg-${__FreeBSDPkg} + wget -O - "https://github.com/freebsd/pkg/archive/${__FreeBSDPkg}.tar.gz" | tar -C "$__RootfsDir"/tmp -zxf - + cd "$__RootfsDir/tmp/pkg-${__FreeBSDPkg}" # needed for install to succeed - mkdir -p $__RootfsDir/host/etc - ./autogen.sh && ./configure --prefix=$__RootfsDir/host && make -j "$JOBS" && make install - rm -rf $__RootfsDir/tmp/pkg-${__FreeBSDPkg} + mkdir -p "$__RootfsDir"/host/etc + ./autogen.sh && ./configure --prefix="$__RootfsDir"/host && make -j "$JOBS" && make install + rm -rf "$__RootfsDir/tmp/pkg-${__FreeBSDPkg}" # install packages we need. - INSTALL_AS_USER=$(whoami) $__RootfsDir/host/sbin/pkg -r $__RootfsDir -C $__RootfsDir/usr/local/etc/pkg.conf update - INSTALL_AS_USER=$(whoami) $__RootfsDir/host/sbin/pkg -r $__RootfsDir -C $__RootfsDir/usr/local/etc/pkg.conf install --yes $__FreeBSDPackages + INSTALL_AS_USER=$(whoami) "$__RootfsDir"/host/sbin/pkg -r "$__RootfsDir" -C "$__RootfsDir"/usr/local/etc/pkg.conf update + INSTALL_AS_USER=$(whoami) "$__RootfsDir"/host/sbin/pkg -r "$__RootfsDir" -C "$__RootfsDir"/usr/local/etc/pkg.conf install --yes $__FreeBSDPackages elif [[ "$__CodeName" == "illumos" ]]; then mkdir "$__RootfsDir/tmp" pushd "$__RootfsDir/tmp" - JOBS="$(getconf _NPROCESSORS_ONLN)" + JOBS=${MAXJOBS:="$(getconf _NPROCESSORS_ONLN)"} echo "Downloading sysroot." wget -O - https://github.com/illumos/sysroot/releases/download/20181213-de6af22ae73b-v1/illumos-sysroot-i386-20181213-de6af22ae73b-v1.tar.gz | tar -C "$__RootfsDir" -xzf - echo "Building binutils. Please wait.." wget -O - https://ftp.gnu.org/gnu/binutils/binutils-2.33.1.tar.bz2 | tar -xjf - mkdir build-binutils && cd build-binutils - ../binutils-2.33.1/configure --prefix="$__RootfsDir" --target="x86_64-sun-solaris2.10" --program-prefix="x86_64-illumos-" --with-sysroot="$__RootfsDir" + ../binutils-2.33.1/configure --prefix="$__RootfsDir" --target="${__illumosArch}-sun-solaris2.10" --program-prefix="${__illumosArch}-illumos-" --with-sysroot="$__RootfsDir" make -j "$JOBS" && make install && cd .. echo "Building gcc. Please wait.." wget -O - https://ftp.gnu.org/gnu/gcc/gcc-8.4.0/gcc-8.4.0.tar.xz | tar -xJf - @@ -345,7 +387,7 @@ elif [[ "$__CodeName" == "illumos" ]]; then CFLAGS_FOR_TARGET="-fPIC" export CFLAGS CXXFLAGS CXXFLAGS_FOR_TARGET CFLAGS_FOR_TARGET mkdir build-gcc && cd build-gcc - ../gcc-8.4.0/configure --prefix="$__RootfsDir" --target="x86_64-sun-solaris2.10" --program-prefix="x86_64-illumos-" --with-sysroot="$__RootfsDir" --with-gnu-as \ + ../gcc-8.4.0/configure --prefix="$__RootfsDir" --target="${__illumosArch}-sun-solaris2.10" --program-prefix="${__illumosArch}-illumos-" --with-sysroot="$__RootfsDir" --with-gnu-as \ --with-gnu-ld --disable-nls --disable-libgomp --disable-libquadmath --disable-libssp --disable-libvtv --disable-libcilkrts --disable-libada --disable-libsanitizer \ --disable-libquadmath-support --disable-shared --enable-tls make -j "$JOBS" && make install && cd .. @@ -353,14 +395,18 @@ elif [[ "$__CodeName" == "illumos" ]]; then if [[ "$__UseMirror" == 1 ]]; then BaseUrl=http://pkgsrc.smartos.skylime.net fi - BaseUrl="$BaseUrl"/packages/SmartOS/2020Q1/x86_64/All + BaseUrl="$BaseUrl/packages/SmartOS/trunk/${__illumosArch}/All" + echo "Downloading manifest" + wget "$BaseUrl" echo "Downloading dependencies." read -ra array <<<"$__IllumosPackages" for package in "${array[@]}"; do - echo "Installing $package..." + echo "Installing '$package'" + package="$(grep ">$package-[0-9]" All | sed -En 's/.*href="(.*)\.tgz".*/\1/p')" + echo "Resolved name '$package'" wget "$BaseUrl"/"$package".tgz ar -x "$package".tgz - tar --skip-old-files -xzf "$package".tmp.tgz -C "$__RootfsDir" 2>/dev/null + tar --skip-old-files -xzf "$package".tmp.tg* -C "$__RootfsDir" 2>/dev/null done echo "Cleaning up temporary files." popd @@ -371,26 +417,90 @@ elif [[ "$__CodeName" == "illumos" ]]; then wget -P "$__RootfsDir"/usr/include/net https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/io/bpf/net/dlt.h wget -P "$__RootfsDir"/usr/include/netpacket https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/inet/sockmods/netpacket/packet.h wget -P "$__RootfsDir"/usr/include/sys https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/sys/sdt.h -elif [[ -n $__CodeName ]]; then - qemu-debootstrap $__Keyring --arch $__UbuntuArch $__CodeName $__RootfsDir $__UbuntuRepo - cp $__CrossDir/$__BuildArch/sources.list.$__CodeName $__RootfsDir/etc/apt/sources.list - chroot $__RootfsDir apt-get update - chroot $__RootfsDir apt-get -f -y install - chroot $__RootfsDir apt-get -y install $__UbuntuPackages - chroot $__RootfsDir symlinks -cr /usr - chroot $__RootfsDir apt-get clean - - if [ $__SkipUnmount == 0 ]; then - umount $__RootfsDir/* || true +elif [[ "$__CodeName" == "haiku" ]]; then + JOBS=${MAXJOBS:="$(getconf _NPROCESSORS_ONLN)"} + + echo "Building Haiku sysroot for x86_64" + mkdir -p "$__RootfsDir/tmp" + cd "$__RootfsDir/tmp" + git clone -b hrev56235 https://review.haiku-os.org/haiku + git clone -b btrev43195 https://review.haiku-os.org/buildtools + cd "$__RootfsDir/tmp/buildtools" && git checkout 7487388f5110021d400b9f3b88e1a7f310dc066d + + # Fetch some unmerged patches + cd "$__RootfsDir/tmp/haiku" + ## Add development build profile (slimmer than nightly) + git fetch origin refs/changes/64/4164/1 && git -c commit.gpgsign=false cherry-pick FETCH_HEAD + + # Build jam + cd "$__RootfsDir/tmp/buildtools/jam" + make + + # Configure cross tools + echo "Building cross-compiler" + mkdir -p "$__RootfsDir/generated" + cd "$__RootfsDir/generated" + "$__RootfsDir/tmp/haiku/configure" -j"$JOBS" --sysroot "$__RootfsDir" --cross-tools-source "$__RootfsDir/tmp/buildtools" --build-cross-tools x86_64 + + # Build Haiku packages + echo "Building Haiku" + echo 'HAIKU_BUILD_PROFILE = "development-raw" ;' > UserProfileConfig + "$__RootfsDir/tmp/buildtools/jam/jam0" -j"$JOBS" -q '<build>package' '<repository>Haiku' + + BaseUrl="https://depot.haiku-os.org/__api/v2/pkg/get-pkg" + + # Download additional packages + echo "Downloading additional required packages" + read -ra array <<<"$__HaikuPackages" + for package in "${array[@]}"; do + echo "Downloading $package..." + # API documented here: https://github.com/haiku/haikudepotserver/blob/master/haikudepotserver-api2/src/main/resources/api2/pkg.yaml#L60 + # The schema here: https://github.com/haiku/haikudepotserver/blob/master/haikudepotserver-api2/src/main/resources/api2/pkg.yaml#L598 + hpkgDownloadUrl="$(wget -qO- --post-data='{"name":"'"$package"'","repositorySourceCode":"haikuports_x86_64","versionType":"LATEST","naturalLanguageCode":"en"}' \ + --header='Content-Type:application/json' "$BaseUrl" | jq -r '.result.versions[].hpkgDownloadURL')" + wget -P "$__RootfsDir/generated/download" "$hpkgDownloadUrl" + done + + # Setup the sysroot + echo "Setting up sysroot and extracting needed packages" + mkdir -p "$__RootfsDir/boot/system" + for file in "$__RootfsDir/generated/objects/haiku/x86_64/packaging/packages/"*.hpkg; do + "$__RootfsDir/generated/objects/linux/x86_64/release/tools/package/package" extract -C "$__RootfsDir/boot/system" "$file" + done + for file in "$__RootfsDir/generated/download/"*.hpkg; do + "$__RootfsDir/generated/objects/linux/x86_64/release/tools/package/package" extract -C "$__RootfsDir/boot/system" "$file" + done + + # Cleaning up temporary files + echo "Cleaning up temporary files" + rm -rf "$__RootfsDir/tmp" + for name in "$__RootfsDir/generated/"*; do + if [[ "$name" =~ "cross-tools-" ]]; then + : # Keep the cross-compiler + else + rm -rf "$name" + fi + done +elif [[ -n "$__CodeName" ]]; then + qemu-debootstrap $__Keyring --arch "$__UbuntuArch" "$__CodeName" "$__RootfsDir" "$__UbuntuRepo" + cp "$__CrossDir/$__BuildArch/sources.list.$__CodeName" "$__RootfsDir/etc/apt/sources.list" + chroot "$__RootfsDir" apt-get update + chroot "$__RootfsDir" apt-get -f -y install + chroot "$__RootfsDir" apt-get -y install $__UbuntuPackages + chroot "$__RootfsDir" symlinks -cr /usr + chroot "$__RootfsDir" apt-get clean + + if [[ "$__SkipUnmount" == "0" ]]; then + umount "$__RootfsDir"/* || true fi if [[ "$__BuildArch" == "armel" && "$__CodeName" == "jessie" ]]; then - pushd $__RootfsDir - patch -p1 < $__CrossDir/$__BuildArch/armel.jessie.patch + pushd "$__RootfsDir" + patch -p1 < "$__CrossDir/$__BuildArch/armel.jessie.patch" popd fi elif [[ "$__Tizen" == "tizen" ]]; then - ROOTFS_DIR=$__RootfsDir $__CrossDir/$__BuildArch/tizen-build-rootfs.sh + ROOTFS_DIR="$__RootfsDir" "$__CrossDir/$__BuildArch/tizen-build-rootfs.sh" else echo "Unsupported target platform." usage; diff --git a/eng/common/cross/riscv64/sources.list.sid b/eng/common/cross/riscv64/sources.list.sid new file mode 100644 index 0000000000..65f730d224 --- /dev/null +++ b/eng/common/cross/riscv64/sources.list.sid @@ -0,0 +1 @@ +deb http://deb.debian.org/debian-ports sid main diff --git a/eng/common/cross/toolchain.cmake b/eng/common/cross/toolchain.cmake index eaeeab38fa..561576be97 100644 --- a/eng/common/cross/toolchain.cmake +++ b/eng/common/cross/toolchain.cmake @@ -7,6 +7,8 @@ if(EXISTS ${CROSS_ROOTFS}/bin/freebsd-version) elseif(EXISTS ${CROSS_ROOTFS}/usr/platform/i86pc) set(CMAKE_SYSTEM_NAME SunOS) set(ILLUMOS 1) +elseif(EXISTS ${CROSS_ROOTFS}/boot/system/develop/headers/config/HaikuConfig.h) + set(CMAKE_SYSTEM_NAME Haiku) else() set(CMAKE_SYSTEM_NAME Linux) set(LINUX 1) @@ -19,13 +21,7 @@ elseif(EXISTS ${CROSS_ROOTFS}/android_platform) set(ANDROID 1) endif() -if(TARGET_ARCH_NAME STREQUAL "armel") - set(CMAKE_SYSTEM_PROCESSOR armv7l) - set(TOOLCHAIN "arm-linux-gnueabi") - if(TIZEN) - set(TIZEN_TOOLCHAIN "armv7l-tizen-linux-gnueabi/9.2.0") - endif() -elseif(TARGET_ARCH_NAME STREQUAL "arm") +if(TARGET_ARCH_NAME STREQUAL "arm") set(CMAKE_SYSTEM_PROCESSOR armv7l) if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv7-alpine-linux-musleabihf) set(TOOLCHAIN "armv7-alpine-linux-musleabihf") @@ -37,43 +33,62 @@ elseif(TARGET_ARCH_NAME STREQUAL "arm") if(TIZEN) set(TIZEN_TOOLCHAIN "armv7hl-tizen-linux-gnueabihf/9.2.0") endif() -elseif(TARGET_ARCH_NAME STREQUAL "armv6") - set(CMAKE_SYSTEM_PROCESSOR armv6l) - if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf) - set(TOOLCHAIN "armv6-alpine-linux-musleabihf") - else() - set(TOOLCHAIN "arm-linux-gnueabihf") - endif() elseif(TARGET_ARCH_NAME STREQUAL "arm64") set(CMAKE_SYSTEM_PROCESSOR aarch64) if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/aarch64-alpine-linux-musl) set(TOOLCHAIN "aarch64-alpine-linux-musl") - else() + elseif(LINUX) set(TOOLCHAIN "aarch64-linux-gnu") + if(TIZEN) + set(TIZEN_TOOLCHAIN "aarch64-tizen-linux-gnu/9.2.0") + endif() + elseif(FREEBSD) + set(triple "aarch64-unknown-freebsd12") endif() +elseif(TARGET_ARCH_NAME STREQUAL "armel") + set(CMAKE_SYSTEM_PROCESSOR armv7l) + set(TOOLCHAIN "arm-linux-gnueabi") if(TIZEN) - set(TIZEN_TOOLCHAIN "aarch64-tizen-linux-gnu/9.2.0") + set(TIZEN_TOOLCHAIN "armv7l-tizen-linux-gnueabi/9.2.0") + endif() +elseif(TARGET_ARCH_NAME STREQUAL "armv6") + set(CMAKE_SYSTEM_PROCESSOR armv6l) + if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf) + set(TOOLCHAIN "armv6-alpine-linux-musleabihf") + else() + set(TOOLCHAIN "arm-linux-gnueabihf") endif() elseif(TARGET_ARCH_NAME STREQUAL "ppc64le") set(CMAKE_SYSTEM_PROCESSOR ppc64le) set(TOOLCHAIN "powerpc64le-linux-gnu") +elseif(TARGET_ARCH_NAME STREQUAL "riscv64") + set(CMAKE_SYSTEM_PROCESSOR riscv64) + set(TOOLCHAIN "riscv64-linux-gnu") elseif(TARGET_ARCH_NAME STREQUAL "s390x") set(CMAKE_SYSTEM_PROCESSOR s390x) set(TOOLCHAIN "s390x-linux-gnu") +elseif(TARGET_ARCH_NAME STREQUAL "x64") + set(CMAKE_SYSTEM_PROCESSOR x86_64) + if(LINUX) + set(TOOLCHAIN "x86_64-linux-gnu") + if(TIZEN) + set(TIZEN_TOOLCHAIN "x86_64-tizen-linux-gnu/9.2.0") + endif() + elseif(FREEBSD) + set(triple "x86_64-unknown-freebsd12") + elseif(ILLUMOS) + set(TOOLCHAIN "x86_64-illumos") + elseif(HAIKU) + set(TOOLCHAIN "x64_64-unknown-haiku") + endif() elseif(TARGET_ARCH_NAME STREQUAL "x86") set(CMAKE_SYSTEM_PROCESSOR i686) set(TOOLCHAIN "i686-linux-gnu") if(TIZEN) set(TIZEN_TOOLCHAIN "i586-tizen-linux-gnu/9.2.0") endif() -elseif (FREEBSD) - set(CMAKE_SYSTEM_PROCESSOR "x86_64") - set(triple "x86_64-unknown-freebsd12") -elseif (ILLUMOS) - set(CMAKE_SYSTEM_PROCESSOR "x86_64") - set(TOOLCHAIN "x86_64-illumos") else() - message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only armel, arm, armv6, arm64, ppc64le, s390x and x86 are supported!") + message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only arm, arm64, armel, armv6, ppc64le, riscv64, s390x, x64 and x86 are supported!") endif() if(DEFINED ENV{TOOLCHAIN}) @@ -159,6 +174,41 @@ elseif(ILLUMOS) set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lssp") set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lssp") +elseif(HAIKU) + set(CMAKE_SYSROOT "${CROSS_ROOTFS}") + + set(TOOLSET_PREFIX ${TOOLCHAIN}-) + function(locate_toolchain_exec exec var) + string(TOUPPER ${exec} EXEC_UPPERCASE) + if(NOT "$ENV{CLR_${EXEC_UPPERCASE}}" STREQUAL "") + set(${var} "$ENV{CLR_${EXEC_UPPERCASE}}" PARENT_SCOPE) + return() + endif() + + set(SEARCH_PATH "${CROSS_ROOTFS}/generated/cross-tools-x86_64/bin") + + find_program(EXEC_LOCATION_${exec} + PATHS ${SEARCH_PATH} + NAMES + "${TOOLSET_PREFIX}${exec}${CLR_CMAKE_COMPILER_FILE_NAME_VERSION}" + "${TOOLSET_PREFIX}${exec}") + + if (EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND") + message(FATAL_ERROR "Unable to find toolchain executable. Name: ${exec}, Prefix: ${TOOLSET_PREFIX}.") + endif() + set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE) + endfunction() + + set(CMAKE_SYSTEM_PREFIX_PATH "${CROSS_ROOTFS}") + + locate_toolchain_exec(gcc CMAKE_C_COMPILER) + locate_toolchain_exec(g++ CMAKE_CXX_COMPILER) + + set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lssp") + set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lssp") + + # let CMake set up the correct search paths + include(Platform/Haiku) else() set(CMAKE_SYSROOT "${CROSS_ROOTFS}") @@ -218,7 +268,7 @@ endif() # Specify compile options -if((TARGET_ARCH_NAME MATCHES "^(arm|armv6|armel|arm64|ppc64le|s390x)$" AND NOT ANDROID) OR ILLUMOS) +if((TARGET_ARCH_NAME MATCHES "^(arm|arm64|armel|armv6|ppc64le|riscv64|s390x)$" AND NOT ANDROID AND NOT FREEBSD) OR ILLUMOS OR HAIKU) set(CMAKE_C_COMPILER_TARGET ${TOOLCHAIN}) set(CMAKE_CXX_COMPILER_TARGET ${TOOLCHAIN}) set(CMAKE_ASM_COMPILER_TARGET ${TOOLCHAIN}) diff --git a/eng/common/cross/x86/sources.list.focal b/eng/common/cross/x86/sources.list.focal new file mode 100644 index 0000000000..99d5731330 --- /dev/null +++ b/eng/common/cross/x86/sources.list.focal @@ -0,0 +1,11 @@ +deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe +deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe + +deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe +deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe + +deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted +deb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted + +deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse +deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse diff --git a/eng/common/cross/x86/sources.list.jammy b/eng/common/cross/x86/sources.list.jammy new file mode 100644 index 0000000000..af1c1feaea --- /dev/null +++ b/eng/common/cross/x86/sources.list.jammy @@ -0,0 +1,11 @@ +deb http://archive.ubuntu.com/ubuntu/ jammy main restricted universe +deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted universe + +deb http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe +deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe + +deb http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted +deb-src http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted + +deb http://archive.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse +deb-src http://archive.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse diff --git a/eng/common/generate-locproject.ps1 b/eng/common/generate-locproject.ps1 index 25e97ac007..dbf2ab4ee7 100644 --- a/eng/common/generate-locproject.ps1 +++ b/eng/common/generate-locproject.ps1 @@ -10,9 +10,7 @@ Param( Set-StrictMode -Version 2.0 $ErrorActionPreference = "Stop" -. $PSScriptRoot\tools.ps1 - -Import-Module -Name (Join-Path $PSScriptRoot 'native\CommonLibrary.psm1') +. $PSScriptRoot\pipeline-logging-functions.ps1 $exclusionsFilePath = "$SourcesDirectory\eng\Localize\LocExclusions.json" $exclusions = @{ Exclusions = @() } @@ -28,13 +26,15 @@ $jsonFiles = @() $jsonTemplateFiles = Get-ChildItem -Recurse -Path "$SourcesDirectory" | Where-Object { $_.FullName -Match "\.template\.config\\localize\\.+\.en\.json" } # .NET templating pattern $jsonTemplateFiles | ForEach-Object { $null = $_.Name -Match "(.+)\.[\w-]+\.json" # matches '[filename].[langcode].json - + $destinationFile = "$($_.Directory.FullName)\$($Matches.1).json" $jsonFiles += Copy-Item "$($_.FullName)" -Destination $destinationFile -PassThru } $jsonWinformsTemplateFiles = Get-ChildItem -Recurse -Path "$SourcesDirectory" | Where-Object { $_.FullName -Match "en\\strings\.json" } # current winforms pattern +$wxlFiles = Get-ChildItem -Recurse -Path "$SourcesDirectory" | Where-Object { $_.FullName -Match "\\.+\.wxl" -And -Not( $_.Directory.Name -Match "\d{4}" ) } # localized files live in four digit lang ID directories; this excludes them + $xlfFiles = @() $allXlfFiles = Get-ChildItem -Recurse -Path "$SourcesDirectory\*\*.xlf" @@ -46,7 +46,7 @@ if ($allXlfFiles) { } $langXlfFiles | ForEach-Object { $null = $_.Name -Match "(.+)\.[\w-]+\.xlf" # matches '[filename].[langcode].xlf - + $destinationFile = "$($_.Directory.FullName)\$($Matches.1).xlf" $xlfFiles += Copy-Item "$($_.FullName)" -Destination $destinationFile -PassThru } @@ -59,10 +59,10 @@ $locJson = @{ LanguageSet = $LanguageSet LocItems = @( $locFiles | ForEach-Object { - $outputPath = "$(($_.DirectoryName | Resolve-Path -Relative) + "\")" + $outputPath = "$(($_.DirectoryName | Resolve-Path -Relative) + "\")" $continue = $true foreach ($exclusion in $exclusions.Exclusions) { - if ($outputPath.Contains($exclusion)) + if ($_.FullName.Contains($exclusion)) { $continue = $false } @@ -79,8 +79,7 @@ $locJson = @{ CopyOption = "LangIDOnPath" OutputPath = "$($_.Directory.Parent.FullName | Resolve-Path -Relative)\" } - } - else { + } else { return @{ SourceFile = $sourceFile CopyOption = "LangIDOnName" @@ -90,6 +89,32 @@ $locJson = @{ } } ) + }, + @{ + LanguageSet = $LanguageSet + CloneLanguageSet = "WiX_CloneLanguages" + LssFiles = @( "wxl_loc.lss" ) + LocItems = @( + $wxlFiles | ForEach-Object { + $outputPath = "$($_.Directory.FullName | Resolve-Path -Relative)\" + $continue = $true + foreach ($exclusion in $exclusions.Exclusions) { + if ($_.FullName.Contains($exclusion)) + { + $continue = $false + } + } + $sourceFile = ($_.FullName | Resolve-Path -Relative) + if ($continue) + { + return @{ + SourceFile = $sourceFile + CopyOption = "LangIDOnPath" + OutputPath = $outputPath + } + } + } + ) } ) } @@ -108,10 +133,10 @@ else { if ((Get-FileHash "$SourcesDirectory\eng\Localize\LocProject-generated.json").Hash -ne (Get-FileHash "$SourcesDirectory\eng\Localize\LocProject.json").Hash) { Write-PipelineTelemetryError -Category "OneLocBuild" -Message "Existing LocProject.json differs from generated LocProject.json. Download LocProject-generated.json and compare them." - + exit 1 } else { Write-Host "Generated LocProject.json and current LocProject.json are identical." } -} \ No newline at end of file +} diff --git a/eng/common/generate-sbom-prep.ps1 b/eng/common/generate-sbom-prep.ps1 index a733a88858..3e5c1c74a1 100644 --- a/eng/common/generate-sbom-prep.ps1 +++ b/eng/common/generate-sbom-prep.ps1 @@ -2,6 +2,8 @@ Param( [Parameter(Mandatory=$true)][string] $ManifestDirPath # Manifest directory where sbom will be placed ) +. $PSScriptRoot\pipeline-logging-functions.ps1 + Write-Host "Creating dir $ManifestDirPath" # create directory for sbom manifest to be placed if (!(Test-Path -path $ManifestDirPath)) diff --git a/eng/common/generate-sbom-prep.sh b/eng/common/generate-sbom-prep.sh index f6c7745314..d5c76dc827 100644 --- a/eng/common/generate-sbom-prep.sh +++ b/eng/common/generate-sbom-prep.sh @@ -2,6 +2,18 @@ source="${BASH_SOURCE[0]}" +# resolve $SOURCE until the file is no longer a symlink +while [[ -h $source ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" +. $scriptroot/pipeline-logging-functions.sh + manifest_dir=$1 if [ ! -d "$manifest_dir" ] ; then diff --git a/eng/common/init-tools-native.ps1 b/eng/common/init-tools-native.ps1 index 24a5e65de1..ac42f04a9d 100644 --- a/eng/common/init-tools-native.ps1 +++ b/eng/common/init-tools-native.ps1 @@ -87,6 +87,7 @@ try { $NativeTools.PSObject.Properties | ForEach-Object { $ToolName = $_.Name $ToolVersion = $_.Value + $InstalledTools = @{} if ((Get-Command "$ToolName" -ErrorAction SilentlyContinue) -eq $null) { if ($ToolVersion -eq "latest") { @@ -97,11 +98,12 @@ try { Write-Error "Arcade tools directory '$ArcadeToolsDirectory' was not found; artifacts were not properly installed." exit 1 } - $ToolDirectory = (Get-ChildItem -Path "$ArcadeToolsDirectory" -Filter "$ToolName-$ToolVersion*" | Sort-Object -Descending)[0] - if ([string]::IsNullOrWhiteSpace($ToolDirectory)) { + $ToolDirectories = (Get-ChildItem -Path "$ArcadeToolsDirectory" -Filter "$ToolName-$ToolVersion*" | Sort-Object -Descending) + if ($ToolDirectories -eq $null) { Write-Error "Unable to find directory for $ToolName $ToolVersion; please make sure the tool is installed on this image." exit 1 } + $ToolDirectory = $ToolDirectories[0] $BinPathFile = "$($ToolDirectory.FullName)\binpath.txt" if (-not (Test-Path -Path "$BinPathFile")) { Write-Error "Unable to find binpath.txt in '$($ToolDirectory.FullName)' ($ToolName $ToolVersion); artifact is either installed incorrectly or is not a bootstrappable tool." @@ -111,9 +113,10 @@ try { $ToolPath = Convert-Path -Path $BinPath Write-Host "Adding $ToolName to the path ($ToolPath)..." Write-Host "##vso[task.prependpath]$ToolPath" + $InstalledTools += @{ $ToolName = $ToolDirectory.FullName } } } - exit 0 + return $InstalledTools } else { $NativeTools.PSObject.Properties | ForEach-Object { $ToolName = $_.Name diff --git a/eng/common/native/init-compiler.sh b/eng/common/native/init-compiler.sh index 6d7ba15e5f..41a26d802a 100644 --- a/eng/common/native/init-compiler.sh +++ b/eng/common/native/init-compiler.sh @@ -71,7 +71,7 @@ if [[ -z "$CLR_CC" ]]; then # Set default versions if [[ -z "$majorVersion" ]]; then # note: gcc (all versions) and clang versions higher than 6 do not have minor version in file name, if it is zero. - if [[ "$compiler" == "clang" ]]; then versions=( 13 12 11 10 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5 ) + if [[ "$compiler" == "clang" ]]; then versions=( 15 14 13 12 11 10 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5 ) elif [[ "$compiler" == "gcc" ]]; then versions=( 12 11 10 9 8 7 6 5 4.9 ); fi for version in "${versions[@]}"; do diff --git a/eng/common/sdk-task.ps1 b/eng/common/sdk-task.ps1 index 119a6c660d..c35087a060 100644 --- a/eng/common/sdk-task.ps1 +++ b/eng/common/sdk-task.ps1 @@ -64,7 +64,7 @@ try { $GlobalJson.tools | Add-Member -Name "vs" -Value (ConvertFrom-Json "{ `"version`": `"16.5`" }") -MemberType NoteProperty } if( -not ($GlobalJson.tools.PSObject.Properties.Name -match "xcopy-msbuild" )) { - $GlobalJson.tools | Add-Member -Name "xcopy-msbuild" -Value "17.1.0" -MemberType NoteProperty + $GlobalJson.tools | Add-Member -Name "xcopy-msbuild" -Value "17.2.1" -MemberType NoteProperty } if ($GlobalJson.tools."xcopy-msbuild".Trim() -ine "none") { $xcopyMSBuildToolsFolder = InitializeXCopyMSBuild $GlobalJson.tools."xcopy-msbuild" -install $true diff --git a/eng/common/sdl/NuGet.config b/eng/common/sdl/NuGet.config index 0c5451c114..3849bdb3cf 100644 --- a/eng/common/sdl/NuGet.config +++ b/eng/common/sdl/NuGet.config @@ -7,6 +7,11 @@ <clear /> <add key="guardian" value="https://securitytools.pkgs.visualstudio.com/_packaging/Guardian/nuget/v3/index.json" /> </packageSources> + <packageSourceMapping> + <packageSource key="guardian"> + <package pattern="microsoft.guardian.cli" /> + </packageSource> + </packageSourceMapping> <disabledPackageSources> <clear /> </disabledPackageSources> diff --git a/eng/common/sdl/sdl.ps1 b/eng/common/sdl/sdl.ps1 new file mode 100644 index 0000000000..648c5068d7 --- /dev/null +++ b/eng/common/sdl/sdl.ps1 @@ -0,0 +1,38 @@ + +function Install-Gdn { + param( + [Parameter(Mandatory=$true)] + [string]$Path, + + # If omitted, install the latest version of Guardian, otherwise install that specific version. + [string]$Version + ) + + $ErrorActionPreference = 'Stop' + Set-StrictMode -Version 2.0 + $disableConfigureToolsetImport = $true + $global:LASTEXITCODE = 0 + + # `tools.ps1` checks $ci to perform some actions. Since the SDL + # scripts don't necessarily execute in the same agent that run the + # build.ps1/sh script this variable isn't automatically set. + $ci = $true + . $PSScriptRoot\..\tools.ps1 + + $argumentList = @("install", "Microsoft.Guardian.Cli", "-Source https://securitytools.pkgs.visualstudio.com/_packaging/Guardian/nuget/v3/index.json", "-OutputDirectory $Path", "-NonInteractive", "-NoCache") + + if ($Version) { + $argumentList += "-Version $Version" + } + + Start-Process nuget -Verbose -ArgumentList $argumentList -NoNewWindow -Wait + + $gdnCliPath = Get-ChildItem -Filter guardian.cmd -Recurse -Path $Path + + if (!$gdnCliPath) + { + Write-PipelineTelemetryError -Category 'Sdl' -Message 'Failure installing Guardian' + } + + return $gdnCliPath.FullName +} \ No newline at end of file diff --git a/eng/common/templates/job/execute-sdl.yml b/eng/common/templates/job/execute-sdl.yml index 24cec0424e..781a41c940 100644 --- a/eng/common/templates/job/execute-sdl.yml +++ b/eng/common/templates/job/execute-sdl.yml @@ -54,12 +54,14 @@ jobs: # If it's not devdiv, it's dnceng ${{ if ne(variables['System.TeamProject'], 'DevDiv') }}: name: NetCore1ESPool-Internal - demands: ImageOverride -equals Build.Server.Amd64.VS2019 + demands: ImageOverride -equals windows.vs2019.amd64 steps: - checkout: self clean: true - - template: /eng/common/templates/post-build/setup-maestro-vars.yml + # If the template caller didn't provide an AzDO parameter, set them all up as Maestro vars. + - ${{ if not(and(parameters.AzDOProjectName, parameters.AzDOPipelineId, parameters.AzDOBuildId)) }}: + - template: /eng/common/templates/post-build/setup-maestro-vars.yml - ${{ if ne(parameters.downloadArtifacts, 'false')}}: - ${{ if ne(parameters.artifactNames, '') }}: diff --git a/eng/common/templates/job/job.yml b/eng/common/templates/job/job.yml index e3ba939801..459f3c4fcb 100644 --- a/eng/common/templates/job/job.yml +++ b/eng/common/templates/job/job.yml @@ -140,6 +140,7 @@ jobs: languages: ${{ coalesce(parameters.richCodeNavigationLanguage, 'csharp') }} environment: ${{ coalesce(parameters.richCodeNavigationEnvironment, 'production') }} richNavLogOutputDirectory: $(Build.SourcesDirectory)/artifacts/bin + uploadRichNavArtifacts: ${{ coalesce(parameters.richCodeNavigationUploadArtifacts, false) }} continueOnError: true - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), ne(parameters.disableComponentGovernance, 'true')) }}: @@ -183,24 +184,6 @@ jobs: displayName: Publish logs continueOnError: true condition: always() - - ${{ if or(eq(parameters.artifacts.publish.manifests, 'true'), ne(parameters.artifacts.publish.manifests, '')) }}: - - ${{ if and(ne(parameters.enablePublishUsingPipelines, 'true'), eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: - - task: CopyFiles@2 - displayName: Gather Asset Manifests - inputs: - SourceFolder: '$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/AssetManifest' - TargetFolder: '$(Build.ArtifactStagingDirectory)/AssetManifests' - continueOnError: ${{ parameters.continueOnError }} - condition: and(succeeded(), eq(variables['_DotNetPublishToBlobFeed'], 'true')) - - - task: PublishBuildArtifacts@1 - displayName: Push Asset Manifests - inputs: - PathtoPublish: '$(Build.ArtifactStagingDirectory)/AssetManifests' - PublishLocation: Container - ArtifactName: AssetManifests - continueOnError: ${{ parameters.continueOnError }} - condition: and(succeeded(), eq(variables['_DotNetPublishToBlobFeed'], 'true')) - ${{ if ne(parameters.enablePublishBuildArtifacts, 'false') }}: - task: PublishBuildArtifacts@1 @@ -234,24 +217,6 @@ jobs: mergeTestResults: ${{ parameters.mergeTestResults }} continueOnError: true condition: always() - - - ${{ if and(eq(parameters.enablePublishBuildAssets, true), ne(parameters.enablePublishUsingPipelines, 'true'), eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: - - task: CopyFiles@2 - displayName: Gather Asset Manifests - inputs: - SourceFolder: '$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/AssetManifest' - TargetFolder: '$(Build.StagingDirectory)/AssetManifests' - continueOnError: ${{ parameters.continueOnError }} - condition: and(succeeded(), eq(variables['_DotNetPublishToBlobFeed'], 'true')) - - - task: PublishBuildArtifacts@1 - displayName: Push Asset Manifests - inputs: - PathtoPublish: '$(Build.StagingDirectory)/AssetManifests' - PublishLocation: Container - ArtifactName: AssetManifests - continueOnError: ${{ parameters.continueOnError }} - condition: and(succeeded(), eq(variables['_DotNetPublishToBlobFeed'], 'true')) - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), eq(parameters.enableSbom, 'true')) }}: - template: /eng/common/templates/steps/generate-sbom.yml diff --git a/eng/common/templates/job/onelocbuild.yml b/eng/common/templates/job/onelocbuild.yml index 3bcd243c46..6c523b714f 100644 --- a/eng/common/templates/job/onelocbuild.yml +++ b/eng/common/templates/job/onelocbuild.yml @@ -41,7 +41,7 @@ jobs: # If it's not devdiv, it's dnceng ${{ if ne(variables['System.TeamProject'], 'DevDiv') }}: name: NetCore1ESPool-Internal - demands: ImageOverride -equals Build.Server.Amd64.VS2019 + demands: ImageOverride -equals windows.vs2019.amd64 variables: - group: OneLocBuildVariables # Contains the CeapexPat and GithubPat diff --git a/eng/common/templates/job/source-build.yml b/eng/common/templates/job/source-build.yml index 5cd5325d7b..88f6f75a62 100644 --- a/eng/common/templates/job/source-build.yml +++ b/eng/common/templates/job/source-build.yml @@ -46,7 +46,7 @@ jobs: # source-build builds run in Docker, including the default managed platform. pool: ${{ if eq(variables['System.TeamProject'], 'public') }}: - name: NetCore1ESPool-Public + name: NetCore-Public demands: ImageOverride -equals Build.Ubuntu.1804.Amd64.Open ${{ if eq(variables['System.TeamProject'], 'internal') }}: name: NetCore1ESPool-Internal diff --git a/eng/common/templates/job/source-index-stage1.yml b/eng/common/templates/job/source-index-stage1.yml index c2d51098d3..21fd12276b 100644 --- a/eng/common/templates/job/source-index-stage1.yml +++ b/eng/common/templates/job/source-index-stage1.yml @@ -1,6 +1,6 @@ parameters: runAsPublic: false - sourceIndexPackageVersion: 1.0.1-20210614.1 + sourceIndexPackageVersion: 1.0.1-20220804.1 sourceIndexPackageSource: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json sourceIndexBuildCommand: powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "eng/common/build.ps1 -restore -build -binarylog -ci" preSteps: [] @@ -28,11 +28,11 @@ jobs: ${{ if eq(parameters.pool, '') }}: pool: ${{ if eq(variables['System.TeamProject'], 'public') }}: - name: NetCore1ESPool-Public - demands: ImageOverride -equals Build.Server.Amd64.VS2019.Open + name: NetCore-Public + demands: ImageOverride -equals windows.vs2019.amd64.open ${{ if eq(variables['System.TeamProject'], 'internal') }}: name: NetCore1ESPool-Internal - demands: ImageOverride -equals Build.Server.Amd64.VS2019 + demands: ImageOverride -equals windows.vs2019.amd64 steps: - ${{ each preStep in parameters.preSteps }}: diff --git a/eng/common/templates/jobs/jobs.yml b/eng/common/templates/jobs/jobs.yml index 2cca53c2d1..64e5929f22 100644 --- a/eng/common/templates/jobs/jobs.yml +++ b/eng/common/templates/jobs/jobs.yml @@ -96,7 +96,7 @@ jobs: # If it's not devdiv, it's dnceng ${{ if ne(variables['System.TeamProject'], 'DevDiv') }}: name: NetCore1ESPool-Internal - demands: ImageOverride -equals Build.Server.Amd64.VS2019 + demands: ImageOverride -equals windows.vs2019.amd64 runAsPublic: ${{ parameters.runAsPublic }} publishUsingPipelines: ${{ parameters.enablePublishUsingPipelines }} diff --git a/eng/common/templates/post-build/post-build.yml b/eng/common/templates/post-build/post-build.yml index 5a9056f6b2..87fcae940c 100644 --- a/eng/common/templates/post-build/post-build.yml +++ b/eng/common/templates/post-build/post-build.yml @@ -49,6 +49,7 @@ parameters: type: object default: enable: false + publishGdn: false continueOnError: false params: '' artifactNames: '' @@ -106,7 +107,7 @@ stages: # If it's not devdiv, it's dnceng ${{ else }}: name: NetCore1ESPool-Internal - demands: ImageOverride -equals Build.Server.Amd64.VS2019 + demands: ImageOverride -equals windows.vs2019.amd64 steps: - template: setup-maestro-vars.yml @@ -143,7 +144,7 @@ stages: # If it's not devdiv, it's dnceng ${{ else }}: name: NetCore1ESPool-Internal - demands: ImageOverride -equals Build.Server.Amd64.VS2019 + demands: ImageOverride -equals windows.vs2019.amd64 steps: - template: setup-maestro-vars.yml parameters: @@ -203,7 +204,7 @@ stages: # If it's not devdiv, it's dnceng ${{ else }}: name: NetCore1ESPool-Internal - demands: ImageOverride -equals Build.Server.Amd64.VS2019 + demands: ImageOverride -equals windows.vs2019.amd64 steps: - template: setup-maestro-vars.yml parameters: @@ -235,6 +236,7 @@ stages: - template: /eng/common/templates/job/execute-sdl.yml parameters: enable: ${{ parameters.SDLValidationParameters.enable }} + publishGuardianDirectoryToPipeline: ${{ parameters.SDLValidationParameters.publishGdn }} additionalParameters: ${{ parameters.SDLValidationParameters.params }} continueOnError: ${{ parameters.SDLValidationParameters.continueOnError }} artifactNames: ${{ parameters.SDLValidationParameters.artifactNames }} @@ -261,7 +263,7 @@ stages: # If it's not devdiv, it's dnceng ${{ else }}: name: NetCore1ESPool-Internal - demands: ImageOverride -equals Build.Server.Amd64.VS2019 + demands: ImageOverride -equals windows.vs2019.amd64 steps: - template: setup-maestro-vars.yml parameters: diff --git a/eng/common/templates/steps/execute-sdl.yml b/eng/common/templates/steps/execute-sdl.yml index 7b8ee18a28..9dd5709f66 100644 --- a/eng/common/templates/steps/execute-sdl.yml +++ b/eng/common/templates/steps/execute-sdl.yml @@ -8,29 +8,28 @@ parameters: condition: '' steps: -- ${{ if ne(parameters.overrideGuardianVersion, '') }}: - - powershell: | - $content = Get-Content $(GuardianPackagesConfigFile) - - Write-Host "packages.config content was:`n$content" - - $content = $content.Replace('$(DefaultGuardianVersion)', '$(GuardianVersion)') - $content | Set-Content $(GuardianPackagesConfigFile) - - Write-Host "packages.config content updated to:`n$content" - displayName: Use overridden Guardian version ${{ parameters.overrideGuardianVersion }} +- task: NuGetAuthenticate@1 + inputs: + nuGetServiceConnections: GuardianConnect - task: NuGetToolInstaller@1 displayName: 'Install NuGet.exe' -- task: NuGetCommand@2 - displayName: 'Install Guardian' - inputs: - restoreSolution: $(Build.SourcesDirectory)\eng\common\sdl\packages.config - feedsToUse: config - nugetConfigPath: $(Build.SourcesDirectory)\eng\common\sdl\NuGet.config - externalFeedCredentials: GuardianConnect - restoreDirectory: $(Build.SourcesDirectory)\.packages +- ${{ if ne(parameters.overrideGuardianVersion, '') }}: + - pwsh: | + Set-Location -Path $(Build.SourcesDirectory)\eng\common\sdl + . .\sdl.ps1 + $guardianCliLocation = Install-Gdn -Path $(Build.SourcesDirectory)\.artifacts -Version ${{ parameters.overrideGuardianVersion }} + Write-Host "##vso[task.setvariable variable=GuardianCliLocation]$guardianCliLocation" + displayName: Install Guardian (Overridden) + +- ${{ if eq(parameters.overrideGuardianVersion, '') }}: + - pwsh: | + Set-Location -Path $(Build.SourcesDirectory)\eng\common\sdl + . .\sdl.ps1 + $guardianCliLocation = Install-Gdn -Path $(Build.SourcesDirectory)\.artifacts + Write-Host "##vso[task.setvariable variable=GuardianCliLocation]$guardianCliLocation" + displayName: Install Guardian - ${{ if ne(parameters.overrideParameters, '') }}: - powershell: ${{ parameters.executeAllSdlToolsScript }} ${{ parameters.overrideParameters }} @@ -40,7 +39,7 @@ steps: - ${{ if eq(parameters.overrideParameters, '') }}: - powershell: ${{ parameters.executeAllSdlToolsScript }} - -GuardianPackageName Microsoft.Guardian.Cli.$(GuardianVersion) + -GuardianCliLocation $(GuardianCliLocation) -NugetPackageDirectory $(Build.SourcesDirectory)\.packages -AzureDevOpsAccessToken $(dn-bot-dotnet-build-rw-code-rw) ${{ parameters.additionalParameters }} @@ -62,7 +61,28 @@ steps: c i condition: succeededOrFailed() + - publish: $(Agent.BuildDirectory)/.gdn artifact: GuardianConfiguration displayName: Publish GuardianConfiguration + condition: succeededOrFailed() + + # Publish the SARIF files in a container named CodeAnalysisLogs to enable integration + # with the "SARIF SAST Scans Tab" Azure DevOps extension + - task: CopyFiles@2 + displayName: Copy SARIF files + inputs: + flattenFolders: true + sourceFolder: $(Agent.BuildDirectory)/.gdn/rc/ + contents: '**/*.sarif' + targetFolder: $(Build.SourcesDirectory)/CodeAnalysisLogs + condition: succeededOrFailed() + + # Use PublishBuildArtifacts because the SARIF extension only checks this case + # see microsoft/sarif-azuredevops-extension#4 + - task: PublishBuildArtifacts@1 + displayName: Publish SARIF files to CodeAnalysisLogs container + inputs: + pathToPublish: $(Build.SourcesDirectory)/CodeAnalysisLogs + artifactName: CodeAnalysisLogs condition: succeededOrFailed() \ No newline at end of file diff --git a/eng/common/templates/steps/send-to-helix.yml b/eng/common/templates/steps/send-to-helix.yml index 09a223989f..3eb7e2d5f8 100644 --- a/eng/common/templates/steps/send-to-helix.yml +++ b/eng/common/templates/steps/send-to-helix.yml @@ -3,7 +3,7 @@ parameters: HelixSource: 'pr/default' # required -- sources must start with pr/, official/, prodcon/, or agent/ HelixType: 'tests/default/' # required -- Helix telemetry which identifies what type of data this is; should include "test" for clarity and must end in '/' HelixBuild: $(Build.BuildNumber) # required -- the build number Helix will use to identify this -- automatically set to the AzDO build number - HelixTargetQueues: '' # required -- semicolon delimited list of Helix queues to test on; see https://helix.dot.net/ for a list of queues + HelixTargetQueues: '' # required -- semicolon-delimited list of Helix queues to test on; see https://helix.dot.net/ for a list of queues HelixAccessToken: '' # required -- access token to make Helix API requests; should be provided by the appropriate variable group HelixConfiguration: '' # optional -- additional property attached to a job HelixPreCommands: '' # optional -- commands to run before Helix work item execution @@ -12,7 +12,7 @@ parameters: WorkItemCommand: '' # optional -- a command to execute on the payload; requires WorkItemDirectory; incompatible with XUnitProjects WorkItemTimeout: '' # optional -- a timeout in TimeSpan.Parse-ready value (e.g. 00:02:00) for the work item command; requires WorkItemDirectory; incompatible with XUnitProjects CorrelationPayloadDirectory: '' # optional -- a directory to zip up and send to Helix as a correlation payload - XUnitProjects: '' # optional -- semicolon delimited list of XUnitProjects to parse and send to Helix; requires XUnitRuntimeTargetFramework, XUnitPublishTargetFramework, XUnitRunnerVersion, and IncludeDotNetCli=true + XUnitProjects: '' # optional -- semicolon-delimited list of XUnitProjects to parse and send to Helix; requires XUnitRuntimeTargetFramework, XUnitPublishTargetFramework, XUnitRunnerVersion, and IncludeDotNetCli=true XUnitWorkItemTimeout: '' # optional -- the workitem timeout in seconds for all workitems created from the xUnit projects specified by XUnitProjects XUnitPublishTargetFramework: '' # optional -- framework to use to publish your xUnit projects XUnitRuntimeTargetFramework: '' # optional -- framework to use for the xUnit console runner @@ -22,14 +22,14 @@ parameters: DotNetCliVersion: '' # optional -- version of the CLI to send to Helix; based on this: https://raw.githubusercontent.com/dotnet/core/main/release-notes/releases-index.json WaitForWorkItemCompletion: true # optional -- true will make the task wait until work items have been completed and fail the build if work items fail. False is "fire and forget." IsExternal: false # [DEPRECATED] -- doesn't do anything, jobs are external if HelixAccessToken is empty and Creator is set - HelixBaseUri: 'https://helix.dot.net/' # optional -- sets the Helix API base URI (allows targeting int) + HelixBaseUri: 'https://helix.dot.net/' # optional -- sets the Helix API base URI (allows targeting https://helix.int-dot.net ) Creator: '' # optional -- if the build is external, use this to specify who is sending the job DisplayNamePrefix: 'Run Tests' # optional -- rename the beginning of the displayName of the steps in AzDO condition: succeeded() # optional -- condition for step to execute; defaults to succeeded() continueOnError: false # optional -- determines whether to continue the build if the step errors; defaults to false steps: - - powershell: 'powershell "$env:BUILD_SOURCESDIRECTORY\eng\common\msbuild.ps1 $env:BUILD_SOURCESDIRECTORY\eng\common\helixpublish.proj /restore /t:Test /bl:$env:BUILD_SOURCESDIRECTORY\artifacts\log\$env:BuildConfig\SendToHelix.binlog"' + - powershell: 'powershell "$env:BUILD_SOURCESDIRECTORY\eng\common\msbuild.ps1 $env:BUILD_SOURCESDIRECTORY\eng\common\helixpublish.proj /restore /p:TreatWarningsAsErrors=false /t:Test /bl:$env:BUILD_SOURCESDIRECTORY\artifacts\log\$env:BuildConfig\SendToHelix.binlog"' displayName: ${{ parameters.DisplayNamePrefix }} (Windows) env: BuildConfig: $(_BuildConfig) @@ -59,7 +59,7 @@ steps: SYSTEM_ACCESSTOKEN: $(System.AccessToken) condition: and(${{ parameters.condition }}, eq(variables['Agent.Os'], 'Windows_NT')) continueOnError: ${{ parameters.continueOnError }} - - script: $BUILD_SOURCESDIRECTORY/eng/common/msbuild.sh $BUILD_SOURCESDIRECTORY/eng/common/helixpublish.proj /restore /t:Test /bl:$BUILD_SOURCESDIRECTORY/artifacts/log/$BuildConfig/SendToHelix.binlog + - script: $BUILD_SOURCESDIRECTORY/eng/common/msbuild.sh $BUILD_SOURCESDIRECTORY/eng/common/helixpublish.proj /restore /p:TreatWarningsAsErrors=false /t:Test /bl:$BUILD_SOURCESDIRECTORY/artifacts/log/$BuildConfig/SendToHelix.binlog displayName: ${{ parameters.DisplayNamePrefix }} (Unix) env: BuildConfig: $(_BuildConfig) diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index 423bd962e9..aba6308ad3 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -365,10 +365,17 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements = # If the version of msbuild is going to be xcopied, # use this version. Version matches a package here: - # https://dev.azure.com/dnceng/public/_packaging?_a=package&feed=dotnet-eng&package=RoslynTools.MSBuild&protocolType=NuGet&version=17.1.0&view=overview - $defaultXCopyMSBuildVersion = '17.1.0' + # https://dev.azure.com/dnceng/public/_packaging?_a=package&feed=dotnet-eng&package=RoslynTools.MSBuild&protocolType=NuGet&version=17.2.1&view=overview + $defaultXCopyMSBuildVersion = '17.2.1' - if (!$vsRequirements) { $vsRequirements = $GlobalJson.tools.vs } + if (!$vsRequirements) { + if (Get-Member -InputObject $GlobalJson.tools -Name 'vs') { + $vsRequirements = $GlobalJson.tools.vs + } + else { + $vsRequirements = New-Object PSObject -Property @{ version = $vsMinVersionReqdStr } + } + } $vsMinVersionStr = if ($vsRequirements.version) { $vsRequirements.version } else { $vsMinVersionReqdStr } $vsMinVersion = [Version]::new($vsMinVersionStr) @@ -573,7 +580,7 @@ function InitializeBuildTool() { ExitWithExitCode 1 } $dotnetPath = Join-Path $dotnetRoot (GetExecutableFileName 'dotnet') - $buildTool = @{ Path = $dotnetPath; Command = 'msbuild'; Tool = 'dotnet'; Framework = 'netcoreapp3.1' } + $buildTool = @{ Path = $dotnetPath; Command = 'msbuild'; Tool = 'dotnet'; Framework = 'net7.0' } } elseif ($msbuildEngine -eq "vs") { try { $msbuildPath = InitializeVisualStudioMSBuild -install:$restore @@ -635,7 +642,7 @@ function InitializeNativeTools() { InstallDirectory = "$ToolsDir" } } - if (Test-Path variable:NativeToolsOnMachine) { + if ($env:NativeToolsOnMachine) { Write-Host "Variable NativeToolsOnMachine detected, enabling native tool path promotion..." $nativeArgs += @{ PathPromotion = $true } } diff --git a/eng/common/tools.sh b/eng/common/tools.sh index 17f0a36580..c110d0ed41 100644 --- a/eng/common/tools.sh +++ b/eng/common/tools.sh @@ -312,7 +312,7 @@ function InitializeBuildTool { # return values _InitializeBuildTool="$_InitializeDotNetCli/dotnet" _InitializeBuildToolCommand="msbuild" - _InitializeBuildToolFramework="netcoreapp3.1" + _InitializeBuildToolFramework="net7.0" } # Set RestoreNoCache as a workaround for https://github.com/NuGet/Home/issues/3116 diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 294e9832ad..dd0dea81cd 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -11,7 +11,7 @@ initTargetDistroRid() passedRootfsDir="$ROOTFS_DIR" fi - initDistroRidGlobal "$__TargetOS" "$__BuildArch" "$__PortableBuild" "$passedRootfsDir" + initDistroRidGlobal "$__TargetOS" "$__TargetArch" "$__PortableBuild" "$passedRootfsDir" } setup_dirs() @@ -35,7 +35,7 @@ check_prereqs() if ! pkg-config openssl ; then # We export the proper PKG_CONFIG_PATH where openssl was installed by Homebrew # It's important to _export_ it since build-commons.sh is sourced by other scripts such as build-native.sh - export PKG_CONFIG_PATH=$(brew --prefix)/opt/openssl@1.1/lib/pkgconfig:$(brew --prefix)/opt/openssl/lib/pkgconfig + export PKG_CONFIG_PATH=$(brew --prefix)/opt/openssl@3/lib/pkgconfig:$(brew --prefix)/opt/openssl@1.1/lib/pkgconfig:$(brew --prefix)/opt/openssl/lib/pkgconfig # We try again with the PKG_CONFIG_PATH in place, if pkg-config still can't find OpenSSL, exit with an error, cmake won't find OpenSSL either pkg-config openssl || { echo >&2 "Please install openssl before running this script, see https://github.com/dotnet/runtime/blob/main/docs/workflow/requirements/macos-requirements.md"; exit 1; } fi @@ -53,7 +53,7 @@ build_native() fi targetOS="$1" - platformArch="$2" + hostArch="$2" cmakeDir="$3" intermediatesDir="$4" target="$5" @@ -61,15 +61,15 @@ build_native() message="$7" # All set to commence the build - echo "Commencing build of \"$target\" target in \"$message\" for $__TargetOS.$__BuildArch.$__BuildType in $intermediatesDir" + echo "Commencing build of \"$target\" target in \"$message\" for $__TargetOS.$__TargetArch.$__BuildType in $intermediatesDir" if [[ "$targetOS" == OSX || "$targetOS" == MacCatalyst ]]; then - if [[ "$platformArch" == x64 ]]; then + if [[ "$hostArch" == x64 ]]; then cmakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"x86_64\" $cmakeArgs" - elif [[ "$platformArch" == arm64 ]]; then + elif [[ "$hostArch" == arm64 ]]; then cmakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"arm64\" $cmakeArgs" else - echo "Error: Unknown OSX architecture $platformArch." + echo "Error: Unknown OSX architecture $hostArch." exit 1 fi fi @@ -78,28 +78,28 @@ build_native() cmakeArgs="-DCMAKE_SYSTEM_VARIANT=MacCatalyst $cmakeArgs" fi - if [[ "$targetOS" == Android && -z "$ROOTFS_DIR" ]]; then + if [[ ( "$targetOS" == Android || "$targetOS" == linux-bionic ) && -z "$ROOTFS_DIR" ]]; then if [[ -z "$ANDROID_NDK_ROOT" ]]; then echo "Error: You need to set the ANDROID_NDK_ROOT environment variable pointing to the Android NDK root." exit 1 fi - # keep ANDROID_NATIVE_API_LEVEL in sync with src/mono/Directory.Build.props - cmakeArgs="-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=21 $cmakeArgs" + # keep ANDROID_PLATFORM in sync with src/mono/Directory.Build.props + cmakeArgs="-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-21 $cmakeArgs" # Don't try to set CC/CXX in init-compiler.sh - it's handled in android.toolchain.cmake already __Compiler="default" - if [[ "$platformArch" == x64 ]]; then + if [[ "$hostArch" == x64 ]]; then cmakeArgs="-DANDROID_ABI=x86_64 $cmakeArgs" - elif [[ "$platformArch" == x86 ]]; then + elif [[ "$hostArch" == x86 ]]; then cmakeArgs="-DANDROID_ABI=x86 $cmakeArgs" - elif [[ "$platformArch" == arm64 ]]; then + elif [[ "$hostArch" == arm64 ]]; then cmakeArgs="-DANDROID_ABI=arm64-v8a $cmakeArgs" - elif [[ "$platformArch" == arm ]]; then + elif [[ "$hostArch" == arm ]]; then cmakeArgs="-DANDROID_ABI=armeabi-v7a $cmakeArgs" else - echo "Error: Unknown Android architecture $platformArch." + echo "Error: Unknown Android architecture $hostArch." exit 1 fi fi @@ -117,7 +117,7 @@ build_native() scan_build=scan-build fi - nextCommand="\"$__RepoRootDir/eng/native/gen-buildsys.sh\" \"$cmakeDir\" \"$intermediatesDir\" $platformArch $__Compiler $__BuildType \"$generator\" $scan_build $cmakeArgs" + nextCommand="\"$__RepoRootDir/eng/native/gen-buildsys.sh\" \"$cmakeDir\" \"$intermediatesDir\" $hostArch $__Compiler $__BuildType \"$generator\" $scan_build $cmakeArgs" echo "Invoking $nextCommand" eval $nextCommand @@ -197,7 +197,7 @@ usage() echo "" echo "Common Options:" echo "" - echo "BuildArch can be: -arm, -armv6, -armel, -arm64, -loongarch64, -s390x, x64, x86, -wasm" + echo "BuildArch can be: -arm, -armv6, -armel, -arm64, -loongarch64, -riscv64, -s390x, -ppc64le, x64, x86, -wasm" echo "BuildType can be: -debug, -checked, -release" echo "-os: target OS (defaults to running OS)" echo "-bindir: output directory (defaults to $__ProjectRoot/artifacts)" @@ -228,30 +228,25 @@ usage() source "$__RepoRootDir/eng/native/init-os-and-arch.sh" -__BuildArch=$arch -__HostArch=$arch +__TargetArch=$arch __TargetOS=$os __HostOS=$os __BuildOS=$os # Get the number of processors available to the scheduler -# Other techniques such as `nproc` only get the number of -# processors available to a single process. platform="$(uname)" if [[ "$platform" == "FreeBSD" ]]; then - __NumProc=$(($(sysctl -n hw.ncpu)+1)) + __NumProc="$(($(sysctl -n hw.ncpu)+1))" elif [[ "$platform" == "NetBSD" || "$platform" == "SunOS" ]]; then - __NumProc=$(($(getconf NPROCESSORS_ONLN)+1)) + __NumProc="$(($(getconf NPROCESSORS_ONLN)+1))" elif [[ "$platform" == "Darwin" ]]; then - __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1)) + __NumProc="$(($(getconf _NPROCESSORS_ONLN)+1))" +elif command -v nproc > /dev/null 2>&1; then + __NumProc="$(nproc)" +elif (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then + __NumProc="$(getconf _NPROCESSORS_ONLN)" else - if command -v nproc > /dev/null 2>&1; then - __NumProc=$(nproc --all) - elif (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then - __NumProc=$(getconf _NPROCESSORS_ONLN) - else - __NumProc=1 - fi + __NumProc=1 fi while :; do @@ -267,19 +262,19 @@ while :; do ;; arm|-arm) - __BuildArch=arm + __TargetArch=arm ;; armv6|-armv6) - __BuildArch=armv6 + __TargetArch=armv6 ;; arm64|-arm64) - __BuildArch=arm64 + __TargetArch=arm64 ;; armel|-armel) - __BuildArch=armel + __TargetArch=armel ;; bindir|-bindir) @@ -374,23 +369,31 @@ while :; do ;; x86|-x86) - __BuildArch=x86 + __TargetArch=x86 ;; x64|-x64) - __BuildArch=x64 + __TargetArch=x64 ;; loongarch64|-loongarch64) - __BuildArch=loongarch64 + __TargetArch=loongarch64 + ;; + + riscv64|-riscv64) + __TargetArch=riscv64 ;; s390x|-s390x) - __BuildArch=s390x + __TargetArch=s390x ;; wasm|-wasm) - __BuildArch=wasm + __TargetArch=wasm + ;; + + ppc64le|-ppc64le) + __TargetArch=ppc64le ;; os|-os) @@ -403,6 +406,16 @@ while :; do fi ;; + hostarch|-hostarch) + if [[ -n "$2" ]]; then + __HostArch="$2" + shift + else + echo "ERROR: 'hostarch' requires a non-empty option argument" + exit 1 + fi + ;; + *) handle_arguments "$1" "$2" if [[ "$__ShiftArgs" == 1 ]]; then @@ -415,7 +428,11 @@ while :; do shift done -__CommonMSBuildArgs="/p:TargetArchitecture=$__BuildArch /p:Configuration=$__BuildType /p:TargetOS=$__TargetOS /nodeReuse:false $__OfficialBuildIdArg $__SignTypeArg $__SkipRestoreArg" +if [[ -z "$__HostArch" ]]; then + __HostArch=$__TargetArch +fi + +__CommonMSBuildArgs="/p:TargetArchitecture=$__TargetArch /p:Configuration=$__BuildType /p:TargetOS=$__TargetOS /nodeReuse:false $__OfficialBuildIdArg $__SignTypeArg $__SkipRestoreArg" # Configure environment if we are doing a verbose build if [[ "$__VerboseBuild" == 1 ]]; then @@ -428,7 +445,7 @@ if [[ "$__PortableBuild" == 0 ]]; then __CommonMSBuildArgs="$__CommonMSBuildArgs /p:PortableBuild=false" fi -if [[ "$__BuildArch" == wasm ]]; then +if [[ "$__TargetArch" == wasm ]]; then # nothing to do here true elif [[ "$__TargetOS" == iOS || "$__TargetOS" == iOSSimulator ]]; then @@ -450,7 +467,7 @@ if [[ "$__CrossBuild" == 1 ]]; then export CROSSCOMPILE # Darwin that doesn't use rootfs if [[ -z "$ROOTFS_DIR" && "$platform" != "Darwin" ]]; then - ROOTFS_DIR="$__RepoRootDir/.tools/rootfs/$__BuildArch" + ROOTFS_DIR="$__RepoRootDir/.tools/rootfs/$__TargetArch" export ROOTFS_DIR fi fi diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index c3e757ccde..a0163845e6 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -133,7 +133,7 @@ elseif (CLR_CMAKE_HOST_UNIX) message("Address Sanitizer (asan) enabled") endif () if (${__UBSAN_POS} GREATER -1) - # all sanitizier flags are enabled except alignment (due to heavy use of __unaligned modifier) + # all sanitizer flags are enabled except alignment (due to heavy use of __unaligned modifier) list(APPEND CLR_CXX_SANITIZERS "bool" bounds @@ -227,6 +227,9 @@ elseif (CLR_CMAKE_HOST_ARCH_ARM64) elseif (CLR_CMAKE_HOST_ARCH_LOONGARCH64) set(ARCH_HOST_NAME loongarch64) add_definitions(-DHOST_LOONGARCH64 -DHOST_64BIT) +elseif (CLR_CMAKE_HOST_ARCH_RISCV64) + set(ARCH_HOST_NAME riscv64) + add_definitions(-DHOST_RISCV64 -DHOST_64BIT) elseif (CLR_CMAKE_HOST_ARCH_S390X) set(ARCH_HOST_NAME s390x) add_definitions(-DHOST_S390X -DHOST_64BIT -DBIGENDIAN) @@ -236,6 +239,9 @@ elseif (CLR_CMAKE_HOST_ARCH_WASM) elseif (CLR_CMAKE_HOST_ARCH_MIPS64) set(ARCH_HOST_NAME mips64) add_definitions(-DHOST_MIPS64 -DHOST_64BIT=1) +elseif (CLR_CMAKE_HOST_ARCH_POWERPC64) + set(ARCH_HOST_NAME ppc64le) + add_definitions(-DHOST_POWERPC64 -DHOST_64BIT) else () clr_unknown_arch() endif () @@ -245,17 +251,21 @@ if (CLR_CMAKE_HOST_UNIX) if(CLR_CMAKE_HOST_UNIX_AMD64) message("Detected Linux x86_64") elseif(CLR_CMAKE_HOST_UNIX_ARM) - message("Detected Linux ARM") + message("Detected Linux arm") elseif(CLR_CMAKE_HOST_UNIX_ARMV6) - message("Detected Linux ARMv6") + message("Detected Linux armv6") elseif(CLR_CMAKE_HOST_UNIX_ARM64) - message("Detected Linux ARM64") + message("Detected Linux arm64") elseif(CLR_CMAKE_HOST_UNIX_LOONGARCH64) - message("Detected Linux LOONGARCH64") + message("Detected Linux loongarch64") + elseif(CLR_CMAKE_HOST_UNIX_RISCV64) + message("Detected Linux riscv64") elseif(CLR_CMAKE_HOST_UNIX_X86) message("Detected Linux i686") elseif(CLR_CMAKE_HOST_UNIX_S390X) message("Detected Linux s390x") + elseif(CLR_CMAKE_HOST_UNIX_POWERPC64) + message("Detected Linux ppc64le") else() clr_unknown_arch() endif() @@ -327,11 +337,21 @@ elseif (CLR_CMAKE_TARGET_ARCH_LOONGARCH64) set(ARCH_SOURCES_DIR loongarch64) add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_LOONGARCH64>) add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_64BIT>) +elseif (CLR_CMAKE_TARGET_ARCH_RISCV64) + set(ARCH_TARGET_NAME riscv64) + set(ARCH_SOURCES_DIR riscv64) + add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_RISCV64>) + add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_64BIT>) elseif (CLR_CMAKE_TARGET_ARCH_S390X) set(ARCH_TARGET_NAME s390x) set(ARCH_SOURCES_DIR s390x) add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_S390X>) add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_64BIT>) +elseif (CLR_CMAKE_TARGET_ARCH_POWERPC64) + set(ARCH_TARGET_NAME ppc64le) + set(ARCH_SOURCES_DIR ppc64le) + add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_POWERPC64>) + add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_ARCH>>>:TARGET_64BIT>) elseif (CLR_CMAKE_TARGET_ARCH_WASM) set(ARCH_TARGET_NAME wasm) set(ARCH_SOURCES_DIR wasm) @@ -365,6 +385,11 @@ if (CLR_CMAKE_HOST_UNIX) if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_MACCATALYST) # We cannot enable "stack-protector-strong" on OS X due to a bug in clang compiler (current version 7.0.2) add_compile_options(-fstack-protector) + if(CLR_CMAKE_HOST_UNIX_ARM64) + # For OSX-Arm64, LSE instructions are enabled by default + add_definitions(-DLSE_INSTRUCTIONS_ENABLED_BY_DEFAULT) + add_compile_options(-mcpu=apple-m1) + endif(CLR_CMAKE_HOST_UNIX_ARM64) elseif(NOT CLR_CMAKE_HOST_BROWSER) check_c_compiler_flag(-fstack-protector-strong COMPILER_SUPPORTS_F_STACK_PROTECTOR_STRONG) if (COMPILER_SUPPORTS_F_STACK_PROTECTOR_STRONG) @@ -426,11 +451,17 @@ if (CLR_CMAKE_HOST_UNIX) add_compile_options(-Wno-uninitialized) add_compile_options(-Wno-strict-aliasing) add_compile_options(-Wno-array-bounds) - add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-class-memaccess>) add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-misleading-indentation>) add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-stringop-overflow>) + add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-restrict>) add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-stringop-truncation>) - add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-placement-new>) + + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.0) + # this warning is only reported by g++ 11 in debug mode when building + # src/coreclr/vm/stackingallocator.h. It is a false-positive, fixed in g++ 12. + # see: https://github.com/dotnet/runtime/pull/69188#issuecomment-1136764770 + add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-placement-new>) + endif() if (CMAKE_CXX_COMPILER_ID) check_cxx_compiler_flag(-faligned-new COMPILER_SUPPORTS_F_ALIGNED_NEW) @@ -586,48 +617,42 @@ if (MSVC) add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4065>) # switch statement contains 'default' but no 'case' labels add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4100>) # 'identifier' : unreferenced formal parameter add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4127>) # conditional expression is constant + add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4131>) # 'function' : uses old-style declarator add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4189>) # local variable is initialized but not referenced add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4200>) # nonstandard extension used : zero-sized array in struct/union add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4201>) # nonstandard extension used : nameless struct/union + add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4206>) # nonstandard extension used : translation unit is empty + add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4239>) # nonstandard extension used : 'token' : conversion from 'type' to 'type' add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4245>) # conversion from 'type1' to 'type2', signed/unsigned mismatch add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4291>) # no matching operator delete found; memory will not be freed if initialization throws an exception + add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4310>) # cast truncates constant value + add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4324>) # 'struct_name' : structure was padded due to __declspec(align()) + add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4366>) # The result of the unary 'operator' operator may be unaligned add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4456>) # declaration of 'identifier' hides previous local declaration add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4457>) # declaration of 'identifier' hides function parameter add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4458>) # declaration of 'identifier' hides class member + add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4459>) # declaration of 'identifier' hides global declaration + add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4463>) # overflow; assigning value to bit-field that can only hold values from low_value to high_value + add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4505>) # unreferenced function with internal linkage has been removed add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4702>) # unreachable code + add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4706>) # assignment within conditional expression add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4733>) # Inline asm assigning to 'FS:0' : handler not registered as safe handler + add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4815>) # 'var': zero-sized array in stack object will have no elements (unless the object is an aggregate that has been aggregate initialized) add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4838>) # conversion from 'type_1' to 'type_2' requires a narrowing conversion + add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4918>) # 'character' : invalid character in pragma optimization list add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4960>) # 'function' is too big to be profiled add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4961>) # No profile data was merged into '.pgd file', profile-guided optimizations disabled add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd5105>) # macro expansion producing 'defined' has undefined behavior + add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd5205>) # delete of an abstract class 'type-name' that has a non-virtual destructor results in undefined behavior # Treat Warnings as Errors: add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4007>) # 'main' : must be __cdecl. add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4013>) # 'function' undefined - assuming extern returning int. - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4018>) # 'expression' : signed/unsigned mismatch - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4055>) # 'conversion' : from data pointer 'type1' to function pointer 'type2' add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4102>) # "'%$S' : unreferenced label". - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4146>) # unary minus operator applied to unsigned type, result still unsigned - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4242>) # 'identifier' : conversion from 'type1' to 'type2', possible loss of data - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4244>) # 'conversion' conversion from 'type1' to 'type2', possible loss of data - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4267>) # 'var' : conversion from 'size_t' to 'type', possible loss of data - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4302>) # 'conversion' : truncation from 'type 1' to 'type 2' - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4308>) # negative integral constant converted to unsigned type - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4509>) # nonstandard extension used: 'function' uses SEH and 'object' has destructor - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4510>) # 'class' : default constructor could not be generated - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4532>) # 'continue' : jump out of __finally/finally block has undefined behavior during termination handling - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4533>) # initialization of 'variable' is skipped by 'instruction' add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4551>) # Function call missing argument list. - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4610>) # object 'class' can never be instantiated - user-defined constructor required - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4611>) # interaction between 'function' and C++ object destruction is non-portable - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4640>) # 'instance' : construction of local static object is not thread-safe add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4700>) # Local used w/o being initialized. - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4701>) # Potentially uninitialized local variable 'name' used - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4703>) # Potentially uninitialized local pointer variable 'name' used - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4789>) # destination of memory copy is too small + add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4640>) # 'instance' : construction of local static object is not thread-safe add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4806>) # Unsafe operation involving type 'bool'. - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4995>) # 'function': name was marked as #pragma deprecated - add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4996>) # 'function': was declared deprecated also 'std::': Function call with parameters that are potentially unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' # Set Warning Level 3: add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34092>) # Sizeof returns 'unsigned long'. @@ -762,6 +787,13 @@ if (CLR_CMAKE_HOST_WIN32) endif() elseif (NOT CLR_CMAKE_HOST_BROWSER) + # This is a workaround for upstream issue: https://gitlab.kitware.com/cmake/cmake/-/issues/22995. + # + # In Clang.cmake, the decision to use single or double hyphen for target and gcc-toolchain + # is made based on CMAKE_${LANG}_COMPILER_VERSION, but CMAKE_ASM_COMPILER_VERSION is empty + # so it picks up single hyphen options, which new clang versions don't recognize. + set (CMAKE_ASM_COMPILER_VERSION "${CMAKE_C_COMPILER_VERSION}") + enable_language(ASM) -endif(CLR_CMAKE_HOST_WIN32) \ No newline at end of file +endif(CLR_CMAKE_HOST_WIN32) diff --git a/eng/native/configureoptimization.cmake b/eng/native/configureoptimization.cmake index 50c7b1cfa8..f6b5da696f 100644 --- a/eng/native/configureoptimization.cmake +++ b/eng/native/configureoptimization.cmake @@ -12,6 +12,11 @@ if(CLR_CMAKE_HOST_WIN32) elseif(CLR_CMAKE_HOST_UNIX) add_compile_options($<$<CONFIG:Debug>:-O0>) add_compile_options($<$<CONFIG:Checked>:-O2>) - add_compile_options($<$<CONFIG:Release>:-O3>) + if(CLR_CMAKE_TARGET_ANDROID) + # -O2 optimization generates faster/smaller code on Android + add_compile_options($<$<CONFIG:Release>:-O2>) + else() + add_compile_options($<$<CONFIG:Release>:-O3>) + endif() add_compile_options($<$<CONFIG:RelWithDebInfo>:-O2>) endif() diff --git a/eng/native/configurepaths.cmake b/eng/native/configurepaths.cmake index 3f41026eee..7d6851d1cf 100644 --- a/eng/native/configurepaths.cmake +++ b/eng/native/configurepaths.cmake @@ -2,6 +2,7 @@ get_filename_component(CLR_REPO_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../.. ABSOLUT set(CLR_ENG_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR}) get_filename_component(CLR_SRC_NATIVE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../src/native ABSOLUTE) set (CLR_ARTIFACTS_OBJ_DIR "${CLR_REPO_ROOT_DIR}/artifacts/obj") +set (CLR_SOURCELINK_FILE_PATH "${CLR_ARTIFACTS_OBJ_DIR}/native.sourcelink.json") set(VERSION_HEADER_PATH "${CLR_ARTIFACTS_OBJ_DIR}/_version.h") set(VERSION_FILE_PATH "${CLR_ARTIFACTS_OBJ_DIR}/_version.c") set(VERSION_FILE_RC_PATH "${CLR_ARTIFACTS_OBJ_DIR}/NativeVersion.rc") diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake index ecf10a8d4c..c7a38c3eee 100644 --- a/eng/native/configureplatform.cmake +++ b/eng/native/configureplatform.cmake @@ -1,7 +1,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/functions.cmake) -# If set, indicates that this is not an officially supported release -# Keep in sync with IsPrerelease in Directory.Build.props +# If set, indicates that this is not an officially supported release. +# Release branches should set this to false. set(PRERELEASE 1) #---------------------------------------- @@ -36,7 +36,7 @@ if(CLR_CMAKE_HOST_OS STREQUAL Linux) # "amd64" string. Accept either of the two here. if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64) set(CLR_CMAKE_HOST_UNIX_AMD64 1) - elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l) + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l OR CMAKE_SYSTEM_PROCESSOR STREQUAL armv8l) set(CLR_CMAKE_HOST_UNIX_ARM 1) set(CLR_CMAKE_HOST_UNIX_ARMV7L 1) elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm OR CMAKE_SYSTEM_PROCESSOR STREQUAL armv7-a) @@ -45,12 +45,16 @@ if(CLR_CMAKE_HOST_OS STREQUAL Linux) set(CLR_CMAKE_HOST_UNIX_ARMV6 1) elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL arm64) set(CLR_CMAKE_HOST_UNIX_ARM64 1) - elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL loongarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL loongarch64) + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL loongarch64) set(CLR_CMAKE_HOST_UNIX_LOONGARCH64 1) + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL riscv64) + set(CLR_CMAKE_HOST_UNIX_RISCV64 1) elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL i686 OR CMAKE_SYSTEM_PROCESSOR STREQUAL x86) set(CLR_CMAKE_HOST_UNIX_X86 1) elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL s390x) set(CLR_CMAKE_HOST_UNIX_S390X 1) + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL ppc64le) + set(CLR_CMAKE_HOST_UNIX_POWERPC64 1) elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL mips64) set(CLR_CMAKE_HOST_UNIX_MIPS64 1) else() @@ -70,6 +74,11 @@ if(CLR_CMAKE_HOST_OS STREQUAL Linux) COMMAND bash -c "source ${LINUX_ID_FILE} && echo \$ID" OUTPUT_VARIABLE CLR_CMAKE_LINUX_ID OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process( + COMMAND bash -c "if strings \"${CMAKE_SYSROOT}/usr/bin/ldd\" 2>&1 | grep -q musl; then echo musl; fi" + OUTPUT_VARIABLE CLR_CMAKE_LINUX_MUSL + OUTPUT_STRIP_TRAILING_WHITESPACE) endif() if(DEFINED CLR_CMAKE_LINUX_ID) @@ -80,6 +89,10 @@ if(CLR_CMAKE_HOST_OS STREQUAL Linux) set(CLR_CMAKE_HOST_ALPINE_LINUX 1) set(CLR_CMAKE_HOST_OS ${CLR_CMAKE_LINUX_ID}) endif() + + if(CLR_CMAKE_LINUX_MUSL STREQUAL musl) + set(CLR_CMAKE_HOST_LINUX_MUSL 1) + endif() endif(DEFINED CLR_CMAKE_LINUX_ID) endif(CLR_CMAKE_HOST_OS STREQUAL Linux) @@ -232,6 +245,9 @@ elseif(CLR_CMAKE_HOST_UNIX_ARM64) elseif(CLR_CMAKE_HOST_UNIX_LOONGARCH64) set(CLR_CMAKE_HOST_ARCH_LOONGARCH64 1) set(CLR_CMAKE_HOST_ARCH "loongarch64") +elseif(CLR_CMAKE_HOST_UNIX_RISCV64) + set(CLR_CMAKE_HOST_ARCH_RISCV64 1) + set(CLR_CMAKE_HOST_ARCH "riscv64") elseif(CLR_CMAKE_HOST_UNIX_AMD64) set(CLR_CMAKE_HOST_ARCH_AMD64 1) set(CLR_CMAKE_HOST_ARCH "x64") @@ -241,6 +257,9 @@ elseif(CLR_CMAKE_HOST_UNIX_X86) elseif(CLR_CMAKE_HOST_UNIX_S390X) set(CLR_CMAKE_HOST_ARCH_S390X 1) set(CLR_CMAKE_HOST_ARCH "s390x") +elseif(CLR_CMAKE_HOST_UNIX_POWERPC64) + set(CLR_CMAKE_HOST_ARCH_POWERPC64 1) + set(CLR_CMAKE_HOST_ARCH "ppc64le") elseif(CLR_CMAKE_HOST_BROWSER) set(CLR_CMAKE_HOST_ARCH_WASM 1) set(CLR_CMAKE_HOST_ARCH "wasm") @@ -278,27 +297,31 @@ endif() # Set target architecture variables if (CLR_CMAKE_TARGET_ARCH STREQUAL x64) set(CLR_CMAKE_TARGET_ARCH_AMD64 1) - elseif(CLR_CMAKE_TARGET_ARCH STREQUAL x86) +elseif(CLR_CMAKE_TARGET_ARCH STREQUAL x86) set(CLR_CMAKE_TARGET_ARCH_I386 1) - elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm64) +elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm64) set(CLR_CMAKE_TARGET_ARCH_ARM64 1) - elseif(CLR_CMAKE_TARGET_ARCH STREQUAL loongarch64) +elseif(CLR_CMAKE_TARGET_ARCH STREQUAL loongarch64) set(CLR_CMAKE_TARGET_ARCH_LOONGARCH64 1) - elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm) +elseif(CLR_CMAKE_TARGET_ARCH STREQUAL riscv64) + set(CLR_CMAKE_TARGET_ARCH_RISCV64 1) +elseif(CLR_CMAKE_TARGET_ARCH STREQUAL arm) set(CLR_CMAKE_TARGET_ARCH_ARM 1) - elseif(CLR_CMAKE_TARGET_ARCH STREQUAL armv6) +elseif(CLR_CMAKE_TARGET_ARCH STREQUAL armv6) set(CLR_CMAKE_TARGET_ARCH_ARMV6 1) - elseif(CLR_CMAKE_TARGET_ARCH STREQUAL armel) +elseif(CLR_CMAKE_TARGET_ARCH STREQUAL armel) set(CLR_CMAKE_TARGET_ARCH_ARM 1) set(CLR_CMAKE_TARGET_ARCH_ARMV7L 1) set(ARM_SOFTFP 1) - elseif(CLR_CMAKE_TARGET_ARCH STREQUAL s390x) +elseif(CLR_CMAKE_TARGET_ARCH STREQUAL s390x) set(CLR_CMAKE_TARGET_ARCH_S390X 1) - elseif(CLR_CMAKE_TARGET_ARCH STREQUAL wasm) +elseif(CLR_CMAKE_TARGET_ARCH STREQUAL ppc64le) + set(CLR_CMAKE_TARGET_ARCH_POWERPC64 1) +elseif(CLR_CMAKE_TARGET_ARCH STREQUAL wasm) set(CLR_CMAKE_TARGET_ARCH_WASM 1) - elseif(CLR_CMAKE_TARGET_ARCH STREQUAL mips64) +elseif(CLR_CMAKE_TARGET_ARCH STREQUAL mips64) set(CLR_CMAKE_TARGET_ARCH_MIPS64 1) - else() +else() clr_unknown_arch() endif() @@ -314,6 +337,10 @@ if(CLR_CMAKE_TARGET_OS STREQUAL Linux) set(CLR_CMAKE_TARGET_LINUX 1) endif(CLR_CMAKE_TARGET_OS STREQUAL Linux) +if(CLR_CMAKE_HOST_LINUX_MUSL) + set(CLR_CMAKE_TARGET_LINUX_MUSL 1) +endif(CLR_CMAKE_HOST_LINUX_MUSL) + if(CLR_CMAKE_TARGET_OS STREQUAL tizen) set(CLR_CMAKE_TARGET_UNIX 1) set(CLR_CMAKE_TARGET_LINUX 1) @@ -396,10 +423,14 @@ if(CLR_CMAKE_TARGET_UNIX) set(CLR_CMAKE_TARGET_UNIX_ARM64 1) elseif(CLR_CMAKE_TARGET_ARCH STREQUAL loongarch64) set(CLR_CMAKE_TARGET_UNIX_LOONGARCH64 1) + elseif(CLR_CMAKE_TARGET_ARCH STREQUAL riscv64) + set(CLR_CMAKE_TARGET_UNIX_RISCV64 1) elseif(CLR_CMAKE_TARGET_ARCH STREQUAL x86) set(CLR_CMAKE_TARGET_UNIX_X86 1) elseif(CLR_CMAKE_TARGET_ARCH STREQUAL s390x) set(CLR_CMAKE_TARGET_UNIX_S390X 1) + elseif(CLR_CMAKE_TARGET_ARCH STREQUAL ppc64le) + set(CLR_CMAKE_TARGET_UNIX_POWERPC64 1) elseif(CLR_CMAKE_TARGET_ARCH STREQUAL wasm) set(CLR_CMAKE_TARGET_UNIX_WASM 1) elseif(CLR_CMAKE_TARGET_ARCH STREQUAL mips64) diff --git a/eng/native/configuretools.cmake b/eng/native/configuretools.cmake index ad5dc38107..07a3bbfafe 100644 --- a/eng/native/configuretools.cmake +++ b/eng/native/configuretools.cmake @@ -7,59 +7,69 @@ if (CMAKE_C_COMPILER MATCHES "-?[0-9]+(\.[0-9]+)?$") endif() if(NOT WIN32 AND NOT CLR_CMAKE_TARGET_BROWSER) - if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + if(CMAKE_C_COMPILER_ID MATCHES "Clang") if(APPLE) set(TOOLSET_PREFIX "") else() set(TOOLSET_PREFIX "llvm-") endif() - elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + elseif(CMAKE_C_COMPILER_ID MATCHES "GNU") if(CMAKE_CROSSCOMPILING) - set(TOOLSET_PREFIX "${CMAKE_CXX_COMPILER_TARGET}-") + set(TOOLSET_PREFIX "${CMAKE_C_COMPILER_TARGET}-") else() set(TOOLSET_PREFIX "") endif() endif() - function(locate_toolchain_exec exec var) + function(locate_toolchain_exec exec var required) string(TOUPPER ${exec} EXEC_UPPERCASE) if(NOT "$ENV{CLR_${EXEC_UPPERCASE}}" STREQUAL "") set(${var} "$ENV{CLR_${EXEC_UPPERCASE}}" PARENT_SCOPE) return() endif() + unset(EXEC_LOCATION_${exec} CACHE) find_program(EXEC_LOCATION_${exec} NAMES "${TOOLSET_PREFIX}${exec}${CLR_CMAKE_COMPILER_FILE_NAME_VERSION}" "${TOOLSET_PREFIX}${exec}") - if (EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND") - message(FATAL_ERROR "Unable to find toolchain executable. Name: ${exec}, Prefix: ${TOOLSET_PREFIX}.") + if (required AND EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND") + message(FATAL_ERROR "Unable to find toolchain executable. Name: '${exec}', Prefix: '${TOOLSET_PREFIX}'") + endif() + + if (NOT EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND") + set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE) endif() - set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE) endfunction() - locate_toolchain_exec(ar CMAKE_AR) - locate_toolchain_exec(nm CMAKE_NM) - locate_toolchain_exec(ranlib CMAKE_RANLIB) + locate_toolchain_exec(ar CMAKE_AR YES) + locate_toolchain_exec(nm CMAKE_NM YES) + locate_toolchain_exec(ranlib CMAKE_RANLIB YES) if(CMAKE_C_COMPILER_ID MATCHES "Clang") - locate_toolchain_exec(link CMAKE_LINKER) + locate_toolchain_exec(link CMAKE_LINKER YES) endif() if(NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND (NOT CLR_CMAKE_TARGET_ANDROID OR CROSS_ROOTFS)) - locate_toolchain_exec(objdump CMAKE_OBJDUMP) + locate_toolchain_exec(objdump CMAKE_OBJDUMP YES) - if(CLR_CMAKE_TARGET_ANDROID) - set(TOOLSET_PREFIX ${ANDROID_TOOLCHAIN_PREFIX}) - elseif(CMAKE_CROSSCOMPILING AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD AND - CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv7l|armv6l|aarch64|arm|s390x)$") - set(TOOLSET_PREFIX "${TOOLCHAIN}-") - else() - set(TOOLSET_PREFIX "") + unset(CMAKE_OBJCOPY CACHE) + locate_toolchain_exec(objcopy CMAKE_OBJCOPY NO) + + if (CMAKE_OBJCOPY) + execute_process( + COMMAND ${CMAKE_OBJCOPY} --help + OUTPUT_VARIABLE OBJCOPY_HELP_OUTPUT + ) endif() - locate_toolchain_exec(objcopy CMAKE_OBJCOPY) + # if llvm-objcopy does not support --only-keep-debug argument, try to locate binutils' objcopy + if (NOT CMAKE_OBJCOPY OR (CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT "${OBJCOPY_HELP_OUTPUT}" MATCHES "--only-keep-debug")) + set(TOOLSET_PREFIX "") + locate_toolchain_exec(objcopy CMAKE_OBJCOPY YES) + endif () + endif() endif() diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake index bc5e3c879d..efb36de6e4 100644 --- a/eng/native/functions.cmake +++ b/eng/native/functions.cmake @@ -4,7 +4,7 @@ function(clr_unknown_arch) elseif(CLR_CROSS_COMPONENTS_BUILD) message(FATAL_ERROR "Only AMD64, I386 host are supported for linux cross-architecture component. Found: ${CMAKE_SYSTEM_PROCESSOR}") else() - message(FATAL_ERROR "Only AMD64, ARMV6, ARM64, LOONGARCH64 and ARM are supported. Found: ${CMAKE_SYSTEM_PROCESSOR}") + message(FATAL_ERROR "'${CMAKE_SYSTEM_PROCESSOR}' is an unsupported architecture.") endif() endfunction() @@ -15,7 +15,7 @@ function(h2inc filename output) get_filename_component(path "${filename}" DIRECTORY) file(RELATIVE_PATH relative_filename "${CLR_REPO_ROOT_DIR}" "${filename}") - file(APPEND "${output}" "// File start: ${relative_filename}\n") + file(WRITE "${output}" "// File start: ${relative_filename}\n") # Use of NEWLINE_CONSUME is needed for lines with trailing backslash file(STRINGS ${filename} contents NEWLINE_CONSUME) @@ -167,6 +167,10 @@ function(find_unwind_libs UnwindLibs) find_library(UNWIND_ARCH NAMES unwind-loongarch64) endif() + if(CLR_CMAKE_HOST_ARCH_RISCV64) + find_library(UNWIND_ARCH NAMES unwind-riscv64) + endif() + if(CLR_CMAKE_HOST_ARCH_AMD64) find_library(UNWIND_ARCH NAMES unwind-x86_64) endif() @@ -175,6 +179,10 @@ function(find_unwind_libs UnwindLibs) find_library(UNWIND_ARCH NAMES unwind-s390x) endif() + if(CLR_CMAKE_HOST_ARCH_POWERPC64) + find_library(UNWIND_ARCH NAMES unwind-ppc64le) + endif() + if(NOT UNWIND_ARCH STREQUAL UNWIND_ARCH-NOTFOUND) set(UNWIND_LIBS ${UNWIND_ARCH}) endif() @@ -200,7 +208,8 @@ endfunction(find_unwind_libs) function(convert_to_absolute_path RetSources) set(Sources ${ARGN}) foreach(Source IN LISTS Sources) - list(APPEND AbsolutePathSources ${CMAKE_CURRENT_SOURCE_DIR}/${Source}) + get_filename_component(AbsolutePathSource ${Source} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + list(APPEND AbsolutePathSources ${AbsolutePathSource}) endforeach() set(${RetSources} ${AbsolutePathSources} PARENT_SCOPE) endfunction(convert_to_absolute_path) @@ -390,18 +399,29 @@ function(strip_symbols targetName outputFilename) message(FATAL_ERROR "strip not found") endif() + set(strip_command ${STRIP} -no_code_signature_warning -S ${strip_source_file}) + + # codesign release build string(TOLOWER "${CMAKE_BUILD_TYPE}" LOWERCASE_CMAKE_BUILD_TYPE) if (LOWERCASE_CMAKE_BUILD_TYPE STREQUAL release) - set(strip_command ${STRIP} -no_code_signature_warning -S ${strip_source_file} && codesign -f -s - ${strip_source_file}) - else () - set(strip_command) + set(strip_command ${strip_command} && codesign -f -s - ${strip_source_file}) + endif () + + execute_process( + COMMAND ${DSYMUTIL} --help + OUTPUT_VARIABLE DSYMUTIL_HELP_OUTPUT + ) + + set(DSYMUTIL_OPTS "--flat") + if ("${DSYMUTIL_HELP_OUTPUT}" MATCHES "--minimize") + list(APPEND DSYMUTIL_OPTS "--minimize") endif () add_custom_command( TARGET ${targetName} POST_BUILD VERBATIM - COMMAND ${DSYMUTIL} --flat ${strip_source_file} + COMMAND ${DSYMUTIL} ${DSYMUTIL_OPTS} ${strip_source_file} COMMAND ${strip_command} COMMENT "Stripping symbols from ${strip_source_file} into file ${strip_destination_file}" ) @@ -412,7 +432,7 @@ function(strip_symbols targetName outputFilename) POST_BUILD VERBATIM COMMAND ${CMAKE_OBJCOPY} --only-keep-debug ${strip_source_file} ${strip_destination_file} - COMMAND ${CMAKE_OBJCOPY} --strip-unneeded ${strip_source_file} + COMMAND ${CMAKE_OBJCOPY} --strip-debug --strip-unneeded ${strip_source_file} COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${strip_destination_file} ${strip_source_file} COMMENT "Stripping symbols from ${strip_source_file} into file ${strip_destination_file}" ) diff --git a/eng/native/gen-buildsys.cmd b/eng/native/gen-buildsys.cmd index 243921d93d..3701e639ce 100644 --- a/eng/native/gen-buildsys.cmd +++ b/eng/native/gen-buildsys.cmd @@ -29,8 +29,6 @@ if /i "%__Ninja%" == "1" ( ) else ( if /i NOT "%__Arch%" == "wasm" ( if /i "%__VSVersion%" == "vs2022" (set __CmakeGenerator=%__CmakeGenerator% 17 2022) - if /i "%__VSVersion%" == "vs2019" (set __CmakeGenerator=%__CmakeGenerator% 16 2019) - if /i "%__VSVersion%" == "vs2017" (set __CmakeGenerator=%__CmakeGenerator% 15 2017) if /i "%__Arch%" == "x64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A x64) if /i "%__Arch%" == "arm" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM) diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index 550613b163..c3bf9adbbe 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -10,7 +10,7 @@ if [[ "$#" -lt 4 ]]; then echo "gen-buildsys.sh <path to top level CMakeLists.txt> <path to intermediate directory> <Architecture> <compiler> [build flavor] [ninja] [scan-build] [cmakeargs]" echo "Specify the path to the top level CMake file." echo "Specify the path that the build system files are generated in." - echo "Specify the target architecture." + echo "Specify the host architecture (the architecture the built tools should run on)." echo "Specify the name of compiler (clang or gcc)." echo "Optionally specify the build configuration (flavor.) Defaults to DEBUG." echo "Optionally specify 'scan-build' to enable build with clang static analyzer." @@ -19,12 +19,12 @@ if [[ "$#" -lt 4 ]]; then exit 1 fi -build_arch="$3" +host_arch="$3" compiler="$4" if [[ "$compiler" != "default" ]]; then nativescriptroot="$( cd -P "$scriptroot/../common/native" && pwd )" - source "$nativescriptroot/init-compiler.sh" "$nativescriptroot" "$build_arch" "$compiler" + source "$nativescriptroot/init-compiler.sh" "$nativescriptroot" "$host_arch" "$compiler" CCC_CC="$CC" CCC_CXX="$CXX" @@ -67,7 +67,7 @@ if [[ "$CROSSCOMPILE" == "1" ]]; then exit 1 fi - TARGET_BUILD_ARCH="$build_arch" + TARGET_BUILD_ARCH="$host_arch" export TARGET_BUILD_ARCH cmake_extra_defines="$cmake_extra_defines -C $scriptroot/tryrun.cmake" @@ -79,7 +79,7 @@ if [[ "$CROSSCOMPILE" == "1" ]]; then fi fi -if [[ "$build_arch" == "armel" ]]; then +if [[ "$host_arch" == "armel" ]]; then cmake_extra_defines="$cmake_extra_defines -DARM_SOFTFP=1" fi @@ -92,23 +92,10 @@ if [[ "$scan_build" == "ON" && -n "$SCAN_BUILD_COMMAND" ]]; then cmake_command="$SCAN_BUILD_COMMAND $cmake_command" fi -if [[ "$build_arch" == "wasm" ]]; then +if [[ "$host_arch" == "wasm" ]]; then cmake_command="emcmake $cmake_command" fi -cmake_args_to_cache="$scan_build\n$SCAN_BUILD_COMMAND\n$generator\n$__UnprocessedCMakeArgs" -cmake_args_cache_file="$2/cmake_cmd_line.txt" -if [[ -z "$__ConfigureOnly" ]]; then - if [[ -e "$cmake_args_cache_file" ]]; then - cmake_args_cache=$(<"$cmake_args_cache_file") - if [[ "$cmake_args_cache" == "$cmake_args_to_cache" ]]; then - echo "CMake command line is unchanged. Reusing previous cache instead of regenerating." - exit 0 - fi - fi - echo $cmake_args_to_cache > $cmake_args_cache_file -fi - # We have to be able to build with CMake 3.6.2, so we can't use the -S or -B options pushd "$2" diff --git a/eng/native/ijw/IJW.cmake b/eng/native/ijw/IJW.cmake new file mode 100644 index 0000000000..9a38a18dc0 --- /dev/null +++ b/eng/native/ijw/IJW.cmake @@ -0,0 +1,82 @@ +if (CLR_CMAKE_HOST_WIN32) + + function(remove_ijw_incompatible_options options updatedOptions) + + # IJW isn't compatible with Ehsc, which CMake enables by default, + if(options MATCHES "/EHsc") + string(REPLACE "/EHsc" "" options "${options}") + endif() + + # IJW isn't compatible with CFG + if(options MATCHES "/guard:cf") + string(REPLACE "/guard:cf" "" options "${options}") + endif() + + # IJW isn't compatible with EHCONT, which requires CFG + if(options MATCHES "/guard:ehcont") + string(REPLACE "/guard:ehcont" "" options "${options}") + endif() + + # IJW isn't compatible with GR- + if(options MATCHES "/GR-") + string(REPLACE "/GR-" "" options "${options}") + endif() + + SET(${updatedOptions} "${options}" PARENT_SCOPE) + endfunction() + + function(remove_ijw_incompatible_target_options targetName) + get_target_property(compileOptions ${targetName} COMPILE_OPTIONS) + remove_ijw_incompatible_options("${compileOptions}" compileOptions) + set_target_properties(${targetName} PROPERTIES COMPILE_OPTIONS "${compileOptions}") + endfunction() + + # 4365 - signed/unsigned mismatch + # 4679 - Could not import member. This is an issue with IJW and static abstract methods in interfaces. + add_compile_options(/wd4365 /wd4679) + + # IJW + add_compile_options(/clr:netcore) + + # IJW requires the CRT as a dll, not linked in + set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:Debug>DLL) + + # CMake enables /RTC1 and /EHsc by default, but they're not compatible with /clr, so remove them + if(CMAKE_CXX_FLAGS_DEBUG MATCHES "/RTC1") + string(REPLACE "/RTC1" " " CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") + endif() + + remove_ijw_incompatible_options("${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS) + + set(CLR_SDK_REF_PACK_OUTPUT "") + set(CLR_SDK_REF_PACK_DISCOVERY_ERROR "") + set(CLR_SDK_REF_PACK_DISCOVERY_RESULT 0) + + if (CPP_CLI_LIVE_REF_ASSEMBLIES) + message("Using live-built ref assemblies for C++/CLI runtime tests.") + execute_process( + COMMAND powershell -ExecutionPolicy ByPass -NoProfile "${CMAKE_CURRENT_LIST_DIR}/getRefPackFolderFromArtifacts.ps1" + OUTPUT_VARIABLE CLR_SDK_REF_PACK_OUTPUT + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE CLR_SDK_REF_PACK_DISCOVERY_ERROR + RESULT_VARIABLE CLR_SDK_REF_PACK_DISCOVERY_RESULT) + else() + execute_process( + COMMAND powershell -ExecutionPolicy ByPass -NoProfile "${CMAKE_CURRENT_LIST_DIR}/getRefPackFolderFromSdk.ps1" + OUTPUT_VARIABLE CLR_SDK_REF_PACK_OUTPUT + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE CLR_SDK_REF_PACK_DISCOVERY_ERROR + RESULT_VARIABLE CLR_SDK_REF_PACK_DISCOVERY_RESULT) + endif() + + if (NOT CLR_SDK_REF_PACK_DISCOVERY_RESULT EQUAL 0) + message(FATAL_ERROR "Unable to find reference assemblies: ${CLR_SDK_REF_PACK_DISCOVERY_ERROR}") + endif() + + string(REGEX REPLACE ".*refPackPath=(.*)" "\\1" CLR_SDK_REF_PACK ${CLR_SDK_REF_PACK_OUTPUT}) + + add_compile_options(/AI${CLR_SDK_REF_PACK}) + + list(APPEND LINK_LIBRARIES_ADDITIONAL ijwhost) + +endif() diff --git a/eng/native/ijw/getRefPackFolderFromArtifacts.ps1 b/eng/native/ijw/getRefPackFolderFromArtifacts.ps1 new file mode 100644 index 0000000000..f9b53286c2 --- /dev/null +++ b/eng/native/ijw/getRefPackFolderFromArtifacts.ps1 @@ -0,0 +1,21 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. + +$engNativeFolder = Split-Path $PSScriptRoot -Parent +$engFolder = Split-Path $engNativeFolder -Parent +$repoRoot = Split-Path $engFolder -Parent + +$versionPropsFile = "$repoRoot/eng/Versions.props" + +$majorVersion = Select-Xml -Path $versionPropsFile -XPath "/Project/PropertyGroup/MajorVersion" | %{$_.Node.InnerText} +$minorVersion = Select-Xml -Path $versionPropsFile -XPath "/Project/PropertyGroup/MinorVersion" | %{$_.Node.InnerText} + +$refPackPath = "$repoRoot/artifacts/bin/ref/net$majorVersion.$minorVersion" + +if (-not (Test-Path $refPackPath)) +{ + Write-Error "Reference assemblies not found in the artifacts folder at '$refPackPath'. Did you invoke 'build.cmd libs.sfx+libs.oob /p:RefOnly=true' to make sure that refs are built? Did the repo layout change?" + exit 1 +} + +Write-Output "refPackPath=$refPackPath" diff --git a/eng/native/ijw/getRefPackFolderFromSdk.ps1 b/eng/native/ijw/getRefPackFolderFromSdk.ps1 new file mode 100644 index 0000000000..1b59248cb4 --- /dev/null +++ b/eng/native/ijw/getRefPackFolderFromSdk.ps1 @@ -0,0 +1,27 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. + +$engNativeFolder = Split-Path $PSScriptRoot -Parent +$engFolder = Split-Path $engNativeFolder -Parent +$repoRoot = Split-Path $engFolder -Parent + +. "$repoRoot/eng/common/tools.ps1" + +$dotnetRoot = InitializeDotNetCli $true $false + +$dotnetSdkVersion = $GlobalJson.tools.dotnet + +$sdkBundledVersionsFile = "$dotnetRoot/sdk/$dotnetSdkVersion/Microsoft.NETCoreSdk.BundledVersions.props" + +$refPackVersion = Select-Xml -Path $sdkBundledVersionsFile -XPath "/Project/PropertyGroup/BundledNETCoreAppPackageVersion" | %{$_.Node.InnerText} +$refPackTfmVersion = Select-Xml -Path $sdkBundledVersionsFile -XPath "/Project/PropertyGroup/BundledNETCoreAppTargetFrameworkVersion" | %{$_.Node.InnerText} + +$refPackPath = "$dotnetRoot/packs/Microsoft.NETCore.App.Ref/$refPackVersion/ref/net$refPackTfmVersion" + +if (-not (Test-Path $refPackPath)) +{ + Write-Error "Reference assemblies not found in the SDK folder. Did the SDK layout change? Did the SDK change how it describes the bundled runtime version?" + exit 1 +} + +Write-Output "refPackPath=$refPackPath" diff --git a/eng/native/init-distro-rid.sh b/eng/native/init-distro-rid.sh index 97fd647081..7501224063 100644 --- a/eng/native/init-distro-rid.sh +++ b/eng/native/init-distro-rid.sh @@ -41,7 +41,7 @@ initNonPortableDistroRid() # We have forced __PortableBuild=0. This is because -portablebuld # has been passed as false. if (( isPortable == 0 )); then - if [[ "${ID}" == "rhel" || "${ID}" == "rocky" ]]; then + if [[ "${ID}" == "rhel" || "${ID}" == "rocky" || "${ID}" == "alpine" ]]; then # remove the last version digit VERSION_ID="${VERSION_ID%.*}" fi @@ -138,7 +138,7 @@ initDistroRidGlobal() fi if [ -n "${rootfsDir}" ]; then - # We may have a cross build. Check for the existance of the rootfsDir + # We may have a cross build. Check for the existence of the rootfsDir if [ ! -e "${rootfsDir}" ]; then echo "Error rootfsDir has been passed, but the location is not valid." exit 1 @@ -168,6 +168,8 @@ initDistroRidGlobal() if [ -z "${distroRid}" ]; then if [ "$targetOs" = "Linux" ]; then distroRid="linux-$buildArch" + elif [ "$targetOs" = "linux-bionic" ]; then + distroRid="linux-bionic-$buildArch" elif [ "$targetOs" = "OSX" ]; then distroRid="osx-$buildArch" elif [ "$targetOs" = "MacCatalyst" ]; then diff --git a/eng/native/init-os-and-arch.sh b/eng/native/init-os-and-arch.sh index eda07a5fee..9f8b78984d 100644 --- a/eng/native/init-os-and-arch.sh +++ b/eng/native/init-os-and-arch.sh @@ -13,8 +13,8 @@ FreeBSD|Linux|NetBSD|OpenBSD|SunOS|Android) Darwin) os=OSX ;; *) - echo "Unsupported OS $OSName detected, configuring as if for Linux" - os=Linux ;; + echo "Unsupported OS $OSName detected!" + exit 1 ;; esac # On Solaris, `uname -m` is discouraged, see https://docs.oracle.com/cd/E36784_01/html/E36870/uname-1.html @@ -41,11 +41,15 @@ case "$CPUName" in arch=loongarch64 ;; + riscv64) + arch=riscv64 + ;; + amd64|x86_64) arch=x64 ;; - armv7l) + armv7l|armv8l) if (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then arch=armel else @@ -64,10 +68,13 @@ case "$CPUName" in s390x) arch=s390x - ;; + ;; + ppc64le) + arch=ppc64le + ;; *) - echo "Unknown CPU $CPUName detected, configuring as if for x64" - arch=x64 + echo "Unknown CPU $CPUName detected!" + exit 1 ;; esac diff --git a/eng/native/init-vs-env.cmd b/eng/native/init-vs-env.cmd index 7eefeea127..5f450d0636 100644 --- a/eng/native/init-vs-env.cmd +++ b/eng/native/init-vs-env.cmd @@ -16,7 +16,7 @@ if /i "%~1" == "wasm" (set __VCBuildArch=x86_amd64) :: is no longer set as a global environment variable and is instead only set if the user :: has launched the Visual Studio Developer Command Prompt. :: -:: Following this logic, we will default to the Visual Studio toolset assocated with the active +:: Following this logic, we will default to the Visual Studio toolset associated with the active :: Developer Command Prompt. Otherwise, we will query VSWhere to locate the later version of :: Visual Studio available on the machine. Finally, we will fail the script if no supported :: instance can be found. @@ -45,14 +45,9 @@ set "__VSCOMNTOOLS=" set "VSCMD_START_DIR=" :VSDetected -if "%VisualStudioVersion%"=="16.0" ( - set __VSVersion=vs2019 - set __PlatformToolset=v142 - goto :SetVCEnvironment -) if "%VisualStudioVersion%"=="17.0" ( set __VSVersion=vs2022 - set __PlatformToolset=v142 + set __PlatformToolset=v143 goto :SetVCEnvironment ) diff --git a/eng/native/naming.props b/eng/native/naming.props index 2f39564569..b50c0c131c 100644 --- a/eng/native/naming.props +++ b/eng/native/naming.props @@ -21,15 +21,6 @@ <SymbolsSuffix>.dwarf</SymbolsSuffix> </PropertyGroup> </When> - <When Condition="$(PackageRID.StartsWith('android'))"> - <PropertyGroup> - <LibPrefix>lib</LibPrefix> - <LibSuffix>.so</LibSuffix> - <StaticLibSuffix>.a</StaticLibSuffix> - <!--symbols included in .so, like Linux, but can be generated externally and if so, uses .debug ext--> - <SymbolsSuffix>.debug</SymbolsSuffix> - </PropertyGroup> - </When> <Otherwise> <PropertyGroup> <LibPrefix>lib</LibPrefix> @@ -45,10 +36,4 @@ <AdditionalSymbolPackageExcludes Condition="'$(LibSuffix)' != ''" Include="%2A%2A\%2A.a;%2A%2A\%2A$(LibSuffix)" /> </ItemGroup> - <!-- arcade is using long name for this property; 'SymbolFileExtension'. - remove this property group when arcade is updated with short name (SymbolsSuffix). --> - <PropertyGroup> - <SymbolFileExtension>$(SymbolsSuffix)</SymbolFileExtension> - </PropertyGroup> - </Project> diff --git a/eng/native/tryrun.cmake b/eng/native/tryrun.cmake index fca410fcb4..5c5344bd80 100644 --- a/eng/native/tryrun.cmake +++ b/eng/native/tryrun.cmake @@ -68,7 +68,7 @@ if(DARWIN) else() message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only arm64 or x64 is supported for OSX cross build!") endif() -elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|s390x|x86)$" OR FREEBSD OR ILLUMOS) +elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|riscv64|s390x|ppc64le|x86)$" OR FREEBSD OR ILLUMOS) set_cache_value(FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL_EXITCODE 1) set_cache_value(GETPWUID_R_SETS_ERRNO_EXITCODE 0) set_cache_value(HAS_POSIX_SEMAPHORES_EXITCODE 0) @@ -146,9 +146,9 @@ elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|s390x|x86)$ set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0) endif() else() - message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only armel, arm, armv6, arm64, loongarch64, s390x and x86 are supported!") + message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only armel, arm, armv6, arm64, loongarch64, s390x, ppc64le and x86 are supported!") endif() -if(TARGET_ARCH_NAME STREQUAL "x86" OR TARGET_ARCH_NAME STREQUAL "s390x" OR TARGET_ARCH_NAME STREQUAL "armv6" OR TARGET_ARCH_NAME STREQUAL "loongarch64") +if(TARGET_ARCH_NAME MATCHES "^(x86|s390x|armv6|loongarch64|riscv64|ppc64le)$") set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0) endif() diff --git a/eng/prepare-release.yml b/eng/prepare-release.yml index f1246e2ec5..73bf0499c0 100644 --- a/eng/prepare-release.yml +++ b/eng/prepare-release.yml @@ -7,13 +7,13 @@ stages: jobs: - job: PrepareReleaseJob displayName: Prepare release with Darc - pool: + pool: ${{ if eq(variables['System.TeamProject'], 'public') }}: - name: NetCore1ESPool-Public - demands: ImageOverride -equals build.windows.10.amd64.vs2019.open + name: NetCore-Public + demands: ImageOverride -equals windows.vs2022.amd64.open ${{ if eq(variables['System.TeamProject'], 'internal') }}: name: NetCore1ESPool-Internal - demands: ImageOverride -equals build.windows.10.amd64.vs2019 + demands: ImageOverride -equals windows.vs2022.amd64 variables: - ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/')) }}: - group: DotNet-Diagnostics-Storage @@ -70,4 +70,4 @@ stages: inputs: targetPath: '$(System.ArtifactsDirectory)\ReleaseStaging' publishLocation: 'pipeline' - artifact: 'DiagnosticsRelease' \ No newline at end of file + artifact: 'DiagnosticsRelease' diff --git a/eng/release/DiagnosticsReleaseTool/DiagnosticsReleaseTool.csproj b/eng/release/DiagnosticsReleaseTool/DiagnosticsReleaseTool.csproj index 08643e0346..46ace05f44 100644 --- a/eng/release/DiagnosticsReleaseTool/DiagnosticsReleaseTool.csproj +++ b/eng/release/DiagnosticsReleaseTool/DiagnosticsReleaseTool.csproj @@ -19,7 +19,7 @@ <PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="[5.0.0]" /> <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="[5.0.0]" /> - <PackageReference Include="Azure.Storage.Blobs" Version="[12.9.1]" /> + <PackageReference Include="Azure.Storage.Blobs" Version="[12.13.0]" /> <PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20467.2" /> </ItemGroup> diff --git a/global.json b/global.json index 4d6c9be5a9..c55bd1ad65 100644 --- a/global.json +++ b/global.json @@ -1,21 +1,25 @@ { "tools": { - "dotnet": "7.0.100-preview.2.22153.17", + "dotnet": "7.0.100-preview.7.22377.5", "runtimes": { "dotnet/x64": [ "$(MicrosoftNETCoreApp31Version)", - "$(MicrosoftNETCoreApp50Version)", - "$(VSRedistCommonNetCoreSharedFrameworkx6460Version)" + "$(MicrosoftNETCoreApp60Version)", + "$(VSRedistCommonNetCoreSharedFrameworkx6470Version)" ], "dotnet/x86": [ "$(MicrosoftNETCoreApp31Version)", - "$(MicrosoftNETCoreApp50Version)", - "$(VSRedistCommonNetCoreSharedFrameworkx6460Version)" + "$(MicrosoftNETCoreApp60Version)", + "$(VSRedistCommonNetCoreSharedFrameworkx6470Version)" + ], + "dotnet/arm64": [ + "$(MicrosoftNETCoreApp60Version)", + "$(VSRedistCommonNetCoreSharedFrameworkx6470Version)" ] } }, "msbuild-sdks": { - "Microsoft.Build.NoTargets": "2.0.1", - "Microsoft.DotNet.Arcade.Sdk": "7.0.0-beta.22276.1" + "Microsoft.Build.NoTargets": "3.5.0", + "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.22466.3" } } diff --git a/src/Directory.Build.props b/src/Directory.Build.props index a57c548c0b..c901bc12d0 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -11,11 +11,11 @@ </PropertyGroup> <PropertyGroup Condition="'$(Configuration)' == 'Debug'"> - <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow> + <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)' == 'Release'"> - <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow> + <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow> </PropertyGroup> <PropertyGroup Condition="'$(TargetFramework)' == 'net462'"> @@ -26,6 +26,7 @@ <DebugType>portable</DebugType> </PropertyGroup> + <Import Project="$(RepositoryEngineeringDir)native\naming.props" /> <Import Condition="'$(DotNetBuildFromSource)' != 'true'" Project="$(RepositoryEngineeringDir)Analyzers.props" /> </Project> diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/CommandService.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/CommandService.cs index bfb2bc5720..7585f33b90 100644 --- a/src/Microsoft.Diagnostics.DebugServices.Implementation/CommandService.cs +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/CommandService.cs @@ -42,8 +42,8 @@ public CommandService(string commandPrompt = null) /// </summary> /// <param name="commandLine">command line text</param> /// <param name="services">services for the command</param> - /// <returns>exit code</returns> - public int Execute(string commandLine, IServiceProvider services) + /// <returns>true success, false failure</returns> + public bool Execute(string commandLine, IServiceProvider services) { // Parse the command line and invoke the command ParseResult parseResult = Parser.Parse(commandLine); @@ -70,7 +70,7 @@ public int Execute(string commandLine, IServiceProvider services) { context.Console.Error.WriteLine($"Command '{command.Name}' needs a target"); } - return 1; + return false; } try { @@ -78,14 +78,27 @@ public int Execute(string commandLine, IServiceProvider services) } catch (Exception ex) { - OnException(ex, context); + if (ex is NullReferenceException || + ex is ArgumentException || + ex is ArgumentNullException || + ex is ArgumentOutOfRangeException || + ex is NotImplementedException) + { + context.Console.Error.WriteLine(ex.ToString()); + } + else + { + context.Console.Error.WriteLine(ex.Message); + } + Trace.TraceError(ex.ToString()); + return false; } } } } context.InvocationResult?.Apply(context); - return context.ResultCode; + return context.ResultCode == 0; } /// <summary> @@ -137,6 +150,13 @@ public bool DisplayHelp(string commandName, IServiceProvider services) return true; } + /// <summary> + /// Does this command or alias exists? + /// </summary> + /// <param name="commandName">command or alias name</param> + /// <returns>true if command exists</returns> + public bool IsCommand(string commandName) => _rootBuilder.Command.Children.Contains(commandName); + /// <summary> /// Enumerates all the command's name and help /// </summary> @@ -149,28 +169,31 @@ public bool DisplayHelp(string commandName, IServiceProvider services) /// <param name="factory">function to create command instance</param> public void AddCommands(Type type, Func<IServiceProvider, object> factory) { - for (Type baseType = type; baseType != null; baseType = baseType.BaseType) + if (type.IsClass) { - if (baseType == typeof(CommandBase)) { - break; - } - var commandAttributes = (CommandAttribute[])baseType.GetCustomAttributes(typeof(CommandAttribute), inherit: false); - foreach (CommandAttribute commandAttribute in commandAttributes) + for (Type baseType = type; baseType != null; baseType = baseType.BaseType) { - if (factory == null) + if (baseType == typeof(CommandBase)) { - // Assumes zero parameter constructor - ConstructorInfo constructor = type.GetConstructors().SingleOrDefault((info) => info.GetParameters().Length == 0) ?? - throw new ArgumentException($"No eligible constructor found in {type}"); - - factory = (services) => constructor.Invoke(Array.Empty<object>()); + break; + } + var commandAttributes = (CommandAttribute[])baseType.GetCustomAttributes(typeof(CommandAttribute), inherit: false); + foreach (CommandAttribute commandAttribute in commandAttributes) + { + if ((commandAttribute.Flags & CommandFlags.Manual) == 0 || factory != null) + { + if (factory == null) + { + factory = (services) => Utilities.InvokeConstructor(type, services, optional: true); + } + CreateCommand(baseType, commandAttribute, factory); + } } - CreateCommand(baseType, commandAttribute, factory); } - } - // Build or re-build parser instance after all these commands and aliases are added - FlushParser(); + // Build or re-build parser instance after all these commands and aliases are added + FlushParser(); + } } private void CreateCommand(Type type, CommandAttribute commandAttribute, Func<IServiceProvider, object> factory) @@ -234,27 +257,6 @@ private void CreateCommand(Type type, CommandAttribute commandAttribute, Func<IS private void FlushParser() => _parser = null; - private void OnException(Exception ex, InvocationContext context) - { - if (ex is TargetInvocationException) - { - ex = ex.InnerException; - } - if (ex is NullReferenceException || - ex is ArgumentException || - ex is ArgumentNullException || - ex is ArgumentOutOfRangeException || - ex is NotImplementedException) - { - context.Console.Error.WriteLine(ex.ToString()); - } - else - { - context.Console.Error.WriteLine(ex.Message); - } - Trace.TraceError(ex.ToString()); - } - private static string BuildOptionAlias(string parameterName) { if (string.IsNullOrWhiteSpace(parameterName)) { @@ -319,7 +321,7 @@ Task<int> ICommandHandler.InvokeAsync(InvocationContext context) /// </summary> internal bool IsValidPlatform(ITarget target) { - if ((_commandAttribute.Platform & CommandPlatform.Global) != 0) + if ((_commandAttribute.Flags & CommandFlags.Global) != 0) { return true; } @@ -327,15 +329,15 @@ internal bool IsValidPlatform(ITarget target) { if (target.OperatingSystem == OSPlatform.Windows) { - return (_commandAttribute.Platform & CommandPlatform.Windows) != 0; + return (_commandAttribute.Flags & CommandFlags.Windows) != 0; } if (target.OperatingSystem == OSPlatform.Linux) { - return (_commandAttribute.Platform & CommandPlatform.Linux) != 0; + return (_commandAttribute.Flags & CommandFlags.Linux) != 0; } if (target.OperatingSystem == OSPlatform.OSX) { - return (_commandAttribute.Platform & CommandPlatform.OSX) != 0; + return (_commandAttribute.Flags & CommandFlags.OSX) != 0; } } return false; @@ -372,9 +374,7 @@ private void Invoke(MethodInfo methodInfo, InvocationContext context, Parser par { object instance = _factory(services); SetProperties(context, parser, services, instance); - - object[] arguments = BuildArguments(methodInfo, services); - methodInfo.Invoke(instance, arguments); + Utilities.Invoke(methodInfo, instance, services, optional: true); } private void SetProperties(InvocationContext context, Parser parser, IServiceProvider services, object instance) @@ -461,21 +461,6 @@ private void SetProperties(InvocationContext context, Parser parser, IServicePro argument.Property.SetValue(instance, array != null ? array.ToArray() : value); } } - - private object[] BuildArguments(MethodBase methodBase, IServiceProvider services) - { - ParameterInfo[] parameters = methodBase.GetParameters(); - object[] arguments = new object[parameters.Length]; - for (int i = 0; i < parameters.Length; i++) - { - Type parameterType = parameters[i].ParameterType; - - // The parameter will passed as null to allow for "optional" services. The invoked - // method needs to check for possible null parameters. - arguments[i] = services.GetService(parameterType); - } - return arguments; - } } /// <summary> diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/DataReader.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/DataReader.cs new file mode 100644 index 0000000000..27fe813105 --- /dev/null +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/DataReader.cs @@ -0,0 +1,208 @@ +// 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 Microsoft.Diagnostics.Runtime; +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace Microsoft.Diagnostics.DebugServices.Implementation +{ + /// <summary> + /// ClrMD runtime service implementation + /// </summary> + internal class DataReader : IDataReader + { + private readonly ITarget _target; + private IEnumerable<ModuleInfo> _modules; + private IModuleService _moduleService; + private IThreadService _threadService; + private IMemoryService _memoryService; + + public DataReader(ITarget target) + { + _target = target; + target.OnFlushEvent.Register(() => _modules = null); + } + + #region IDataReader + + string IDataReader.DisplayName => ""; + + bool IDataReader.IsThreadSafe => false; + + OSPlatform IDataReader.TargetPlatform => _target.OperatingSystem; + + Architecture IDataReader.Architecture => _target.Architecture; + + int IDataReader.ProcessId => unchecked((int)_target.ProcessId.GetValueOrDefault()); + + IEnumerable<ModuleInfo> IDataReader.EnumerateModules() => _modules ??= ModuleService.EnumerateModules().Select((module) => new DataReaderModule(module)).ToList(); + + bool IDataReader.GetThreadContext(uint threadId, uint contextFlags, Span<byte> context) + { + try + { + byte[] registerContext = ThreadService.GetThreadFromId(threadId).GetThreadContext(); + context = new Span<byte>(registerContext); + return true; + } + catch (DiagnosticsException ex) + { + Trace.TraceError($"GetThreadContext: {threadId} exception {ex.Message}"); + } + return false; + } + + void IDataReader.FlushCachedData() + { + } + + #endregion + + #region IMemoryReader + + int IMemoryReader.PointerSize => MemoryService.PointerSize; + + int IMemoryReader.Read(ulong address, Span<byte> buffer) + { + MemoryService.ReadMemory(address, buffer, out int bytesRead); + return bytesRead; + } + + bool IMemoryReader.Read<T>(ulong address, out T value) + { + Span<byte> buffer = stackalloc byte[Marshal.SizeOf<T>()]; + if (((IMemoryReader)this).Read(address, buffer) == buffer.Length) + { + value = Unsafe.As<byte, T>(ref MemoryMarshal.GetReference(buffer)); + return true; + } + value = default; + return false; + } + + T IMemoryReader.Read<T>(ulong address) + { + ((IMemoryReader)this).Read(address, out T result); + return result; + } + + bool IMemoryReader.ReadPointer(ulong address, out ulong value) + { + return MemoryService.ReadPointer(address, out value); + } + + ulong IMemoryReader.ReadPointer(ulong address) + { + MemoryService.ReadPointer(address, out ulong value); + return value; + } + + #endregion + + private IModuleService ModuleService => _moduleService ??= _target.Services.GetService<IModuleService>(); + + private IMemoryService MemoryService => _memoryService ??= _target.Services.GetService<IMemoryService>(); + + private IThreadService ThreadService => _threadService ??= _target.Services.GetService<IThreadService>(); + + private class DataReaderModule : ModuleInfo + { + private readonly IModule _module; + + public DataReaderModule(IModule module) + : base(module.ImageBase, module.FileName) + { + _module = module; + } + + public override long ImageSize => unchecked((long)_module.ImageSize); + + public override int IndexFileSize => unchecked((int)_module.IndexFileSize.GetValueOrDefault(0)); + + public override int IndexTimeStamp => unchecked((int)_module.IndexTimeStamp.GetValueOrDefault(0)); + + public override ModuleKind Kind => ModuleKind.Unknown; + + public override Version Version + { + get + { + try + { + return _module.GetVersionData() ?? Utilities.EmptyVersion; + } + catch (DiagnosticsException ex) + { + Trace.TraceError($"ModuleInfo.Version: {_module.ImageBase:X16} exception {ex.Message}"); + } + return Utilities.EmptyVersion; + } + } + + public override ImmutableArray<byte> BuildId + { + get + { + try + { + return _module.BuildId; + } + catch (DiagnosticsException ex) + { + Trace.TraceError($"ModuleInfo.BuildId: {_module.ImageBase:X16} exception {ex.Message}"); + } + return ImmutableArray<byte>.Empty; + } + } + + public override PdbInfo Pdb + { + get + { + try + { + PdbFileInfo pdbFileInfo = _module.GetPdbFileInfos().Where((pdbFileInfo) => pdbFileInfo.IsPortable).LastOrDefault(); + if (pdbFileInfo is null) + { + pdbFileInfo = _module.GetPdbFileInfos().LastOrDefault(); + if (pdbFileInfo is null) + { + return default; + } + } + return new PdbInfo(pdbFileInfo.Path, pdbFileInfo.Guid, pdbFileInfo.Revision); + } + catch (DiagnosticsException ex) + { + Trace.TraceError($"ModuleInfo.Pdb: {_module.ImageBase:X16} exception {ex.Message}"); + } + return default; + } + } + + public override bool IsManaged => _module.IsManaged; + + public override ulong GetExportSymbolAddress(string symbol) + { + var exportSymbols = _module.Services.GetService<IExportSymbols>(); + if (exportSymbols is not null) + { + if (exportSymbols.TryGetSymbolAddress(symbol, out ulong offset)) + { + return offset; + } + } + return 0; + } + + public override IResourceNode ResourceRoot => base.ResourceRoot; + } + } +} diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/DiagnosticLoggingService.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/DiagnosticLoggingService.cs new file mode 100644 index 0000000000..94ee4a312e --- /dev/null +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/DiagnosticLoggingService.cs @@ -0,0 +1,166 @@ +// 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 Microsoft.Diagnostics.DebugServices; +using System; +using System.Diagnostics; +using System.IO; +using System.Security; + +namespace Microsoft.Diagnostics.ExtensionCommands +{ + public class DiagnosticLoggingService : IDiagnosticLoggingService + { + private const string ListenerName = "SOS.LoggingListener"; + private IConsoleService _consoleService; + private IConsoleFileLoggingService _fileLoggingService; + private StreamWriter _writer; + + public static DiagnosticLoggingService Instance { get; } = new DiagnosticLoggingService(); + + private DiagnosticLoggingService() + { + } + + #region IDiagnosticLoggingService + + /// <summary> + /// Returns true if logging to console or file + /// </summary> + public bool IsEnabled => Trace.Listeners[ListenerName] is not null; + + /// <summary> + /// The file path if logging to file. + /// </summary> + public string FilePath => (_writer?.BaseStream as FileStream)?.Name; + + /// <summary> + /// Enable diagnostics logging. + /// </summary> + /// <param name="filePath">log file path or null if log to console</param> + /// <remarks>see File.Open for possible exceptions thrown</remarks> + public void Enable(string filePath) + { + if (filePath is not null) + { + FileStream stream = File.Open(filePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite); + CloseLogging(); + _writer = new StreamWriter(stream) { + AutoFlush = true + }; + _fileLoggingService?.AddStream(stream); + } + if (Trace.Listeners[ListenerName] is null) + { + Trace.Listeners.Add(new LoggingListener(this)); + Trace.AutoFlush = true; + } + } + + /// <summary> + /// Disable diagnostics logging (close if logging to file). + /// </summary> + public void Disable() + { + CloseLogging(); + Trace.Listeners.Remove(ListenerName); + } + + #endregion + + /// <summary> + /// Initializes the diagnostic logging service. Reads the DOTNET_ENABLED_SOS_LOGGING + /// environment variable to log to console or file. + /// </summary> + /// <param name="logfile"></param> + public static void Initialize(string logfile = null) + { + try + { + if (string.IsNullOrWhiteSpace(logfile)) + { + logfile = Environment.GetEnvironmentVariable("DOTNET_ENABLED_SOS_LOGGING"); + } + if (!string.IsNullOrWhiteSpace(logfile)) + { + Instance.Enable(logfile == "1" ? null : logfile); + } + } + catch (Exception ex) when ( ex is IOException || ex is NotSupportedException || ex is SecurityException || ex is UnauthorizedAccessException) + { + } + } + + /// <summary> + /// Sets the console service and the console file logging control service. + /// </summary> + /// <param name="consoleService">This is used for to log to the console</param> + /// <param name="fileLoggingService">This is used to hook the command console output to write the diagnostic log file.</param> + public void SetConsole(IConsoleService consoleService, IConsoleFileLoggingService fileLoggingService = null) + { + _consoleService = consoleService; + _fileLoggingService = fileLoggingService; + } + + private void CloseLogging() + { + if (_writer is not null) + { + _fileLoggingService?.RemoveStream(_writer.BaseStream); + _writer.Flush(); + _writer.Close(); + _writer = null; + } + } + + class LoggingListener : TraceListener + { + private readonly DiagnosticLoggingService _diagnosticLoggingService; + + internal LoggingListener(DiagnosticLoggingService diagnosticLoggingService) + : base(ListenerName) + { + _diagnosticLoggingService = diagnosticLoggingService; + } + + public override void Close() + { + _diagnosticLoggingService.CloseLogging(); + base.Close(); + } + + public override void Write(string message) + { + if (_diagnosticLoggingService._writer is not null) + { + try + { + _diagnosticLoggingService._writer.Write(message); + return; + } + catch (Exception ex) when (ex is IOException || ex is ObjectDisposedException || ex is NotSupportedException) + { + } + } + _diagnosticLoggingService._consoleService?.Write(message); + } + + public override void WriteLine(string message) + { + if (_diagnosticLoggingService._writer is not null) + { + try + { + _diagnosticLoggingService._writer.WriteLine(message); + return; + } + catch (Exception ex) when (ex is IOException || ex is ObjectDisposedException || ex is NotSupportedException) + { + } + } + _diagnosticLoggingService._consoleService?.WriteLine(message); + } + } + } +} diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/FileLoggingConsoleService.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/FileLoggingConsoleService.cs new file mode 100644 index 0000000000..ea041eda99 --- /dev/null +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/FileLoggingConsoleService.cs @@ -0,0 +1,171 @@ +// 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.Threading; + +namespace Microsoft.Diagnostics.DebugServices.Implementation +{ + /// <summary> + /// Log to file console service wrapper + /// </summary> + public class FileLoggingConsoleService : IConsoleService, IConsoleFileLoggingService, IDisposable + { + private readonly IConsoleService _consoleService; + private readonly List<StreamWriter> _writers; + private FileStream _consoleStream; + + public FileLoggingConsoleService(IConsoleService consoleService) + { + _consoleService = consoleService; + _writers = new List<StreamWriter>(); + } + + public void Dispose() => Disable(); + + #region IConsoleFileLoggingService + + /// <summary> + /// The log file path if enabled, otherwise null. + /// </summary> + public string FilePath => _consoleStream?.Name; + + /// <summary> + /// Enable console file logging. + /// </summary> + /// <param name="filePath">log file path</param> + /// <remarks>see File.Open for more exceptions</remarks> + public void Enable(string filePath) + { + FileStream consoleStream = File.Open(filePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite); + Disable(); + AddStream(consoleStream); + _consoleStream = consoleStream; + } + + /// <summary> + /// Disable/close console file logging + /// </summary> + public void Disable() + { + if (_consoleStream is not null) + { + RemoveStream(_consoleStream); + _consoleStream.Close(); + _consoleStream = null; + } + } + + /// <summary> + /// Add to the list of file streams to write the console output. + /// </summary> + /// <param name="stream">Stream to add. Lifetime managed by caller.</param> + public void AddStream(Stream stream) + { + Debug.Assert(stream is not null); + _writers.Add(new StreamWriter(stream) { + AutoFlush = true + }); + } + + /// <summary> + /// Remove the specified file stream from the writers. + /// </summary> + /// <param name="stream">Stream passed to add. Stream not closed or disposed.</param> + public void RemoveStream(Stream stream) + { + if (stream is not null) + { + foreach (StreamWriter writer in _writers) + { + if (writer.BaseStream == stream) + { + _writers.Remove(writer); + break; + } + } + } + } + + #endregion + + #region IConsoleService + + public void Write(string text) + { + _consoleService.Write(text); + foreach (StreamWriter writer in _writers) + { + try + { + writer.Write(text); + } + catch (Exception ex) when (ex is IOException || ex is ObjectDisposedException || ex is NotSupportedException) + { + } + } + } + + public void WriteWarning(string text) + { + _consoleService.WriteWarning(text); + foreach (StreamWriter writer in _writers) + { + try + { + writer.Write(text); + } + catch (Exception ex) when (ex is IOException || ex is ObjectDisposedException || ex is NotSupportedException) + { + } + } + } + + public void WriteError(string text) + { + _consoleService.WriteError(text); + foreach (StreamWriter writer in _writers) + { + try + { + writer.Write(text); + } + catch (Exception ex) when (ex is IOException || ex is ObjectDisposedException || ex is NotSupportedException) + { + } + } + } + + public bool SupportsDml => _consoleService.SupportsDml; + + public void WriteDml(string text) + { + _consoleService.WriteDml(text); + foreach (StreamWriter writer in _writers) + { + try + { + // TODO: unwrap the DML? + writer.Write(text); + } + catch (Exception ex) when (ex is IOException || ex is ObjectDisposedException || ex is NotSupportedException) + { + } + } + } + + public CancellationToken CancellationToken + { + get { return _consoleService.CancellationToken; } + set { _consoleService.CancellationToken = value; } + } + + public int WindowWidth => _consoleService.WindowWidth; + + #endregion + } +} diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/ImageMappingMemoryService.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/ImageMappingMemoryService.cs index c27f5d4df1..1ceffe6044 100644 --- a/src/Microsoft.Diagnostics.DebugServices.Implementation/ImageMappingMemoryService.cs +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/ImageMappingMemoryService.cs @@ -2,15 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Diagnostics.Runtime.Utilities; using Microsoft.FileFormats; -using Microsoft.FileFormats.ELF; -using Microsoft.FileFormats.MachO; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Linq; using System.Reflection.Metadata; using System.Reflection.PortableExecutable; @@ -229,7 +225,7 @@ private void ApplyRelocations(IModule module, PEReader reader, int dataVA, byte[ PEMemoryBlock relocations = reader.GetSectionData(".reloc"); if (relocations.Length > 0) { - ulong baseDelta = module.ImageBase - reader.PEHeaders.PEHeader.ImageBase; + ulong baseDelta = unchecked(module.ImageBase - reader.PEHeaders.PEHeader.ImageBase); #if TRACE_VERBOSE Trace.TraceInformation("ApplyRelocations: dataVA {0:X8} dataCB {1} baseDelta: {2:X16}", dataVA, data.Length, baseDelta); #endif @@ -271,7 +267,7 @@ private void ApplyRelocations(IModule module, PEReader reader, int dataVA, byte[ if ((offset + sizeof(uint)) <= data.Length) { uint value = BitConverter.ToUInt32(data, offset); - value += (uint)baseDelta; + unchecked { value += (uint)baseDelta; } byte[] source = BitConverter.GetBytes(value); Array.Copy(source, 0, data, offset, source.Length); } diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/MetadataMappingMemoryService.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/MetadataMappingMemoryService.cs index e2811bd58c..19b382ee80 100644 --- a/src/Microsoft.Diagnostics.DebugServices.Implementation/MetadataMappingMemoryService.cs +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/MetadataMappingMemoryService.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using Microsoft.Diagnostics.Runtime; -using Microsoft.Diagnostics.Runtime.Utilities; using Microsoft.FileFormats; using Microsoft.FileFormats.PE; using System; diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/Module.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/Module.cs index dde7210a41..20ba0b92b7 100644 --- a/src/Microsoft.Diagnostics.DebugServices.Implementation/Module.cs +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/Module.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Diagnostics.Runtime.Utilities; +using Microsoft.Diagnostics.Runtime; using Microsoft.FileFormats; using Microsoft.FileFormats.ELF; using Microsoft.FileFormats.MachO; @@ -197,7 +197,7 @@ public string GetSymbolFileName() { if (InitializeValue(Flags.InitializeSymbolFileName)) { - if (Target.OperatingSystem == OSPlatform.Linux) + if (ImageSize > 0 && Target.OperatingSystem == OSPlatform.Linux) { try { @@ -216,8 +216,8 @@ public string GetSymbolFileName() (ex is InvalidVirtualAddressException || ex is ArgumentOutOfRangeException || ex is IndexOutOfRangeException || + ex is OverflowException || ex is BadInputFormatException) - { Trace.TraceWarning("ELF .gnu_debuglink section in {0}: {1}", this, ex.Message); } @@ -226,7 +226,7 @@ ex is IndexOutOfRangeException || return _symbolFileName; } - public abstract VersionData GetVersionData(); + public abstract Version GetVersionData(); public abstract string GetVersionString(); @@ -254,24 +254,15 @@ bool IExportSymbols.TryGetSymbolAddress(string name, out ulong address) } else if (Target.OperatingSystem == OSPlatform.Linux) { - try + if (ImageSize > 0) { - Stream stream = ModuleService.MemoryService.CreateMemoryStream(ImageBase, ImageSize); - ElfFile elfFile = new(stream, position: ImageBase, leaveOpen: false, isVirtual: true); - if (elfFile.Header.IsValid) + ModuleInfo module = ModuleInfo.TryCreate(Target.Services.GetService<DataReader>(), ImageBase, FileName); + if (module is not null) { - if (elfFile.TryGetExportSymbol(name, out ulong offset)) - { - address = ImageBase + offset; - return true; - } - address = 0; - return false; + address = module.GetExportSymbolAddress(name); + return address != 0; } } - catch (InvalidDataException) - { - } } return TryGetSymbolAddressInner(name, out address); } @@ -284,9 +275,9 @@ protected virtual bool TryGetSymbolAddressInner(string name, out ulong address) #endregion - protected VersionData GetVersion() + protected Version GetVersionInner() { - VersionData versionData = null; + Version version = null; PEFile peFile = GetPEInfo(); if (peFile != null) @@ -296,7 +287,7 @@ protected VersionData GetVersion() VsFixedFileInfo fileInfo = peFile.VersionInfo; if (fileInfo != null) { - versionData = fileInfo.ToVersionData(); + version = fileInfo.ToVersion(); } } catch (Exception ex) when (ex is InvalidVirtualAddressException || ex is BadInputFormatException) @@ -325,8 +316,7 @@ protected VersionData GetVersion() string versionToParse = versionString.Substring(0, spaceIndex); try { - Version version = System.Version.Parse(versionToParse); - versionData = new VersionData(version.Major, version.Minor, version.Build, version.Revision); + version = Version.Parse(versionToParse); } catch (ArgumentException ex) { @@ -336,7 +326,7 @@ protected VersionData GetVersion() } } - return versionData; + return version; } protected PEFile GetPEInfo() diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/ModuleService.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/ModuleService.cs index d58bf78cc5..bd437e85e7 100644 --- a/src/Microsoft.Diagnostics.DebugServices.Implementation/ModuleService.cs +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/ModuleService.cs @@ -212,7 +212,7 @@ internal PEFile GetPEInfo(ulong address, ulong size, out IEnumerable<PdbFileInfo moduleFlags &= ~(Module.Flags.IsPEImage | Module.Flags.IsManaged | Module.Flags.IsLoadedLayout | Module.Flags.IsFileLayout); // None of the modules that lldb (on either Linux/MacOS) provides are PEs - if (Target.Host.HostType != HostType.Lldb) + if (size > 0 && Target.Host.HostType != HostType.Lldb) { // First try getting the PE info as loaded layout (native Windows DLLs and most managed PEs). peFile = GetPEInfo(isVirtual: true, address, size, out List<PdbFileInfo> pdbs, out Module.Flags flags); @@ -367,7 +367,7 @@ protected string GetVersionString(IModule module) } else { - Trace.TraceError($"GetVersionString: unsupported module {module} or platform {Target.OperatingSystem}"); + Trace.TraceError($"GetVersionString: unsupported module {module} on platform {Target.OperatingSystem}"); } } } @@ -494,7 +494,7 @@ internal bool Read(ulong address, byte[] buffer, int bufferSize, out int bytesRe return _memoryService.ReadMemory(address, buffer, bufferSize, out bytesRead); } - if (!_cacheValid || (address < _startCache) || (address > (_startCache + (ulong)(_cacheSize - bufferSize)))) + if (!_cacheValid || (address < _startCache) || (address > (_startCache + (ulong)_cacheSize - (ulong)bufferSize))) { _cacheValid = false; _startCache = address; diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/ModuleServiceFromDataReader.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/ModuleServiceFromDataReader.cs index 4624b94a22..0ad0019c47 100644 --- a/src/Microsoft.Diagnostics.DebugServices.Implementation/ModuleServiceFromDataReader.cs +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/ModuleServiceFromDataReader.cs @@ -22,21 +22,18 @@ class ModuleFromDataReader : Module // This is what clrmd returns for non-PE modules that don't have a timestamp private const uint InvalidTimeStamp = 0; - private static readonly VersionInfo EmptyVersionInfo = new (0, 0, 0, 0); private readonly ModuleServiceFromDataReader _moduleService; - private readonly IExportReader _exportReader; private readonly ModuleInfo _moduleInfo; private readonly ulong _imageSize; - private VersionData _versionData; + private Version _version; private string _versionString; - public ModuleFromDataReader(ModuleServiceFromDataReader moduleService, IExportReader exportReader, int moduleIndex, ModuleInfo moduleInfo, ulong imageSize) + public ModuleFromDataReader(ModuleServiceFromDataReader moduleService, int moduleIndex, ModuleInfo moduleInfo, ulong imageSize) : base(moduleService.Target) { _moduleService = moduleService; _moduleInfo = moduleInfo; _imageSize = imageSize; - _exportReader = exportReader; ModuleIndex = moduleIndex; } @@ -50,9 +47,9 @@ public ModuleFromDataReader(ModuleServiceFromDataReader moduleService, IExportRe public override ulong ImageSize => _imageSize; - public override uint? IndexFileSize => _moduleInfo.IndexTimeStamp == InvalidTimeStamp ? null : (uint)_moduleInfo.IndexFileSize; + public override uint? IndexFileSize => _moduleInfo.IndexTimeStamp == InvalidTimeStamp ? null : unchecked((uint)_moduleInfo.IndexFileSize); - public override uint? IndexTimeStamp => _moduleInfo.IndexTimeStamp == InvalidTimeStamp ? null : (uint)_moduleInfo.IndexTimeStamp; + public override uint? IndexTimeStamp => _moduleInfo.IndexTimeStamp == InvalidTimeStamp ? null : unchecked((uint)_moduleInfo.IndexTimeStamp); public override ImmutableArray<byte> BuildId { @@ -60,7 +57,7 @@ public override ImmutableArray<byte> BuildId { if (_buildId.IsDefault) { - ImmutableArray<byte> buildId = _moduleService._dataReader.GetBuildId(ImageBase); + ImmutableArray<byte> buildId = _moduleInfo.BuildId; // If the data reader can't get the build id, it returns a empty (instead of default) immutable array. _buildId = buildId.IsDefaultOrEmpty ? base.BuildId : buildId; } @@ -68,23 +65,23 @@ public override ImmutableArray<byte> BuildId } } - public override VersionData GetVersionData() + public override Version GetVersionData() { if (InitializeValue(Module.Flags.InitializeVersion)) { - if (_moduleInfo.Version != EmptyVersionInfo) + if (!_moduleInfo.Version.Equals(Utilities.EmptyVersion)) { - _versionData = _moduleInfo.Version.ToVersionData(); + _version = _moduleInfo.Version; } else { if (_moduleService.Target.OperatingSystem != OSPlatform.Windows) { - _versionData = GetVersion(); + _version = GetVersionInner(); } } } - return _versionData; + return _version; } public override string GetVersionString() @@ -108,12 +105,8 @@ public override string LoadSymbols() protected override bool TryGetSymbolAddressInner(string name, out ulong address) { - if (_exportReader is not null) - { - return _exportReader.TryGetSymbolAddress(ImageBase, name, out address); - } - address = 0; - return false; + address = _moduleInfo.GetExportSymbolAddress(name); + return address != 0; } protected override ModuleService ModuleService => _moduleService; @@ -135,35 +128,44 @@ protected override Dictionary<ulong, IModule> GetModulesInner() var modules = new Dictionary<ulong, IModule>(); int moduleIndex = 0; - IExportReader exportReader = _dataReader as IExportReader; ModuleInfo[] moduleInfos = _dataReader.EnumerateModules().OrderBy((info) => info.ImageBase).ToArray(); for (int i = 0; i < moduleInfos.Length; i++) { ModuleInfo moduleInfo = moduleInfos[i]; - ulong imageSize = (uint)moduleInfo.IndexFileSize; - if ((i + 1) < moduleInfos.Length) + ulong imageSize = (ulong)moduleInfo.ImageSize; + + // Only add images that have a size. On Linux these are special files like /run/shm/lttng-ust-wait-8-1000 and non-ELF + // resource(?) files like /usr/share/zoneinfo-icu/44/le/metaZones.res. Haven't see any 0 sized PE or MachO files. + if (imageSize > 0) { - ModuleInfo moduleInfoNext = moduleInfos[i + 1]; - ulong start = moduleInfo.ImageBase; - ulong end = moduleInfo.ImageBase + imageSize; - ulong startNext = moduleInfoNext.ImageBase; + // There are times when the module infos returned by the data reader overlap which breaks the module + // service's address binary search. This code adjusts the module's image size to the next module's + // image base address if there is overlap. + if ((i + 1) < moduleInfos.Length) + { + ModuleInfo moduleInfoNext = moduleInfos[i + 1]; + ulong start = moduleInfo.ImageBase; + ulong end = moduleInfo.ImageBase + imageSize; + ulong startNext = moduleInfoNext.ImageBase; - if (end > startNext) + if (end > startNext) + { + Trace.TraceWarning($"Module {moduleInfo.FileName} {start:X16} - {end:X16} ({imageSize:X8})"); + Trace.TraceWarning($" overlaps with {moduleInfoNext.FileName} {startNext:X16}"); + imageSize = startNext - start; + } + } + var module = new ModuleFromDataReader(this, moduleIndex, moduleInfo, imageSize); + try { - Trace.TraceWarning($"Module {moduleInfo.FileName} {start:X16} - {end:X16} ({imageSize:X8})"); - Trace.TraceWarning($" overlaps with {moduleInfoNext.FileName} {startNext:X16}"); - imageSize = startNext - start; + modules.Add(moduleInfo.ImageBase, module); + } + catch (ArgumentException) + { + Trace.TraceError($"GetModules(): duplicate module base '{module}' dup '{modules[moduleInfo.ImageBase]}'"); } } - var module = new ModuleFromDataReader(this, exportReader, moduleIndex, moduleInfo, imageSize); - try - { - modules.Add(moduleInfo.ImageBase, module); - } - catch (ArgumentException) - { - Trace.TraceError($"GetModules(): duplicate module base '{module}' dup '{modules[moduleInfo.ImageBase]}'"); - } + moduleIndex++; } return modules; diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/Runtime.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/Runtime.cs index 6eb88cb6a9..eb0d608f85 100644 --- a/src/Microsoft.Diagnostics.DebugServices.Implementation/Runtime.cs +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/Runtime.cs @@ -70,12 +70,7 @@ public string GetDacFilePath() { if (_dacFilePath is null) { - string dacFileName = GetDacFileName(); - _dacFilePath = GetLocalDacPath(dacFileName); - if (_dacFilePath is null) - { - _dacFilePath = DownloadFile(dacFileName); - } + _dacFilePath = GetLibraryPath(DebugLibraryKind.Dac); } return _dacFilePath; } @@ -84,12 +79,7 @@ public string GetDbiFilePath() { if (_dbiFilePath is null) { - string dbiFileName = GetDbiFileName(); - _dbiFilePath = GetLocalPath(dbiFileName); - if (_dbiFilePath is null) - { - _dbiFilePath = DownloadFile(dbiFileName); - } + _dbiFilePath = GetLibraryPath(DebugLibraryKind.Dbi); } return _dbiFilePath; } @@ -131,62 +121,45 @@ ex is InvalidDataException || return _clrRuntime; } - private string GetDacFileName() + private string GetLibraryPath(DebugLibraryKind kind) { - if (_clrInfo.SingleFileRuntimeInfo.HasValue) - { - return ClrInfoProvider.GetDacFileName(_clrInfo.Flavor, Target.OperatingSystem); - } - Debug.Assert(!string.IsNullOrEmpty(_clrInfo.DacInfo.PlatformSpecificFileName)); - return _clrInfo.DacInfo.PlatformSpecificFileName; - } + Architecture currentArch = RuntimeInformation.ProcessArchitecture; + string libraryPath = null; - private string GetLocalDacPath(string dacFileName) - { - string dacFilePath; - if (!string.IsNullOrEmpty(RuntimeModuleDirectory)) - { - dacFilePath = Path.Combine(RuntimeModuleDirectory, dacFileName); - } - else + foreach (DebugLibraryInfo libraryInfo in _clrInfo.DebuggingLibraries) { - dacFilePath = _clrInfo.DacInfo.LocalDacPath; - - // On MacOS CLRMD doesn't return the full DAC path just the file name so check if it exists - if (string.IsNullOrEmpty(dacFilePath) || !File.Exists(dacFilePath)) + if (libraryInfo.Kind == kind && RuntimeInformation.IsOSPlatform(libraryInfo.Platform) && libraryInfo.TargetArchitecture == currentArch) { - dacFilePath = Path.Combine(Path.GetDirectoryName(RuntimeModule.FileName), dacFileName); + libraryPath = GetLocalPath(libraryInfo.FileName); + if (libraryPath is not null) + { + break; + } + libraryPath = DownloadFile(libraryInfo); + if (libraryPath is not null) + { + break; + } } } - if (!File.Exists(dacFilePath)) - { - dacFilePath = null; - } - return dacFilePath; - } - - private string GetDbiFileName() - { - string name = Target.GetPlatformModuleName("mscordbi"); - // If this is the Linux runtime module name, but we are running on Windows return the cross-OS DBI name. - if (Target.OperatingSystem == OSPlatform.Linux && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - name = "mscordbi.dll"; - } - return name; + return libraryPath; } private string GetLocalPath(string fileName) { + if (File.Exists(fileName)) + { + return fileName; + } string localFilePath; if (!string.IsNullOrEmpty(RuntimeModuleDirectory)) { - localFilePath = Path.Combine(RuntimeModuleDirectory, fileName); + localFilePath = Path.Combine(RuntimeModuleDirectory, Path.GetFileName(fileName)); } else { - localFilePath = Path.Combine(Path.GetDirectoryName(RuntimeModule.FileName), fileName); + localFilePath = Path.Combine(Path.GetDirectoryName(RuntimeModule.FileName), Path.GetFileName(fileName)); } if (!File.Exists(localFilePath)) { @@ -195,7 +168,7 @@ private string GetLocalPath(string fileName) return localFilePath; } - private string DownloadFile(string fileName) + private string DownloadFile(DebugLibraryInfo libraryInfo) { OSPlatform platform = Target.OperatingSystem; string filePath = null; @@ -207,41 +180,54 @@ private string DownloadFile(string fileName) if (platform == OSPlatform.Windows) { // It is the coreclr.dll's id (timestamp/filesize) in the DacInfo used to download the the dac module. - if (_clrInfo.DacInfo.IndexTimeStamp != 0 && _clrInfo.DacInfo.IndexFileSize != 0) + if (libraryInfo.IndexTimeStamp != 0 && libraryInfo.IndexFileSize != 0) { - key = PEFileKeyGenerator.GetKey(fileName, (uint)_clrInfo.DacInfo.IndexTimeStamp, (uint)_clrInfo.DacInfo.IndexFileSize); + key = PEFileKeyGenerator.GetKey(libraryInfo.FileName, (uint)libraryInfo.IndexTimeStamp, (uint)libraryInfo.IndexFileSize); } else { - Trace.TraceError($"DownloadFile: {fileName}: key not generated - no index timestamp/filesize"); + Trace.TraceError($"DownloadFile: {libraryInfo}: key not generated - no index timestamp/filesize"); } } else { // Use the runtime's build id to download the the dac module. - if (!_clrInfo.DacInfo.ClrBuildId.IsDefaultOrEmpty) + if (!libraryInfo.IndexBuildId.IsDefaultOrEmpty) { - byte[] buildId = _clrInfo.DacInfo.ClrBuildId.ToArray(); + byte[] buildId = libraryInfo.IndexBuildId.ToArray(); IEnumerable<SymbolStoreKey> keys = null; + KeyTypeFlags flags = KeyTypeFlags.None; + string fileName = null; + + switch (libraryInfo.ArchivedUnder) + { + case SymbolProperties.Self: + flags = KeyTypeFlags.IdentityKey; + fileName = libraryInfo.FileName; + break; + case SymbolProperties.Coreclr: + flags = KeyTypeFlags.DacDbiKeys; + break; + } if (platform == OSPlatform.Linux) { - keys = ELFFileKeyGenerator.GetKeys(KeyTypeFlags.DacDbiKeys, "libcoreclr.so", buildId, symbolFile: false, symbolFileName: null); + keys = ELFFileKeyGenerator.GetKeys(flags, fileName ?? "libcoreclr.so", buildId, symbolFile: false, symbolFileName: null); } else if (platform == OSPlatform.OSX) { - keys = MachOFileKeyGenerator.GetKeys(KeyTypeFlags.DacDbiKeys, "libcoreclr.dylib", buildId, symbolFile: false, symbolFileName: null); + keys = MachOFileKeyGenerator.GetKeys(flags, fileName ?? "libcoreclr.dylib", buildId, symbolFile: false, symbolFileName: null); } else { - Trace.TraceError($"DownloadFile: {fileName}: platform not supported - {platform}"); + Trace.TraceError($"DownloadFile: {libraryInfo}: platform not supported - {platform}"); } - key = keys?.SingleOrDefault((k) => Path.GetFileName(k.FullPathName) == fileName); + key = keys?.SingleOrDefault((k) => Path.GetFileName(k.FullPathName) == Path.GetFileName(libraryInfo.FileName)); } else { - Trace.TraceError($"DownloadFile: {fileName}: key not generated - no index time stamp or file size"); + Trace.TraceError($"DownloadFile: {libraryInfo}: key not generated - no index time stamp or file size"); } } @@ -253,7 +239,7 @@ private string DownloadFile(string fileName) } else { - Trace.TraceInformation($"DownLoadFile: {fileName}: symbol store not enabled"); + Trace.TraceInformation($"DownLoadFile: {libraryInfo}: symbol store not enabled"); } return filePath; } @@ -282,8 +268,9 @@ public override string ToString() { var sb = new StringBuilder(); string config = s_runtimeTypeNames[(int)RuntimeType]; - sb.AppendLine($"#{Id} {config} runtime at {RuntimeModule.ImageBase:X16} size {RuntimeModule.ImageSize:X8}"); - if (_clrInfo.SingleFileRuntimeInfo.HasValue) { + string index = _clrInfo.BuildId.IsDefaultOrEmpty ? $"{_clrInfo.IndexTimeStamp:X8} {_clrInfo.IndexFileSize:X8}" : _clrInfo.BuildId.ToHex(); + sb.AppendLine($"#{Id} {config} runtime at {RuntimeModule.ImageBase:X16} size {RuntimeModule.ImageSize:X8} index {index}"); + if (_clrInfo.IsSingleFile) { sb.AppendLine($" Single-file runtime module path: {RuntimeModule.FileName}"); } else { diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/RuntimeService.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/RuntimeService.cs index 8892e8bb3c..74e93da88d 100644 --- a/src/Microsoft.Diagnostics.DebugServices.Implementation/RuntimeService.cs +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/RuntimeService.cs @@ -5,29 +5,20 @@ using Microsoft.Diagnostics.Runtime; using System; using System.Collections.Generic; -using System.Collections.Immutable; -using System.Diagnostics; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; using System.Text; -using Architecture = System.Runtime.InteropServices.Architecture; namespace Microsoft.Diagnostics.DebugServices.Implementation { /// <summary> /// ClrMD runtime service implementation /// </summary> - public class RuntimeService : IRuntimeService, IDataReader, IExportReader + public class RuntimeService : IRuntimeService { private readonly ITarget _target; private readonly IDisposable _onFlushEvent; private DataTarget _dataTarget; private List<Runtime> _runtimes; private IContextService _contextService; - private IModuleService _moduleService; - private IThreadService _threadService; - private IMemoryService _memoryService; public RuntimeService(ITarget target) { @@ -63,8 +54,8 @@ public IEnumerable<IRuntime> EnumerateRuntimes() _runtimes = new List<Runtime>(); if (_dataTarget is null) { - _dataTarget = new DataTarget(new CustomDataTarget(this)) { - BinaryLocator = null + _dataTarget = new DataTarget(new CustomDataTarget(_target.Services.GetService<DataReader>())) { + FileLocator = null }; } if (_dataTarget is not null) @@ -80,169 +71,10 @@ public IEnumerable<IRuntime> EnumerateRuntimes() #endregion - #region IDataReader - - string IDataReader.DisplayName => ""; - - bool IDataReader.IsThreadSafe => false; - - OSPlatform IDataReader.TargetPlatform => _target.OperatingSystem; - - Microsoft.Diagnostics.Runtime.Architecture IDataReader.Architecture - { - get - { - return _target.Architecture switch - { - Architecture.X64 => Microsoft.Diagnostics.Runtime.Architecture.Amd64, - Architecture.X86 => Microsoft.Diagnostics.Runtime.Architecture.X86, - Architecture.Arm => Microsoft.Diagnostics.Runtime.Architecture.Arm, - Architecture.Arm64 => Microsoft.Diagnostics.Runtime.Architecture.Arm64, - _ => throw new PlatformNotSupportedException($"{_target.Architecture}"), - }; - } - } - - int IDataReader.ProcessId => unchecked((int)_target.ProcessId.GetValueOrDefault()); - - IEnumerable<ModuleInfo> IDataReader.EnumerateModules() => - ModuleService.EnumerateModules().Select((module) => CreateModuleInfo(module)).ToList(); - - private ModuleInfo CreateModuleInfo(IModule module) => - new ModuleInfo( - this, - module.ImageBase, - module.FileName, - isVirtual: true, - unchecked((int)module.IndexFileSize.GetValueOrDefault(0)), - unchecked((int)module.IndexTimeStamp.GetValueOrDefault(0)), - new ImmutableArray<byte>()); - - ImmutableArray<byte> IDataReader.GetBuildId(ulong baseAddress) - { - try - { - return ModuleService.GetModuleFromBaseAddress(baseAddress).BuildId; - } - catch (DiagnosticsException ex) - { - Trace.TraceError($"GetBuildId: {baseAddress:X16} exception {ex.Message}"); - } - return ImmutableArray<byte>.Empty; - } - - bool IDataReader.GetVersionInfo(ulong baseAddress, out Microsoft.Diagnostics.Runtime.VersionInfo version) - { - try - { - VersionData versionData = ModuleService.GetModuleFromBaseAddress(baseAddress).GetVersionData(); - if (versionData is not null) - { - version = versionData.ToVersionInfo(); - return true; - } - } - catch (DiagnosticsException ex) - { - Trace.TraceError($"GetVersionInfo: {baseAddress:X16} exception {ex.Message}"); - } - version = default; - return false; - } - - bool IDataReader.GetThreadContext(uint threadId, uint contextFlags, Span<byte> context) - { - try - { - byte[] registerContext = ThreadService.GetThreadFromId(threadId).GetThreadContext(); - context = new Span<byte>(registerContext); - return true; - } - catch (DiagnosticsException ex) - { - Trace.TraceError($"GetThreadContext: {threadId} exception {ex.Message}"); - } - return false; - } - - void IDataReader.FlushCachedData() - { - } - - #endregion - - #region IMemoryReader - - int IMemoryReader.PointerSize => MemoryService.PointerSize; - - int IMemoryReader.Read(ulong address, Span<byte> buffer) - { - MemoryService.ReadMemory(address, buffer, out int bytesRead); - return bytesRead; - } - - bool IMemoryReader.Read<T>(ulong address, out T value) - { - Span<byte> buffer = stackalloc byte[Marshal.SizeOf<T>()]; - if (((IMemoryReader)this).Read(address, buffer) == buffer.Length) - { - value = Unsafe.As<byte, T>(ref MemoryMarshal.GetReference(buffer)); - return true; - } - value = default; - return false; - } - - T IMemoryReader.Read<T>(ulong address) - { - ((IMemoryReader)this).Read(address, out T result); - return result; - } - - bool IMemoryReader.ReadPointer(ulong address, out ulong value) - { - return MemoryService.ReadPointer(address, out value); - } - - ulong IMemoryReader.ReadPointer(ulong address) - { - MemoryService.ReadPointer(address, out ulong value); - return value; - } - - #endregion - - #region IExportReader - - bool IExportReader.TryGetSymbolAddress(ulong baseAddress, string name, out ulong offset) - { - try - { - IExportSymbols exportSymbols = ModuleService.GetModuleFromBaseAddress(baseAddress).Services.GetService<IExportSymbols>(); - if (exportSymbols is not null) - { - return exportSymbols.TryGetSymbolAddress(name, out offset); - } - } - catch (DiagnosticsException) - { - } - offset = 0; - return false; - } - - #endregion - private IRuntime CurrentRuntime => ContextService.Services.GetService<IRuntime>(); private IContextService ContextService => _contextService ??= _target.Services.GetService<IContextService>(); - private IModuleService ModuleService => _moduleService ??= _target.Services.GetService<IModuleService>(); - - private IMemoryService MemoryService => _memoryService ??= _target.Services.GetService<IMemoryService>(); - - private IThreadService ThreadService => _threadService ??= _target.Services.GetService<IThreadService>(); - public override string ToString() { var sb = new StringBuilder(); diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/SymbolService.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/SymbolService.cs index b7fba25079..58b453f1bd 100644 --- a/src/Microsoft.Diagnostics.DebugServices.Implementation/SymbolService.cs +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/SymbolService.cs @@ -31,7 +31,7 @@ public class SymbolService : ISymbolService /// Symbol server URLs /// </summary> public const string MsdlSymbolServer = "https://msdl.microsoft.com/download/symbols/"; - public const string SymwebSymbolServer = "https://symweb.corp.microsoft.com/"; + public const string SymwebSymbolServer = "https://symweb/"; private readonly IHost _host; private string _defaultSymbolCache; @@ -41,6 +41,8 @@ public SymbolService(IHost host) { _host = host; OnChangeEvent = new ServiceEvent(); + // dbgeng's console can not handle the async logging (Tracer output on another thread than the main one). + Tracer.Enable = host.HostType != HostType.DbgEng; } #region ISymbolService @@ -701,7 +703,8 @@ private string DownloadELF(IModule module, KeyTypeFlags flags) return null; } - SymbolStoreKey fileKey = ELFFileKeyGenerator.GetKeys(flags, module.FileName, module.BuildId.ToArray(), symbolFile: false, module.GetSymbolFileName()).SingleOrDefault(); + string symbolFileName = (flags & KeyTypeFlags.SymbolKey) != 0 ? module.GetSymbolFileName() : null; + SymbolStoreKey fileKey = ELFFileKeyGenerator.GetKeys(flags, module.FileName, module.BuildId.ToArray(), symbolFile: false, symbolFileName).SingleOrDefault(); if (fileKey is null) { Trace.TraceWarning($"DownloadELF: no index generated for module {module.FileName} "); @@ -916,15 +919,18 @@ private SymbolFile TryOpenReaderFromEmbeddedPdb(PEReader peReader, DebugDirector public override string ToString() { StringBuilder sb = new StringBuilder(); + + sb.AppendLine("Current symbol store settings:"); + ForEachSymbolStore<Microsoft.SymbolStore.SymbolStores.SymbolStore>((symbolStore) => { if (symbolStore is HttpSymbolStore httpSymbolStore) { - sb.AppendLine($"{httpSymbolStore} Timeout: {httpSymbolStore.Timeout.Minutes} RetryCount: {httpSymbolStore.RetryCount}"); + sb.AppendLine($"-> {httpSymbolStore} Timeout: {httpSymbolStore.Timeout.Minutes} RetryCount: {httpSymbolStore.RetryCount}"); } else { - sb.AppendLine(symbolStore.ToString()); + sb.AppendLine($"-> {symbolStore.ToString()}"); } }); return sb.ToString(); diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/Target.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/Target.cs index 61337d2aed..e4d66bcd1b 100644 --- a/src/Microsoft.Diagnostics.DebugServices.Implementation/Target.cs +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/Target.cs @@ -37,6 +37,7 @@ public Target(IHost host, int id, string dumpPath) // Add the per-target services ServiceProvider.AddService<ITarget>(this); + ServiceProvider.AddServiceFactory<DataReader>(() => new DataReader(this)); ServiceProvider.AddServiceFactory<IRuntimeService>(() => new RuntimeService(this)); } diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/TargetFromDataReader.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/TargetFromDataReader.cs index 55dbe636de..07d901bb04 100644 --- a/src/Microsoft.Diagnostics.DebugServices.Implementation/TargetFromDataReader.cs +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/TargetFromDataReader.cs @@ -31,21 +31,14 @@ public TargetFromDataReader(IDataReader dataReader, OSPlatform targetOS, IHost h OperatingSystem = targetOS; IsDump = true; - OnFlushEvent.Register(dataReader.FlushCachedData); - - Architecture = dataReader.Architecture switch - { - Microsoft.Diagnostics.Runtime.Architecture.Amd64 => Architecture.X64, - Microsoft.Diagnostics.Runtime.Architecture.X86 => Architecture.X86, - Microsoft.Diagnostics.Runtime.Architecture.Arm => Architecture.Arm, - Microsoft.Diagnostics.Runtime.Architecture.Arm64 => Architecture.Arm64, - _ => throw new PlatformNotSupportedException($"{dataReader.Architecture}"), - }; + Architecture = dataReader.Architecture; if (dataReader.ProcessId != -1) { ProcessId = (uint)dataReader.ProcessId; } + OnFlushEvent.Register(dataReader.FlushCachedData); + // Add the thread, memory, and module services IMemoryService rawMemoryService = new MemoryServiceFromDataReader(_dataReader); ServiceProvider.AddServiceFactory<IThreadService>(() => new ThreadServiceFromDataReader(this, _dataReader)); @@ -56,8 +49,10 @@ public TargetFromDataReader(IDataReader dataReader, OSPlatform targetOS, IHost h { memoryService = new ImageMappingMemoryService(this, memoryService); // Any dump created for a MacOS target does not have managed assemblies in the module service so - // we need to use the metadata mapping memory service to make sure the metadata is available. - if (targetOS == OSPlatform.OSX) + // we need to use the metadata mapping memory service to make sure the metadata is available and + // 7.0 Linux builds have an extra System.Private.CoreLib module mapping that causes the image + // mapper not to be able to map in the metadata. + if (targetOS == OSPlatform.OSX || targetOS == OSPlatform.Linux) { memoryService = new MetadataMappingMemoryService(this, memoryService); } diff --git a/src/Microsoft.Diagnostics.DebugServices/Tracer.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/Tracer.cs similarity index 57% rename from src/Microsoft.Diagnostics.DebugServices/Tracer.cs rename to src/Microsoft.Diagnostics.DebugServices.Implementation/Tracer.cs index 516d495c0c..6a7d593774 100644 --- a/src/Microsoft.Diagnostics.DebugServices/Tracer.cs +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/Tracer.cs @@ -2,16 +2,19 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.SymbolStore; using System.Diagnostics; -namespace Microsoft.Diagnostics.DebugServices +namespace Microsoft.Diagnostics.DebugServices.Implementation { /// <summary> /// Simple trace/logging support. /// </summary> - public sealed class Tracer : Microsoft.SymbolStore.ITracer + public sealed class Tracer : ITracer { - public static Microsoft.SymbolStore.ITracer Instance { get; } = new Tracer(); + public static bool Enable { get; set; } + + public static ITracer Instance { get; } = Enable ? new Tracer() : new NullTracer(); private Tracer() { @@ -45,7 +48,7 @@ public void Warning(string message) Trace.TraceWarning(message); Trace.Flush(); } - + public void Warning(string format, params object[] arguments) { Trace.TraceWarning(format, arguments); @@ -73,5 +76,52 @@ public void Verbose(string format, params object[] arguments) { Information(format, arguments); } + + sealed class NullTracer : ITracer + { + internal NullTracer() + { + } + + public void WriteLine(string message) + { + } + + public void WriteLine(string format, params object[] arguments) + { + } + + public void Information(string message) + { + } + + public void Information(string format, params object[] arguments) + { + } + + public void Warning(string message) + { + } + + public void Warning(string format, params object[] arguments) + { + } + + public void Error(string message) + { + } + + public void Error(string format, params object[] arguments) + { + } + + public void Verbose(string message) + { + } + + public void Verbose(string format, params object[] arguments) + { + } + } } } diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/Utilities.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/Utilities.cs index 2646ea90cf..6eba2ce406 100644 --- a/src/Microsoft.Diagnostics.DebugServices.Implementation/Utilities.cs +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/Utilities.cs @@ -4,14 +4,27 @@ using Microsoft.FileFormats.PE; using System; +using System.Collections.Immutable; using System.Diagnostics; using System.IO; +using System.Linq; +using System.Reflection; using System.Reflection.PortableExecutable; namespace Microsoft.Diagnostics.DebugServices.Implementation { public static class Utilities - { + { + /// <summary> + /// An empty Version instance. + /// </summary> + public static readonly Version EmptyVersion = new(); + + /// <summary> + /// Format a immutable array of bytes into hex (i.e build id). + /// </summary> + public static string ToHex(this ImmutableArray<byte> array) => string.Concat(array.Select((b) => b.ToString("x2"))); + /// <summary> /// Combines two hash codes into a single hash code, in an order-dependent manner. /// </summary> @@ -33,25 +46,9 @@ public static int CombineHashCodes(int hashCode0, int hashCode1) /// <summary> /// Convert from symstore VsFixedFileInfo to DebugServices VersionData /// </summary> - public static VersionData ToVersionData(this VsFixedFileInfo fileInfo) - { - return new VersionData(fileInfo.FileVersionMajor, fileInfo.FileVersionMinor, fileInfo.FileVersionRevision, fileInfo.FileVersionBuild); - } - - /// <summary> - /// Convert from clrmd VersionInfo to DebugServices VersionData - /// </summary> - public static VersionData ToVersionData(this Microsoft.Diagnostics.Runtime.VersionInfo versionInfo) + public static Version ToVersion(this VsFixedFileInfo fileInfo) { - return new VersionData(versionInfo.Major, versionInfo.Minor, versionInfo.Revision, versionInfo.Patch); - } - - /// <summary> - /// Convert from DebugServices VersionData to clrmd VersionInfo - /// </summary> - public static Microsoft.Diagnostics.Runtime.VersionInfo ToVersionInfo(this VersionData versionData) - { - return new Microsoft.Diagnostics.Runtime.VersionInfo(versionData.Major, versionData.Minor, versionData.Revision, versionData.Patch); + return new Version(fileInfo.FileVersionMajor, fileInfo.FileVersionMinor, fileInfo.FileVersionBuild, fileInfo.FileVersionRevision); } /// <summary> @@ -108,7 +105,70 @@ public static Stream TryOpenFile(string path) Trace.TraceError($"TryOpenFile: {ex.Message}"); } } + return null; } + + /// <summary> + /// Call the constructor of the type and return the instance binding any + /// services in the constructor parameters. + /// </summary> + /// <param name="type">type to create</param> + /// <param name="provider">services</param> + /// <param name="optional">if true, the service is not required</param> + /// <returns>type instance</returns> + public static object InvokeConstructor(Type type, IServiceProvider provider, bool optional) + { + ConstructorInfo constructor = type.GetConstructors().Single(); + object[] arguments = BuildArguments(constructor, provider, optional); + try + { + return constructor.Invoke(arguments); + } + catch (TargetInvocationException ex) + { + Trace.TraceError(ex.ToString()); + throw ex.InnerException; + } + } + + /// <summary> + /// Call the method and bind any services in the constructor parameters. + /// </summary> + /// <param name="method">method to invoke</param> + /// <param name="instance">class instance or null if static</param> + /// <param name="provider">services</param> + /// <param name="optional">if true, the service is not required</param> + /// <returns>method return value</returns> + public static object Invoke(MethodBase method, object instance, IServiceProvider provider, bool optional) + { + object[] arguments = BuildArguments(method, provider, optional); + try + { + return method.Invoke(instance, arguments); + } + catch (TargetInvocationException ex) + { + Trace.TraceError(ex.ToString()); + throw ex.InnerException; + } + } + + private static object[] BuildArguments(MethodBase methodBase, IServiceProvider services, bool optional) + { + ParameterInfo[] parameters = methodBase.GetParameters(); + object[] arguments = new object[parameters.Length]; + for (int i = 0; i < parameters.Length; i++) + { + // The parameter will passed as null to allow for "optional" services. The invoked + // method needs to check for possible null parameters. + arguments[i] = services.GetService(parameters[i].ParameterType); + if (arguments[i] is null && !optional) + { + throw new DiagnosticsException($"The {parameters[i].ParameterType} service is required by the {parameters[i].Name} parameter"); + } + } + return arguments; + } } } diff --git a/src/Microsoft.Diagnostics.DebugServices/CommandAttributes.cs b/src/Microsoft.Diagnostics.DebugServices/CommandAttributes.cs index a02161eb70..a41d076712 100644 --- a/src/Microsoft.Diagnostics.DebugServices/CommandAttributes.cs +++ b/src/Microsoft.Diagnostics.DebugServices/CommandAttributes.cs @@ -7,10 +7,10 @@ namespace Microsoft.Diagnostics.DebugServices { /// <summary> - /// OS Platforms to add command + /// Command flags to filter by OS Platforms, control scope and how the command is registered. /// </summary> [Flags] - public enum CommandPlatform : byte + public enum CommandFlags : byte { Windows = 0x01, Linux = 0x02, @@ -21,6 +21,11 @@ public enum CommandPlatform : byte /// </summary> Global = 0x08, + /// <summary> + /// Command is not added through reflection, but manually with command service API. + /// </summary> + Manual = 0x10, + /// <summary> /// Default. All operating system, but target is required /// </summary> @@ -49,9 +54,9 @@ public class CommandAttribute : Attribute public string[] Aliases = Array.Empty<string>(); /// <summary> - /// Optional OS platform for the command + /// Command flags to filter by OS Platforms, control scope and how the command is registered. /// </summary> - public CommandPlatform Platform = CommandPlatform.Default; + public CommandFlags Flags = CommandFlags.Default; /// <summary> /// A string of options that are parsed before the command line options diff --git a/src/Microsoft.Diagnostics.DebugServices/IConsoleFileLoggingService.cs b/src/Microsoft.Diagnostics.DebugServices/IConsoleFileLoggingService.cs new file mode 100644 index 0000000000..58592867e9 --- /dev/null +++ b/src/Microsoft.Diagnostics.DebugServices/IConsoleFileLoggingService.cs @@ -0,0 +1,43 @@ +// 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.IO; + +namespace Microsoft.Diagnostics.DebugServices +{ + /// <summary> + /// Console file logging control service + /// </summary> + public interface IConsoleFileLoggingService + { + /// <summary> + /// The log file path if enabled, otherwise null. + /// </summary> + string FilePath { get; } + + /// <summary> + /// Enable console file logging. + /// </summary> + /// <param name="filePath">log file path</param> + /// <remarks>see File.Open for possible exceptions thrown</remarks> + void Enable(string filePath); + + /// <summary> + /// Disable/close console file logging. + /// </summary> + void Disable(); + + /// <summary> + /// Add to the list of file streams to write the console output. + /// </summary> + /// <param name="stream">Stream to add. Lifetime managed by caller.</param> + void AddStream(Stream stream); + + /// <summary> + /// Remove the specified file stream from the writers. + /// </summary> + /// <param name="stream">Stream passed to add. Stream not closed or disposed.</param> + void RemoveStream(Stream stream); + } +} diff --git a/src/Microsoft.Diagnostics.DebugServices/IDiagnosticLoggingService.cs b/src/Microsoft.Diagnostics.DebugServices/IDiagnosticLoggingService.cs new file mode 100644 index 0000000000..de2ed45f15 --- /dev/null +++ b/src/Microsoft.Diagnostics.DebugServices/IDiagnosticLoggingService.cs @@ -0,0 +1,34 @@ +// 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. + +namespace Microsoft.Diagnostics.DebugServices +{ + /// <summary> + /// Service to control the internal diagnostic (Trace) logging. + /// </summary> + public interface IDiagnosticLoggingService + { + /// <summary> + /// Returns true if logging to console or file + /// </summary> + bool IsEnabled { get; } + + /// <summary> + /// The file path if logging to file. + /// </summary> + string FilePath { get; } + + /// <summary> + /// Enable diagnostics logging. + /// </summary> + /// <param name="filePath">log file path or null if log to console</param> + /// <remarks>see File.Open for possible exceptions thrown</remarks> + void Enable(string filePath); + + /// <summary> + /// Disable diagnostics logging (close if logging to file). + /// </summary> + void Disable(); + } +} diff --git a/src/Microsoft.Diagnostics.DebugServices/IModule.cs b/src/Microsoft.Diagnostics.DebugServices/IModule.cs index b40badf316..6de913c552 100644 --- a/src/Microsoft.Diagnostics.DebugServices/IModule.cs +++ b/src/Microsoft.Diagnostics.DebugServices/IModule.cs @@ -86,7 +86,7 @@ public interface IModule /// <summary> /// Returns the version information for the modules. /// </summary> - VersionData GetVersionData(); + Version GetVersionData(); /// <summary> /// Returns the file version string containing the build version and commit id. diff --git a/src/Microsoft.Diagnostics.DebugServices/VersionData.cs b/src/Microsoft.Diagnostics.DebugServices/VersionData.cs deleted file mode 100644 index 5a2625d264..0000000000 --- a/src/Microsoft.Diagnostics.DebugServices/VersionData.cs +++ /dev/null @@ -1,102 +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. - -using System; - -namespace Microsoft.Diagnostics.DebugServices -{ - /// <summary> - /// Represents the version of a module - /// </summary> - public sealed class VersionData : IEquatable<VersionData>, IComparable<VersionData> - { - /// <summary> - /// In a version 'A.B.C.D', this field represents 'A'. - /// </summary> - public int Major { get; } - - /// <summary> - /// In a version 'A.B.C.D', this field represents 'B'. - /// </summary> - public int Minor { get; } - - /// <summary> - /// In a version 'A.B.C.D', this field represents 'C'. - /// </summary> - public int Revision { get; } - - /// <summary> - /// In a version 'A.B.C.D', this field represents 'D'. - /// </summary> - public int Patch { get; } - - public VersionData(int major, int minor, int revision, int patch) - { - if (major < 0) - throw new ArgumentOutOfRangeException(nameof(major)); - - if (minor < 0) - throw new ArgumentOutOfRangeException(nameof(minor)); - - if (revision < 0) - throw new ArgumentOutOfRangeException(nameof(revision)); - - if (patch < 0) - throw new ArgumentOutOfRangeException(nameof(patch)); - - Major = major; - Minor = minor; - Revision = revision; - Patch = patch; - } - - /// <inheritdoc/> - public bool Equals(VersionData other) => Major == other.Major && Minor == other.Minor && Revision == other.Revision && Patch == other.Patch; - - /// <inheritdoc/> - public override bool Equals(object obj) => obj is VersionData other && Equals(other); - - /// <inheritdoc/> - public override int GetHashCode() - { - unchecked - { - int hashCode = Major; - hashCode = (hashCode * 397) ^ Minor; - hashCode = (hashCode * 397) ^ Revision; - hashCode = (hashCode * 397) ^ Patch; - return hashCode; - } - } - - /// <inheritdoc/> - public int CompareTo(VersionData other) - { - if (Major != other.Major) - return Major.CompareTo(other.Major); - - if (Minor != other.Minor) - return Minor.CompareTo(other.Minor); - - if (Revision != other.Revision) - return Revision.CompareTo(other.Revision); - - return Patch.CompareTo(other.Patch); - } - - public override string ToString() => $"{Major}.{Minor}.{Revision}.{Patch}"; - - public static bool operator ==(VersionData left, VersionData right) => left.Equals(right); - - public static bool operator !=(VersionData left, VersionData right) => !(left == right); - - public static bool operator <(VersionData left, VersionData right) => left.CompareTo(right) < 0; - - public static bool operator <=(VersionData left, VersionData right) => left.CompareTo(right) <= 0; - - public static bool operator >(VersionData left, VersionData right) => right < left; - - public static bool operator >=(VersionData left, VersionData right) => right <= left; - } -} \ No newline at end of file diff --git a/src/Microsoft.Diagnostics.ExtensionCommands/ClrModulesCommand.cs b/src/Microsoft.Diagnostics.ExtensionCommands/ClrModulesCommand.cs index 35fabd1ebe..4c253cdfba 100644 --- a/src/Microsoft.Diagnostics.ExtensionCommands/ClrModulesCommand.cs +++ b/src/Microsoft.Diagnostics.ExtensionCommands/ClrModulesCommand.cs @@ -4,6 +4,7 @@ using Microsoft.Diagnostics.DebugServices; using Microsoft.Diagnostics.Runtime; +using System; using System.IO; using System.Text.RegularExpressions; @@ -39,14 +40,15 @@ public override void Invoke() WriteLine(" AssemblyName: {0}", module.AssemblyName); WriteLine(" ImageBase: {0:X16}", module.ImageBase); WriteLine(" Size: {0:X8}", module.Size); - WriteLine(" Address: {0:X16}", module.Address); + WriteLine(" ModuleAddress: {0:X16}", module.Address); + WriteLine(" AssemblyAddress: {0:X16}", module.AssemblyAddress); WriteLine(" IsPEFile: {0}", module.IsPEFile); WriteLine(" Layout: {0}", module.Layout); WriteLine(" IsDynamic: {0}", module.IsDynamic); WriteLine(" MetadataAddress: {0:X16}", module.MetadataAddress); WriteLine(" MetadataSize: {0:X16}", module.MetadataLength); WriteLine(" PdbInfo: {0}", module.Pdb?.ToString() ?? "<none>"); - VersionData version = null; + Version version = null; try { version = ModuleService.GetModuleFromBaseAddress(module.ImageBase).GetVersionData(); diff --git a/src/Microsoft.Diagnostics.ExtensionCommands/DumpAsyncCommand.cs b/src/Microsoft.Diagnostics.ExtensionCommands/DumpAsyncCommand.cs index b5d2c54556..8f1bb430e7 100644 --- a/src/Microsoft.Diagnostics.ExtensionCommands/DumpAsyncCommand.cs +++ b/src/Microsoft.Diagnostics.ExtensionCommands/DumpAsyncCommand.cs @@ -13,7 +13,7 @@ namespace Microsoft.Diagnostics.ExtensionCommands { - [Command(Name = CommandName, Help = "Displays information about async \"stacks\" on the garbage-collected heap.")] + [Command(Name = CommandName, Aliases = new string[] { "DumpAsync" }, Help = "Displays information about async \"stacks\" on the garbage-collected heap.")] public sealed class DumpAsyncCommand : ExtensionCommandBase { /// <summary>The name of the command.</summary> diff --git a/src/Microsoft.Diagnostics.ExtensionCommands/Host/ConsoleLoggingCommand.cs b/src/Microsoft.Diagnostics.ExtensionCommands/Host/ConsoleLoggingCommand.cs new file mode 100644 index 0000000000..18eb2cb87b --- /dev/null +++ b/src/Microsoft.Diagnostics.ExtensionCommands/Host/ConsoleLoggingCommand.cs @@ -0,0 +1,46 @@ +// 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 Microsoft.Diagnostics.DebugServices; + +namespace Microsoft.Diagnostics.ExtensionCommands +{ + [Command(Name = "logopen", Help = "Enable console file logging", Flags = CommandFlags.Global)] + [Command(Name = "logclose", DefaultOptions = "--disable", Help = "Disable console file logging", Flags = CommandFlags.Global)] + public class ConsoleLoggingCommand : CommandBase + { + public IConsoleFileLoggingService FileLoggingService { get; set; } + + [Argument(Name = "path", Help = "Log file path.")] + public string FilePath { get; set; } + + [Option(Name = "--disable", Help = "Disable console file logging.")] + public bool Disable { get; set; } + + public override void Invoke() + { + if (FileLoggingService is null) + { + throw new DiagnosticsException("Console logging is not supported"); + } + if (Disable) + { + FileLoggingService.Disable(); + } + else if (!string.IsNullOrWhiteSpace(FilePath)) + { + FileLoggingService.Enable(FilePath); + } + string filePath = FileLoggingService.FilePath; + if (filePath is not null) + { + WriteLine($"Console is logging to {filePath}"); + } + else + { + WriteLine("Console logging is disabled"); + } + } + } +} diff --git a/src/Microsoft.Diagnostics.ExtensionCommands/Host/LoggingCommand.cs b/src/Microsoft.Diagnostics.ExtensionCommands/Host/LoggingCommand.cs index 10ec2d68d1..11f969b8d8 100644 --- a/src/Microsoft.Diagnostics.ExtensionCommands/Host/LoggingCommand.cs +++ b/src/Microsoft.Diagnostics.ExtensionCommands/Host/LoggingCommand.cs @@ -5,68 +5,44 @@ using Microsoft.Diagnostics.DebugServices; using System; using System.Diagnostics; +using System.IO; +using System.Security; namespace Microsoft.Diagnostics.ExtensionCommands { - [Command(Name = "logging", Help = "Enable/disable internal logging", Platform = CommandPlatform.Global)] + [Command(Name = "logging", Help = "Enable/disable internal diagnostic logging", Flags = CommandFlags.Global)] public class LoggingCommand : CommandBase { - [Option(Name = "enable", Help = "Enable internal logging.")] + public IDiagnosticLoggingService DiagnosticLoggingService { get; set; } + + [Argument(Name = "path", Help = "Log file path.")] + public string FilePath { get; set; } + + [Option(Name = "--enable", Aliases = new string[] { "enable", "-e" }, Help = "Enable internal logging.")] public bool Enable { get; set; } - [Option(Name = "disable", Help = "Disable internal logging.")] + [Option(Name = "--disable", Aliases = new string[] { "disable", "-d"}, Help = "Disable internal logging.")] public bool Disable { get; set; } - private const string ListenerName = "Analyze.LoggingListener"; - public override void Invoke() { - if (Enable) { - EnableLogging(); - } - else if (Disable) { - DisableLogging(); - } - WriteLine("Logging is {0}", Trace.Listeners[ListenerName] != null ? "enabled" : "disabled"); - } - - public static void Initialize() - { - if (Environment.GetEnvironmentVariable("DOTNET_ENABLED_SOS_LOGGING") == "1") - { - EnableLogging(); - } - } - - public static void EnableLogging() - { - if (Trace.Listeners[ListenerName] == null) + if (DiagnosticLoggingService is null) { - Trace.Listeners.Add(new LoggingListener()); - Trace.AutoFlush = true; + throw new DiagnosticsException("Diagnostic logging is not supported"); } - } - - public static void DisableLogging() - { - Trace.Listeners.Remove(ListenerName); - } - - class LoggingListener : TraceListener - { - internal LoggingListener() - : base(ListenerName) + if (Disable) { + DiagnosticLoggingService.Disable(); } - - public override void Write(string message) + else if (Enable || !string.IsNullOrWhiteSpace(FilePath)) { - System.Console.Write(message); + DiagnosticLoggingService.Enable(FilePath); } + WriteLine("Logging is {0}", DiagnosticLoggingService.IsEnabled ? "enabled" : "disabled"); - public override void WriteLine(string message) + if (!string.IsNullOrWhiteSpace(DiagnosticLoggingService.FilePath)) { - System.Console.WriteLine(message); + WriteLine(DiagnosticLoggingService.FilePath); } } } diff --git a/src/Microsoft.Diagnostics.ExtensionCommands/Host/ModulesCommand.cs b/src/Microsoft.Diagnostics.ExtensionCommands/Host/ModulesCommand.cs index 9a450ea1ad..74fd7a9cab 100644 --- a/src/Microsoft.Diagnostics.ExtensionCommands/Host/ModulesCommand.cs +++ b/src/Microsoft.Diagnostics.ExtensionCommands/Host/ModulesCommand.cs @@ -28,51 +28,73 @@ public class ModulesCommand : CommandBase [Option(Name = "--name", Aliases = new string[] { "-n" }, Help = "RegEx filter on module name (path not included).")] public string ModuleName { get; set; } + [Option(Name = "--address", Aliases = new string[] { "-a" }, Help = "Lookup address in module list.")] + public ulong? Address { get; set; } + public IModuleService ModuleService { get; set; } public override void Invoke() { - Regex regex = ModuleName is not null ? new Regex(ModuleName, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant) : null; - ulong totalSize = 0; - - foreach (IModule module in ModuleService.EnumerateModules().OrderBy((m) => m.ModuleIndex)) + if (Address.HasValue) { - totalSize += module.ImageSize; - if (regex is null || !string.IsNullOrEmpty(module.FileName) && regex.IsMatch(Path.GetFileName(module.FileName))) + IModule module = ModuleService.GetModuleFromAddress(Address.Value); + if (module != null) { - if (Verbose) - { - WriteLine("{0} {1}", module.ModuleIndex, module.FileName); - WriteLine(" Address: {0:X16}", module.ImageBase); - WriteLine(" ImageSize: {0:X8}", module.ImageSize); - WriteLine(" IsPEImage: {0}", module.IsPEImage); - WriteLine(" IsManaged: {0}", module.IsManaged); - WriteLine(" IsFileLayout: {0}", module.IsFileLayout?.ToString() ?? "<unknown>"); - WriteLine(" IndexFileSize: {0}", module.IndexFileSize?.ToString("X8") ?? "<none>"); - WriteLine(" IndexTimeStamp: {0}", module.IndexTimeStamp?.ToString("X8") ?? "<none>"); - WriteLine(" Version: {0}", module.GetVersionData()?.ToString() ?? "<none>"); - string versionString = module.GetVersionString(); - if (!string.IsNullOrEmpty(versionString)) - { - WriteLine(" {0}", versionString); - } - foreach (PdbFileInfo pdbFileInfo in module.GetPdbFileInfos()) - { - WriteLine(" PdbInfo: {0}", pdbFileInfo); - } - WriteLine(" BuildId: {0}", !module.BuildId.IsDefaultOrEmpty ? string.Concat(module.BuildId.Select((b) => b.ToString("x2"))) : "<none>"); - } - else - { - WriteLine("{0:X16} {1:X8} {2}", module.ImageBase, module.ImageSize, module.FileName); - } - if (Segment) + DisplayModule(module); + } + else + { + WriteLineError($"Address 0x{Address:X16} not found"); + } + } + else + { + Regex regex = ModuleName is not null ? new Regex(ModuleName, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant) : null; + ulong totalSize = 0; + foreach (IModule module in ModuleService.EnumerateModules().OrderBy((m) => m.ModuleIndex)) + { + totalSize += module.ImageSize; + if (regex is null || !string.IsNullOrEmpty(module.FileName) && regex.IsMatch(Path.GetFileName(module.FileName))) { - DisplaySegments(module); + DisplayModule(module); } } + WriteLine("Total image size: {0}", totalSize); + } + } + + void DisplayModule(IModule module) + { + if (Verbose) + { + WriteLine("{0} {1}", module.ModuleIndex, module.FileName); + WriteLine(" Address: {0:X16}", module.ImageBase); + WriteLine(" ImageSize: {0:X8}", module.ImageSize); + WriteLine(" IsPEImage: {0}", module.IsPEImage); + WriteLine(" IsManaged: {0}", module.IsManaged); + WriteLine(" IsFileLayout: {0}", module.IsFileLayout?.ToString() ?? "<unknown>"); + WriteLine(" IndexFileSize: {0}", module.IndexFileSize?.ToString("X8") ?? "<none>"); + WriteLine(" IndexTimeStamp: {0}", module.IndexTimeStamp?.ToString("X8") ?? "<none>"); + WriteLine(" Version: {0}", module.GetVersionData()?.ToString() ?? "<none>"); + string versionString = module.GetVersionString(); + if (!string.IsNullOrEmpty(versionString)) + { + WriteLine(" {0}", versionString); + } + foreach (PdbFileInfo pdbFileInfo in module.GetPdbFileInfos()) + { + WriteLine(" PdbInfo: {0}", pdbFileInfo); + } + WriteLine(" BuildId: {0}", !module.BuildId.IsDefaultOrEmpty ? string.Concat(module.BuildId.Select((b) => b.ToString("x2"))) : "<none>"); + } + else + { + WriteLine("{0:X16} {1:X8} {2}", module.ImageBase, module.ImageSize, module.FileName); + } + if (Segment) + { + DisplaySegments(module); } - WriteLine("Total image size: {0}", totalSize); } public ITarget Target { get; set; } diff --git a/src/Microsoft.Diagnostics.ExtensionCommands/Host/RuntimesCommand.cs b/src/Microsoft.Diagnostics.ExtensionCommands/Host/RuntimesCommand.cs index 8b05aa50b5..40820a0e25 100644 --- a/src/Microsoft.Diagnostics.ExtensionCommands/Host/RuntimesCommand.cs +++ b/src/Microsoft.Diagnostics.ExtensionCommands/Host/RuntimesCommand.cs @@ -39,7 +39,7 @@ public override void Invoke() foreach (IRuntime runtime in RuntimeService.EnumerateRuntimes()) { if (NetFx && runtime.RuntimeType == RuntimeType.Desktop || - NetCore && runtime.RuntimeType == RuntimeType.NetCore) + NetCore && runtime.RuntimeType == RuntimeType.NetCore) { ContextService.SetCurrentRuntime(runtime.Id); WriteLine("Switched to {0} runtime successfully", name); @@ -61,45 +61,20 @@ public override void Invoke() ClrInfo clrInfo = runtime.Services.GetService<ClrInfo>(); if (clrInfo is not null) { - unsafe + WriteLine(" Libraries:"); + foreach (DebugLibraryInfo library in clrInfo.DebuggingLibraries) { - if (clrInfo.SingleFileRuntimeInfo.HasValue) - { - RuntimeInfo runtimeInfo = clrInfo.SingleFileRuntimeInfo.Value; - WriteLine(" Signature: {0}", Encoding.ASCII.GetString(runtimeInfo.Signature, RuntimeInfo.SignatureValueLength - 1)); - WriteLine(" Version: {0}", runtimeInfo.Version); - if (Target.OperatingSystem == OSPlatform.Windows) - { - WriteLine(" Runtime: {0}", GetWindowsIndex(runtimeInfo.RuntimeModuleIndex)); - WriteLine(" DBI: {0}", GetWindowsIndex(runtimeInfo.DbiModuleIndex)); - WriteLine(" DAC: {0}", GetWindowsIndex(runtimeInfo.DacModuleIndex)); - } - else - { - WriteLine(" Runtime: {0}", GetUnixIndex(runtimeInfo.RuntimeModuleIndex)); - WriteLine(" DBI: {0}", GetUnixIndex(runtimeInfo.DbiModuleIndex)); - WriteLine(" DAC: {0}", GetUnixIndex(runtimeInfo.DacModuleIndex)); - } - } + string index = library.IndexBuildId.IsDefaultOrEmpty ? $"{library.IndexTimeStamp:X8} {library.IndexFileSize:X8}" : library.IndexBuildId.ToHex(); + WriteLine($" {library.Kind} {library.FileName} {library.Platform} {library.TargetArchitecture} {library.ArchivedUnder} {index}"); } } } } } + } - private unsafe string GetWindowsIndex(byte* index) - { - uint timeStamp = BitConverter.ToUInt32(new ReadOnlySpan<byte>(index + sizeof(byte), sizeof(uint)).ToArray(), 0); - uint fileSize = BitConverter.ToUInt32(new ReadOnlySpan<byte>(index + sizeof(byte) + sizeof(uint), sizeof(uint)).ToArray(), 0); - return string.Format("TimeStamp {0:X8} FileSize {1:X8}", timeStamp, fileSize); - } - - private unsafe string GetUnixIndex(byte* index) - { - var buildId = new ReadOnlySpan<byte>(index + sizeof(byte), index[0]).ToArray().ToImmutableArray(); - return string.Format("BuildId {0}", ToHex(buildId)); - } - - private string ToHex(ImmutableArray<byte> array) => string.Concat(array.Select((b) => b.ToString("x2"))); + public static class Utilities + { + public static string ToHex(this ImmutableArray<byte> array) => string.Concat(array.Select((b) => b.ToString("x2"))); } } diff --git a/src/Microsoft.Diagnostics.ExtensionCommands/Host/SetSymbolServerCommand.cs b/src/Microsoft.Diagnostics.ExtensionCommands/Host/SetSymbolServerCommand.cs index 756b302c00..eaf0797af8 100644 --- a/src/Microsoft.Diagnostics.ExtensionCommands/Host/SetSymbolServerCommand.cs +++ b/src/Microsoft.Diagnostics.ExtensionCommands/Host/SetSymbolServerCommand.cs @@ -10,7 +10,12 @@ namespace Microsoft.Diagnostics.ExtensionCommands Name = "setsymbolserver", Aliases = new string[] { "SetSymbolServer" }, Help = "Enable and set symbol server support for symbols and module download", - Platform = CommandPlatform.Global)] + Flags = CommandFlags.Global)] + [Command( + Name = "loadsymbols", + DefaultOptions = "--loadsymbols", + Help = "Load symbols for all modules", + Flags = CommandFlags.Global)] public class SetSymbolServerCommand : CommandBase { public ISymbolService SymbolService { get; set; } diff --git a/src/Microsoft.Diagnostics.ExtensionCommands/Host/StatusCommand.cs b/src/Microsoft.Diagnostics.ExtensionCommands/Host/StatusCommand.cs index 5edce2a823..0ea5401076 100644 --- a/src/Microsoft.Diagnostics.ExtensionCommands/Host/StatusCommand.cs +++ b/src/Microsoft.Diagnostics.ExtensionCommands/Host/StatusCommand.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using Microsoft.Diagnostics.DebugServices; +using System; namespace Microsoft.Diagnostics.ExtensionCommands { @@ -27,6 +28,8 @@ public override void Invoke() { Write(Target.ToString()); Write(SymbolService.ToString()); + long memoryUsage = GC.GetTotalMemory(forceFullCollection: true); + WriteLine($"GC memory usage for managed SOS components: {memoryUsage:##,#} bytes"); } } } diff --git a/src/Microsoft.Diagnostics.Monitoring.EventPipe/Microsoft.Diagnostics.Monitoring.EventPipe.csproj b/src/Microsoft.Diagnostics.Monitoring.EventPipe/Microsoft.Diagnostics.Monitoring.EventPipe.csproj index 733d18da1e..db90173d71 100644 --- a/src/Microsoft.Diagnostics.Monitoring.EventPipe/Microsoft.Diagnostics.Monitoring.EventPipe.csproj +++ b/src/Microsoft.Diagnostics.Monitoring.EventPipe/Microsoft.Diagnostics.Monitoring.EventPipe.csproj @@ -29,7 +29,7 @@ <ItemGroup> <PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="$(MicrosoftDiagnosticsTracingTraceEventVersion)" /> <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="$(MicrosoftBclAsyncInterfacesVersion)" /> - <PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingVersion)" /> + <PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingPinnedVersion)" /> <PackageReference Include="System.ComponentModel.Annotations" Version="$(SystemComponentModelAnnotationsVersion)" /> <PackageReference Include="System.Text.Encodings.Web" Version="$(SystemTextEncodingsWebVersion)" /> <PackageReference Include="System.Text.Json" Version="$(SystemTextJsonVersion)" /> diff --git a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs index 2d58ef8626..c4cb1eab00 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs +++ b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Buffers.Binary; using System.Collections.Generic; using System.Globalization; using System.IO; @@ -566,7 +567,7 @@ internal static bool ValidateResponseMessage(IpcMessage responseMessage, string return true; case DiagnosticsServerResponseId.Error: - uint hr = BitConverter.ToUInt32(responseMessage.Payload, 0); + uint hr = BinaryPrimitives.ReadUInt32LittleEndian(new ReadOnlySpan<byte>(responseMessage.Payload, 0, 4)); int index = sizeof(uint); string message = null; switch (hr) diff --git a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/EventPipeSession.cs b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/EventPipeSession.cs index 79577037c0..e44bf27317 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/EventPipeSession.cs +++ b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/EventPipeSession.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Buffers.Binary; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -92,7 +93,7 @@ private static EventPipeSession CreateSessionFromResponse(IpcEndpoint endpoint, { DiagnosticsClient.ValidateResponseMessage(response.Value.Message, operationName); - long sessionId = BitConverter.ToInt64(response.Value.Message.Payload, 0); + long sessionId = BinaryPrimitives.ReadInt64LittleEndian(new ReadOnlySpan<byte>(response.Value.Message.Payload, 0, 8)); var session = new EventPipeSession(endpoint, response.Value, sessionId); response = null; @@ -120,6 +121,10 @@ private bool TryCreateStopMessage(out IpcMessage stopMessage) } byte[] payload = BitConverter.GetBytes(_sessionId); + if (!BitConverter.IsLittleEndian) + { + Array.Reverse(payload); + } stopMessage = new IpcMessage(DiagnosticsServerCommandSet.EventPipe, (byte)EventPipeCommandId.StopTracing, payload); @@ -153,4 +158,4 @@ public void Dispose() Dispose(true); } } -} \ No newline at end of file +} diff --git a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcAdvertise.cs b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcAdvertise.cs index 861c6245d2..a38470c601 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcAdvertise.cs +++ b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcAdvertise.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Buffers.Binary; using System.Linq; using System.IO; using System.Text; @@ -69,10 +70,10 @@ public static async Task<IpcAdvertise> ParseAsync(Stream stream, CancellationTok Guid cookie = new Guid(cookieBuffer); index += 16; - UInt64 pid = BitConverter.ToUInt64(buffer, index); + UInt64 pid = BinaryPrimitives.ReadUInt64LittleEndian(new ReadOnlySpan<byte>(buffer, index, 8)); index += 8; - UInt16 future = BitConverter.ToUInt16(buffer, index); + UInt16 future = BinaryPrimitives.ReadUInt16LittleEndian(new ReadOnlySpan<byte>(buffer, index, 2)); index += 2; // FUTURE: switch on incoming magic and change if version ever increments @@ -91,7 +92,12 @@ public static async Task SerializeAsync(Stream stream, Guid runtimeInstanceCooki Array.Copy(cookieBuffer, 0, buffer, index, cookieBuffer.Length); index += cookieBuffer.Length; - Array.Copy(BitConverter.GetBytes(processId), 0, buffer, index, sizeof(ulong)); + byte[] processIdBuffer = BitConverter.GetBytes(processId); + if (!BitConverter.IsLittleEndian) + { + Array.Reverse(processIdBuffer); + } + Array.Copy(processIdBuffer, 0, buffer, index, sizeof(ulong)); index += sizeof(ulong); short future = 0; diff --git a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/ProcessEnvironment.cs b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/ProcessEnvironment.cs index c221a93a0f..dacb9dcbdc 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/ProcessEnvironment.cs +++ b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/ProcessEnvironment.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Buffers.Binary; using System.Collections.Generic; using System.IO; using System.Threading; @@ -18,8 +19,8 @@ public static ProcessEnvironmentHelper Parse(byte[] payload) { ProcessEnvironmentHelper helper = new ProcessEnvironmentHelper(); - helper.ExpectedSizeInBytes = BitConverter.ToUInt32(payload, 0); - helper.Future = BitConverter.ToUInt16(payload, 4); + helper.ExpectedSizeInBytes = BinaryPrimitives.ReadUInt32LittleEndian(new ReadOnlySpan<byte>(payload, 0, 4)); + helper.Future = BinaryPrimitives.ReadUInt16LittleEndian(new ReadOnlySpan<byte>(payload, 4, 2)); return helper; } @@ -48,7 +49,7 @@ private Dictionary<string, string> ReadEnvironmentCore(MemoryStream stream) var env = new Dictionary<string, string>(); int cursor = 0; - UInt32 nElements = BitConverter.ToUInt32(envBlock, cursor); + UInt32 nElements = BinaryPrimitives.ReadUInt32LittleEndian(new ReadOnlySpan<byte>(envBlock, cursor, 4)); cursor += sizeof(UInt32); while (cursor < envBlock.Length) { @@ -64,4 +65,4 @@ private Dictionary<string, string> ReadEnvironmentCore(MemoryStream stream) private UInt32 ExpectedSizeInBytes { get; set; } private UInt16 Future { get; set; } } -} \ No newline at end of file +} diff --git a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/ProcessInfo.cs b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/ProcessInfo.cs index 28d2340c39..58492dca67 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/ProcessInfo.cs +++ b/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/ProcessInfo.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Buffers.Binary; using System.Text; namespace Microsoft.Diagnostics.NETCore.Client @@ -65,7 +66,7 @@ private static ProcessInfo ParseCommon(byte[] payload, ref int index) { ProcessInfo processInfo = new ProcessInfo(); - processInfo.ProcessId = BitConverter.ToUInt64(payload, index); + processInfo.ProcessId = BinaryPrimitives.ReadUInt64LittleEndian(new ReadOnlySpan<byte>(payload, index, 8)); index += sizeof(UInt64); byte[] cookieBuffer = new byte[GuidSizeInBytes]; @@ -88,4 +89,4 @@ private static ProcessInfo ParseCommon(byte[] payload, ref int index) public string ManagedEntrypointAssemblyName { get; private set; } public string ClrProductVersionString { get; private set; } } -} \ No newline at end of file +} diff --git a/src/Microsoft.Diagnostics.NETCore.Client/IpcHelpers.cs b/src/Microsoft.Diagnostics.NETCore.Client/IpcHelpers.cs index 08ddc7eafa..418c6da1db 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/IpcHelpers.cs +++ b/src/Microsoft.Diagnostics.NETCore.Client/IpcHelpers.cs @@ -1,4 +1,5 @@ using System; +using System.Buffers.Binary; using System.Collections.Generic; using System.Text; @@ -9,7 +10,7 @@ internal static class IpcHelpers public static string ReadString(byte[] buffer, ref int index) { // Length of the string of UTF-16 characters - int length = (int)BitConverter.ToUInt32(buffer, index); + int length = BinaryPrimitives.ReadInt32LittleEndian(new ReadOnlySpan<byte>(buffer, index, 4)); index += sizeof(UInt32); int size = (int)length * sizeof(char); diff --git a/src/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj b/src/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj index 929f82d0fa..2553b9e0d7 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj +++ b/src/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj @@ -11,16 +11,18 @@ <GenerateDocumentationFile>true</GenerateDocumentationFile> <IncludeSymbols>true</IncludeSymbols> <IsShipping>true</IsShipping> + <BuildingOutsideDiagnostics>false</BuildingOutsideDiagnostics> + <BuildingOutsideDiagnostics Condition="'$(GitHubRepositoryName)' != 'diagnostics'">true</BuildingOutsideDiagnostics> </PropertyGroup> - <PropertyGroup Condition="'$(GitHubRepositoryName)' == 'runtime'"> + <PropertyGroup Condition="$(BuildingOutsideDiagnostics)"> <DefineConstants>$(DefineConstants);DIAGNOSTICS_RUNTIME</DefineConstants> <NoWarn>CS1591,CS8073,CS0162</NoWarn> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="$(MicrosoftBclAsyncInterfacesVersion)" /> - <PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingVersion)" /> + <PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingPinnedVersion)" /> </ItemGroup> <ItemGroup> @@ -36,6 +38,6 @@ </ItemGroup> <ItemGroup> - <Compile Condition="'$(GitHubRepositoryName)' == 'runtime'" Include="**/*.cs" /> + <Compile Condition="$(BuildingOutsideDiagnostics)" Include="**/*.cs" /> </ItemGroup> </Project> diff --git a/src/Microsoft.Diagnostics.NETCore.Client/ReversedServer/ReversedDiagnosticsServer.cs b/src/Microsoft.Diagnostics.NETCore.Client/ReversedServer/ReversedDiagnosticsServer.cs index b4e26bd207..f4a9d4fae1 100644 --- a/src/Microsoft.Diagnostics.NETCore.Client/ReversedServer/ReversedDiagnosticsServer.cs +++ b/src/Microsoft.Diagnostics.NETCore.Client/ReversedServer/ReversedDiagnosticsServer.cs @@ -29,8 +29,9 @@ internal sealed class ReversedDiagnosticsServer : IAsyncDisposable private readonly string _address; private bool _disposed = false; - private Task _listenTask; + private Task _acceptTransportTask; private bool _enableTcpIpProtocol = false; + private IpcServerTransport _transport; /// <summary> /// Constructs the <see cref="ReversedDiagnosticsServer"/> instance with an endpoint bound @@ -72,13 +73,24 @@ public async ValueTask DisposeAsync() { if (!_disposed) { + // Dispose the server transport before signaling cancellation in order to prevent the + // AcceptAsync call on the server transport from recreating the server stream. + try + { + _transport?.Dispose(); + } + catch (Exception ex) + { + Debug.Fail(ex.Message); + } + _disposalSource.Cancel(); - if (null != _listenTask) + if (null != _acceptTransportTask) { try { - await _listenTask.ConfigureAwait(false); + await _acceptTransportTask.ConfigureAwait(false); } catch (Exception ex) { @@ -122,9 +134,12 @@ public void Start(int maxConnections) throw new InvalidOperationException(nameof(ReversedDiagnosticsServer.Start) + " method can only be called once."); } - _listenTask = ListenAsync(maxConnections, _disposalSource.Token); - if (_listenTask.IsFaulted) - _listenTask.Wait(); // Rethrow aggregated exception. + _transport = IpcServerTransport.Create(_address, maxConnections, _enableTcpIpProtocol, TransportCallback); + + _acceptTransportTask = AcceptTransportAsync(_transport, _disposalSource.Token); + + if (_acceptTransportTask.IsFaulted) + _acceptTransportTask.Wait(); // Rethrow aggregated exception. } /// <summary> @@ -188,19 +203,13 @@ private void VerifyIsStarted() } /// <summary> - /// Listens at the address for new connections. + /// Accept connections from the transport. /// </summary> - /// <param name="maxConnections">The maximum number of connections the server will support.</param> + /// <param name="transport">The server transport from which connections are accepted.</param> /// <param name="token">The token to monitor for cancellation requests.</param> /// <returns>A task that completes when the server is no longer listening at the address.</returns> - private async Task ListenAsync(int maxConnections, CancellationToken token) + private async Task AcceptTransportAsync(IpcServerTransport transport, CancellationToken token) { - // This disposal shuts down the transport in case an exception is thrown. - using var transport = IpcServerTransport.Create(_address, maxConnections, _enableTcpIpProtocol, TransportCallback); - // This disposal shuts down the transport in case of cancellation; causes the transport - // to not recreate the server stream before the AcceptAsync call observes the cancellation. - using var _ = token.Register(() => transport.Dispose()); - while (!token.IsCancellationRequested) { Stream stream = null; @@ -366,7 +375,7 @@ private static bool TestStream(Stream stream) return false; } - private bool IsStarted => null != _listenTask; + private bool IsStarted => null != _transport; public static int MaxAllowedConnections = IpcServerTransport.MaxAllowedConnections; diff --git a/src/Microsoft.Diagnostics.Repl/ConsoleService.cs b/src/Microsoft.Diagnostics.Repl/ConsoleService.cs index fa4687baea..bb139a000c 100644 --- a/src/Microsoft.Diagnostics.Repl/ConsoleService.cs +++ b/src/Microsoft.Diagnostics.Repl/ConsoleService.cs @@ -73,7 +73,7 @@ public ConsoleService(ConsoleColor errorColor = ConsoleColor.Red, ConsoleColor w /// Start input processing and command dispatching /// </summary> /// <param name="dispatchCommand">Called to dispatch a command on ENTER</param> - public void Start(Action<string, CancellationToken> dispatchCommand) + public void Start(Action<string, string, CancellationToken> dispatchCommand) { m_lastCommandLine = null; m_interactiveConsole = !Console.IsInputRedirected; @@ -159,14 +159,6 @@ public void SetPrompt(string prompt) RefreshLine(); } - /// <summary> - /// Writes a message with a new line to console. - /// </summary> - public void WriteLine(string format, params object[] parameters) - { - WriteLine(OutputType.Normal, format, parameters); - } - /// <summary> /// Writes a message with a new line to console. /// </summary> @@ -268,13 +260,14 @@ private void ClearLine() return; } - if (m_clearLine == null || m_clearLine.Length != Console.WindowWidth) { - m_clearLine = "\r" + new string(' ', Console.WindowWidth - 1); + int width = Console.WindowWidth; + if (m_clearLine == null || width != m_clearLine.Length) { + m_clearLine = "\r" + (width > 0 ? new string(' ', width - 1) : ""); } Console.Write(m_clearLine); - if (!m_outputRedirected) { + if (!m_outputRedirected && Console.CursorTop >= 0 ) { Console.CursorLeft = 0; } } @@ -320,7 +313,7 @@ private void PrintActiveLine() Console.Write("{0}{1}", prompt, text); - if (!m_outputRedirected) { + if (!m_outputRedirected && Console.CursorTop >= 0) { Console.CursorLeft = prompt.Length + (m_cursorPosition - m_scrollPosition); } } @@ -337,7 +330,7 @@ private void RefreshLine() m_refreshingLine = false; } - private void ProcessKeyInfo(ConsoleKeyInfo keyInfo, Action<string, CancellationToken> dispatchCommand) + private void ProcessKeyInfo(ConsoleKeyInfo keyInfo, Action<string, string, CancellationToken> dispatchCommand) { int activeLineLen = m_activeLine.Length; @@ -454,7 +447,7 @@ private void ProcessKeyInfo(ConsoleKeyInfo keyInfo, Action<string, CancellationT } } - private bool Dispatch(string newCommand, Action<string, CancellationToken> dispatchCommand) + private bool Dispatch(string newCommand, Action<string, string, CancellationToken> dispatchCommand) { bool result = true; CommandStarting(); @@ -468,8 +461,7 @@ private bool Dispatch(string newCommand, Action<string, CancellationToken> dispa } try { - WriteLine(OutputType.Normal, "{0}{1}", m_prompt, newCommand); - dispatchCommand(newCommand, m_interruptExecutingCommand.Token); + dispatchCommand(m_prompt, newCommand, m_interruptExecutingCommand.Token); m_lastCommandLine = newCommand; } catch (OperationCanceledException) @@ -477,8 +469,9 @@ private bool Dispatch(string newCommand, Action<string, CancellationToken> dispa // ctrl-c interrupted the command m_lastCommandLine = null; } - catch (Exception ex) when (!(ex is NullReferenceException || ex is ArgumentNullException || ex is ArgumentException)) + catch (Exception ex) { + // Most exceptions should not excape the command dispatch, but just in case WriteLine(OutputType.Error, "ERROR: {0}", ex.Message); Trace.TraceError(ex.ToString()); m_lastCommandLine = null; diff --git a/src/Microsoft.Diagnostics.Repl/ExitCommand.cs b/src/Microsoft.Diagnostics.Repl/ExitCommand.cs index c7678c3f1f..4d4eb4eee1 100644 --- a/src/Microsoft.Diagnostics.Repl/ExitCommand.cs +++ b/src/Microsoft.Diagnostics.Repl/ExitCommand.cs @@ -7,7 +7,7 @@ namespace Microsoft.Diagnostics.Repl { - [Command(Name = "exit", Aliases = new string[] { "quit", "q" }, Help = "Exit interactive mode.", Platform = CommandPlatform.Global)] + [Command(Name = "exit", Aliases = new string[] { "quit", "q" }, Help = "Exit interactive mode.", Flags = CommandFlags.Global | CommandFlags.Manual)] public class ExitCommand : CommandBase { private readonly Action _exit; diff --git a/src/Microsoft.Diagnostics.Repl/HelpCommand.cs b/src/Microsoft.Diagnostics.Repl/HelpCommand.cs index cbf3699f4f..b4153706f4 100644 --- a/src/Microsoft.Diagnostics.Repl/HelpCommand.cs +++ b/src/Microsoft.Diagnostics.Repl/HelpCommand.cs @@ -7,7 +7,7 @@ namespace Microsoft.Diagnostics.Repl { - [Command(Name = "help", Help = "Display help for a command.", Platform = CommandPlatform.Global)] + [Command(Name = "help", Help = "Display help for a command.", Flags = CommandFlags.Global | CommandFlags.Manual)] public class HelpCommand : CommandBase { [Argument(Help = "Command to find help.")] diff --git a/src/Microsoft.Diagnostics.TestHelpers/DotNetBuildDebuggeeTestStep.cs b/src/Microsoft.Diagnostics.TestHelpers/DotNetBuildDebuggeeTestStep.cs index 63ef96bbbe..b2a3cb234d 100644 --- a/src/Microsoft.Diagnostics.TestHelpers/DotNetBuildDebuggeeTestStep.cs +++ b/src/Microsoft.Diagnostics.TestHelpers/DotNetBuildDebuggeeTestStep.cs @@ -192,6 +192,7 @@ protected async Task Restore(string extraArgs, ITestOutputHelper output) ProcessRunner runner = new ProcessRunner(DotNetToolPath, args). WithEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0"). WithEnvironmentVariable("DOTNET_ROOT", Path.GetDirectoryName(DotNetToolPath)). + WithEnvironmentVariable("DOTNET_CLI_DO_NOT_USE_MSBUILD_SERVER", "true"). WithEnvironmentVariable("DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR", Path.GetDirectoryName(DotNetToolPath)). WithEnvironmentVariable("DOTNET_INSTALL_DIR", Path.GetDirectoryName(DotNetToolPath)). RemoveEnvironmentVariable("MSBuildSDKsPath"). @@ -238,6 +239,7 @@ protected async Task Build(string dotnetArgs, ITestOutputHelper output) ProcessRunner runner = new ProcessRunner(DotNetToolPath, dotnetArgs). WithEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0"). WithEnvironmentVariable("DOTNET_ROOT", Path.GetDirectoryName(DotNetToolPath)). + WithEnvironmentVariable("DOTNET_CLI_DO_NOT_USE_MSBUILD_SERVER", "true"). WithEnvironmentVariable("DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR", Path.GetDirectoryName(DotNetToolPath)). WithEnvironmentVariable("DOTNET_INSTALL_DIR", Path.GetDirectoryName(DotNetToolPath)). RemoveEnvironmentVariable("MSBuildSDKsPath"). diff --git a/src/Microsoft.Diagnostics.TestHelpers/IProcessLogger.cs b/src/Microsoft.Diagnostics.TestHelpers/IProcessLogger.cs index 233372a1f5..f99080b752 100644 --- a/src/Microsoft.Diagnostics.TestHelpers/IProcessLogger.cs +++ b/src/Microsoft.Diagnostics.TestHelpers/IProcessLogger.cs @@ -15,6 +15,7 @@ public enum ProcessStream public enum KillReason { TimedOut, + Stopped, Unknown } diff --git a/src/Microsoft.Diagnostics.TestHelpers/ProcessRunner.cs b/src/Microsoft.Diagnostics.TestHelpers/ProcessRunner.cs index e5bca1393d..9bee89c895 100644 --- a/src/Microsoft.Diagnostics.TestHelpers/ProcessRunner.cs +++ b/src/Microsoft.Diagnostics.TestHelpers/ProcessRunner.cs @@ -29,7 +29,7 @@ namespace Microsoft.Diagnostics.TestHelpers /// only calls to Kill() and property getters invoked within the logging callbacks will be called /// asynchronously. /// </remarks> - public class ProcessRunner + public class ProcessRunner : IDisposable { // All of the locals might accessed from multiple threads and need to read/written under // the _lock. We also use the lock to synchronize property access on the process object. @@ -232,6 +232,11 @@ public int ExitCode get { lock (_lock) { return _p.ExitCode; } } } + public int ModuleCount + { + get { lock (_lock) { return _p.Modules.Count; } } + } + public void StandardInputWriteLine(string line) { IProcessLogger[] loggers = null; @@ -246,6 +251,7 @@ public void StandardInputWriteLine(string line) logger.WriteLine(this, line, ProcessStream.StandardIn); } inputStream.WriteLine(line); + inputStream.Flush(); } public Task<int> Run() @@ -262,6 +268,16 @@ public Task<int> WaitForExit() } } + public void Dispose() + { + Process p = null; + lock (_lock) + { + p = _p; + } + p?.Dispose(); + } + public ProcessRunner Start() { Process p = null; diff --git a/src/Microsoft.Diagnostics.TestHelpers/TestConfiguration.cs b/src/Microsoft.Diagnostics.TestHelpers/TestConfiguration.cs index ece382ad0d..95b41a190a 100644 --- a/src/Microsoft.Diagnostics.TestHelpers/TestConfiguration.cs +++ b/src/Microsoft.Diagnostics.TestHelpers/TestConfiguration.cs @@ -454,6 +454,10 @@ private string GetStringViewWithVersion(string version) sb.Append("."); sb.Append(debuggeeBuildProcess); } + if (PublishSingleFile) + { + sb.Append(".singlefile"); + } if (!string.IsNullOrEmpty(version)) { sb.Append("."); @@ -462,20 +466,23 @@ private string GetStringViewWithVersion(string version) return sb.ToString(); } - internal string GetLogSuffix() + public string LogSuffix { - string version = RuntimeFrameworkVersion; - - // The log name can't contain wild cards, which are used in some testing scenarios. - // TODO: The better solution would be to sanitize the file name properly, in case - // there's a key being used that contains a character that is not a valid file - // name charater. - if (!string.IsNullOrEmpty(version) && version.Contains('*')) + get { - version = _truncatedRuntimeFrameworkVersion; - } + string version = RuntimeFrameworkVersion; + + // The log name can't contain wild cards, which are used in some testing scenarios. + // TODO: The better solution would be to sanitize the file name properly, in case + // there's a key being used that contains a character that is not a valid file + // name charater. + if (!string.IsNullOrEmpty(version) && version.Contains('*')) + { + version = _truncatedRuntimeFrameworkVersion; + } - return GetStringViewWithVersion(version); + return GetStringViewWithVersion(version); + } } public IReadOnlyDictionary<string, string> AllSettings @@ -781,6 +788,18 @@ public string LinkerPackageVersion get { return GetValue("LinkerPackageVersion"); } } + /// <summary> + /// The root of the dotnet install to use to run the test (i.e. $(RepoRootDir)/.dotnet-test) + /// </summary> + public string DotNetRoot + { + get + { + string dotnetRoot = GetValue("DotNetRoot"); + return MakeCanonicalPath(dotnetRoot); + } + } + #region Runtime Features properties /// <summary> diff --git a/src/Microsoft.Diagnostics.TestHelpers/TestHost/TestDataReader.cs b/src/Microsoft.Diagnostics.TestHelpers/TestHost/TestDataReader.cs index 192fe06fbc..98be1acec9 100644 --- a/src/Microsoft.Diagnostics.TestHelpers/TestHost/TestDataReader.cs +++ b/src/Microsoft.Diagnostics.TestHelpers/TestHost/TestDataReader.cs @@ -103,6 +103,11 @@ public static void GetValue(Type type, string valueString, ref object result) } } + /// <summary> + /// Version 1.0.0 constant + /// </summary> + public static readonly Version Version100 = new Version("1.0.0"); + /// <summary> /// Test data file version /// </summary> @@ -187,52 +192,6 @@ private static ImmutableDictionary<string, Value> Build(XElement node) } return members.ToImmutableDictionary(); } - } - - public static class TestDataExtensions - { - /// <summary> - /// Helper function to get a test data value - /// </summary> - /// <typeparam name="T">type to convert test data value</typeparam> - /// <param name="values">values collection to lookup name</param> - /// <param name="name">value name</param> - /// <param name="value">result value of type T</param> - /// <returns></returns> - public static bool TryGetValue<T>( - this ImmutableDictionary<string, TestDataReader.Value> values, string name, out T value) - { - if (values.TryGetValue(name, out TestDataReader.Value testValue)) - { - value = testValue.GetValue<T>(); - return true; - } - value = default; - return false; - } - - /// <summary> - /// Finds the match item (i.e. IModule, IThread, etc.) in the test data. - /// </summary> - /// <typeparam name="T">field or property type</typeparam> - /// <param name="items">Modules, Threads, Registers, etc. test data</param> - /// <param name="propety">name of property to use for search</param> - /// <param name="propertyValue"></param> - /// <returns>test data values</returns> - public static ImmutableDictionary<string, TestDataReader.Value> Find<T>( - this ImmutableArray<ImmutableDictionary<string, TestDataReader.Value>> items, string propety, T propertyValue) - where T : IComparable - { - foreach (var item in items) - { - TestDataReader.Value value = item[propety]; - if (propertyValue.CompareTo(value.GetValue<T>()) == 0) - { - return item; - } - } - return default; - } /// <summary> /// Compares the test data values with the properties in the instance with the same name. This is @@ -240,13 +199,17 @@ public static bool TryGetValue<T>( /// </summary> /// <param name="values">test data for the item</param> /// <param name="instance">object to compare</param> - public static void CompareMembers( - this ImmutableDictionary<string, TestDataReader.Value> values, object instance) + public void CompareMembers(ImmutableDictionary<string, TestDataReader.Value> values, object instance) { foreach (KeyValuePair<string, TestDataReader.Value> testData in values) { + string testDataKey = testData.Key; + if (Version <= Version100 && testDataKey == "VersionData") + { + testDataKey = "GetVersionData"; + } MemberInfo[] members = instance.GetType().GetMember( - testData.Key, + testDataKey, MemberTypes.Field | MemberTypes.Property | MemberTypes.Method, BindingFlags.Public | BindingFlags.Instance); @@ -278,7 +241,7 @@ public static void CompareMembers( { if (testData.Value.IsSubValue) { - Trace.TraceInformation($"CompareMembers {testData.Key} sub value:"); + Trace.TraceInformation($"CompareMembers {testDataKey} sub value:"); CompareMembers(testData.Value.Values.Single(), memberValue); } else @@ -305,15 +268,15 @@ public static void CompareMembers( memberValue = memberValue?.ToString() ?? string.Empty; } object testDataValue = testData.Value.GetValue(memberType); - Trace.TraceInformation($"CompareMembers {testData.Key}: expected '{testDataValue}' actual '{memberValue}'"); + Trace.TraceInformation($"CompareMembers {testDataKey}: expected '{testDataValue}' actual '{memberValue}'"); // Disable checking the VersionData property because downloading the necessary binary to map into the address is unreliable // See issue: https://github.com/dotnet/diagnostics/issues/2955 - if (testData.Key == "VersionData") + if (testDataKey == "GetVersionData") { if (!object.Equals(testDataValue, memberValue)) { - Trace.TraceError($"CompareMembers VersionData: expected '{testDataValue}' != actual '{memberValue}'"); + Trace.TraceError($"CompareMembers GetVersionData(): expected '{testDataValue}' != actual '{memberValue}'"); } } else @@ -324,15 +287,61 @@ public static void CompareMembers( } else { - Trace.TraceWarning($"CompareMembers {testData.Key} member not found"); + Trace.TraceWarning($"CompareMembers {testDataKey} member not found"); return; } } else { - Trace.TraceWarning($"CompareMembers {testData.Key} not found"); + Trace.TraceWarning($"CompareMembers {testDataKey} not found"); + } + } + } + } + + public static class TestDataExtensions + { + /// <summary> + /// Helper function to get a test data value + /// </summary> + /// <typeparam name="T">type to convert test data value</typeparam> + /// <param name="values">values collection to lookup name</param> + /// <param name="name">value name</param> + /// <param name="value">result value of type T</param> + /// <returns></returns> + public static bool TryGetValue<T>( + this ImmutableDictionary<string, TestDataReader.Value> values, string name, out T value) + { + if (values.TryGetValue(name, out TestDataReader.Value testValue)) + { + value = testValue.GetValue<T>(); + return true; + } + value = default; + return false; + } + + /// <summary> + /// Finds the match item (i.e. IModule, IThread, etc.) in the test data. + /// </summary> + /// <typeparam name="T">field or property type</typeparam> + /// <param name="items">Modules, Threads, Registers, etc. test data</param> + /// <param name="propety">name of property to use for search</param> + /// <param name="propertyValue"></param> + /// <returns>test data values</returns> + public static ImmutableDictionary<string, TestDataReader.Value> Find<T>( + this ImmutableArray<ImmutableDictionary<string, TestDataReader.Value>> items, string propety, T propertyValue) + where T : IComparable + { + foreach (var item in items) + { + TestDataReader.Value value = item[propety]; + if (propertyValue.CompareTo(value.GetValue<T>()) == 0) + { + return item; } } + return default; } } } diff --git a/src/Microsoft.Diagnostics.TestHelpers/TestHost/TestDataWriter.cs b/src/Microsoft.Diagnostics.TestHelpers/TestHost/TestDataWriter.cs index adc4c668ff..537275ce3a 100644 --- a/src/Microsoft.Diagnostics.TestHelpers/TestHost/TestDataWriter.cs +++ b/src/Microsoft.Diagnostics.TestHelpers/TestHost/TestDataWriter.cs @@ -20,7 +20,7 @@ public class TestDataWriter public TestDataWriter() { Root = new XElement("TestData"); - Root.Add(new XElement("Version", "1.0.0")); + Root.Add(new XElement("Version", "1.0.1")); Target = new XElement("Target"); Root.Add(Target); } @@ -93,7 +93,7 @@ public void Write(string testDataFile) private void AddModuleMembers(XElement element, IModule module, string symbolModuleName) { - AddMembers(element, typeof(IModule), module, nameof(IModule.ModuleIndex), nameof(IModule.GetPdbFileInfos), nameof(IModule.GetVersionString)); + AddMembers(element, typeof(IModule), module, nameof(IModule.ModuleIndex), nameof(IModule.GetPdbFileInfos), nameof(IModule.GetVersionString), nameof(IModule.GetSymbolFileName)); if (symbolModuleName != null && IsModuleEqual(module, symbolModuleName)) { @@ -230,7 +230,7 @@ private void AddMembers(XElement element, Type type, object instance, params str result = string.Format($"0x{{0:X{digits}}}", memberValue); } } - else if (memberType.IsValueType || memberType == typeof(VersionData) || memberType == typeof(PdbFileInfo)) + else if (memberType.IsValueType || memberType == typeof(Version) || memberType == typeof(PdbFileInfo)) { result = memberValue?.ToString(); } diff --git a/src/Microsoft.Diagnostics.TestHelpers/TestOutputProcessLogger.cs b/src/Microsoft.Diagnostics.TestHelpers/TestOutputProcessLogger.cs index 6966668dd7..475d45398f 100644 --- a/src/Microsoft.Diagnostics.TestHelpers/TestOutputProcessLogger.cs +++ b/src/Microsoft.Diagnostics.TestHelpers/TestOutputProcessLogger.cs @@ -12,9 +12,9 @@ namespace Microsoft.Diagnostics.TestHelpers { public class TestOutputProcessLogger : IProcessLogger { - string _timeFormat = "mm\\:ss\\.fff"; - ITestOutputHelper _output; - StringBuilder[] _lineBuffers; + private static readonly string _timeFormat = "mm\\:ss\\.fff"; + private readonly ITestOutputHelper _output; + private readonly StringBuilder[] _lineBuffers; public TestOutputProcessLogger(ITestOutputHelper output) { @@ -69,7 +69,7 @@ public virtual void ProcessExited(ProcessRunner runner) { TimeSpan offset = runner.StartTime - DateTime.Now; _output.WriteLine("}"); - _output.WriteLine("Exit code: " + runner.ExitCode + " ( " + offset.ToString(_timeFormat) + " elapsed)"); + _output.WriteLine($"Process {runner.ProcessId} exited {runner.ExitCode} ({offset.ToString(_timeFormat)} elapsed)"); _output.WriteLine(""); } } @@ -79,16 +79,14 @@ public void ProcessKilled(ProcessRunner runner, KillReason reason) lock (this) { TimeSpan offset = runner.StartTime - DateTime.Now; - string reasonText = ""; - if (reason == KillReason.TimedOut) + string reasonText = reason switch { - reasonText = "Process timed out"; - } - else if (reason == KillReason.Unknown) - { - reasonText = "Kill() was called"; - } - _output.WriteLine(" Killing process: " + offset.ToString(_timeFormat) + ": " + reasonText); + KillReason.TimedOut => "Process timed out", + KillReason.Stopped => "Process was stopped", + KillReason.Unknown => "Kill() was called", + _ => "Reason Unknown" + }; + _output.WriteLine($"Killing process {runner.ProcessId}: {offset.ToString(_timeFormat)} - {reasonText}"); } } diff --git a/src/Microsoft.Diagnostics.TestHelpers/TestRunner.cs b/src/Microsoft.Diagnostics.TestHelpers/TestRunner.cs index bc8e2f7d5c..2176a6654a 100644 --- a/src/Microsoft.Diagnostics.TestHelpers/TestRunner.cs +++ b/src/Microsoft.Diagnostics.TestHelpers/TestRunner.cs @@ -139,7 +139,7 @@ public static TestRunner.OutputHelper ConfigureLogging(TestConfiguration config, ConsoleTestOutputHelper consoleLogger = null; if (!string.IsNullOrEmpty(config.LogDirPath)) { - string logFileName = $"{ testName }.{ config.GetLogSuffix() }.log"; + string logFileName = $"{testName}.{config.LogSuffix}.log"; string logPath = Path.Combine(config.LogDirPath, logFileName); fileLogger = new FileTestOutputHelper(logPath, FileMode.Append); } diff --git a/src/SOS/CMakeLists.txt b/src/SOS/CMakeLists.txt index 4d426880a7..ec58ca3239 100644 --- a/src/SOS/CMakeLists.txt +++ b/src/SOS/CMakeLists.txt @@ -13,9 +13,9 @@ if(CLR_CMAKE_HOST_WIN32) add_compile_options(/Zl) # omit default library name in .OBJ add_subdirectory(runcommand) - if(NOT CLR_CMAKE_TARGET_ARCH_ARM64) + if(NOT CLR_CMAKE_TARGET_ARCH_ARM64 AND NOT CLR_CMAKE_TARGET_ARCH_ARM) add_subdirectory(SOS.UnitTests/Debuggees/DesktopClrHost) - endif() + endif(NOT CLR_CMAKE_TARGET_ARCH_ARM64 AND NOT CLR_CMAKE_TARGET_ARCH_ARM) endif(CLR_CMAKE_HOST_WIN32) add_definitions(-D_SECURE_SCL=0) diff --git a/src/SOS/SOS.Extensions/ConsoleServiceFromDebuggerServices.cs b/src/SOS/SOS.Extensions/ConsoleServiceFromDebuggerServices.cs index 927f21b8f2..4a6c52ae38 100644 --- a/src/SOS/SOS.Extensions/ConsoleServiceFromDebuggerServices.cs +++ b/src/SOS/SOS.Extensions/ConsoleServiceFromDebuggerServices.cs @@ -1,5 +1,5 @@ using Microsoft.Diagnostics.DebugServices; -using Microsoft.Diagnostics.Runtime.Interop; +using SOS.Hosting.DbgEng.Interop; using System.Threading; namespace SOS.Extensions diff --git a/src/SOS/SOS.Extensions/DebuggerServices.cs b/src/SOS/SOS.Extensions/DebuggerServices.cs index eb8d85b19c..a6ebabb0c3 100644 --- a/src/SOS/SOS.Extensions/DebuggerServices.cs +++ b/src/SOS/SOS.Extensions/DebuggerServices.cs @@ -4,11 +4,10 @@ using Microsoft.Diagnostics.DebugServices; using Microsoft.Diagnostics.Runtime; -using Microsoft.Diagnostics.Runtime.Interop; using Microsoft.Diagnostics.Runtime.Utilities; +using SOS.Hosting.DbgEng.Interop; using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -366,32 +365,32 @@ public HResult AddModuleSymbol(string symbolFileName) [StructLayout(LayoutKind.Sequential)] private readonly unsafe struct IDebuggerServicesVTable { - public readonly delegate* unmanaged[Stdcall]<IntPtr, out DebuggerServices.OperatingSystem, HResult> GetOperatingSystem; - public readonly delegate* unmanaged[Stdcall]<IntPtr, out DEBUG_CLASS, out DEBUG_CLASS_QUALIFIER, HResult> GetDebuggeeType; - public readonly delegate* unmanaged[Stdcall]<IntPtr, out IMAGE_FILE_MACHINE, HResult> GetExecutingProcessorType; - public readonly delegate* unmanaged[Stdcall]<IntPtr, byte*, byte*, IntPtr*, int, HResult> AddCommand; + public readonly delegate* unmanaged[Stdcall]<IntPtr, out DebuggerServices.OperatingSystem, int> GetOperatingSystem; + public readonly delegate* unmanaged[Stdcall]<IntPtr, out DEBUG_CLASS, out DEBUG_CLASS_QUALIFIER, int> GetDebuggeeType; + public readonly delegate* unmanaged[Stdcall]<IntPtr, out IMAGE_FILE_MACHINE, int> GetExecutingProcessorType; + public readonly delegate* unmanaged[Stdcall]<IntPtr, byte*, byte*, IntPtr*, int, int> AddCommand; public readonly delegate* unmanaged[Stdcall]<IntPtr, DEBUG_OUTPUT, byte*, void> OutputString; - public readonly delegate* unmanaged[Stdcall]<IntPtr, ulong, byte*, uint, out int, HResult> ReadVirtual; - public readonly delegate* unmanaged[Stdcall]<IntPtr, ulong, byte*, uint, out int, HResult> WriteVirtual; - public readonly delegate* unmanaged[Stdcall]<IntPtr, out uint, out uint, HResult> GetNumberModules; - public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, ulong, byte*, uint, out uint, byte*, uint, uint*, byte*, uint, uint*, HResult> GetModuleNames; - public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, out ulong, out ulong, out uint, out uint, HResult> GetModuleInfo; - public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, ulong, byte*, byte*, uint, uint*, HResult> GetModuleVersionInformation; - public readonly delegate* unmanaged[Stdcall]<IntPtr, out uint, HResult> GetNumberThreads; - public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, uint, uint*, uint*, HResult> GetThreadIdsByIndex; - public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, uint, uint, byte*, HResult> GetThreadContextBySystemId; - public readonly delegate* unmanaged[Stdcall]<IntPtr, out uint, HResult> GetCurrentProcessSystemId; - public readonly delegate* unmanaged[Stdcall]<IntPtr, out uint, HResult> GetCurrentThreadSystemId; - public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, HResult> SetCurrentThreadSystemId; - public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, out ulong, HResult> GetThreadTeb; - public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, uint, byte*, HResult> VirtualUnwind; - public readonly delegate* unmanaged[Stdcall]<IntPtr, byte*, uint, out uint, HResult> GetSymbolPath; - public readonly delegate* unmanaged[Stdcall]<IntPtr, int, ulong, byte*, int, out uint, out ulong, HResult> GetSymbolByOffset; - public readonly delegate* unmanaged[Stdcall]<IntPtr, int, byte*, out ulong, HResult> GetOffsetBySymbol; + public readonly delegate* unmanaged[Stdcall]<IntPtr, ulong, byte*, uint, out int, int> ReadVirtual; + public readonly delegate* unmanaged[Stdcall]<IntPtr, ulong, byte*, uint, out int, int> WriteVirtual; + public readonly delegate* unmanaged[Stdcall]<IntPtr, out uint, out uint, int> GetNumberModules; + public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, ulong, byte*, uint, out uint, byte*, uint, uint*, byte*, uint, uint*, int> GetModuleNames; + public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, out ulong, out ulong, out uint, out uint, int> GetModuleInfo; + public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, ulong, byte*, byte*, uint, uint*, int> GetModuleVersionInformation; + public readonly delegate* unmanaged[Stdcall]<IntPtr, out uint, int> GetNumberThreads; + public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, uint, uint*, uint*, int> GetThreadIdsByIndex; + public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, uint, uint, byte*, int> GetThreadContextBySystemId; + public readonly delegate* unmanaged[Stdcall]<IntPtr, out uint, int> GetCurrentProcessSystemId; + public readonly delegate* unmanaged[Stdcall]<IntPtr, out uint, int> GetCurrentThreadSystemId; + public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, int> SetCurrentThreadSystemId; + public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, out ulong, int> GetThreadTeb; + public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, uint, byte*, int> VirtualUnwind; + public readonly delegate* unmanaged[Stdcall]<IntPtr, byte*, uint, out uint, int> GetSymbolPath; + public readonly delegate* unmanaged[Stdcall]<IntPtr, int, ulong, byte*, int, out uint, out ulong, int> GetSymbolByOffset; + public readonly delegate* unmanaged[Stdcall]<IntPtr, int, byte*, out ulong, int> GetOffsetBySymbol; public readonly delegate* unmanaged[Stdcall]<IntPtr, uint> GetOutputWidth; - public readonly delegate* unmanaged[Stdcall]<IntPtr, uint*, HResult> SupportsDml; + public readonly delegate* unmanaged[Stdcall]<IntPtr, uint*, int> SupportsDml; public readonly delegate* unmanaged[Stdcall]<IntPtr, DEBUG_OUTPUT, byte*, void> OutputDmlString; - public readonly delegate* unmanaged[Stdcall]<IntPtr, IntPtr, byte*, HResult> AddModuleSymbol; + public readonly delegate* unmanaged[Stdcall]<IntPtr, IntPtr, byte*, int> AddModuleSymbol; } } } diff --git a/src/SOS/SOS.Extensions/HostServices.cs b/src/SOS/SOS.Extensions/HostServices.cs index 41b9947ac8..744d54c590 100644 --- a/src/SOS/SOS.Extensions/HostServices.cs +++ b/src/SOS/SOS.Extensions/HostServices.cs @@ -13,6 +13,7 @@ using System.Diagnostics; using System.Reflection; using System.Runtime.InteropServices; +using System.Text; namespace SOS.Extensions { @@ -29,7 +30,7 @@ public sealed unsafe class HostServices : COMCallableIUnknown, IHost /// <param name="hostServices">The instance of the host services for the native code to use</param> /// <returns></returns> [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate HResult InitializeCallbackDelegate( + private delegate int InitializeCallbackDelegate( IntPtr hostServices); internal IntPtr IHostServices { get; } @@ -53,7 +54,7 @@ static HostServices() if (RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework")) { AssemblyResolver.Enable(); } - LoggingCommand.Initialize(); + DiagnosticLoggingService.Initialize(); } /// <summary> @@ -106,6 +107,7 @@ public static int Initialize( private HostServices() { _serviceProvider = new ServiceProvider(); + _serviceProvider.AddService<IDiagnosticLoggingService>(DiagnosticLoggingService.Instance); _symbolService = new SymbolService(this); _symbolService.DefaultTimeout = DefaultTimeout; _symbolService.DefaultRetryCount = DefaultRetryCount; @@ -128,7 +130,7 @@ private HostServices() builder.AddMethod(new FlushTargetDelegate(FlushTarget)); builder.AddMethod(new DestroyTargetDelegate(DestroyTarget)); builder.AddMethod(new DispatchCommandDelegate(DispatchCommand)); - builder.AddMethod(new DispatchCommandDelegate(DisplayHelp)); + builder.AddMethod(new DisplayHelpDelegate(DisplayHelp)); builder.AddMethod(new UninitializeDelegate(Uninitialize)); IHostServices = builder.Complete(); @@ -177,7 +179,7 @@ public void DestroyTarget(ITarget target) #region IHostServices - private HResult GetHost( + private int GetHost( IntPtr self, out IntPtr host) { @@ -186,7 +188,7 @@ private HResult GetHost( return HResult.S_OK; } - private HResult RegisterDebuggerServices( + private int RegisterDebuggerServices( IntPtr self, IntPtr iunk) { @@ -216,7 +218,10 @@ private HResult RegisterDebuggerServices( try { var consoleService = new ConsoleServiceFromDebuggerServices(DebuggerServices); - _serviceProvider.AddService<IConsoleService>(consoleService); + var fileLoggingConsoleService = new FileLoggingConsoleService(consoleService); + DiagnosticLoggingService.Instance.SetConsole(consoleService, fileLoggingConsoleService); + _serviceProvider.AddService<IConsoleService>(fileLoggingConsoleService); + _serviceProvider.AddService<IConsoleFileLoggingService>(fileLoggingConsoleService); _contextService = new ContextServiceFromDebuggerServices(this, DebuggerServices); _serviceProvider.AddService<IContextService>(_contextService); @@ -257,7 +262,7 @@ private HResult RegisterDebuggerServices( return HResult.S_OK; } - private HResult CreateTarget( + private int CreateTarget( IntPtr self) { Trace.TraceInformation("HostServices.CreateTarget"); @@ -279,7 +284,7 @@ private HResult CreateTarget( return HResult.S_OK; } - private HResult UpdateTarget( + private int UpdateTarget( IntPtr self, uint processId) { @@ -323,17 +328,32 @@ private void DestroyTarget( } } - private HResult DispatchCommand( + private int DispatchCommand( IntPtr self, - string commandLine) + string commandName, + string commandArguments) { - if (commandLine == null) + if (string.IsNullOrWhiteSpace(commandName)) { return HResult.E_INVALIDARG; } + if (!_commandService.IsCommand(commandName)) + { + return HResult.E_NOTIMPL; + } try { - return _commandService.Execute(commandLine, _contextService.Services); + StringBuilder sb = new(); + sb.Append(commandName); + if (!string.IsNullOrWhiteSpace(commandArguments)) + { + sb.Append(' '); + sb.Append(commandArguments); + } + if (_commandService.Execute(sb.ToString(), _contextService.Services)) + { + return HResult.S_OK; + } } catch (Exception ex) { @@ -342,13 +362,13 @@ private HResult DispatchCommand( return HResult.E_FAIL; } - private HResult DisplayHelp( + private int DisplayHelp( IntPtr self, - string command) + string commandName) { try { - if (!_commandService.DisplayHelp(command, _contextService.Services)) + if (!_commandService.DisplayHelp(commandName, _contextService.Services)) { return HResult.E_INVALIDARG; } @@ -371,6 +391,8 @@ private void Uninitialize( if (DebuggerServices != null) { + // This turns off any logging to console now that debugger services will be released and the console service will no longer work. + DiagnosticLoggingService.Instance.SetConsole(consoleService: null, fileLoggingService: null); DebuggerServices.Release(); DebuggerServices = null; } @@ -395,21 +417,21 @@ private void Uninitialize( #region IHostServices delegates [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult GetHostDelegate( + private delegate int GetHostDelegate( [In] IntPtr self, [Out] out IntPtr host); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult RegisterDebuggerServicesDelegate( + private delegate int RegisterDebuggerServicesDelegate( [In] IntPtr self, [In] IntPtr iunk); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult CreateTargetDelegate( + private delegate int CreateTargetDelegate( [In] IntPtr self); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult UpdateTargetDelegate( + private delegate int UpdateTargetDelegate( [In] IntPtr self, [In] uint processId); @@ -422,14 +444,15 @@ private delegate void DestroyTargetDelegate( [In] IntPtr self); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult DispatchCommandDelegate( + private delegate int DispatchCommandDelegate( [In] IntPtr self, - [In, MarshalAs(UnmanagedType.LPStr)] string commandLine); + [In, MarshalAs(UnmanagedType.LPStr)] string commandName, + [In, MarshalAs(UnmanagedType.LPStr)] string commandArguments); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult DisplayHelpDelegate( + private delegate int DisplayHelpDelegate( [In] IntPtr self, - [In, MarshalAs(UnmanagedType.LPStr)] string command); + [In, MarshalAs(UnmanagedType.LPStr)] string commandName); [UnmanagedFunctionPointer(CallingConvention.Winapi)] private delegate void UninitializeDelegate( diff --git a/src/SOS/SOS.Extensions/ModuleServiceFromDebuggerServices.cs b/src/SOS/SOS.Extensions/ModuleServiceFromDebuggerServices.cs index ef097f3f3d..f94977be0c 100644 --- a/src/SOS/SOS.Extensions/ModuleServiceFromDebuggerServices.cs +++ b/src/SOS/SOS.Extensions/ModuleServiceFromDebuggerServices.cs @@ -4,8 +4,9 @@ using Microsoft.Diagnostics.DebugServices; using Microsoft.Diagnostics.DebugServices.Implementation; -using Microsoft.Diagnostics.Runtime.Interop; using Microsoft.Diagnostics.Runtime.Utilities; +using SOS.Hosting.DbgEng.Interop; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Runtime.InteropServices; @@ -23,7 +24,7 @@ class ModuleFromDebuggerServices : Module, IModuleSymbols private const uint InvalidTimeStamp = 0xFFFFFFFE; private readonly ModuleServiceFromDebuggerServices _moduleService; - private VersionData _versionData; + private Version _version; private string _versionString; public ModuleFromDebuggerServices( @@ -61,7 +62,7 @@ public ModuleFromDebuggerServices( public override uint? IndexTimeStamp { get; } - public override VersionData GetVersionData() + public override Version GetVersionData() { if (InitializeValue(Module.Flags.InitializeVersion)) { @@ -70,19 +71,19 @@ public override VersionData GetVersionData() { int major = (int)(fileInfo.dwFileVersionMS >> 16); int minor = (int)(fileInfo.dwFileVersionMS & 0xffff); - int revision = (int)(fileInfo.dwFileVersionLS >> 16); - int patch = (int)(fileInfo.dwFileVersionLS & 0xffff); - _versionData = new VersionData(major, minor, revision, patch); + int build = (int)(fileInfo.dwFileVersionLS >> 16); + int revision = (int)(fileInfo.dwFileVersionLS & 0xffff); + _version = new Version(major, minor, build, revision); } else { if (_moduleService.Target.OperatingSystem != OSPlatform.Windows) { - _versionData = GetVersion(); + _version = GetVersionInner(); } } } - return _versionData; + return _version; } public override string GetVersionString() diff --git a/src/SOS/SOS.Extensions/RemoteMemoryService.cs b/src/SOS/SOS.Extensions/RemoteMemoryService.cs index 70aa7598ef..307b657444 100644 --- a/src/SOS/SOS.Extensions/RemoteMemoryService.cs +++ b/src/SOS/SOS.Extensions/RemoteMemoryService.cs @@ -35,8 +35,8 @@ public bool FreeMemory(ulong address, uint size, uint typeFlags) [StructLayout(LayoutKind.Sequential)] private readonly unsafe struct IRemoteMemoryServiceVTable { - public readonly delegate* unmanaged[Stdcall]<IntPtr, ulong, uint, uint, uint, out ulong, HResult> AllocVirtual; - public readonly delegate* unmanaged[Stdcall]<IntPtr, ulong, uint, uint, HResult> FreeVirtual; + public readonly delegate* unmanaged[Stdcall]<IntPtr, ulong, uint, uint, uint, out ulong, int> AllocVirtual; + public readonly delegate* unmanaged[Stdcall]<IntPtr, ulong, uint, uint, int> FreeVirtual; } } } diff --git a/src/SOS/SOS.Extensions/SOS.Extensions.csproj b/src/SOS/SOS.Extensions/SOS.Extensions.csproj index 0185dcec4a..c639bf201a 100644 --- a/src/SOS/SOS.Extensions/SOS.Extensions.csproj +++ b/src/SOS/SOS.Extensions/SOS.Extensions.csproj @@ -13,7 +13,6 @@ <ItemGroup> <PackageReference Include="Microsoft.SymbolStore" Version="$(MicrosoftSymbolStoreVersion)" /> <PackageReference Include="Microsoft.Diagnostics.Runtime" Version="$(MicrosoftDiagnosticsRuntimeVersion)" /> - <PackageReference Include="Microsoft.Diagnostics.Runtime.Utilities" Version="$(MicrosoftDiagnosticsRuntimeUtilitiesVersion)" /> <PackageReference Include="System.Memory" Version="$(SystemMemoryVersion)" /> <PackageReference Include="Microsoft.DiaSymReader.Native" Version="$(MicrosoftDiaSymReaderNativePackageVersion)" Condition="'$(OS)' == 'Windows_NT'" /> </ItemGroup> diff --git a/src/SOS/SOS.Extensions/TargetFromFromDebuggerServices.cs b/src/SOS/SOS.Extensions/TargetFromFromDebuggerServices.cs index 3ce6225dae..b57f491fde 100644 --- a/src/SOS/SOS.Extensions/TargetFromFromDebuggerServices.cs +++ b/src/SOS/SOS.Extensions/TargetFromFromDebuggerServices.cs @@ -4,8 +4,8 @@ using Microsoft.Diagnostics.DebugServices; using Microsoft.Diagnostics.DebugServices.Implementation; -using Microsoft.Diagnostics.Runtime.Interop; using Microsoft.Diagnostics.Runtime.Utilities; +using SOS.Hosting.DbgEng.Interop; using System; using System.Diagnostics; using System.Runtime.InteropServices; diff --git a/src/SOS/SOS.Hosting/Commands/SOSCommand.cs b/src/SOS/SOS.Hosting/Commands/SOSCommand.cs index d3eb44e128..71203f26aa 100644 --- a/src/SOS/SOS.Hosting/Commands/SOSCommand.cs +++ b/src/SOS/SOS.Hosting/Commands/SOSCommand.cs @@ -10,6 +10,7 @@ namespace SOS.Hosting { + [Command(Name = "analyzeoom", DefaultOptions = "AnalyzeOOM", Help = "Displays the info of the last OOM occurred on an allocation request to the GC heap.")] [Command(Name = "clrstack", DefaultOptions = "ClrStack", Help = "Provides a stack trace of managed code only.")] [Command(Name = "clrthreads", DefaultOptions = "Threads", Help = "List the managed threads running.")] [Command(Name = "dbgout", DefaultOptions = "dbgout", Help = "Enable/disable (-off) internal SOS logging.")] @@ -19,6 +20,7 @@ namespace SOS.Hosting [Command(Name = "dumpclass", DefaultOptions = "DumpClass", Help = "Displays information about a EE class structure at the specified address.")] [Command(Name = "dumpdelegate", DefaultOptions = "DumpDelegate", Help = "Displays information about a delegate.")] [Command(Name = "dumpdomain", DefaultOptions = "DumpDomain", Help = "Displays information all the AppDomains and all assemblies within the domains.")] + [Command(Name = "dumpgcdata", DefaultOptions = "DumpGCData", Help = "Displays information about the GC data.")] [Command(Name = "dumpheap", DefaultOptions = "DumpHeap", Help = "Displays info about the garbage-collected heap and collection statistics about objects.")] [Command(Name = "dumpil", DefaultOptions = "DumpIL", Help = "Displays the Microsoft intermediate language (MSIL) that is associated with a managed method.")] [Command(Name = "dumplog", DefaultOptions = "DumpLog", Help = "Writes the contents of an in-memory stress log to the specified file.")] @@ -26,38 +28,47 @@ namespace SOS.Hosting [Command(Name = "dumpmodule", DefaultOptions = "DumpModule", Help = "Displays information about a EE module structure at the specified address.")] [Command(Name = "dumpmt", DefaultOptions = "DumpMT", Help = "Displays information about a method table at the specified address.")] [Command(Name = "dumpobj", DefaultOptions = "DumpObj", Aliases = new string[] { "do" }, Help = "Displays info about an object at the specified address.")] - [Command(Name = "dumpvc", DefaultOptions = "DumpVC", Help = "Displays info about the fields of a value class.")] + [Command(Name = "dumpruntimetypes", DefaultOptions = "DumpRuntimeTypes", Help = "Finds all System.RuntimeType objects in the gc heap and prints the type name and MethodTable they refer too.")] + [Command(Name = "dumpsig", DefaultOptions = "DumpSig", Help = "This command dumps the signature of a method or field given by <sigaddr> <moduleaddr>.")] + [Command(Name = "dumpsigelem", DefaultOptions = "DumpSigElem", Help = "This command dumps a single element of a signature object.")] [Command(Name = "dumpstackobjects", DefaultOptions = "DumpStackObjects", Aliases = new string[] { "dso" }, Help = "Displays all managed objects found within the bounds of the current stack.")] + [Command(Name = "dumpvc", DefaultOptions = "DumpVC", Help = "Displays info about the fields of a value class.")] [Command(Name = "eeheap", DefaultOptions = "EEHeap", Help = "Displays info about process memory consumed by internal runtime data structures.")] [Command(Name = "eeversion", DefaultOptions = "EEVersion", Help = "Displays information about the runtime version.")] + [Command(Name = "ehinfo", DefaultOptions = "EHInfo", Help = "Displays the exception handling blocks in a jitted method.")] + [Command(Name = "enummem", DefaultOptions = "enummem", Help = "ICLRDataEnumMemoryRegions.EnumMemoryRegions test command.")] [Command(Name = "finalizequeue", DefaultOptions = "FinalizeQueue", Help = "Displays all objects registered for finalization.")] + [Command(Name = "findappdomain", DefaultOptions = "FindAppDomain", Help = "Attempts to resolve the AppDomain of a GC object.")] + [Command(Name = "gchandles", DefaultOptions = "GCHandles", Help = "Provides statistics about GCHandles in the process.")] + [Command(Name = "gcheapstat", DefaultOptions = "GCHeapStat", Help = "Display various GC heap stats.")] [Command(Name = "gcroot", DefaultOptions = "GCRoot", Help = "Displays info about references (or roots) to an object at the specified address.")] + [Command(Name = "gcinfo", DefaultOptions = "GCInfo", Help = "Displays info JIT GC encoding for a method.")] [Command(Name = "gcwhere", DefaultOptions = "GCWhere", Help = "Displays the location in the GC heap of the argument passed in.")] - [Command(Name = "ip2md", DefaultOptions = "IP2MD", Help = "Displays the MethodDesc structure at the specified address in code that has been JIT-compiled.")] - [Command(Name = "name2ee", DefaultOptions = "Name2EE", Help = "Displays the MethodTable structure and EEClass structure for the specified type or method in the specified module.")] - [Command(Name = "printexception", DefaultOptions = "PrintException", Aliases = new string[] { "pe" }, Help = "Displays and formats fields of any object derived from the Exception class at the specified address.")] - [Command(Name = "syncblk", DefaultOptions = "SyncBlk", Help = "Displays the SyncBlock holder info.")] [Command(Name = "histclear", DefaultOptions = "HistClear", Help = "Releases any resources used by the family of Hist commands.")] [Command(Name = "histinit", DefaultOptions = "HistInit", Help = "Initializes the SOS structures from the stress log saved in the debuggee.")] [Command(Name = "histobj", DefaultOptions = "HistObj", Help = "Examines all stress log relocation records and displays the chain of garbage collection relocations that may have led to the address passed in as an argument.")] [Command(Name = "histobjfind", DefaultOptions = "HistObjFind", Help = "Displays all the log entries that reference an object at the specified address.")] [Command(Name = "histroot", DefaultOptions = "HistRoot", Help = "Displays information related to both promotions and relocations of the specified root.")] - [Command(Name = "verifyheap", DefaultOptions = "VerifyHeap", Help = "Checks the GC heap for signs of corruption.")] - [Command(Name = "threadpool", DefaultOptions = "ThreadPool", Help = "Lists basic information about the thread pool.")] + [Command(Name = "histstats", DefaultOptions = "HistStats", Help = "Displays stress log stats.")] + [Command(Name = "ip2md", DefaultOptions = "IP2MD", Help = "Displays the MethodDesc structure at the specified address in code that has been JIT-compiled.")] + [Command(Name = "listnearobj", DefaultOptions = "ListNearObj", Help = "Displays the object preceding and succeeding the address specified.")] + [Command(Name = "name2ee", DefaultOptions = "Name2EE", Help = "Displays the MethodTable structure and EEClass structure for the specified type or method in the specified module.")] + [Command(Name = "objsize", DefaultOptions = "ObjSize", Help = "Lists the sizes of the all the objects found on managed threads.")] + [Command(Name = "pathto", DefaultOptions = "PathTo", Help = "Displays the GC path from <root> to <target>.")] + [Command(Name = "printexception", DefaultOptions = "PrintException", Aliases = new string[] { "pe" }, Help = "Displays and formats fields of any object derived from the Exception class at the specified address.")] [Command(Name = "soshelp", DefaultOptions = "Help", Help = "Displays help for a specific SOS command.")] - [Command(Name = "dumprcw", DefaultOptions = "DumpRCW", Platform = CommandPlatform.Windows, Help = "Displays information about a Runtime Callable Wrapper.")] - [Command(Name = "dumpccw", DefaultOptions = "DumpCCW", Platform = CommandPlatform.Windows, Help = "Displays information about a COM Callable Wrapper.")] - [Command(Name = "dumppermissionset",DefaultOptions = "DumpPermissionSet", Platform = CommandPlatform.Windows, Help = "Displays a PermissionSet object (debug build only).")] - [Command(Name = "traverseheap", DefaultOptions = "TraverseHeap", Platform = CommandPlatform.Windows, Help = "Writes out a file in a format understood by the CLR Profiler.")] - [Command(Name = "analyzeoom", DefaultOptions = "AnalyzeOOM", Platform = CommandPlatform.Windows, Help = "Displays the info of the last OOM occurred on an allocation request to the GC heap.")] - [Command(Name = "verifyobj", DefaultOptions = "VerifyObj", Platform = CommandPlatform.Windows, Help = "Checks the object for signs of corruption.")] - [Command(Name = "listnearobj", DefaultOptions = "ListNearObj", Platform = CommandPlatform.Windows, Help = "Displays the object preceding and succeeding the address specified.")] - [Command(Name = "gcheapstat", DefaultOptions = "GCHeapStat", Platform = CommandPlatform.Windows, Help = "Display various GC heap stats.")] - [Command(Name = "watsonbuckets", DefaultOptions = "WatsonBuckets", Platform = CommandPlatform.Windows, Help = "Displays the Watson buckets.")] - [Command(Name = "comstate", DefaultOptions = "COMState", Platform = CommandPlatform.Windows, Help = "Lists the COM apartment model for each thread.")] - [Command(Name = "gchandles", DefaultOptions = "GCHandles", Help = "Provides statistics about GCHandles in the process.")] - [Command(Name = "objsize", DefaultOptions = "ObjSize", Platform = CommandPlatform.Windows, Help = "Lists the sizes of the all the objects found on managed threads.")] - [Command(Name = "gchandleleaks", DefaultOptions = "GCHandleLeaks", Platform = CommandPlatform.Windows, Help = "Helps in tracking down GCHandle leaks")] + [Command(Name = "syncblk", DefaultOptions = "SyncBlk", Help = "Displays the SyncBlock holder info.")] + [Command(Name = "threadpool", DefaultOptions = "ThreadPool", Help = "Lists basic information about the thread pool.")] + [Command(Name = "threadstate", DefaultOptions = "ThreadState", Help = "Pretty prints the meaning of a threads state.")] + [Command(Name = "traverseheap", DefaultOptions = "TraverseHeap", Help = "Writes out heap information to a file in a format understood by the CLR Profiler.")] + [Command(Name = "verifyheap", DefaultOptions = "VerifyHeap", Help = "Checks the GC heap for signs of corruption.")] + [Command(Name = "verifyobj", DefaultOptions = "VerifyObj", Help = "Checks the object for signs of corruption.")] + [Command(Name = "comstate", DefaultOptions = "COMState", Flags = CommandFlags.Windows, Help = "Lists the COM apartment model for each thread.")] + [Command(Name = "dumprcw", DefaultOptions = "DumpRCW", Flags = CommandFlags.Windows, Help = "Displays information about a Runtime Callable Wrapper.")] + [Command(Name = "dumpccw", DefaultOptions = "DumpCCW", Flags = CommandFlags.Windows, Help = "Displays information about a COM Callable Wrapper.")] + [Command(Name = "dumppermissionset",DefaultOptions = "DumpPermissionSet", Flags = CommandFlags.Windows, Help = "Displays a PermissionSet object (debug build only).")] + [Command(Name = "gchandleleaks", DefaultOptions = "GCHandleLeaks", Flags = CommandFlags.Windows, Help = "Helps in tracking down GCHandle leaks")] + [Command(Name = "watsonbuckets", DefaultOptions = "WatsonBuckets", Flags = CommandFlags.Windows, Help = "Displays the Watson buckets.")] public class SOSCommand : CommandBase { [Argument(Name = "arguments", Help = "Arguments to SOS command.")] @@ -69,7 +80,7 @@ public override void Invoke() { try { Debug.Assert(Arguments != null && Arguments.Length > 0); - string arguments = string.Concat(Arguments.Skip(1).Select((arg) => arg + " ")); + string arguments = string.Concat(Arguments.Skip(1).Select((arg) => arg + " ")).Trim(); SOSHost.ExecuteCommand(Arguments[0], arguments); } catch (Exception ex) when (ex is FileNotFoundException || ex is EntryPointNotFoundException || ex is InvalidOperationException) { diff --git a/src/SOS/SOS.Hosting/CorDebugDataTargetWrapper.cs b/src/SOS/SOS.Hosting/CorDebugDataTargetWrapper.cs index 0954470bc5..058cdb4dfb 100644 --- a/src/SOS/SOS.Hosting/CorDebugDataTargetWrapper.cs +++ b/src/SOS/SOS.Hosting/CorDebugDataTargetWrapper.cs @@ -125,13 +125,17 @@ private unsafe int ReadVirtual( uint bytesRequested, uint* pbytesRead) { - address &= _ignoreAddressBitsMask; - if (!_memoryService.ReadMemory(address, buffer, unchecked((int)bytesRequested), out int bytesRead)) + int read = 0; + if (bytesRequested > 0) { - Trace.TraceError("CorDebugDataTargetWrappter.ReadVirtual FAILED address {0:X16} size {1:X8}", address, bytesRequested); - return HResult.E_FAIL; + address &= _ignoreAddressBitsMask; + if (!_memoryService.ReadMemory(address, buffer, unchecked((int)bytesRequested), out read)) + { + Trace.TraceError("CorDebugDataTargetWrappter.ReadVirtual FAILED address {0:X16} size {1:X8}", address, bytesRequested); + return HResult.E_FAIL; + } } - SOSHost.Write(pbytesRead, (uint)bytesRead); + SOSHost.Write(pbytesRead, (uint)read); return HResult.S_OK; } diff --git a/src/SOS/SOS.Hosting/DataTargetWrapper.cs b/src/SOS/SOS.Hosting/DataTargetWrapper.cs index e8106b67e8..a5a9d4992e 100644 --- a/src/SOS/SOS.Hosting/DataTargetWrapper.cs +++ b/src/SOS/SOS.Hosting/DataTargetWrapper.cs @@ -3,8 +3,8 @@ // See the LICENSE file in the project root for more information. using Microsoft.Diagnostics.DebugServices; -using Microsoft.Diagnostics.Runtime.Interop; using Microsoft.Diagnostics.Runtime.Utilities; +using SOS.Hosting.DbgEng.Interop; using System; using System.Diagnostics; using System.Linq; @@ -101,7 +101,7 @@ protected override void Destroy() #region ICLRDataTarget - private HResult GetMachineType( + private int GetMachineType( IntPtr self, out IMAGE_FILE_MACHINE machineType) { @@ -121,7 +121,7 @@ private HResult GetMachineType( return HResult.S_OK; } - private HResult GetPointerSize( + private int GetPointerSize( IntPtr self, out int pointerSize) { @@ -129,7 +129,7 @@ private HResult GetPointerSize( return HResult.S_OK; } - private HResult GetImageBase( + private int GetImageBase( IntPtr self, string imagePath, out ulong baseAddress) @@ -144,26 +144,30 @@ private HResult GetImageBase( return HResult.E_FAIL; } - private HResult ReadVirtual( + private int ReadVirtual( IntPtr self, ulong address, IntPtr buffer, uint bytesRequested, - uint* bytesRead) + uint* pbytesRead) { Debug.Assert(address != MagicCallbackConstant); - address &= _ignoreAddressBitsMask; - if (!_memoryService.ReadMemory(address, buffer, unchecked((int)bytesRequested), out int read)) + int read = 0; + if (bytesRequested > 0) { - Trace.TraceError("DataTargetWrapper.ReadVirtual FAILED address {0:X16} size {1:X8}", address, bytesRequested); - SOSHost.Write(bytesRead); - return HResult.E_FAIL; + address &= _ignoreAddressBitsMask; + if (!_memoryService.ReadMemory(address, buffer, unchecked((int)bytesRequested), out read)) + { + Trace.TraceError("DataTargetWrapper.ReadVirtual FAILED address {0:X16} size {1:X8}", address, bytesRequested); + SOSHost.Write(pbytesRead); + return HResult.E_FAIL; + } } - SOSHost.Write(bytesRead, (uint)read); + SOSHost.Write(pbytesRead, (uint)read); return HResult.S_OK; } - private HResult WriteVirtual( + private int WriteVirtual( IntPtr self, ulong address, IntPtr buffer, @@ -180,7 +184,7 @@ private HResult WriteVirtual( return HResult.S_OK; } - private HResult GetTLSValue( + private int GetTLSValue( IntPtr self, uint threadId, uint index, @@ -189,7 +193,7 @@ private HResult GetTLSValue( return HResult.E_NOTIMPL; } - private HResult SetTLSValue( + private int SetTLSValue( IntPtr self, uint threadId, uint index, @@ -198,7 +202,7 @@ private HResult SetTLSValue( return HResult.E_NOTIMPL; } - private HResult GetCurrentThreadID( + private int GetCurrentThreadID( IntPtr self, out uint threadId) { @@ -212,7 +216,7 @@ private HResult GetCurrentThreadID( return HResult.E_FAIL; } - private HResult GetThreadContext( + private int GetThreadContext( IntPtr self, uint threadId, uint contextFlags, @@ -241,7 +245,7 @@ private HResult GetThreadContext( return HResult.S_OK; } - private HResult SetThreadContext( + private int SetThreadContext( IntPtr self, uint threadId, int contextSize, @@ -250,7 +254,7 @@ private HResult SetThreadContext( return HResult.E_NOTIMPL; } - private HResult Request( + private int Request( IntPtr self, uint reqCode, uint inBufferSize, @@ -265,7 +269,7 @@ private HResult Request( #region ICLRDataTarget2 - private HResult AllocVirtual( + private int AllocVirtual( IntPtr self, ulong address, uint size, @@ -283,7 +287,7 @@ private HResult AllocVirtual( return HResult.S_OK; } - private HResult FreeVirtual( + private int FreeVirtual( IntPtr self, ulong address, uint size, @@ -325,7 +329,7 @@ private int VirtualUnwind( #region ICLRMetadataLocator - private HResult GetMetadata( + private int GetMetadata( IntPtr self, string fileName, uint imageTimestamp, @@ -344,7 +348,7 @@ private HResult GetMetadata( #region ICLRRuntimeLocator - private HResult GetRuntimeBase( + private int GetRuntimeBase( IntPtr self, out ulong address) { @@ -357,23 +361,23 @@ private HResult GetRuntimeBase( #region ICLRDataTarget delegates [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult GetMachineTypeDelegate( + private delegate int GetMachineTypeDelegate( [In] IntPtr self, [Out] out IMAGE_FILE_MACHINE machineType); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult GetPointerSizeDelegate( + private delegate int GetPointerSizeDelegate( [In] IntPtr self, [Out] out int pointerSize); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult GetImageBaseDelegate( + private delegate int GetImageBaseDelegate( [In] IntPtr self, [In][MarshalAs(UnmanagedType.LPWStr)] string imagePath, [Out] out ulong baseAddress); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult ReadVirtualDelegate( + private delegate int ReadVirtualDelegate( [In] IntPtr self, [In] ulong address, [In] IntPtr buffer, @@ -381,7 +385,7 @@ private delegate HResult ReadVirtualDelegate( [Out] uint* bytesRead); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult WriteVirtualDelegate( + private delegate int WriteVirtualDelegate( [In] IntPtr self, [In] ulong address, [In] IntPtr buffer, @@ -389,26 +393,26 @@ private delegate HResult WriteVirtualDelegate( [Out] uint* bytesWritten); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult GetTLSValueDelegate( + private delegate int GetTLSValueDelegate( [In] IntPtr self, [In] uint threadId, [In] uint index, [Out] ulong* value); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult SetTLSValueDelegate( + private delegate int SetTLSValueDelegate( [In] IntPtr self, [In] uint threadId, [In] uint index, [In] ulong value); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult GetCurrentThreadIDDelegate( + private delegate int GetCurrentThreadIDDelegate( [In] IntPtr self, [Out] out uint threadId); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult GetThreadContextDelegate( + private delegate int GetThreadContextDelegate( [In] IntPtr self, [In] uint threadId, [In] uint contextFlags, @@ -416,14 +420,14 @@ private delegate HResult GetThreadContextDelegate( [Out] IntPtr context); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult SetThreadContextDelegate( + private delegate int SetThreadContextDelegate( [In] IntPtr self, [In] uint threadId, [In] int contextSize, [In] IntPtr context); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult RequestDelegate( + private delegate int RequestDelegate( [In] IntPtr self, [In] uint reqCode, [In] uint inBufferSize, @@ -436,7 +440,7 @@ private delegate HResult RequestDelegate( #region ICLRDataTarget2 delegates [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult AllocVirtualDelegate( + private delegate int AllocVirtualDelegate( [In] IntPtr self, [In] ulong address, [In] uint size, @@ -445,7 +449,7 @@ private delegate HResult AllocVirtualDelegate( [Out] ulong* buffer); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult FreeVirtualDelegate( + private delegate int FreeVirtualDelegate( [In] IntPtr self, [In] ulong address, [In] uint size, @@ -467,7 +471,7 @@ private delegate int VirtualUnwindDelegate( #region ICLRMetadataLocator delegate [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult GetMetadataDelegate( + private delegate int GetMetadataDelegate( [In] IntPtr self, [In][MarshalAs(UnmanagedType.LPWStr)] string fileName, [In] uint imageTimestamp, @@ -484,7 +488,7 @@ [In] [MarshalAs(UnmanagedType.LPArray, SizeConst = 16)] byte[] mvid, #region ICLRRuntimeLocator delegate [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult GetRuntimeBaseDelegate( + private delegate int GetRuntimeBaseDelegate( [In] IntPtr self, [Out] out ulong address); diff --git a/src/SOS/SOS.Hosting/dbgeng/DebugAdvanced.cs b/src/SOS/SOS.Hosting/DbgEng/DebugAdvanced.cs similarity index 94% rename from src/SOS/SOS.Hosting/dbgeng/DebugAdvanced.cs rename to src/SOS/SOS.Hosting/DbgEng/DebugAdvanced.cs index a1af7924fb..9bc754fb25 100644 --- a/src/SOS/SOS.Hosting/dbgeng/DebugAdvanced.cs +++ b/src/SOS/SOS.Hosting/DbgEng/DebugAdvanced.cs @@ -2,12 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Diagnostics.Runtime.Interop; using Microsoft.Diagnostics.Runtime.Utilities; +using SOS.Hosting.DbgEng.Interop; using System; using System.Runtime.InteropServices; -namespace SOS.Hosting +namespace SOS.Hosting.DbgEng { internal unsafe class DebugAdvanced { diff --git a/src/SOS/SOS.Hosting/dbgeng/DebugClient.cs b/src/SOS/SOS.Hosting/DbgEng/DebugClient.cs similarity index 99% rename from src/SOS/SOS.Hosting/dbgeng/DebugClient.cs rename to src/SOS/SOS.Hosting/DbgEng/DebugClient.cs index 19e595cca8..58a57b05bd 100644 --- a/src/SOS/SOS.Hosting/dbgeng/DebugClient.cs +++ b/src/SOS/SOS.Hosting/DbgEng/DebugClient.cs @@ -2,14 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Diagnostics.Runtime.Interop; using Microsoft.Diagnostics.Runtime.Utilities; +using SOS.Hosting.DbgEng.Interop; using System; using System.Diagnostics; using System.Runtime.InteropServices; using System.Text; -namespace SOS.Hosting +namespace SOS.Hosting.DbgEng { internal unsafe class DebugClient : COMCallableIUnknown { diff --git a/src/SOS/SOS.Hosting/dbgeng/DebugControl.cs b/src/SOS/SOS.Hosting/DbgEng/DebugControl.cs similarity index 99% rename from src/SOS/SOS.Hosting/dbgeng/DebugControl.cs rename to src/SOS/SOS.Hosting/DbgEng/DebugControl.cs index 9536e665b7..a8efb85831 100644 --- a/src/SOS/SOS.Hosting/dbgeng/DebugControl.cs +++ b/src/SOS/SOS.Hosting/DbgEng/DebugControl.cs @@ -2,13 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Diagnostics.Runtime.Interop; using Microsoft.Diagnostics.Runtime.Utilities; +using SOS.Hosting.DbgEng.Interop; using System; using System.Runtime.InteropServices; using System.Text; -namespace SOS.Hosting +namespace SOS.Hosting.DbgEng { internal unsafe class DebugControl { diff --git a/src/SOS/SOS.Hosting/dbgeng/DebugDataSpaces.cs b/src/SOS/SOS.Hosting/DbgEng/DebugDataSpaces.cs similarity index 99% rename from src/SOS/SOS.Hosting/dbgeng/DebugDataSpaces.cs rename to src/SOS/SOS.Hosting/DbgEng/DebugDataSpaces.cs index 61108219f5..5d05a9b8b3 100644 --- a/src/SOS/SOS.Hosting/dbgeng/DebugDataSpaces.cs +++ b/src/SOS/SOS.Hosting/DbgEng/DebugDataSpaces.cs @@ -2,12 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Diagnostics.Runtime.Interop; using Microsoft.Diagnostics.Runtime.Utilities; +using SOS.Hosting.DbgEng.Interop; using System; using System.Runtime.InteropServices; -namespace SOS.Hosting +namespace SOS.Hosting.DbgEng { internal unsafe class DebugDataSpaces { diff --git a/src/SOS/SOS.Hosting/dbgeng/DebugRegisters.cs b/src/SOS/SOS.Hosting/DbgEng/DebugRegisters.cs similarity index 98% rename from src/SOS/SOS.Hosting/dbgeng/DebugRegisters.cs rename to src/SOS/SOS.Hosting/DbgEng/DebugRegisters.cs index c6554d7b73..25c0d8d882 100644 --- a/src/SOS/SOS.Hosting/dbgeng/DebugRegisters.cs +++ b/src/SOS/SOS.Hosting/DbgEng/DebugRegisters.cs @@ -2,13 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Diagnostics.Runtime.Interop; using Microsoft.Diagnostics.Runtime.Utilities; +using SOS.Hosting.DbgEng.Interop; using System; using System.Runtime.InteropServices; using System.Text; -namespace SOS.Hosting +namespace SOS.Hosting.DbgEng { internal unsafe class DebugRegisters { diff --git a/src/SOS/SOS.Hosting/dbgeng/DebugSymbols.cs b/src/SOS/SOS.Hosting/DbgEng/DebugSymbols.cs similarity index 99% rename from src/SOS/SOS.Hosting/dbgeng/DebugSymbols.cs rename to src/SOS/SOS.Hosting/DbgEng/DebugSymbols.cs index b2cbe689e0..ff3c066c8e 100644 --- a/src/SOS/SOS.Hosting/dbgeng/DebugSymbols.cs +++ b/src/SOS/SOS.Hosting/DbgEng/DebugSymbols.cs @@ -2,13 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Diagnostics.Runtime.Interop; using Microsoft.Diagnostics.Runtime.Utilities; +using SOS.Hosting.DbgEng.Interop; using System; using System.Runtime.InteropServices; using System.Text; -namespace SOS.Hosting +namespace SOS.Hosting.DbgEng { internal unsafe class DebugSymbols { @@ -269,7 +269,7 @@ private delegate int GetModuleNamesDelegate( [Out] uint* ModuleNameSize, [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder LoadedImageNameBuffer, [In] uint LoadedImageNameBufferSize, - [Out] uint* LoadedImageNameSize); + [Out] uint* LoadedImageNameSize); [UnmanagedFunctionPointer(CallingConvention.Winapi)] private delegate int GetModuleParametersDelegate( @@ -424,7 +424,7 @@ private delegate int CreateSymbolGroupDelegate( private delegate int StartSymbolMatchDelegate( IntPtr self, [In][MarshalAs(UnmanagedType.LPStr)] string Pattern, - [Out] ulong* Handle); + [Out] ulong* Handle); [UnmanagedFunctionPointer(CallingConvention.Winapi)] private delegate int GetNextSymbolMatchDelegate( @@ -613,7 +613,7 @@ private delegate int GetNearNameByOffsetWideDelegate( [In] int Delta, [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder NameBuffer, [In] int NameBufferSize, - [Out] uint* NameSize, + [Out] uint* NameSize, [Out] ulong* Displacement); [UnmanagedFunctionPointer(CallingConvention.Winapi)] diff --git a/src/SOS/SOS.Hosting/dbgeng/DebugSystemObjects.cs b/src/SOS/SOS.Hosting/DbgEng/DebugSystemObjects.cs similarity index 99% rename from src/SOS/SOS.Hosting/dbgeng/DebugSystemObjects.cs rename to src/SOS/SOS.Hosting/DbgEng/DebugSystemObjects.cs index af2ebbc07a..154fa06ef3 100644 --- a/src/SOS/SOS.Hosting/dbgeng/DebugSystemObjects.cs +++ b/src/SOS/SOS.Hosting/DbgEng/DebugSystemObjects.cs @@ -2,13 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Diagnostics.Runtime.Interop; using Microsoft.Diagnostics.Runtime.Utilities; +using SOS.Hosting.DbgEng.Interop; using System; using System.Runtime.InteropServices; using System.Text; -namespace SOS.Hosting +namespace SOS.Hosting.DbgEng { internal unsafe class DebugSystemObjects { diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/BusDataType.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/BusDataType.cs new file mode 100644 index 0000000000..3d4d12eaed --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/BusDataType.cs @@ -0,0 +1,24 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum BUS_DATA_TYPE + { + ConfigurationSpaceUndefined = -1, + Cmos, + EisaConfiguration, + Pos, + CbusConfiguration, + PCIConfiguration, + VMEConfiguration, + NuBusConfiguration, + PCMCIAConfiguration, + MPIConfiguration, + MPSAConfiguration, + PNPISAConfiguration, + SgiInternalConfiguration, + MaximumBusDataType + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/CodePage.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/CodePage.cs new file mode 100644 index 0000000000..8653a18486 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/CodePage.cs @@ -0,0 +1,18 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum CODE_PAGE : uint + { + ACP = 0, // default to ANSI code page + OEMCP = 1, // default to OEM code page + MACCP = 2, // default to MAC code page + THREAD_ACP = 3, // current thread's ANSI code page + SYMBOL = 42, // SYMBOL translations + + UTF7 = 65000, // UTF-7 translation + UTF8 = 65001 // UTF-8 translation + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugAddSynthMethod.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugAddSynthMethod.cs new file mode 100644 index 0000000000..db46ff1e17 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugAddSynthMethod.cs @@ -0,0 +1,14 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_ADDSYNTHMOD : uint + { + DEFAULT = 0 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugAddSynthSym.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugAddSynthSym.cs new file mode 100644 index 0000000000..ca914b700e --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugAddSynthSym.cs @@ -0,0 +1,14 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_ADDSYNTHSYM : uint + { + DEFAULT = 0 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugAsmOpt.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugAsmOpt.cs new file mode 100644 index 0000000000..44550d3584 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugAsmOpt.cs @@ -0,0 +1,18 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_ASMOPT : uint + { + DEFAULT = 0x00000000, + VERBOSE = 0x00000001, + NO_CODE_BYTES = 0x00000002, + IGNORE_OUTPUT_WIDTH = 0x00000004, + SOURCE_LINE_NUMBER = 0x00000008 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugAttach.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugAttach.cs new file mode 100644 index 0000000000..d02e26210d --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugAttach.cs @@ -0,0 +1,24 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_ATTACH : uint + { + KERNEL_CONNECTION = 0, + LOCAL_KERNEL = 1, + EXDI_DRIVER = 2, + + DEFAULT = 0, + NONINVASIVE = 1, + EXISTING = 2, + NONINVASIVE_NO_SUSPEND = 4, + INVASIVE_NO_INITIAL_BREAK = 8, + INVASIVE_RESUME_PROCESS = 0x10, + NONINVASIVE_ALLOW_PARTIAL = 0x20 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugBreakpointAccessType.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugBreakpointAccessType.cs new file mode 100644 index 0000000000..cf2195f3a0 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugBreakpointAccessType.cs @@ -0,0 +1,17 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_BREAKPOINT_ACCESS_TYPE : uint + { + READ = 1, + WRITE = 2, + EXECUTE = 4, + IO = 8 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugBreakpointFlag.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugBreakpointFlag.cs new file mode 100644 index 0000000000..9fdf4a3ee1 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugBreakpointFlag.cs @@ -0,0 +1,18 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_BREAKPOINT_FLAG : uint + { + GO_ONLY = 1, + DEFERRED = 2, + ENABLED = 4, + ADDER_ONLY = 8, + ONE_SHOT = 0x10 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugBreakpointType.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugBreakpointType.cs new file mode 100644 index 0000000000..e8f608a623 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugBreakpointType.cs @@ -0,0 +1,13 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_BREAKPOINT_TYPE : uint + { + CODE = 0, + DATA = 1, + TIME = 2 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCds.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCds.cs new file mode 100644 index 0000000000..765ef2580e --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCds.cs @@ -0,0 +1,17 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_CDS : uint + { + ALL = 0xffffffff, + REGISTERS = 1, + DATA = 2, + REFRESH = 4 // Inform the GUI clients to refresh debugger windows. + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCdsRefresh.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCdsRefresh.cs new file mode 100644 index 0000000000..2b08f1186e --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCdsRefresh.cs @@ -0,0 +1,31 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + // What windows should the GUI client refresh? + [Flags] + public enum DEBUG_CDS_REFRESH : uint + { + EVALUATE = 1, + EXECUTE = 2, + EXECUTECOMMANDFILE = 3, + ADDBREAKPOINT = 4, + REMOVEBREAKPOINT = 5, + WRITEVIRTUAL = 6, + WRITEVIRTUALUNCACHED = 7, + WRITEPHYSICAL = 8, + WRITEPHYSICAL2 = 9, + SETVALUE = 10, + SETVALUE2 = 11, + SETSCOPE = 12, + SETSCOPEFRAMEBYINDEX = 13, + SETSCOPEFROMJITDEBUGINFO = 14, + SETSCOPEFROMSTOREDEVENT = 15, + INLINESTEP = 16, + INLINESTEP_PSEUDO = 17 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCes.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCes.cs new file mode 100644 index 0000000000..29f16759f7 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCes.cs @@ -0,0 +1,29 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_CES : uint + { + ALL = 0xffffffff, + CURRENT_THREAD = 1, + EFFECTIVE_PROCESSOR = 2, + BREAKPOINTS = 4, + CODE_LEVEL = 8, + EXECUTION_STATUS = 0x10, + ENGINE_OPTIONS = 0x20, + LOG_FILE = 0x40, + RADIX = 0x80, + EVENT_FILTERS = 0x100, + PROCESS_OPTIONS = 0x200, + EXTENSIONS = 0x400, + SYSTEMS = 0x800, + ASSEMBLY_OPTIONS = 0x1000, + EXPRESSION_SYNTAX = 0x2000, + TEXT_REPLACEMENTS = 0x4000 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCesExecutionStatus.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCesExecutionStatus.cs new file mode 100644 index 0000000000..a99bc627bd --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCesExecutionStatus.cs @@ -0,0 +1,15 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_CES_EXECUTION_STATUS : ulong + { + INSIDE_WAIT = 0x100000000UL, + WAIT_TIMEOUT = 0x200000000UL + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugClass.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugClass.cs new file mode 100644 index 0000000000..e53617bc41 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugClass.cs @@ -0,0 +1,14 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_CLASS : uint + { + UNINITIALIZED = 0, + KERNEL = 1, + USER_WINDOWS = 2, + IMAGE_FILE = 3 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugClassQualifier.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugClassQualifier.cs new file mode 100644 index 0000000000..7afbabb85d --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugClassQualifier.cs @@ -0,0 +1,22 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_CLASS_QUALIFIER : uint + { + KERNEL_CONNECTION = 0, + KERNEL_LOCAL = 1, + KERNEL_EXDI_DRIVER = 2, + KERNEL_IDNA = 3, + KERNEL_SMALL_DUMP = 1024, + KERNEL_DUMP = 1025, + KERNEL_FULL_DUMP = 1026, + USER_WINDOWS_PROCESS = 0, + USER_WINDOWS_PROCESS_SERVER = 1, + USER_WINDOWS_IDNA = 2, + USER_WINDOWS_SMALL_DUMP = 1024, + USER_WINDOWS_DUMP = 1026 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugConnectSession.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugConnectSession.cs new file mode 100644 index 0000000000..ad989027cb --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugConnectSession.cs @@ -0,0 +1,16 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_CONNECT_SESSION : uint + { + DEFAULT = 0, + NO_VERSION = 1, + NO_ANNOUNCE = 2 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCreateProcess.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCreateProcess.cs new file mode 100644 index 0000000000..0c7d957013 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCreateProcess.cs @@ -0,0 +1,16 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_CREATE_PROCESS : uint + { + DEFAULT = 0, + NO_DEBUG_HEAP = 0x00000400, /* CREATE_UNICODE_ENVIRONMENT */ + THROUGH_RTL = 0x00010000 /* STACK_SIZE_PARAM_IS_A_RESERVATION */ + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCss.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCss.cs new file mode 100644 index 0000000000..b2f33ab85a --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCss.cs @@ -0,0 +1,20 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_CSS : uint + { + ALL = 0xffffffff, + LOADS = 1, + UNLOADS = 2, + SCOPE = 4, + PATHS = 8, + SYMBOL_OPTIONS = 0x10, + TYPE_OPTIONS = 0x20 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCurrent.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCurrent.cs new file mode 100644 index 0000000000..cd6c76466e --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugCurrent.cs @@ -0,0 +1,18 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_CURRENT : uint + { + DEFAULT = 0xf, + SYMBOL = 1, + DISASM = 2, + REGISTERS = 4, + SOURCE_LINE = 8 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugData.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugData.cs new file mode 100644 index 0000000000..1bfb3fd275 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugData.cs @@ -0,0 +1,16 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_DATA : uint + { + KPCR_OFFSET = 0, + KPRCB_OFFSET = 1, + KTHREAD_OFFSET = 2, + BASE_TRANSLATION_VIRTUAL_OFFSET = 3, + PROCESSOR_IDENTIFICATION = 4, + PROCESSOR_SPEED = 5 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugDataSpace.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugDataSpace.cs new file mode 100644 index 0000000000..248ef64728 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugDataSpace.cs @@ -0,0 +1,17 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_DATA_SPACE : uint + { + VIRTUAL = 0, + PHYSICAL = 1, + CONTROL = 2, + IO = 3, + MSR = 4, + BUS_DATA = 5, + DEBUGGER_DATA = 6 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugDisasm.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugDisasm.cs new file mode 100644 index 0000000000..8ae2114a0e --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugDisasm.cs @@ -0,0 +1,17 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_DISASM : uint + { + EFFECTIVE_ADDRESS = 1, + MATCHING_SYMBOLS = 2, + SOURCE_LINE_NUMBER = 4, + SOURCE_FILE_NAME = 8 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugDump.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugDump.cs new file mode 100644 index 0000000000..34f8873d53 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugDump.cs @@ -0,0 +1,19 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_DUMP : uint + { + SMALL = 1024, + DEFAULT = 1025, + FULL = 1026, + IMAGE_FILE = 1027, + TRACE_LOG = 1028, + WINDOWS_CD = 1029, + KERNEL_DUMP = 1025, + KERNEL_SMALL_DUMP = 1024, + KERNEL_FULL_DUMP = 1026 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugDumpFile.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugDumpFile.cs new file mode 100644 index 0000000000..28a8c80dd6 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugDumpFile.cs @@ -0,0 +1,12 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_DUMP_FILE : uint + { + BASE = 0xffffffff, + PAGE_FILE_DUMP = 0 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugECreateProcess.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugECreateProcess.cs new file mode 100644 index 0000000000..2b11c97215 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugECreateProcess.cs @@ -0,0 +1,17 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_ECREATE_PROCESS : uint + { + DEFAULT = 0, + INHERIT_HANDLES = 1, + USE_VERIFIER_FLAGS = 2, + USE_IMPLICIT_COMMAND_LINE = 4 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugEIndex.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugEIndex.cs new file mode 100644 index 0000000000..6ed0085cd6 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugEIndex.cs @@ -0,0 +1,14 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_EINDEX : uint + { + NAME = 0, + FROM_START = 0, + FROM_END = 1, + FROM_CURRENT = 2 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugEnd.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugEnd.cs new file mode 100644 index 0000000000..caffe34845 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugEnd.cs @@ -0,0 +1,15 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_END : uint + { + PASSIVE = 0, + ACTIVE_TERMINATE = 1, + ACTIVE_DETACH = 2, + END_REENTRANT = 3, + END_DISCONNECT = 4 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugEngOpt.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugEngOpt.cs new file mode 100644 index 0000000000..8f1d2c066c --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugEngOpt.cs @@ -0,0 +1,35 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_ENGOPT : uint + { + NONE = 0, + IGNORE_DBGHELP_VERSION = 0x00000001, + IGNORE_EXTENSION_VERSIONS = 0x00000002, + ALLOW_NETWORK_PATHS = 0x00000004, + DISALLOW_NETWORK_PATHS = 0x00000008, + NETWORK_PATHS = 0x00000004 | 0x00000008, + IGNORE_LOADER_EXCEPTIONS = 0x00000010, + INITIAL_BREAK = 0x00000020, + INITIAL_MODULE_BREAK = 0x00000040, + FINAL_BREAK = 0x00000080, + NO_EXECUTE_REPEAT = 0x00000100, + FAIL_INCOMPLETE_INFORMATION = 0x00000200, + ALLOW_READ_ONLY_BREAKPOINTS = 0x00000400, + SYNCHRONIZE_BREAKPOINTS = 0x00000800, + DISALLOW_SHELL_COMMANDS = 0x00001000, + KD_QUIET_MODE = 0x00002000, + DISABLE_MANAGED_SUPPORT = 0x00004000, + DISABLE_MODULE_SYMBOL_LOAD = 0x00008000, + DISABLE_EXECUTION_COMMANDS = 0x00010000, + DISALLOW_IMAGE_FILE_MAPPING = 0x00020000, + PREFER_DML = 0x00040000, + ALL = 0x0007FFFF + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugEvent.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugEvent.cs new file mode 100644 index 0000000000..ab670126b3 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugEvent.cs @@ -0,0 +1,27 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_EVENT : uint + { + NONE = 0, + BREAKPOINT = 1, + EXCEPTION = 2, + CREATE_THREAD = 4, + EXIT_THREAD = 8, + CREATE_PROCESS = 0x10, + EXIT_PROCESS = 0x20, + LOAD_MODULE = 0x40, + UNLOAD_MODULE = 0x80, + SYSTEM_ERROR = 0x100, + SESSION_STATUS = 0x200, + CHANGE_DEBUGGEE_STATE = 0x400, + CHANGE_ENGINE_STATE = 0x800, + CHANGE_SYMBOL_STATE = 0x1000 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugExecute.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugExecute.cs new file mode 100644 index 0000000000..c7e5bb0e0b --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugExecute.cs @@ -0,0 +1,17 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_EXECUTE : uint + { + DEFAULT = 0, + ECHO = 1, + NOT_LOGGED = 2, + NO_REPEAT = 4 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugExpr.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugExpr.cs new file mode 100644 index 0000000000..9a36305b1a --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugExpr.cs @@ -0,0 +1,12 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_EXPR : uint + { + MASM = 0, + CPLUSPLUS = 1 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFilterContinueOption.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFilterContinueOption.cs new file mode 100644 index 0000000000..c316dfb0af --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFilterContinueOption.cs @@ -0,0 +1,12 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_FILTER_CONTINUE_OPTION : uint + { + GO_HANDLED = 0x00000000, + GO_NOT_HANDLED = 0x00000001 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFilterEvent.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFilterEvent.cs new file mode 100644 index 0000000000..a190a38983 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFilterEvent.cs @@ -0,0 +1,20 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_FILTER_EVENT : uint + { + CREATE_THREAD = 0x00000000, + EXIT_THREAD = 0x00000001, + CREATE_PROCESS = 0x00000002, + EXIT_PROCESS = 0x00000003, + LOAD_MODULE = 0x00000004, + UNLOAD_MODULE = 0x00000005, + SYSTEM_ERROR = 0x00000006, + INITIAL_BREAKPOINT = 0x00000007, + INITIAL_MODULE_LOAD = 0x00000008, + DEBUGGEE_OUTPUT = 0x00000009 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFilterExecOption.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFilterExecOption.cs new file mode 100644 index 0000000000..d8120f8d86 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFilterExecOption.cs @@ -0,0 +1,15 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_FILTER_EXEC_OPTION : uint + { + BREAK = 0x00000000, + SECOND_CHANCE_BREAK = 0x00000001, + OUTPUT = 0x00000002, + IGNORE = 0x00000003, + REMOVE = 0x00000004 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFindSource.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFindSource.cs new file mode 100644 index 0000000000..34242dc63a --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFindSource.cs @@ -0,0 +1,18 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_FIND_SOURCE : uint + { + DEFAULT = 0, + FULL_PATH = 1, + BEST_MATCH = 2, + NO_SRCSRV = 4, + TOKEN_LOOKUP = 8 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFormat.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFormat.cs new file mode 100644 index 0000000000..c55a14947c --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFormat.cs @@ -0,0 +1,35 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_FORMAT : uint + { + DEFAULT = 0x00000000, + CAB_SECONDARY_ALL_IMAGES = 0x10000000, + WRITE_CAB = 0x20000000, + CAB_SECONDARY_FILES = 0x40000000, + NO_OVERWRITE = 0x80000000, + + USER_SMALL_FULL_MEMORY = 0x00000001, + USER_SMALL_HANDLE_DATA = 0x00000002, + USER_SMALL_UNLOADED_MODULES = 0x00000004, + USER_SMALL_INDIRECT_MEMORY = 0x00000008, + USER_SMALL_DATA_SEGMENTS = 0x00000010, + USER_SMALL_FILTER_MEMORY = 0x00000020, + USER_SMALL_FILTER_PATHS = 0x00000040, + USER_SMALL_PROCESS_THREAD_DATA = 0x00000080, + USER_SMALL_PRIVATE_READ_WRITE_MEMORY = 0x00000100, + USER_SMALL_NO_OPTIONAL_DATA = 0x00000200, + USER_SMALL_FULL_MEMORY_INFO = 0x00000400, + USER_SMALL_THREAD_INFO = 0x00000800, + USER_SMALL_CODE_SEGMENTS = 0x00001000, + USER_SMALL_NO_AUXILIARY_STATE = 0x00002000, + USER_SMALL_FULL_AUXILIARY_STATE = 0x00004000, + USER_SMALL_IGNORE_INACCESSIBLE_MEM = 0x08000000 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFrame.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFrame.cs new file mode 100644 index 0000000000..17bd1312d3 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugFrame.cs @@ -0,0 +1,15 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_FRAME : uint + { + DEFAULT = 0, + IGNORE_INLINE = 1 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGetFnent.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGetFnent.cs new file mode 100644 index 0000000000..766765ac51 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGetFnent.cs @@ -0,0 +1,15 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_GETFNENT : uint + { + DEFAULT = 0, + RAW_ENTRY_ONLY = 1 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGetMod.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGetMod.cs new file mode 100644 index 0000000000..0953fa4515 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGetMod.cs @@ -0,0 +1,16 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_GETMOD : uint + { + DEFAULT = 0, + NO_LOADED_MODULES = 1, + NO_UNLOADED_MODULES = 2 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGetProc.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGetProc.cs new file mode 100644 index 0000000000..5d516e8ad0 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGetProc.cs @@ -0,0 +1,17 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_GET_PROC : uint + { + DEFAULT = 0, + FULL_MATCH = 1, + ONLY_MATCH = 2, + SERVICE_NAME = 4 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGetTextCompletions.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGetTextCompletions.cs new file mode 100644 index 0000000000..f91d0e43e4 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGetTextCompletions.cs @@ -0,0 +1,20 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_GET_TEXT_COMPLETIONS : uint + { + NONE = 0, + NO_DOT_COMMANDS = 1, + NO_EXTENSION_COMMANDS = 2, + NO_SYMBOLS = 4, + IS_DOT_COMMAND = 1, + IS_EXTENSION_COMMAND = 2, + IS_SYMBOL = 4 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGsel.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGsel.cs new file mode 100644 index 0000000000..05887ec10d --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugGsel.cs @@ -0,0 +1,19 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_GSEL : uint + { + DEFAULT = 0, + NO_SYMBOL_LOADS = 1, + ALLOW_LOWER = 2, + ALLOW_HIGHER = 4, + NEAREST_ONLY = 8, + INLINE_CALLSITE = 0x10 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugHandleDataType.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugHandleDataType.cs new file mode 100644 index 0000000000..c129c27e1e --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugHandleDataType.cs @@ -0,0 +1,23 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_HANDLE_DATA_TYPE : uint + { + BASIC = 0, + TYPE_NAME = 1, + OBJECT_NAME = 2, + HANDLE_COUNT = 3, + TYPE_NAME_WIDE = 4, + OBJECT_NAME_WIDE = 5, + MINI_THREAD_1 = 6, + MINI_MUTANT_1 = 7, + MINI_MUTANT_2 = 8, + PER_HANDLE_OPERATIONS = 9, + ALL_HANDLE_OPERATIONS = 10, + MINI_PROCESS_1 = 11, + MINI_PROCESS_2 = 12 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugInterrupt.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugInterrupt.cs new file mode 100644 index 0000000000..4a85a90936 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugInterrupt.cs @@ -0,0 +1,13 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_INTERRUPT : uint + { + ACTIVE = 0, + PASSIVE = 1, + EXIT = 2 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugLevel.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugLevel.cs new file mode 100644 index 0000000000..b681e1dc8b --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugLevel.cs @@ -0,0 +1,12 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_LEVEL : uint + { + SOURCE = 0, + ASSEMBLY = 1 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugLog.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugLog.cs new file mode 100644 index 0000000000..558e3bb44e --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugLog.cs @@ -0,0 +1,17 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_LOG : uint + { + DEFAULT = 0, + APPEND = 1, + UNICODE = 2, + DML = 4 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugManReset.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugManReset.cs new file mode 100644 index 0000000000..065eaea9a0 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugManReset.cs @@ -0,0 +1,15 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_MANRESET : uint + { + DEFAULT = 0, + LOAD_DLL = 1 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugManStr.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugManStr.cs new file mode 100644 index 0000000000..2edd38c82a --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugManStr.cs @@ -0,0 +1,16 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_MANSTR : uint + { + NONE = 0, + LOADED_SUPPORT_DLL = 1, + LOAD_STATUS = 2 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugManaged.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugManaged.cs new file mode 100644 index 0000000000..26025e722b --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugManaged.cs @@ -0,0 +1,16 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_MANAGED : uint + { + DISABLED = 0, + ALLOWED = 1, + DLL_LOADED = 2 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugModName.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugModName.cs new file mode 100644 index 0000000000..88440309bf --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugModName.cs @@ -0,0 +1,15 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_MODNAME : uint + { + IMAGE = 0x00000000, + MODULE = 0x00000001, + LOADED_IMAGE = 0x00000002, + SYMBOL_FILE = 0x00000003, + MAPPED_IMAGE = 0x00000004 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugModule.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugModule.cs new file mode 100644 index 0000000000..a135a4c94a --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugModule.cs @@ -0,0 +1,21 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_MODULE : uint + { + LOADED = 0, + UNLOADED = 1, + USER_MODE = 2, + EXE_MODULE = 4, + EXPLICIT = 8, + SECONDARY = 0x10, + SYNTHETIC = 0x20, + SYM_BAD_CHECKSUM = 0x10000 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOffsInfo.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOffsInfo.cs new file mode 100644 index 0000000000..1befaab101 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOffsInfo.cs @@ -0,0 +1,11 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_OFFSINFO : uint + { + VIRTUAL_SOURCE = 0x00000001 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutCb.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutCb.cs new file mode 100644 index 0000000000..33147822b9 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutCb.cs @@ -0,0 +1,13 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_OUTCB : uint + { + TEXT = 0, + DML = 1, + EXPLICIT_FLUSH = 2 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutCbf.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutCbf.cs new file mode 100644 index 0000000000..2ca8c73208 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutCbf.cs @@ -0,0 +1,16 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_OUTCBF : uint + { + EXPLICIT_FLUSH = 1, + DML_HAS_TAGS = 2, + DML_HAS_SPECIAL_CHARACTERS = 4 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutCbi.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutCbi.cs new file mode 100644 index 0000000000..03fbf6c262 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutCbi.cs @@ -0,0 +1,17 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_OUTCBI : uint + { + EXPLICIT_FLUSH = 1, + TEXT = 2, + DML = 4, + ANY_FORMAT = 6 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutCtl.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutCtl.cs new file mode 100644 index 0000000000..5d59dc8a43 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutCtl.cs @@ -0,0 +1,24 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_OUTCTL : uint + { + THIS_CLIENT = 0, + ALL_CLIENTS = 1, + ALL_OTHER_CLIENTS = 2, + IGNORE = 3, + LOG_ONLY = 4, + SEND_MASK = 7, + NOT_LOGGED = 8, + OVERRIDE_MASK = 0x10, + DML = 0x20, + AMBIENT_DML = 0xfffffffe, + AMBIENT_TEXT = 0xffffffff + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutSym.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutSym.cs new file mode 100644 index 0000000000..616906804c --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutSym.cs @@ -0,0 +1,17 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_OUTSYM : uint + { + DEFAULT = 0, + FORCE_OFFSET = 1, + SOURCE_LINE = 2, + ALLOW_DISPLACEMENT = 4 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutTextRepl.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutTextRepl.cs new file mode 100644 index 0000000000..f64aec72f9 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutTextRepl.cs @@ -0,0 +1,14 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_OUT_TEXT_REPL : uint + { + DEFAULT = 0 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutType.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutType.cs new file mode 100644 index 0000000000..300d101c9b --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutType.cs @@ -0,0 +1,21 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_OUTTYPE + { + DEFAULT = 0, + NO_INDENT = 1, + NO_OFFSET = 2, + VERBOSE = 4, + COMPACT_OUTPUT = 8, + ADDRESS_OF_FIELD = 0x10000, + ADDRESS_ANT_END = 0x20000, + BLOCK_RECURSE = 0x200000 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutput.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutput.cs new file mode 100644 index 0000000000..739ce80ba7 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutput.cs @@ -0,0 +1,23 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_OUTPUT : uint + { + NORMAL = 1, + ERROR = 2, + WARNING = 4, + VERBOSE = 8, + PROMPT = 0x10, + PROMPT_REGISTERS = 0x20, + EXTENSION_WARNING = 0x40, + DEBUGGEE = 0x80, + DEBUGGEE_PROMPT = 0x100, + SYMBOLS = 0x200 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutputSymbols.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutputSymbols.cs new file mode 100644 index 0000000000..d5f59c1ebd --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugOutputSymbols.cs @@ -0,0 +1,18 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_OUTPUT_SYMBOLS + { + DEFAULT = 0, + NO_NAMES = 1, + NO_OFFSETS = 2, + NO_VALUES = 4, + NO_TYPES = 0x10 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugPhysical.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugPhysical.cs new file mode 100644 index 0000000000..390119287f --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugPhysical.cs @@ -0,0 +1,14 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_PHYSICAL : uint + { + DEFAULT = 0, + CACHED = 1, + UNCACHED = 2, + WRITE_COMBINED = 3 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugProcDesc.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugProcDesc.cs new file mode 100644 index 0000000000..199f5f7927 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugProcDesc.cs @@ -0,0 +1,20 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_PROC_DESC : uint + { + DEFAULT = 0, + NO_PATHS = 1, + NO_SERVICES = 2, + NO_MTS_PACKAGES = 4, + NO_COMMAND_LINE = 8, + NO_SESSION_ID = 0x10, + NO_USER_NAME = 0x20 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugProcess.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugProcess.cs new file mode 100644 index 0000000000..78ffe19245 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugProcess.cs @@ -0,0 +1,16 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_PROCESS : uint + { + DEFAULT = 0, + DETACH_ON_EXIT = 1, + ONLY_THIS_PROCESS = 2 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugRegSrc.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugRegSrc.cs new file mode 100644 index 0000000000..536e310d45 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugRegSrc.cs @@ -0,0 +1,13 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_REGSRC : uint + { + DEBUGGEE = 0, + EXPLICIT = 1, + FRAME = 2 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugRegister.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugRegister.cs new file mode 100644 index 0000000000..8c10c119bc --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugRegister.cs @@ -0,0 +1,14 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_REGISTER : uint + { + SUB_REGISTER = 1 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugRegisters.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugRegisters.cs new file mode 100644 index 0000000000..f312439393 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugRegisters.cs @@ -0,0 +1,18 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_REGISTERS : uint + { + DEFAULT = 0, + INT32 = 1, + INT64 = 2, + FLOAT = 4, + ALL = 7 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugRequest.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugRequest.cs new file mode 100644 index 0000000000..2c0b57e48b --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugRequest.cs @@ -0,0 +1,221 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_REQUEST : uint + { + /// <summary> + /// InBuffer - Unused. + /// OutBuffer - Unused. + /// </summary> + SOURCE_PATH_HAS_SOURCE_SERVER = 0, + + /// <summary> + /// InBuffer - Unused. + /// OutBuffer - Machine-specific CONTEXT. + /// </summary> + TARGET_EXCEPTION_CONTEXT = 1, + + /// <summary> + /// InBuffer - Unused. + /// OutBuffer - ULONG system ID of thread. + /// </summary> + TARGET_EXCEPTION_THREAD = 2, + + /// <summary> + /// InBuffer - Unused. + /// OutBuffer - EXCEPTION_RECORD64. + /// </summary> + TARGET_EXCEPTION_RECORD = 3, + + /// <summary> + /// InBuffer - Unused. + /// OutBuffer - DEBUG_CREATE_PROCESS_OPTIONS. + /// </summary> + GET_ADDITIONAL_CREATE_OPTIONS = 4, + + /// <summary> + /// InBuffer - DEBUG_CREATE_PROCESS_OPTIONS. + /// OutBuffer - Unused. + /// </summary> + SET_ADDITIONAL_CREATE_OPTIONS = 5, + + /// <summary> + /// InBuffer - Unused. + /// OutBuffer - ULONG[2] major/minor. + /// </summary> + GET_WIN32_MAJOR_MINOR_VERSIONS = 6, + + /// <summary> + /// InBuffer - DEBUG_READ_USER_MINIDUMP_STREAM. + /// OutBuffer - Unused. + /// </summary> + READ_USER_MINIDUMP_STREAM = 7, + + /// <summary> + /// InBuffer - Unused. + /// OutBuffer - Unused. + /// </summary> + TARGET_CAN_DETACH = 8, + + /// <summary> + /// InBuffer - PTSTR. + /// OutBuffer - Unused. + /// </summary> + SET_LOCAL_IMPLICIT_COMMAND_LINE = 9, + + /// <summary> + /// InBuffer - Unused. + /// OutBuffer - Event code stream offset. + /// </summary> + GET_CAPTURED_EVENT_CODE_OFFSET = 10, + + /// <summary> + /// InBuffer - Unused. + /// OutBuffer - Event code stream information. + /// </summary> + READ_CAPTURED_EVENT_CODE_STREAM = 11, + + /// <summary> + /// InBuffer - Input data block. + /// OutBuffer - Processed data block. + /// </summary> + EXT_TYPED_DATA_ANSI = 12, + + /// <summary> + /// InBuffer - Unused. + /// OutBuffer - Returned path. + /// </summary> + GET_EXTENSION_SEARCH_PATH_WIDE = 13, + + /// <summary> + /// InBuffer - DEBUG_GET_TEXT_COMPLETIONS_IN. + /// OutBuffer - DEBUG_GET_TEXT_COMPLETIONS_OUT. + /// </summary> + GET_TEXT_COMPLETIONS_WIDE = 14, + + /// <summary> + /// InBuffer - ULONG64 cookie. + /// OutBuffer - DEBUG_CACHED_SYMBOL_INFO. + /// </summary> + GET_CACHED_SYMBOL_INFO = 15, + + /// <summary> + /// InBuffer - DEBUG_CACHED_SYMBOL_INFO. + /// OutBuffer - ULONG64 cookie. + /// </summary> + ADD_CACHED_SYMBOL_INFO = 16, + + /// <summary> + /// InBuffer - ULONG64 cookie. + /// OutBuffer - Unused. + /// </summary> + REMOVE_CACHED_SYMBOL_INFO = 17, + + /// <summary> + /// InBuffer - DEBUG_GET_TEXT_COMPLETIONS_IN. + /// OutBuffer - DEBUG_GET_TEXT_COMPLETIONS_OUT. + /// </summary> + GET_TEXT_COMPLETIONS_ANSI = 18, + + /// <summary> + /// InBuffer - Unused. + /// OutBuffer - Unused. + /// </summary> + CURRENT_OUTPUT_CALLBACKS_ARE_DML_AWARE = 19, + + /// <summary> + /// InBuffer - ULONG64 offset. + /// OutBuffer - Unwind information. + /// </summary> + GET_OFFSET_UNWIND_INFORMATION = 20, + + /// <summary> + /// InBuffer - Unused + /// OutBuffer - returned DUMP_HEADER32/DUMP_HEADER64 structure. + /// </summary> + GET_DUMP_HEADER = 21, + + /// <summary> + /// InBuffer - DUMP_HEADER32/DUMP_HEADER64 structure. + /// OutBuffer - Unused + /// </summary> + SET_DUMP_HEADER = 22, + + /// <summary> + /// InBuffer - Midori specific + /// OutBuffer - Midori specific + /// </summary> + MIDORI = 23, + + /// <summary> + /// InBuffer - Unused + /// OutBuffer - PROCESS_NAME_ENTRY blocks + /// </summary> + PROCESS_DESCRIPTORS = 24, + + /// <summary> + /// InBuffer - Unused + /// OutBuffer - MINIDUMP_MISC_INFO_N blocks + /// </summary> + MISC_INFORMATION = 25, + + /// <summary> + /// InBuffer - Unused + /// OutBuffer - ULONG64 as TokenHandle value + /// </summary> + OPEN_PROCESS_TOKEN = 26, + + /// <summary> + /// InBuffer - Unused + /// OutBuffer - ULONG64 as TokenHandle value + /// </summary> + OPEN_THREAD_TOKEN = 27, + + /// <summary> + /// InBuffer - ULONG64 as TokenHandle being duplicated + /// OutBuffer - ULONG64 as new duplicated TokenHandle + /// </summary> + DUPLICATE_TOKEN = 28, + + /// <summary> + /// InBuffer - a ULONG64 as TokenHandle and a ULONG as NtQueryInformationToken() request code + /// OutBuffer - NtQueryInformationToken() return + /// </summary> + QUERY_INFO_TOKEN = 29, + + /// <summary> + /// InBuffer - ULONG64 as TokenHandle + /// OutBuffer - Unused + /// </summary> + CLOSE_TOKEN = 30, + + /// <summary> + /// InBuffer - ULONG64 for process server identification and ULONG as PID + /// OutBuffer - Unused + /// </summary> + WOW_PROCESS = 31, + + /// <summary> + /// InBuffer - ULONG64 for process server identification and PWSTR as module path + /// OutBuffer - Unused + /// </summary> + WOW_MODULE = 32, + + /// <summary> + /// InBuffer - Unused + /// OutBuffer - Unused + /// return - S_OK if non-invasive user-mode attach, S_FALSE if not (but still live user-mode), E_FAIL otherwise. + /// </summary> + LIVE_USER_NON_INVASIVE = 33, + + /// <summary> + /// InBuffer - TID + /// OutBuffer - Unused + /// return - ResumeThreads() return. + /// </summary> + RESUME_THREAD = 34 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugScopeGroup.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugScopeGroup.cs new file mode 100644 index 0000000000..fef6444123 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugScopeGroup.cs @@ -0,0 +1,16 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_SCOPE_GROUP : uint + { + ARGUMENTS = 1, + LOCALS = 2, + ALL = 3 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugServers.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugServers.cs new file mode 100644 index 0000000000..9d37ff421c --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugServers.cs @@ -0,0 +1,13 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_SERVERS : uint + { + DEBUGGER = 1, + PROCESS = 2, + ALL = 3 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSession.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSession.cs new file mode 100644 index 0000000000..e69cf6557c --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSession.cs @@ -0,0 +1,18 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_SESSION : uint + { + ACTIVE = 0, + END_SESSION_ACTIVE_TERMINATE = 1, + END_SESSION_ACTIVE_DETACH = 2, + END_SESSION_PASSIVE = 3, + END = 4, + REBOOT = 5, + HIBERNATE = 6, + FAILURE = 7 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSource.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSource.cs new file mode 100644 index 0000000000..444f853c16 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSource.cs @@ -0,0 +1,14 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_SOURCE : uint + { + IS_STATEMENT = 1 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSrcFile.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSrcFile.cs new file mode 100644 index 0000000000..d97c5bbcd6 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSrcFile.cs @@ -0,0 +1,12 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_SRCFILE : uint + { + SYMBOL_TOKEN = 0, + SYMBOL_TOKEN_SOURCE_COMMAND_WIDE = 1 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugStackcs.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugStackcs.cs new file mode 100644 index 0000000000..c1c9fd2741 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugStackcs.cs @@ -0,0 +1,26 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_STACK : uint + { + ARGUMENTS = 0x1, + FUNCTION_INFO = 0x2, + SOURCE_LINE = 0x4, + FRAME_ADDRESSES = 0x8, + COLUMN_NAMES = 0x10, + NONVOLATILE_REGISTERS = 0x20, + FRAME_NUMBERS = 0x40, + PARAMETERS = 0x80, + FRAME_ADDRESSES_RA_ONLY = 0x100, + FRAME_MEMORY_USAGE = 0x200, + PARAMETERS_NEWLINE = 0x400, + DML = 0x800, + FRAME_OFFSETS = 0x1000 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugStatus.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugStatus.cs new file mode 100644 index 0000000000..09ac6a0ee1 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugStatus.cs @@ -0,0 +1,29 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_STATUS : uint + { + NO_CHANGE = 0, + GO = 1, + GO_HANDLED = 2, + GO_NOT_HANDLED = 3, + STEP_OVER = 4, + STEP_INTO = 5, + BREAK = 6, + NO_DEBUGGEE = 7, + STEP_BRANCH = 8, + IGNORE_EVENT = 9, + RESTART_REQUESTED = 10, + REVERSE_GO = 11, + REVERSE_STEP_BRANCH = 12, + REVERSE_STEP_OVER = 13, + REVERSE_STEP_INTO = 14, + OUT_OF_SYNC = 15, + WAIT_INPUT = 16, + TIMEOUT = 17, + MASK = 0x1f + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugStatusFlags.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugStatusFlags.cs new file mode 100644 index 0000000000..91dba8b981 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugStatusFlags.cs @@ -0,0 +1,24 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_STATUS_FLAGS : ulong + { + /// <summary> + /// This bit is added in DEBUG_CES_EXECUTION_STATUS notifications when the + /// engines execution status is changing due to operations performed during a + /// wait, such as making synchronous callbacks. If the bit is not set the + /// execution status is changing due to a wait being satisfied. + /// </summary> + INSIDE_WAIT = 0x100000000, + + /// <summary> + /// This bit is added in DEBUG_CES_EXECUTION_STATUS notifications when the + /// engines execution status update is coming after a wait has timed-out. It + /// indicates that the execution status change was not due to an actual event. + /// </summary> + WAIT_TIMEOUT = 0x200000000 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSymInfo.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSymInfo.cs new file mode 100644 index 0000000000..1bad3213f7 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSymInfo.cs @@ -0,0 +1,14 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_SYMINFO : uint + { + BREAKPOINT_SOURCE_LINE = 0, + IMAGEHLP_MODULEW64 = 1, + GET_SYMBOL_NAME_BY_OFFSET_AND_TAG_WIDE = 2, + GET_MODULE_SYMBOL_NAMES_AND_OFFSETS = 3 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSymType.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSymType.cs new file mode 100644 index 0000000000..69a7cc35ae --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSymType.cs @@ -0,0 +1,18 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_SYMTYPE : uint + { + NONE = 0, + COFF = 1, + CODEVIEW = 2, + PDB = 3, + EXPORT = 4, + DEFERRED = 5, + SYM = 6, + DIA = 7 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSymbol.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSymbol.cs new file mode 100644 index 0000000000..73c872f089 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSymbol.cs @@ -0,0 +1,20 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_SYMBOL : uint + { + EXPANSION_LEVEL_MASK = 0xf, + EXPANDED = 0x10, + READ_ONLY = 0x20, + IS_ARRAY = 0x40, + IS_FLOAT = 0x80, + IS_ARGUMENT = 0x100, + IS_LOCAL = 0x200 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSysObjInfo.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSysObjInfo.cs new file mode 100644 index 0000000000..321ef3c248 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSysObjInfo.cs @@ -0,0 +1,13 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_SYSOBJINFO : uint + { + THREAD_BASIC_INFORMATION = 0, + THREAD_NAME_WIDE = 1, + CURRENT_PROCESS_COOKIE = 2 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSysVerStr.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSysVerStr.cs new file mode 100644 index 0000000000..63f29211eb --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugSysVerStr.cs @@ -0,0 +1,12 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_SYSVERSTR : uint + { + SERVICE_PACK = 0, + BUILD = 1 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugTbInfo.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugTbInfo.cs new file mode 100644 index 0000000000..1b345ba4f9 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugTbInfo.cs @@ -0,0 +1,21 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_TBINFO : uint + { + NONE = 0, + EXIT_STATUS = 1, + PRIORITY_CLASS = 2, + PRIORITY = 4, + TIMES = 8, + START_OFFSET = 0x10, + AFFINITY = 0x20, + ALL = 0x3f + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugTypeOpts.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugTypeOpts.cs new file mode 100644 index 0000000000..961fd8fd57 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugTypeOpts.cs @@ -0,0 +1,17 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_TYPEOPTS : uint + { + UNICODE_DISPLAY = 1, + LONGSTATUS_DISPLAY = 2, + FORCERADIX_OUTPUT = 4, + MATCH_MAXSIZE = 8 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugVSearch.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugVSearch.cs new file mode 100644 index 0000000000..8caf1540e6 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugVSearch.cs @@ -0,0 +1,12 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_VSEARCH : uint + { + DEFAULT = 0, + WRITABLE_ONLY = 1 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugVSource.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugVSource.cs new file mode 100644 index 0000000000..3dde3f802a --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugVSource.cs @@ -0,0 +1,14 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_VSOURCE : uint + { + INVALID = 0, + DEBUGGEE = 1, + MAPPED_IMAGE = 2, + DUMP_WITHOUT_MEMINFO = 3 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugValueType.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugValueType.cs new file mode 100644 index 0000000000..c3b65ebed4 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugValueType.cs @@ -0,0 +1,23 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum DEBUG_VALUE_TYPE : uint + { + INVALID = 0, + INT8 = 1, + INT16 = 2, + INT32 = 3, + INT64 = 4, + FLOAT32 = 5, + FLOAT64 = 6, + FLOAT80 = 7, + FLOAT82 = 8, + FLOAT128 = 9, + VECTOR64 = 10, + VECTOR128 = 11, + TYPES = 12 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugWait.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugWait.cs new file mode 100644 index 0000000000..dad888dffa --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/DebugWait.cs @@ -0,0 +1,14 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum DEBUG_WAIT : uint + { + DEFAULT = 0 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ECreationDisposition.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ECreationDisposition.cs new file mode 100644 index 0000000000..dbc96de539 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ECreationDisposition.cs @@ -0,0 +1,38 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum ECreationDisposition : uint + { + /// <summary> + /// Creates a new file. The function fails if a specified file exists. + /// </summary> + New = 1, + + /// <summary> + /// Creates a new file, always. + /// If a file exists, the function overwrites the file, clears the existing attributes, combines the specified file attributes, + /// and flags with FILE_ATTRIBUTE_ARCHIVE, but does not set the security descriptor that the SECURITY_ATTRIBUTES structure specifies. + /// </summary> + CreateAlways = 2, + + /// <summary> + /// Opens a file. The function fails if the file does not exist. + /// </summary> + OpenExisting = 3, + + /// <summary> + /// Opens a file, always. + /// If a file does not exist, the function creates a file as if dwCreationDisposition is CREATE_NEW. + /// </summary> + OpenAlways = 4, + + /// <summary> + /// Opens a file and truncates it so that its size is 0 (zero) bytes. The function fails if the file does not exist. + /// The calling process must open the file with the GENERIC_WRITE access right. + /// </summary> + TruncateExisting = 5 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/EFileAccess.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/EFileAccess.cs new file mode 100644 index 0000000000..d5ee3be09a --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/EFileAccess.cs @@ -0,0 +1,18 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum EFileAccess : uint + { + None = 0x00000000, + GenericRead = 0x80000000, + GenericWrite = 0x40000000, + GenericExecute = 0x20000000, + GenericAll = 0x10000000 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/EFileAttributes.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/EFileAttributes.cs new file mode 100644 index 0000000000..bfbd99b6e5 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/EFileAttributes.cs @@ -0,0 +1,38 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum EFileAttributes : uint + { + Readonly = 0x00000001, + Hidden = 0x00000002, + System = 0x00000004, + Directory = 0x00000010, + Archive = 0x00000020, + Device = 0x00000040, + Normal = 0x00000080, + Temporary = 0x00000100, + SparseFile = 0x00000200, + ReparsePoint = 0x00000400, + Compressed = 0x00000800, + Offline = 0x00001000, + NotContentIndexed = 0x00002000, + Encrypted = 0x00004000, + Write_Through = 0x80000000, + Overlapped = 0x40000000, + NoBuffering = 0x20000000, + RandomAccess = 0x10000000, + SequentialScan = 0x08000000, + DeleteOnClose = 0x04000000, + BackupSemantics = 0x02000000, + PosixSemantics = 0x01000000, + OpenReparsePoint = 0x00200000, + OpenNoRecall = 0x00100000, + FirstPipeInstance = 0x00080000 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/EFileShare.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/EFileShare.cs new file mode 100644 index 0000000000..703a008ff0 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/EFileShare.cs @@ -0,0 +1,17 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum EFileShare : uint + { + None = 0x00000000, + Read = 0x00000001, + Write = 0x00000002, + Delete = 0x00000004 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ErrorLevel.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ErrorLevel.cs new file mode 100644 index 0000000000..2b330a16d3 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ErrorLevel.cs @@ -0,0 +1,13 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum ERROR_LEVEL + { + ERROR = 1, + MINORERROR = 2, + WARNING = 3 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ExtTdop.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ExtTdop.cs new file mode 100644 index 0000000000..9b47784541 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ExtTdop.cs @@ -0,0 +1,30 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum _EXT_TDOP + { + EXT_TDOP_COPY, + EXT_TDOP_RELEASE, + EXT_TDOP_SET_FROM_EXPR, + EXT_TDOP_SET_FROM_U64_EXPR, + EXT_TDOP_GET_FIELD, + EXT_TDOP_EVALUATE, + EXT_TDOP_GET_TYPE_NAME, + EXT_TDOP_OUTPUT_TYPE_NAME, + EXT_TDOP_OUTPUT_SIMPLE_VALUE, + EXT_TDOP_OUTPUT_FULL_VALUE, + EXT_TDOP_HAS_FIELD, + EXT_TDOP_GET_FIELD_OFFSET, + EXT_TDOP_GET_ARRAY_ELEMENT, + EXT_TDOP_GET_DEREFERENCE, + EXT_TDOP_GET_TYPE_SIZE, + EXT_TDOP_OUTPUT_TYPE_DEFINITION, + EXT_TDOP_GET_POINTER_TO, + EXT_TDOP_SET_FROM_TYPE_ID_AND_U64, + EXT_TDOP_SET_PTR_FROM_TYPE_ID_AND_U64, + EXT_TDOP_COUNT + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/FormatMessage.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/FormatMessage.cs new file mode 100644 index 0000000000..d281cf9f9b --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/FormatMessage.cs @@ -0,0 +1,19 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum FORMAT_MESSAGE + { + ALLOCATE_BUFFER = 0x0100, + IGNORE_INSERTS = 0x0200, + FROM_STRING = 0x0400, + FROM_HMODULE = 0x0800, + FROM_SYSTEM = 0x1000, + ARGUMENT_ARRAY = 0x2000 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/IG.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/IG.cs new file mode 100644 index 0000000000..2c15808415 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/IG.cs @@ -0,0 +1,60 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum IG : ushort + { + KD_CONTEXT = 1, + READ_CONTROL_SPACE = 2, + WRITE_CONTROL_SPACE = 3, + READ_IO_SPACE = 4, + WRITE_IO_SPACE = 5, + READ_PHYSICAL = 6, + WRITE_PHYSICAL = 7, + READ_IO_SPACE_EX = 8, + WRITE_IO_SPACE_EX = 9, + KSTACK_HELP = 10, // obsolete + SET_THREAD = 11, + READ_MSR = 12, + WRITE_MSR = 13, + GET_DEBUGGER_DATA = 14, + GET_KERNEL_VERSION = 15, + RELOAD_SYMBOLS = 16, + GET_SET_SYMPATH = 17, + GET_EXCEPTION_RECORD = 18, + IS_PTR64 = 19, + GET_BUS_DATA = 20, + SET_BUS_DATA = 21, + DUMP_SYMBOL_INFO = 22, + LOWMEM_CHECK = 23, + SEARCH_MEMORY = 24, + GET_CURRENT_THREAD = 25, + GET_CURRENT_PROCESS = 26, + GET_TYPE_SIZE = 27, + GET_CURRENT_PROCESS_HANDLE = 28, + GET_INPUT_LINE = 29, + GET_EXPRESSION_EX = 30, + TRANSLATE_VIRTUAL_TO_PHYSICAL = 31, + GET_CACHE_SIZE = 32, + READ_PHYSICAL_WITH_FLAGS = 33, + WRITE_PHYSICAL_WITH_FLAGS = 34, + POINTER_SEARCH_PHYSICAL = 35, + OBSOLETE_PLACEHOLDER_36 = 36, + GET_THREAD_OS_INFO = 37, + GET_CLR_DATA_INTERFACE = 38, + MATCH_PATTERN_A = 39, + FIND_FILE = 40, + TYPED_DATA_OBSOLETE = 41, + QUERY_TARGET_INTERFACE = 42, + TYPED_DATA = 43, + DISASSEMBLE_BUFFER = 44, + GET_ANY_MODULE_IN_RANGE = 45, + VIRTUAL_TO_PHYSICAL = 46, + PHYSICAL_TO_VIRTUAL = 47, + GET_CONTEXT_EX = 48, + GET_TEB_ADDRESS = 128, + GET_PEB_ADDRESS = 129 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ImageFileMachine.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ImageFileMachine.cs new file mode 100644 index 0000000000..068f309def --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ImageFileMachine.cs @@ -0,0 +1,41 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum IMAGE_FILE_MACHINE : uint + { + UNKNOWN = 0, + I386 = 0x014c, // Intel 386. + R3000 = 0x0162, // MIPS little-endian, 0x160 big-endian + R4000 = 0x0166, // MIPS little-endian + R10000 = 0x0168, // MIPS little-endian + WCEMIPSV2 = 0x0169, // MIPS little-endian WCE v2 + ALPHA = 0x0184, // Alpha_AXP + SH3 = 0x01a2, // SH3 little-endian + SH3DSP = 0x01a3, + SH3E = 0x01a4, // SH3E little-endian + SH4 = 0x01a6, // SH4 little-endian + SH5 = 0x01a8, // SH5 + ARM = 0x01c0, // ARM Little-Endian + THUMB = 0x01c2, + THUMB2 = 0x1c4, + AM33 = 0x01d3, + POWERPC = 0x01F0, // IBM PowerPC Little-Endian + POWERPCFP = 0x01f1, + IA64 = 0x0200, // Intel 64 + MIPS16 = 0x0266, // MIPS + ALPHA64 = 0x0284, // ALPHA64 + MIPSFPU = 0x0366, // MIPS + MIPSFPU16 = 0x0466, // MIPS + AXP64 = 0x0284, + TRICORE = 0x0520, // Infineon + CEF = 0x0CEF, + EBC = 0x0EBC, // EFI Byte Code + AMD64 = 0x8664, // AMD64 (K8) + M32R = 0x9041, // M32R little-endian + ARM64 = 0xAA64, // ARM64 Little-endian + CEE = 0xC0EE + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/InterfaceType.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/InterfaceType.cs new file mode 100644 index 0000000000..2407aa01bb --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/InterfaceType.cs @@ -0,0 +1,29 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum INTERFACE_TYPE + { + InterfaceTypeUndefined = -1, + Internal, + Isa, + Eisa, + MicroChannel, + TurboChannel, + PCIBus, + VMEBus, + NuBus, + PCMCIABus, + CBus, + MPIBus, + MPSABus, + ProcessorInternal, + InternalPowerBus, + PNPISABus, + PNPBus, + Vmcs, + MaximumInterfaceType + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/MEM.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/MEM.cs new file mode 100644 index 0000000000..76036d42ab --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/MEM.cs @@ -0,0 +1,29 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum MEM : uint + { + COMMIT = 0x1000, + RESERVE = 0x2000, + DECOMMIT = 0x4000, + RELEASE = 0x8000, + FREE = 0x10000, + PRIVATE = 0x20000, + MAPPED = 0x40000, + RESET = 0x80000, + TOP_DOWN = 0x100000, + WRITE_WATCH = 0x200000, + PHYSICAL = 0x400000, + ROTATE = 0x800000, + LARGE_PAGES = 0x20000000, + FOURMB_PAGES = 0x80000000, + + IMAGE = SEC.IMAGE + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ModuleArchitecture.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ModuleArchitecture.cs new file mode 100644 index 0000000000..a03479d776 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ModuleArchitecture.cs @@ -0,0 +1,15 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum MODULE_ARCHITECTURE + { + UNKNOWN, + I386, + X64, + IA64, + ANY + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ModuleOrders.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ModuleOrders.cs new file mode 100644 index 0000000000..d403837b01 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/ModuleOrders.cs @@ -0,0 +1,16 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum MODULE_ORDERS : uint + { + MASK = 0xF0000000, + LOADTIME = 0x10000000, + MODULENAME = 0x20000000 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/Paage.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/Paage.cs new file mode 100644 index 0000000000..dcf0ffef9d --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/Paage.cs @@ -0,0 +1,24 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum PAGE : uint + { + NOACCESS = 0x01, + READONLY = 0x02, + READWRITE = 0x04, + WRITECOPY = 0x08, + EXECUTE = 0x10, + EXECUTE_READ = 0x20, + EXECUTE_READWRITE = 0x40, + EXECUTE_WRITECOPY = 0x80, + GUARD = 0x100, + NOCACHE = 0x200, + WRITECOMBINE = 0x400 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/Sec.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/Sec.cs new file mode 100644 index 0000000000..7804fd4ad8 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/Sec.cs @@ -0,0 +1,22 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum SEC : uint + { + FILE = 0x800000, + IMAGE = 0x1000000, + PROTECTED_IMAGE = 0x2000000, + RESERVE = 0x4000000, + COMMIT = 0x8000000, + NOCACHE = 0x10000000, + WRITECOMBINE = 0x40000000, + LARGE_PAGES = 0x80000000, + MEM_IMAGE = IMAGE + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/SpfMoveMethod.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/SpfMoveMethod.cs new file mode 100644 index 0000000000..24ce174147 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/SpfMoveMethod.cs @@ -0,0 +1,13 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum SPF_MOVE_METHOD : uint + { + FILE_BEGIN = 0, + FILE_CURRENT = 1, + FILE_END = 2 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/SymOpt.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/SymOpt.cs new file mode 100644 index 0000000000..48837cc36c --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/SymOpt.cs @@ -0,0 +1,40 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum SYMOPT : uint + { + CASE_INSENSITIVE = 0x00000001, + UNDNAME = 0x00000002, + DEFERRED_LOADS = 0x00000004, + NO_CPP = 0x00000008, + LOAD_LINES = 0x00000010, + OMAP_FIND_NEAREST = 0x00000020, + LOAD_ANYTHING = 0x00000040, + IGNORE_CVREC = 0x00000080, + NO_UNQUALIFIED_LOADS = 0x00000100, + FAIL_CRITICAL_ERRORS = 0x00000200, + EXACT_SYMBOLS = 0x00000400, + ALLOW_ABSOLUTE_SYMBOLS = 0x00000800, + IGNORE_NT_SYMPATH = 0x00001000, + INCLUDE_32BIT_MODULES = 0x00002000, + PUBLICS_ONLY = 0x00004000, + NO_PUBLICS = 0x00008000, + AUTO_PUBLICS = 0x00010000, + NO_IMAGE_SEARCH = 0x00020000, + SECURE = 0x00040000, + NO_PROMPTS = 0x00080000, + OVERWRITE = 0x00100000, + IGNORE_IMAGEDIR = 0x00200000, + FLAT_DIRECTORY = 0x00400000, + FAVOR_COMPRESSED = 0x00800000, + ALLOW_ZERO_ADDRESS = 0x01000000, + DISABLE_SYMSRV_AUTODETECT = 0x02000000, + DEBUG = 0x80000000 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/SymTag.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/SymTag.cs new file mode 100644 index 0000000000..65f0eff97e --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/SymTag.cs @@ -0,0 +1,48 @@ +// 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. + +namespace SOS.Hosting.DbgEng.Interop +{ + public enum SymTag : uint + { + Null, // 0 + Exe, // 1 + Compiland, // 2 + CompilandDetails, // 3 + CompilandEnv, // 4 + Function, // 5 + Block, // 6 + Data, // 7 + Annotation, // 8 + Label, // 9 + PublicSymbol, // 10 + UDT, // 11 + Enum, // 12 + FunctionType, // 13 + PointerType, // 14 + ArrayType, // 15 + BaseType, // 16 + Typedef, // 17 + BaseClass, // 18 + Friend, // 19 + FunctionArgType, // 20 + FuncDebugStart, // 21 + FuncDebugEnd, // 22 + UsingNamespace, // 23 + VTableShape, // 24 + VTable, // 25 + Custom, // 26 + Thunk, // 27 + CustomType, // 28 + ManagedType, // 29 + Dimension, // 30 + CallSite, // 31 + InlineSite, // 32 + BaseInterface, // 33 + VectorType, // 34 + MatrixType, // 35 + HLSLType, // 36 + SymTagMax + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/VsFF.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/VsFF.cs new file mode 100644 index 0000000000..04f937274b --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Enums/VsFF.cs @@ -0,0 +1,19 @@ +// 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; + +namespace SOS.Hosting.DbgEng.Interop +{ + [Flags] + public enum VS_FF : uint + { + DEBUG = 0x00000001, + PRERELEASE = 0x00000002, + PATCHED = 0x00000004, + PRIVATEBUILD = 0x00000008, + INFOINFERRED = 0x00000010, + SPECIALBUILD = 0x00000020 + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugAdvanced.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugAdvanced.cs new file mode 100644 index 0000000000..0ef6c98d88 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugAdvanced.cs @@ -0,0 +1,25 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("f2df5f53-071f-47bd-9de6-5734c3fed689")] + public interface IDebugAdvanced + { + [PreserveSig] + int GetThreadContext( + IntPtr Context, + int ContextSize); + + [PreserveSig] + int SetThreadContext( + IntPtr Context, + int ContextSize); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugAdvanced2.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugAdvanced2.cs new file mode 100644 index 0000000000..1e1dad8b65 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugAdvanced2.cs @@ -0,0 +1,88 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("716d14c9-119b-4ba5-af1f-0890e672416a")] + public interface IDebugAdvanced2 : IDebugAdvanced + { + /* IDebugAdvanced */ + [PreserveSig] + new int GetThreadContext( + IntPtr Context, + int ContextSize); + + [PreserveSig] + new int SetThreadContext( + IntPtr Context, + int ContextSize); + + /* IDebugAdvanced2 */ + + [PreserveSig] + int Request( + DEBUG_REQUEST Request, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] inBuffer, + int InBufferSize, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] + byte[] outBuffer, + int OutBufferSize, + out int OutSize); + + [PreserveSig] + int GetSourceFileInformation( + DEBUG_SRCFILE Which, + [In][MarshalAs(UnmanagedType.LPStr)] string SourceFile, + ulong Arg64, + uint Arg32, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + int BufferSize, + out int InfoSize); + + [PreserveSig] + int FindSourceFileAndToken( + uint StartElement, + ulong ModAddr, + [In][MarshalAs(UnmanagedType.LPStr)] string File, + DEBUG_FIND_SOURCE Flags, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + int FileTokenSize, + out int FoundElement, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out int FoundSize); + + [PreserveSig] + int GetSymbolInformation( + DEBUG_SYMINFO Which, + ulong Arg64, + uint Arg32, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] + byte[] buffer, + int BufferSize, + out int InfoSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder StringBuffer, + int StringBufferSize, + out int StringSize); + + [PreserveSig] + int GetSystemObjectInformation( + DEBUG_SYSOBJINFO Which, + ulong Arg64, + uint Arg32, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] + byte[] buffer, + int BufferSize, + out int InfoSize); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugAdvanced3.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugAdvanced3.cs new file mode 100644 index 0000000000..d6ac82c95c --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugAdvanced3.cs @@ -0,0 +1,128 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("cba4abb4-84c4-444d-87ca-a04e13286739")] + public interface IDebugAdvanced3 : IDebugAdvanced2 + { + /* IDebugAdvanced */ + [PreserveSig] + new int GetThreadContext( + IntPtr Context, + int ContextSize); + + [PreserveSig] + new int SetThreadContext( + IntPtr Context, + int ContextSize); + + /* IDebugAdvanced2 */ + + [PreserveSig] + new int Request( + DEBUG_REQUEST Request, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] inBuffer, + int InBufferSize, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] + byte[] outBuffer, + int OutBufferSize, + out int OutSize); + + [PreserveSig] + new int GetSourceFileInformation( + DEBUG_SRCFILE Which, + [In][MarshalAs(UnmanagedType.LPStr)] string SourceFile, + ulong Arg64, + uint Arg32, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + int BufferSize, + out int InfoSize); + + [PreserveSig] + new int FindSourceFileAndToken( + uint StartElement, + ulong ModAddr, + [In][MarshalAs(UnmanagedType.LPStr)] string File, + DEBUG_FIND_SOURCE Flags, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + int FileTokenSize, + out int FoundElement, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out int FoundSize); + + [PreserveSig] + new int GetSymbolInformation( + DEBUG_SYMINFO Which, + ulong Arg64, + uint Arg32, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] + byte[] buffer, + int BufferSize, + out int InfoSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder StringBuffer, + int StringBufferSize, + out int StringSize); + + [PreserveSig] + new int GetSystemObjectInformation( + DEBUG_SYSOBJINFO Which, + ulong Arg64, + uint Arg32, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] + byte[] buffer, + int BufferSize, + out int InfoSize); + + /* IDebugAdvanced3 */ + + [PreserveSig] + int GetSourceFileInformationWide( + DEBUG_SRCFILE Which, + [In][MarshalAs(UnmanagedType.LPWStr)] string SourceFile, + ulong Arg64, + uint Arg32, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + int BufferSize, + out int InfoSize); + + [PreserveSig] + int FindSourceFileAndTokenWide( + uint StartElement, + ulong ModAddr, + [In][MarshalAs(UnmanagedType.LPWStr)] string File, + DEBUG_FIND_SOURCE Flags, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + int FileTokenSize, + out int FoundElement, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out int FoundSize); + + [PreserveSig] + int GetSymbolInformationWide( + DEBUG_SYMINFO Which, + ulong Arg64, + uint Arg32, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] + byte[] buffer, + int BufferSize, + out int InfoSize, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder StringBuffer, + int StringBufferSize, + out int StringSize); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugBreakpoint.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugBreakpoint.cs new file mode 100644 index 0000000000..534b0830b1 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugBreakpoint.cs @@ -0,0 +1,110 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("5bd9d474-5975-423a-b88b-65a8e7110e65")] + public interface IDebugBreakpoint + { + /* IDebugBreakpoint */ + + [PreserveSig] + int GetId( + out uint Id); + + [PreserveSig] + int GetType( + out DEBUG_BREAKPOINT_TYPE BreakType, + out uint ProcType); + + //FIX ME!!! Should try and get an enum for this + [PreserveSig] + int GetAdder( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugClient Adder); + + [PreserveSig] + int GetFlags( + out DEBUG_BREAKPOINT_FLAG Flags); + + [PreserveSig] + int AddFlags( + DEBUG_BREAKPOINT_FLAG Flags); + + [PreserveSig] + int RemoveFlags( + DEBUG_BREAKPOINT_FLAG Flags); + + [PreserveSig] + int SetFlags( + DEBUG_BREAKPOINT_FLAG Flags); + + [PreserveSig] + int GetOffset( + out ulong Offset); + + [PreserveSig] + int SetOffset( + ulong Offset); + + [PreserveSig] + int GetDataParameters( + out uint Size, + out DEBUG_BREAKPOINT_ACCESS_TYPE AccessType); + + [PreserveSig] + int SetDataParameters( + uint Size, + DEBUG_BREAKPOINT_ACCESS_TYPE AccessType); + + [PreserveSig] + int GetPassCount( + out uint Count); + + [PreserveSig] + int SetPassCount( + uint Count); + + [PreserveSig] + int GetCurrentPassCount( + out uint Count); + + [PreserveSig] + int GetMatchThreadId( + out uint Id); + + [PreserveSig] + int SetMatchThreadId( + uint Thread); + + [PreserveSig] + int GetCommand( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + int SetCommand( + [In][MarshalAs(UnmanagedType.LPStr)] string Command); + + [PreserveSig] + int GetOffsetExpression( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint ExpressionSize); + + [PreserveSig] + int SetOffsetExpression( + [In][MarshalAs(UnmanagedType.LPStr)] string Expression); + + [PreserveSig] + int GetParameters( + out DEBUG_BREAKPOINT_PARAMETERS Params); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugBreakpoint2.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugBreakpoint2.cs new file mode 100644 index 0000000000..faf2c8eeaa --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugBreakpoint2.cs @@ -0,0 +1,132 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("1b278d20-79f2-426e-a3f9-c1ddf375d48e")] + public interface IDebugBreakpoint2 : IDebugBreakpoint + { + /* IDebugBreakpoint */ + + [PreserveSig] + new int GetId( + out uint Id); + + [PreserveSig] + new int GetType( + out DEBUG_BREAKPOINT_TYPE BreakType, + out uint ProcType); + + //FIX ME!!! Should try and get an enum for this + [PreserveSig] + new int GetAdder( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugClient Adder); + + [PreserveSig] + new int GetFlags( + out DEBUG_BREAKPOINT_FLAG Flags); + + [PreserveSig] + new int AddFlags( + DEBUG_BREAKPOINT_FLAG Flags); + + [PreserveSig] + new int RemoveFlags( + DEBUG_BREAKPOINT_FLAG Flags); + + [PreserveSig] + new int SetFlags( + DEBUG_BREAKPOINT_FLAG Flags); + + [PreserveSig] + new int GetOffset( + out ulong Offset); + + [PreserveSig] + new int SetOffset( + ulong Offset); + + [PreserveSig] + new int GetDataParameters( + out uint Size, + out DEBUG_BREAKPOINT_ACCESS_TYPE AccessType); + + [PreserveSig] + new int SetDataParameters( + uint Size, + DEBUG_BREAKPOINT_ACCESS_TYPE AccessType); + + [PreserveSig] + new int GetPassCount( + out uint Count); + + [PreserveSig] + new int SetPassCount( + uint Count); + + [PreserveSig] + new int GetCurrentPassCount( + out uint Count); + + [PreserveSig] + new int GetMatchThreadId( + out uint Id); + + [PreserveSig] + new int SetMatchThreadId( + uint Thread); + + [PreserveSig] + new int GetCommand( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + new int SetCommand( + [In][MarshalAs(UnmanagedType.LPStr)] string Command); + + [PreserveSig] + new int GetOffsetExpression( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint ExpressionSize); + + [PreserveSig] + new int SetOffsetExpression( + [In][MarshalAs(UnmanagedType.LPStr)] string Expression); + + [PreserveSig] + new int GetParameters( + out DEBUG_BREAKPOINT_PARAMETERS Params); + + /* IDebugBreakpoint2 */ + + [PreserveSig] + int GetCommandWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + int SetCommandWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Command); + + [PreserveSig] + int GetOffsetExpressionWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint ExpressionSize); + + [PreserveSig] + int SetOffsetExpressionWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Command); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugBreakpoint3.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugBreakpoint3.cs new file mode 100644 index 0000000000..9e609f6b58 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugBreakpoint3.cs @@ -0,0 +1,138 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("38f5c249-b448-43bb-9835-579d4ec02249")] + public interface IDebugBreakpoint3 : IDebugBreakpoint2 + { + /* IDebugBreakpoint */ + + [PreserveSig] + new int GetId( + out uint Id); + + [PreserveSig] + new int GetType( + out DEBUG_BREAKPOINT_TYPE BreakType, + out uint ProcType); + + //FIX ME!!! Should try and get an enum for this + [PreserveSig] + new int GetAdder( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugClient Adder); + + [PreserveSig] + new int GetFlags( + out DEBUG_BREAKPOINT_FLAG Flags); + + [PreserveSig] + new int AddFlags( + DEBUG_BREAKPOINT_FLAG Flags); + + [PreserveSig] + new int RemoveFlags( + DEBUG_BREAKPOINT_FLAG Flags); + + [PreserveSig] + new int SetFlags( + DEBUG_BREAKPOINT_FLAG Flags); + + [PreserveSig] + new int GetOffset( + out ulong Offset); + + [PreserveSig] + new int SetOffset( + ulong Offset); + + [PreserveSig] + new int GetDataParameters( + out uint Size, + out DEBUG_BREAKPOINT_ACCESS_TYPE AccessType); + + [PreserveSig] + new int SetDataParameters( + uint Size, + DEBUG_BREAKPOINT_ACCESS_TYPE AccessType); + + [PreserveSig] + new int GetPassCount( + out uint Count); + + [PreserveSig] + new int SetPassCount( + uint Count); + + [PreserveSig] + new int GetCurrentPassCount( + out uint Count); + + [PreserveSig] + new int GetMatchThreadId( + out uint Id); + + [PreserveSig] + new int SetMatchThreadId( + uint Thread); + + [PreserveSig] + new int GetCommand( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + new int SetCommand( + [In][MarshalAs(UnmanagedType.LPStr)] string Command); + + [PreserveSig] + new int GetOffsetExpression( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint ExpressionSize); + + [PreserveSig] + new int SetOffsetExpression( + [In][MarshalAs(UnmanagedType.LPStr)] string Expression); + + [PreserveSig] + new int GetParameters( + out DEBUG_BREAKPOINT_PARAMETERS Params); + + /* IDebugBreakpoint2 */ + + [PreserveSig] + new int GetCommandWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + new int SetCommandWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Command); + + [PreserveSig] + new int GetOffsetExpressionWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint ExpressionSize); + + [PreserveSig] + new int SetOffsetExpressionWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Command); + + /* IDebugBreakpoint3 */ + + [PreserveSig] + int GetGuid(out Guid Guid); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient.cs new file mode 100644 index 0000000000..504392a362 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient.cs @@ -0,0 +1,250 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("27fe5639-8407-4f47-8364-ee118fb08ac8")] + public interface IDebugClient + { + /* IDebugClient */ + + [PreserveSig] + int AttachKernel( + DEBUG_ATTACH Flags, + [In][MarshalAs(UnmanagedType.LPStr)] string ConnectOptions); + + [PreserveSig] + int GetKernelConnectionOptions( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint OptionsSize); + + [PreserveSig] + int SetKernelConnectionOptions( + [In][MarshalAs(UnmanagedType.LPStr)] string Options); + + [PreserveSig] + int StartProcessServer( + DEBUG_CLASS Flags, + [In][MarshalAs(UnmanagedType.LPStr)] string Options, + IntPtr Reserved); + + [PreserveSig] + int ConnectProcessServer( + [In][MarshalAs(UnmanagedType.LPStr)] string RemoteOptions, + out ulong Server); + + [PreserveSig] + int DisconnectProcessServer( + ulong Server); + + [PreserveSig] + int GetRunningProcessSystemIds( + ulong Server, + [Out][MarshalAs(UnmanagedType.LPArray)] + uint[] Ids, + uint Count, + out uint ActualCount); + + [PreserveSig] + int GetRunningProcessSystemIdByExecutableName( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string ExeName, + DEBUG_GET_PROC Flags, + out uint Id); + + [PreserveSig] + int GetRunningProcessDescription( + ulong Server, + uint SystemId, + DEBUG_PROC_DESC Flags, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ExeName, + int ExeNameSize, + out uint ActualExeNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Description, + int DescriptionSize, + out uint ActualDescriptionSize); + + [PreserveSig] + int AttachProcess( + ulong Server, + uint ProcessID, + DEBUG_ATTACH AttachFlags); + + [PreserveSig] + int CreateProcess( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandLine, + DEBUG_CREATE_PROCESS Flags); + + [PreserveSig] + int CreateProcessAndAttach( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandLine, + DEBUG_CREATE_PROCESS Flags, + uint ProcessId, + DEBUG_ATTACH AttachFlags); + + [PreserveSig] + int GetProcessOptions( + out DEBUG_PROCESS Options); + + [PreserveSig] + int AddProcessOptions( + DEBUG_PROCESS Options); + + [PreserveSig] + int RemoveProcessOptions( + DEBUG_PROCESS Options); + + [PreserveSig] + int SetProcessOptions( + DEBUG_PROCESS Options); + + [PreserveSig] + int OpenDumpFile( + [In][MarshalAs(UnmanagedType.LPStr)] string DumpFile); + + [PreserveSig] + int WriteDumpFile( + [In][MarshalAs(UnmanagedType.LPStr)] string DumpFile, + DEBUG_DUMP Qualifier); + + [PreserveSig] + int ConnectSession( + DEBUG_CONNECT_SESSION Flags, + uint HistoryLimit); + + [PreserveSig] + int StartServer( + [In][MarshalAs(UnmanagedType.LPStr)] string Options); + + [PreserveSig] + int OutputServer( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Machine, + DEBUG_SERVERS Flags); + + [PreserveSig] + int TerminateProcesses(); + + [PreserveSig] + int DetachProcesses(); + + [PreserveSig] + int EndSession( + DEBUG_END Flags); + + [PreserveSig] + int GetExitCode( + out uint Code); + + [PreserveSig] + int DispatchCallbacks( + uint Timeout); + + [PreserveSig] + int ExitDispatch( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugClient Client); + + [PreserveSig] + int CreateClient( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugClient Client); + + [PreserveSig] + int GetInputCallbacks( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugInputCallbacks Callbacks); + + [PreserveSig] + int SetInputCallbacks( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugInputCallbacks Callbacks); + + /* GetOutputCallbacks could a conversion thunk from the debugger engine so we can't specify a specific interface */ + + [PreserveSig] + int GetOutputCallbacks( + out IDebugOutputCallbacks Callbacks); + + /* We may have to pass a debugger engine conversion thunk back in so we can't specify a specific interface */ + + [PreserveSig] + int SetOutputCallbacks( + [In] IDebugOutputCallbacks Callbacks); + + [PreserveSig] + int GetOutputMask( + out DEBUG_OUTPUT Mask); + + [PreserveSig] + int SetOutputMask( + DEBUG_OUTPUT Mask); + + [PreserveSig] + int GetOtherOutputMask( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugClient Client, + out DEBUG_OUTPUT Mask); + + [PreserveSig] + int SetOtherOutputMask( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugClient Client, + DEBUG_OUTPUT Mask); + + [PreserveSig] + int GetOutputWidth( + out uint Columns); + + [PreserveSig] + int SetOutputWidth( + uint Columns); + + [PreserveSig] + int GetOutputLinePrefix( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PrefixSize); + + [PreserveSig] + int SetOutputLinePrefix( + [In][MarshalAs(UnmanagedType.LPStr)] string Prefix); + + [PreserveSig] + int GetIdentity( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint IdentitySize); + + [PreserveSig] + int OutputIdentity( + DEBUG_OUTCTL OutputControl, + uint Flags, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + /* GetEventCallbacks could a conversion thunk from the debugger engine so we can't specify a specific interface */ + + [PreserveSig] + int GetEventCallbacks( + out IDebugEventCallbacks Callbacks); + + /* We may have to pass a debugger engine conversion thunk back in so we can't specify a specific interface */ + + [PreserveSig] + int SetEventCallbacks( + [In] IDebugEventCallbacks Callbacks); + + [PreserveSig] + int FlushCallbacks(); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient2.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient2.cs new file mode 100644 index 0000000000..d5861e12a7 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient2.cs @@ -0,0 +1,284 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("edbed635-372e-4dab-bbfe-ed0d2f63be81")] + public interface IDebugClient2 : IDebugClient + { + /* IDebugClient */ + + [PreserveSig] + new int AttachKernel( + DEBUG_ATTACH Flags, + [In][MarshalAs(UnmanagedType.LPStr)] string ConnectOptions); + + [PreserveSig] + new int GetKernelConnectionOptions( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint OptionsSize); + + [PreserveSig] + new int SetKernelConnectionOptions( + [In][MarshalAs(UnmanagedType.LPStr)] string Options); + + [PreserveSig] + new int StartProcessServer( + DEBUG_CLASS Flags, + [In][MarshalAs(UnmanagedType.LPStr)] string Options, + IntPtr Reserved); + + [PreserveSig] + new int ConnectProcessServer( + [In][MarshalAs(UnmanagedType.LPStr)] string RemoteOptions, + out ulong Server); + + [PreserveSig] + new int DisconnectProcessServer( + ulong Server); + + [PreserveSig] + new int GetRunningProcessSystemIds( + ulong Server, + [Out][MarshalAs(UnmanagedType.LPArray)] + uint[] Ids, + uint Count, + out uint ActualCount); + + [PreserveSig] + new int GetRunningProcessSystemIdByExecutableName( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string ExeName, + DEBUG_GET_PROC Flags, + out uint Id); + + [PreserveSig] + new int GetRunningProcessDescription( + ulong Server, + uint SystemId, + DEBUG_PROC_DESC Flags, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ExeName, + int ExeNameSize, + out uint ActualExeNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Description, + int DescriptionSize, + out uint ActualDescriptionSize); + + [PreserveSig] + new int AttachProcess( + ulong Server, + uint ProcessID, + DEBUG_ATTACH AttachFlags); + + [PreserveSig] + new int CreateProcess( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandLine, + DEBUG_CREATE_PROCESS Flags); + + [PreserveSig] + new int CreateProcessAndAttach( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandLine, + DEBUG_CREATE_PROCESS Flags, + uint ProcessId, + DEBUG_ATTACH AttachFlags); + + [PreserveSig] + new int GetProcessOptions( + out DEBUG_PROCESS Options); + + [PreserveSig] + new int AddProcessOptions( + DEBUG_PROCESS Options); + + [PreserveSig] + new int RemoveProcessOptions( + DEBUG_PROCESS Options); + + [PreserveSig] + new int SetProcessOptions( + DEBUG_PROCESS Options); + + [PreserveSig] + new int OpenDumpFile( + [In][MarshalAs(UnmanagedType.LPStr)] string DumpFile); + + [PreserveSig] + new int WriteDumpFile( + [In][MarshalAs(UnmanagedType.LPStr)] string DumpFile, + DEBUG_DUMP Qualifier); + + [PreserveSig] + new int ConnectSession( + DEBUG_CONNECT_SESSION Flags, + uint HistoryLimit); + + [PreserveSig] + new int StartServer( + [In][MarshalAs(UnmanagedType.LPStr)] string Options); + + [PreserveSig] + new int OutputServer( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Machine, + DEBUG_SERVERS Flags); + + [PreserveSig] + new int TerminateProcesses(); + + [PreserveSig] + new int DetachProcesses(); + + [PreserveSig] + new int EndSession( + DEBUG_END Flags); + + [PreserveSig] + new int GetExitCode( + out uint Code); + + [PreserveSig] + new int DispatchCallbacks( + uint Timeout); + + [PreserveSig] + new int ExitDispatch( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugClient Client); + + [PreserveSig] + new int CreateClient( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugClient Client); + + [PreserveSig] + new int GetInputCallbacks( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugInputCallbacks Callbacks); + + [PreserveSig] + new int SetInputCallbacks( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugInputCallbacks Callbacks); + + /* GetOutputCallbacks could a conversion thunk from the debugger engine so we can't specify a specific interface */ + + [PreserveSig] + new int GetOutputCallbacks( + out IDebugOutputCallbacks Callbacks); + + /* We may have to pass a debugger engine conversion thunk back in so we can't specify a specific interface */ + + [PreserveSig] + new int SetOutputCallbacks( + [In] IDebugOutputCallbacks Callbacks); + + [PreserveSig] + new int GetOutputMask( + out DEBUG_OUTPUT Mask); + + [PreserveSig] + new int SetOutputMask( + DEBUG_OUTPUT Mask); + + [PreserveSig] + new int GetOtherOutputMask( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugClient Client, + out DEBUG_OUTPUT Mask); + + [PreserveSig] + new int SetOtherOutputMask( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugClient Client, + DEBUG_OUTPUT Mask); + + [PreserveSig] + new int GetOutputWidth( + out uint Columns); + + [PreserveSig] + new int SetOutputWidth( + uint Columns); + + [PreserveSig] + new int GetOutputLinePrefix( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PrefixSize); + + [PreserveSig] + new int SetOutputLinePrefix( + [In][MarshalAs(UnmanagedType.LPStr)] string Prefix); + + [PreserveSig] + new int GetIdentity( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint IdentitySize); + + [PreserveSig] + new int OutputIdentity( + DEBUG_OUTCTL OutputControl, + uint Flags, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + /* GetEventCallbacks could a conversion thunk from the debugger engine so we can't specify a specific interface */ + + [PreserveSig] + new int GetEventCallbacks( + out IDebugEventCallbacks Callbacks); + + /* We may have to pass a debugger engine conversion thunk back in so we can't specify a specific interface */ + + [PreserveSig] + new int SetEventCallbacks( + [In] IDebugEventCallbacks Callbacks); + + [PreserveSig] + new int FlushCallbacks(); + + /* IDebugClient2 */ + + [PreserveSig] + int WriteDumpFile2( + [In][MarshalAs(UnmanagedType.LPStr)] string DumpFile, + DEBUG_DUMP Qualifier, + DEBUG_FORMAT FormatFlags, + [In][MarshalAs(UnmanagedType.LPStr)] string Comment); + + [PreserveSig] + int AddDumpInformationFile( + [In][MarshalAs(UnmanagedType.LPStr)] string InfoFile, + DEBUG_DUMP_FILE Type); + + [PreserveSig] + int EndProcessServer( + ulong Server); + + [PreserveSig] + int WaitForProcessServerEnd( + uint Timeout); + + [PreserveSig] + int IsKernelDebuggerEnabled(); + + [PreserveSig] + int TerminateCurrentProcess(); + + [PreserveSig] + int DetachCurrentProcess(); + + [PreserveSig] + int AbandonCurrentProcess(); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient3.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient3.cs new file mode 100644 index 0000000000..d5e658f3a8 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient3.cs @@ -0,0 +1,319 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("dd492d7f-71b8-4ad6-a8dc-1c887479ff91")] + public interface IDebugClient3 : IDebugClient2 + { + /* IDebugClient */ + + [PreserveSig] + new int AttachKernel( + DEBUG_ATTACH Flags, + [In][MarshalAs(UnmanagedType.LPStr)] string ConnectOptions); + + [PreserveSig] + new int GetKernelConnectionOptions( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint OptionsSize); + + [PreserveSig] + new int SetKernelConnectionOptions( + [In][MarshalAs(UnmanagedType.LPStr)] string Options); + + [PreserveSig] + new int StartProcessServer( + DEBUG_CLASS Flags, + [In][MarshalAs(UnmanagedType.LPStr)] string Options, + IntPtr Reserved); + + [PreserveSig] + new int ConnectProcessServer( + [In][MarshalAs(UnmanagedType.LPStr)] string RemoteOptions, + out ulong Server); + + [PreserveSig] + new int DisconnectProcessServer( + ulong Server); + + [PreserveSig] + new int GetRunningProcessSystemIds( + ulong Server, + [Out][MarshalAs(UnmanagedType.LPArray)] + uint[] Ids, + uint Count, + out uint ActualCount); + + [PreserveSig] + new int GetRunningProcessSystemIdByExecutableName( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string ExeName, + DEBUG_GET_PROC Flags, + out uint Id); + + [PreserveSig] + new int GetRunningProcessDescription( + ulong Server, + uint SystemId, + DEBUG_PROC_DESC Flags, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ExeName, + int ExeNameSize, + out uint ActualExeNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Description, + int DescriptionSize, + out uint ActualDescriptionSize); + + [PreserveSig] + new int AttachProcess( + ulong Server, + uint ProcessID, + DEBUG_ATTACH AttachFlags); + + [PreserveSig] + new int CreateProcess( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandLine, + DEBUG_CREATE_PROCESS Flags); + + [PreserveSig] + new int CreateProcessAndAttach( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandLine, + DEBUG_CREATE_PROCESS Flags, + uint ProcessId, + DEBUG_ATTACH AttachFlags); + + [PreserveSig] + new int GetProcessOptions( + out DEBUG_PROCESS Options); + + [PreserveSig] + new int AddProcessOptions( + DEBUG_PROCESS Options); + + [PreserveSig] + new int RemoveProcessOptions( + DEBUG_PROCESS Options); + + [PreserveSig] + new int SetProcessOptions( + DEBUG_PROCESS Options); + + [PreserveSig] + new int OpenDumpFile( + [In][MarshalAs(UnmanagedType.LPStr)] string DumpFile); + + [PreserveSig] + new int WriteDumpFile( + [In][MarshalAs(UnmanagedType.LPStr)] string DumpFile, + DEBUG_DUMP Qualifier); + + [PreserveSig] + new int ConnectSession( + DEBUG_CONNECT_SESSION Flags, + uint HistoryLimit); + + [PreserveSig] + new int StartServer( + [In][MarshalAs(UnmanagedType.LPStr)] string Options); + + [PreserveSig] + new int OutputServer( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Machine, + DEBUG_SERVERS Flags); + + [PreserveSig] + new int TerminateProcesses(); + + [PreserveSig] + new int DetachProcesses(); + + [PreserveSig] + new int EndSession( + DEBUG_END Flags); + + [PreserveSig] + new int GetExitCode( + out uint Code); + + [PreserveSig] + new int DispatchCallbacks( + uint Timeout); + + [PreserveSig] + new int ExitDispatch( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugClient Client); + + [PreserveSig] + new int CreateClient( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugClient Client); + + [PreserveSig] + new int GetInputCallbacks( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugInputCallbacks Callbacks); + + [PreserveSig] + new int SetInputCallbacks( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugInputCallbacks Callbacks); + + /* GetOutputCallbacks could a conversion thunk from the debugger engine so we can't specify a specific interface */ + + [PreserveSig] + new int GetOutputCallbacks( + out IDebugOutputCallbacks Callbacks); + + /* We may have to pass a debugger engine conversion thunk back in so we can't specify a specific interface */ + + [PreserveSig] + new int SetOutputCallbacks( + [In] IDebugOutputCallbacks Callbacks); + + [PreserveSig] + new int GetOutputMask( + out DEBUG_OUTPUT Mask); + + [PreserveSig] + new int SetOutputMask( + DEBUG_OUTPUT Mask); + + [PreserveSig] + new int GetOtherOutputMask( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugClient Client, + out DEBUG_OUTPUT Mask); + + [PreserveSig] + new int SetOtherOutputMask( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugClient Client, + DEBUG_OUTPUT Mask); + + [PreserveSig] + new int GetOutputWidth( + out uint Columns); + + [PreserveSig] + new int SetOutputWidth( + uint Columns); + + [PreserveSig] + new int GetOutputLinePrefix( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PrefixSize); + + [PreserveSig] + new int SetOutputLinePrefix( + [In][MarshalAs(UnmanagedType.LPStr)] string Prefix); + + [PreserveSig] + new int GetIdentity( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint IdentitySize); + + [PreserveSig] + new int OutputIdentity( + DEBUG_OUTCTL OutputControl, + uint Flags, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + /* GetEventCallbacks could a conversion thunk from the debugger engine so we can't specify a specific interface */ + + [PreserveSig] + new int GetEventCallbacks( + out IDebugEventCallbacks Callbacks); + + /* We may have to pass a debugger engine conversion thunk back in so we can't specify a specific interface */ + + [PreserveSig] + new int SetEventCallbacks( + [In] IDebugEventCallbacks Callbacks); + + [PreserveSig] + new int FlushCallbacks(); + + /* IDebugClient2 */ + + [PreserveSig] + new int WriteDumpFile2( + [In][MarshalAs(UnmanagedType.LPStr)] string DumpFile, + DEBUG_DUMP Qualifier, + DEBUG_FORMAT FormatFlags, + [In][MarshalAs(UnmanagedType.LPStr)] string Comment); + + [PreserveSig] + new int AddDumpInformationFile( + [In][MarshalAs(UnmanagedType.LPStr)] string InfoFile, + DEBUG_DUMP_FILE Type); + + [PreserveSig] + new int EndProcessServer( + ulong Server); + + [PreserveSig] + new int WaitForProcessServerEnd( + uint Timeout); + + [PreserveSig] + new int IsKernelDebuggerEnabled(); + + [PreserveSig] + new int TerminateCurrentProcess(); + + [PreserveSig] + new int DetachCurrentProcess(); + + [PreserveSig] + new int AbandonCurrentProcess(); + + /* IDebugClient3 */ + + [PreserveSig] + int GetRunningProcessSystemIdByExecutableNameWide( + ulong Server, + [In][MarshalAs(UnmanagedType.LPWStr)] string ExeName, + DEBUG_GET_PROC Flags, + out uint Id); + + [PreserveSig] + int GetRunningProcessDescriptionWide( + ulong Server, + uint SystemId, + DEBUG_PROC_DESC Flags, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder ExeName, + int ExeNameSize, + out uint ActualExeNameSize, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Description, + int DescriptionSize, + out uint ActualDescriptionSize); + + [PreserveSig] + int CreateProcessWide( + ulong Server, + [In][MarshalAs(UnmanagedType.LPWStr)] string CommandLine, + DEBUG_CREATE_PROCESS CreateFlags); + + [PreserveSig] + int CreateProcessAndAttachWide( + ulong Server, + [In][MarshalAs(UnmanagedType.LPWStr)] string CommandLine, + DEBUG_CREATE_PROCESS CreateFlags, + uint ProcessId, + DEBUG_ATTACH AttachFlags); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient4.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient4.cs new file mode 100644 index 0000000000..a9a8dae371 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient4.cs @@ -0,0 +1,362 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("ca83c3de-5089-4cf8-93c8-d892387f2a5e")] + public interface IDebugClient4 : IDebugClient3 + { + /* IDebugClient */ + + [PreserveSig] + new int AttachKernel( + DEBUG_ATTACH Flags, + [In][MarshalAs(UnmanagedType.LPStr)] string ConnectOptions); + + [PreserveSig] + new int GetKernelConnectionOptions( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint OptionsSize); + + [PreserveSig] + new int SetKernelConnectionOptions( + [In][MarshalAs(UnmanagedType.LPStr)] string Options); + + [PreserveSig] + new int StartProcessServer( + DEBUG_CLASS Flags, + [In][MarshalAs(UnmanagedType.LPStr)] string Options, + IntPtr Reserved); + + [PreserveSig] + new int ConnectProcessServer( + [In][MarshalAs(UnmanagedType.LPStr)] string RemoteOptions, + out ulong Server); + + [PreserveSig] + new int DisconnectProcessServer( + ulong Server); + + [PreserveSig] + new int GetRunningProcessSystemIds( + ulong Server, + [Out][MarshalAs(UnmanagedType.LPArray)] + uint[] Ids, + uint Count, + out uint ActualCount); + + [PreserveSig] + new int GetRunningProcessSystemIdByExecutableName( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string ExeName, + DEBUG_GET_PROC Flags, + out uint Id); + + [PreserveSig] + new int GetRunningProcessDescription( + ulong Server, + uint SystemId, + DEBUG_PROC_DESC Flags, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ExeName, + int ExeNameSize, + out uint ActualExeNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Description, + int DescriptionSize, + out uint ActualDescriptionSize); + + [PreserveSig] + new int AttachProcess( + ulong Server, + uint ProcessID, + DEBUG_ATTACH AttachFlags); + + [PreserveSig] + new int CreateProcess( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandLine, + DEBUG_CREATE_PROCESS Flags); + + [PreserveSig] + new int CreateProcessAndAttach( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandLine, + DEBUG_CREATE_PROCESS Flags, + uint ProcessId, + DEBUG_ATTACH AttachFlags); + + [PreserveSig] + new int GetProcessOptions( + out DEBUG_PROCESS Options); + + [PreserveSig] + new int AddProcessOptions( + DEBUG_PROCESS Options); + + [PreserveSig] + new int RemoveProcessOptions( + DEBUG_PROCESS Options); + + [PreserveSig] + new int SetProcessOptions( + DEBUG_PROCESS Options); + + [PreserveSig] + new int OpenDumpFile( + [In][MarshalAs(UnmanagedType.LPStr)] string DumpFile); + + [PreserveSig] + new int WriteDumpFile( + [In][MarshalAs(UnmanagedType.LPStr)] string DumpFile, + DEBUG_DUMP Qualifier); + + [PreserveSig] + new int ConnectSession( + DEBUG_CONNECT_SESSION Flags, + uint HistoryLimit); + + [PreserveSig] + new int StartServer( + [In][MarshalAs(UnmanagedType.LPStr)] string Options); + + [PreserveSig] + new int OutputServer( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Machine, + DEBUG_SERVERS Flags); + + [PreserveSig] + new int TerminateProcesses(); + + [PreserveSig] + new int DetachProcesses(); + + [PreserveSig] + new int EndSession( + DEBUG_END Flags); + + [PreserveSig] + new int GetExitCode( + out uint Code); + + [PreserveSig] + new int DispatchCallbacks( + uint Timeout); + + [PreserveSig] + new int ExitDispatch( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugClient Client); + + [PreserveSig] + new int CreateClient( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugClient Client); + + [PreserveSig] + new int GetInputCallbacks( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugInputCallbacks Callbacks); + + [PreserveSig] + new int SetInputCallbacks( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugInputCallbacks Callbacks); + + /* GetOutputCallbacks could a conversion thunk from the debugger engine so we can't specify a specific interface */ + + [PreserveSig] + new int GetOutputCallbacks( + out IDebugOutputCallbacks Callbacks); + + /* We may have to pass a debugger engine conversion thunk back in so we can't specify a specific interface */ + + [PreserveSig] + new int SetOutputCallbacks( + [In] IDebugOutputCallbacks Callbacks); + + [PreserveSig] + new int GetOutputMask( + out DEBUG_OUTPUT Mask); + + [PreserveSig] + new int SetOutputMask( + DEBUG_OUTPUT Mask); + + [PreserveSig] + new int GetOtherOutputMask( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugClient Client, + out DEBUG_OUTPUT Mask); + + [PreserveSig] + new int SetOtherOutputMask( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugClient Client, + DEBUG_OUTPUT Mask); + + [PreserveSig] + new int GetOutputWidth( + out uint Columns); + + [PreserveSig] + new int SetOutputWidth( + uint Columns); + + [PreserveSig] + new int GetOutputLinePrefix( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PrefixSize); + + [PreserveSig] + new int SetOutputLinePrefix( + [In][MarshalAs(UnmanagedType.LPStr)] string Prefix); + + [PreserveSig] + new int GetIdentity( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint IdentitySize); + + [PreserveSig] + new int OutputIdentity( + DEBUG_OUTCTL OutputControl, + uint Flags, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + /* GetEventCallbacks could a conversion thunk from the debugger engine so we can't specify a specific interface */ + + [PreserveSig] + new int GetEventCallbacks( + out IDebugEventCallbacks Callbacks); + + /* We may have to pass a debugger engine conversion thunk back in so we can't specify a specific interface */ + + [PreserveSig] + new int SetEventCallbacks( + [In] IDebugEventCallbacks Callbacks); + + [PreserveSig] + new int FlushCallbacks(); + + /* IDebugClient2 */ + + [PreserveSig] + new int WriteDumpFile2( + [In][MarshalAs(UnmanagedType.LPStr)] string DumpFile, + DEBUG_DUMP Qualifier, + DEBUG_FORMAT FormatFlags, + [In][MarshalAs(UnmanagedType.LPStr)] string Comment); + + [PreserveSig] + new int AddDumpInformationFile( + [In][MarshalAs(UnmanagedType.LPStr)] string InfoFile, + DEBUG_DUMP_FILE Type); + + [PreserveSig] + new int EndProcessServer( + ulong Server); + + [PreserveSig] + new int WaitForProcessServerEnd( + uint Timeout); + + [PreserveSig] + new int IsKernelDebuggerEnabled(); + + [PreserveSig] + new int TerminateCurrentProcess(); + + [PreserveSig] + new int DetachCurrentProcess(); + + [PreserveSig] + new int AbandonCurrentProcess(); + + /* IDebugClient3 */ + + [PreserveSig] + new int GetRunningProcessSystemIdByExecutableNameWide( + ulong Server, + [In][MarshalAs(UnmanagedType.LPWStr)] string ExeName, + DEBUG_GET_PROC Flags, + out uint Id); + + [PreserveSig] + new int GetRunningProcessDescriptionWide( + ulong Server, + uint SystemId, + DEBUG_PROC_DESC Flags, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder ExeName, + int ExeNameSize, + out uint ActualExeNameSize, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Description, + int DescriptionSize, + out uint ActualDescriptionSize); + + [PreserveSig] + new int CreateProcessWide( + ulong Server, + [In][MarshalAs(UnmanagedType.LPWStr)] string CommandLine, + DEBUG_CREATE_PROCESS CreateFlags); + + [PreserveSig] + new int CreateProcessAndAttachWide( + ulong Server, + [In][MarshalAs(UnmanagedType.LPWStr)] string CommandLine, + DEBUG_CREATE_PROCESS CreateFlags, + uint ProcessId, + DEBUG_ATTACH AttachFlags); + + /* IDebugClient4 */ + + [PreserveSig] + int OpenDumpFileWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string FileName, + ulong FileHandle); + + [PreserveSig] + int WriteDumpFileWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string DumpFile, + ulong FileHandle, + DEBUG_DUMP Qualifier, + DEBUG_FORMAT FormatFlags, + [In][MarshalAs(UnmanagedType.LPWStr)] string Comment); + + [PreserveSig] + int AddDumpInformationFileWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string FileName, + ulong FileHandle, + DEBUG_DUMP_FILE Type); + + [PreserveSig] + int GetNumberDumpFiles( + out uint Number); + + [PreserveSig] + int GetDumpFile( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize, + out ulong Handle, + out uint Type); + + [PreserveSig] + int GetDumpFileWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize, + out ulong Handle, + out uint Type); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient5.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient5.cs new file mode 100644 index 0000000000..5b472feaf3 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient5.cs @@ -0,0 +1,533 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("e3acb9d7-7ec2-4f0c-a0da-e81e0cbbe628")] + public interface IDebugClient5 : IDebugClient4 + { + /* IDebugClient */ + + [PreserveSig] + new int AttachKernel( + DEBUG_ATTACH Flags, + [In][MarshalAs(UnmanagedType.LPStr)] string ConnectOptions); + + [PreserveSig] + new int GetKernelConnectionOptions( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint OptionsSize); + + [PreserveSig] + new int SetKernelConnectionOptions( + [In][MarshalAs(UnmanagedType.LPStr)] string Options); + + [PreserveSig] + new int StartProcessServer( + DEBUG_CLASS Flags, + [In][MarshalAs(UnmanagedType.LPStr)] string Options, + IntPtr Reserved); + + [PreserveSig] + new int ConnectProcessServer( + [In][MarshalAs(UnmanagedType.LPStr)] string RemoteOptions, + out ulong Server); + + [PreserveSig] + new int DisconnectProcessServer( + ulong Server); + + [PreserveSig] + new int GetRunningProcessSystemIds( + ulong Server, + [Out][MarshalAs(UnmanagedType.LPArray)] + uint[] Ids, + uint Count, + out uint ActualCount); + + [PreserveSig] + new int GetRunningProcessSystemIdByExecutableName( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string ExeName, + DEBUG_GET_PROC Flags, + out uint Id); + + [PreserveSig] + new int GetRunningProcessDescription( + ulong Server, + uint SystemId, + DEBUG_PROC_DESC Flags, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ExeName, + int ExeNameSize, + out uint ActualExeNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Description, + int DescriptionSize, + out uint ActualDescriptionSize); + + [PreserveSig] + new int AttachProcess( + ulong Server, + uint ProcessID, + DEBUG_ATTACH AttachFlags); + + [PreserveSig] + new int CreateProcess( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandLine, + DEBUG_CREATE_PROCESS Flags); + + [PreserveSig] + new int CreateProcessAndAttach( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandLine, + DEBUG_CREATE_PROCESS Flags, + uint ProcessId, + DEBUG_ATTACH AttachFlags); + + [PreserveSig] + new int GetProcessOptions( + out DEBUG_PROCESS Options); + + [PreserveSig] + new int AddProcessOptions( + DEBUG_PROCESS Options); + + [PreserveSig] + new int RemoveProcessOptions( + DEBUG_PROCESS Options); + + [PreserveSig] + new int SetProcessOptions( + DEBUG_PROCESS Options); + + [PreserveSig] + new int OpenDumpFile( + [In][MarshalAs(UnmanagedType.LPStr)] string DumpFile); + + [PreserveSig] + new int WriteDumpFile( + [In][MarshalAs(UnmanagedType.LPStr)] string DumpFile, + DEBUG_DUMP Qualifier); + + [PreserveSig] + new int ConnectSession( + DEBUG_CONNECT_SESSION Flags, + uint HistoryLimit); + + [PreserveSig] + new int StartServer( + [In][MarshalAs(UnmanagedType.LPStr)] string Options); + + [PreserveSig] + new int OutputServer( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Machine, + DEBUG_SERVERS Flags); + + [PreserveSig] + new int TerminateProcesses(); + + [PreserveSig] + new int DetachProcesses(); + + [PreserveSig] + new int EndSession( + DEBUG_END Flags); + + [PreserveSig] + new int GetExitCode( + out uint Code); + + [PreserveSig] + new int DispatchCallbacks( + uint Timeout); + + [PreserveSig] + new int ExitDispatch( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugClient Client); + + [PreserveSig] + new int CreateClient( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugClient Client); + + [PreserveSig] + new int GetInputCallbacks( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugInputCallbacks Callbacks); + + [PreserveSig] + new int SetInputCallbacks( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugInputCallbacks Callbacks); + + /* GetOutputCallbacks could a conversion thunk from the debugger engine so we can't specify a specific interface */ + + [PreserveSig] + new int GetOutputCallbacks( + out IDebugOutputCallbacks Callbacks); + + /* We may have to pass a debugger engine conversion thunk back in so we can't specify a specific interface */ + + [PreserveSig] + new int SetOutputCallbacks( + [In] IDebugOutputCallbacks Callbacks); + + [PreserveSig] + new int GetOutputMask( + out DEBUG_OUTPUT Mask); + + [PreserveSig] + new int SetOutputMask( + DEBUG_OUTPUT Mask); + + [PreserveSig] + new int GetOtherOutputMask( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugClient Client, + out DEBUG_OUTPUT Mask); + + [PreserveSig] + new int SetOtherOutputMask( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugClient Client, + DEBUG_OUTPUT Mask); + + [PreserveSig] + new int GetOutputWidth( + out uint Columns); + + [PreserveSig] + new int SetOutputWidth( + uint Columns); + + [PreserveSig] + new int GetOutputLinePrefix( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PrefixSize); + + [PreserveSig] + new int SetOutputLinePrefix( + [In][MarshalAs(UnmanagedType.LPStr)] string Prefix); + + [PreserveSig] + new int GetIdentity( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint IdentitySize); + + [PreserveSig] + new int OutputIdentity( + DEBUG_OUTCTL OutputControl, + uint Flags, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + /* GetEventCallbacks could a conversion thunk from the debugger engine so we can't specify a specific interface */ + + [PreserveSig] + new int GetEventCallbacks( + out IDebugEventCallbacks Callbacks); + + /* We may have to pass a debugger engine conversion thunk back in so we can't specify a specific interface */ + + [PreserveSig] + new int SetEventCallbacks( + [In] IDebugEventCallbacks Callbacks); + + [PreserveSig] + new int FlushCallbacks(); + + /* IDebugClient2 */ + + [PreserveSig] + new int WriteDumpFile2( + [In][MarshalAs(UnmanagedType.LPStr)] string DumpFile, + DEBUG_DUMP Qualifier, + DEBUG_FORMAT FormatFlags, + [In][MarshalAs(UnmanagedType.LPStr)] string Comment); + + [PreserveSig] + new int AddDumpInformationFile( + [In][MarshalAs(UnmanagedType.LPStr)] string InfoFile, + DEBUG_DUMP_FILE Type); + + [PreserveSig] + new int EndProcessServer( + ulong Server); + + [PreserveSig] + new int WaitForProcessServerEnd( + uint Timeout); + + [PreserveSig] + new int IsKernelDebuggerEnabled(); + + [PreserveSig] + new int TerminateCurrentProcess(); + + [PreserveSig] + new int DetachCurrentProcess(); + + [PreserveSig] + new int AbandonCurrentProcess(); + + /* IDebugClient3 */ + + [PreserveSig] + new int GetRunningProcessSystemIdByExecutableNameWide( + ulong Server, + [In][MarshalAs(UnmanagedType.LPWStr)] string ExeName, + DEBUG_GET_PROC Flags, + out uint Id); + + [PreserveSig] + new int GetRunningProcessDescriptionWide( + ulong Server, + uint SystemId, + DEBUG_PROC_DESC Flags, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder ExeName, + int ExeNameSize, + out uint ActualExeNameSize, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Description, + int DescriptionSize, + out uint ActualDescriptionSize); + + [PreserveSig] + new int CreateProcessWide( + ulong Server, + [In][MarshalAs(UnmanagedType.LPWStr)] string CommandLine, + DEBUG_CREATE_PROCESS CreateFlags); + + [PreserveSig] + new int CreateProcessAndAttachWide( + ulong Server, + [In][MarshalAs(UnmanagedType.LPWStr)] string CommandLine, + DEBUG_CREATE_PROCESS CreateFlags, + uint ProcessId, + DEBUG_ATTACH AttachFlags); + + /* IDebugClient4 */ + + [PreserveSig] + new int OpenDumpFileWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string FileName, + ulong FileHandle); + + [PreserveSig] + new int WriteDumpFileWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string DumpFile, + ulong FileHandle, + DEBUG_DUMP Qualifier, + DEBUG_FORMAT FormatFlags, + [In][MarshalAs(UnmanagedType.LPWStr)] string Comment); + + [PreserveSig] + new int AddDumpInformationFileWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string FileName, + ulong FileHandle, + DEBUG_DUMP_FILE Type); + + [PreserveSig] + new int GetNumberDumpFiles( + out uint Number); + + [PreserveSig] + new int GetDumpFile( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize, + out ulong Handle, + out uint Type); + + [PreserveSig] + new int GetDumpFileWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize, + out ulong Handle, + out uint Type); + + /* IDebugClient5 */ + + [PreserveSig] + int AttachKernelWide( + DEBUG_ATTACH Flags, + [In][MarshalAs(UnmanagedType.LPWStr)] string ConnectOptions); + + [PreserveSig] + int GetKernelConnectionOptionsWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint OptionsSize); + + [PreserveSig] + int SetKernelConnectionOptionsWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Options); + + [PreserveSig] + int StartProcessServerWide( + DEBUG_CLASS Flags, + [In][MarshalAs(UnmanagedType.LPWStr)] string Options, + IntPtr Reserved); + + [PreserveSig] + int ConnectProcessServerWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string RemoteOptions, + out ulong Server); + + [PreserveSig] + int StartServerWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Options); + + [PreserveSig] + int OutputServersWide( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPWStr)] string Machine, + DEBUG_SERVERS Flags); + + /* GetOutputCallbacks could a conversion thunk from the debugger engine so we can't specify a specific interface */ + + [PreserveSig] + int GetOutputCallbacksWide( + out IDebugOutputCallbacksWide Callbacks); + + /* We may have to pass a debugger engine conversion thunk back in so we can't specify a specific interface */ + + [PreserveSig] + int SetOutputCallbacksWide( + [In] IDebugOutputCallbacksWide Callbacks); + + [PreserveSig] + int GetOutputLinePrefixWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint PrefixSize); + + [PreserveSig] + int SetOutputLinePrefixWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Prefix); + + [PreserveSig] + int GetIdentityWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint IdentitySize); + + [PreserveSig] + int OutputIdentityWide( + DEBUG_OUTCTL OutputControl, + uint Flags, + [In][MarshalAs(UnmanagedType.LPWStr)] string Machine); + + /* GetEventCallbacks could a conversion thunk from the debugger engine so we can't specify a specific interface */ + + [PreserveSig] + int GetEventCallbacksWide( + out IDebugEventCallbacksWide Callbacks); + + /* We may have to pass a debugger engine conversion thunk back in so we can't specify a specific interface */ + + [PreserveSig] + int SetEventCallbacksWide( + [In] IDebugEventCallbacksWide Callbacks); + + [PreserveSig] + int CreateProcess2( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandLine, + in DEBUG_CREATE_PROCESS_OPTIONS OptionsBuffer, + uint OptionsBufferSize, + [In][MarshalAs(UnmanagedType.LPStr)] string InitialDirectory, + [In][MarshalAs(UnmanagedType.LPStr)] string Environment); + + [PreserveSig] + int CreateProcess2Wide( + ulong Server, + [In][MarshalAs(UnmanagedType.LPWStr)] string CommandLine, + in DEBUG_CREATE_PROCESS_OPTIONS OptionsBuffer, + uint OptionsBufferSize, + [In][MarshalAs(UnmanagedType.LPWStr)] string InitialDirectory, + [In][MarshalAs(UnmanagedType.LPWStr)] string Environment); + + [PreserveSig] + int CreateProcessAndAttach2( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandLine, + in DEBUG_CREATE_PROCESS_OPTIONS OptionsBuffer, + uint OptionsBufferSize, + [In][MarshalAs(UnmanagedType.LPStr)] string InitialDirectory, + [In][MarshalAs(UnmanagedType.LPStr)] string Environment, + uint ProcessId, + DEBUG_ATTACH AttachFlags); + + [PreserveSig] + int CreateProcessAndAttach2Wide( + ulong Server, + [In][MarshalAs(UnmanagedType.LPWStr)] string CommandLine, + in DEBUG_CREATE_PROCESS_OPTIONS OptionsBuffer, + uint OptionsBufferSize, + [In][MarshalAs(UnmanagedType.LPWStr)] string InitialDirectory, + [In][MarshalAs(UnmanagedType.LPWStr)] string Environment, + uint ProcessId, + DEBUG_ATTACH AttachFlags); + + [PreserveSig] + int PushOutputLinePrefix( + [In][MarshalAs(UnmanagedType.LPStr)] string NewPrefix, + out ulong Handle); + + [PreserveSig] + int PushOutputLinePrefixWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string NewPrefix, + out ulong Handle); + + [PreserveSig] + int PopOutputLinePrefix( + ulong Handle); + + [PreserveSig] + int GetNumberInputCallbacks( + out uint Count); + + [PreserveSig] + int GetNumberOutputCallbacks( + out uint Count); + + [PreserveSig] + int GetNumberEventCallbacks( + DEBUG_EVENT Flags, + out uint Count); + + [PreserveSig] + int GetQuitLockString( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize); + + [PreserveSig] + int SetQuitLockString( + [In][MarshalAs(UnmanagedType.LPStr)] string LockString); + + [PreserveSig] + int GetQuitLockStringWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize); + + [PreserveSig] + int SetQuitLockStringWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string LockString); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient6.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient6.cs new file mode 100644 index 0000000000..0773a6a7b8 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugClient6.cs @@ -0,0 +1,539 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("e3acb9d7-7ec2-4f0c-a0da-e81e0cbbe628")] + public interface IDebugClient6 : IDebugClient5 + { + /* IDebugClient */ + + [PreserveSig] + new int AttachKernel( + DEBUG_ATTACH Flags, + [In][MarshalAs(UnmanagedType.LPStr)] string ConnectOptions); + + [PreserveSig] + new int GetKernelConnectionOptions( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint OptionsSize); + + [PreserveSig] + new int SetKernelConnectionOptions( + [In][MarshalAs(UnmanagedType.LPStr)] string Options); + + [PreserveSig] + new int StartProcessServer( + DEBUG_CLASS Flags, + [In][MarshalAs(UnmanagedType.LPStr)] string Options, + IntPtr Reserved); + + [PreserveSig] + new int ConnectProcessServer( + [In][MarshalAs(UnmanagedType.LPStr)] string RemoteOptions, + out ulong Server); + + [PreserveSig] + new int DisconnectProcessServer( + ulong Server); + + [PreserveSig] + new int GetRunningProcessSystemIds( + ulong Server, + [Out][MarshalAs(UnmanagedType.LPArray)] + uint[] Ids, + uint Count, + out uint ActualCount); + + [PreserveSig] + new int GetRunningProcessSystemIdByExecutableName( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string ExeName, + DEBUG_GET_PROC Flags, + out uint Id); + + [PreserveSig] + new int GetRunningProcessDescription( + ulong Server, + uint SystemId, + DEBUG_PROC_DESC Flags, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ExeName, + int ExeNameSize, + out uint ActualExeNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Description, + int DescriptionSize, + out uint ActualDescriptionSize); + + [PreserveSig] + new int AttachProcess( + ulong Server, + uint ProcessID, + DEBUG_ATTACH AttachFlags); + + [PreserveSig] + new int CreateProcess( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandLine, + DEBUG_CREATE_PROCESS Flags); + + [PreserveSig] + new int CreateProcessAndAttach( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandLine, + DEBUG_CREATE_PROCESS Flags, + uint ProcessId, + DEBUG_ATTACH AttachFlags); + + [PreserveSig] + new int GetProcessOptions( + out DEBUG_PROCESS Options); + + [PreserveSig] + new int AddProcessOptions( + DEBUG_PROCESS Options); + + [PreserveSig] + new int RemoveProcessOptions( + DEBUG_PROCESS Options); + + [PreserveSig] + new int SetProcessOptions( + DEBUG_PROCESS Options); + + [PreserveSig] + new int OpenDumpFile( + [In][MarshalAs(UnmanagedType.LPStr)] string DumpFile); + + [PreserveSig] + new int WriteDumpFile( + [In][MarshalAs(UnmanagedType.LPStr)] string DumpFile, + DEBUG_DUMP Qualifier); + + [PreserveSig] + new int ConnectSession( + DEBUG_CONNECT_SESSION Flags, + uint HistoryLimit); + + [PreserveSig] + new int StartServer( + [In][MarshalAs(UnmanagedType.LPStr)] string Options); + + [PreserveSig] + new int OutputServer( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Machine, + DEBUG_SERVERS Flags); + + [PreserveSig] + new int TerminateProcesses(); + + [PreserveSig] + new int DetachProcesses(); + + [PreserveSig] + new int EndSession( + DEBUG_END Flags); + + [PreserveSig] + new int GetExitCode( + out uint Code); + + [PreserveSig] + new int DispatchCallbacks( + uint Timeout); + + [PreserveSig] + new int ExitDispatch( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugClient Client); + + [PreserveSig] + new int CreateClient( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugClient Client); + + [PreserveSig] + new int GetInputCallbacks( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugInputCallbacks Callbacks); + + [PreserveSig] + new int SetInputCallbacks( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugInputCallbacks Callbacks); + + /* GetOutputCallbacks could a conversion thunk from the debugger engine so we can't specify a specific interface */ + + [PreserveSig] + new int GetOutputCallbacks( + out IDebugOutputCallbacks Callbacks); + + /* We may have to pass a debugger engine conversion thunk back in so we can't specify a specific interface */ + + [PreserveSig] + new int SetOutputCallbacks( + [In] IDebugOutputCallbacks Callbacks); + + [PreserveSig] + new int GetOutputMask( + out DEBUG_OUTPUT Mask); + + [PreserveSig] + new int SetOutputMask( + DEBUG_OUTPUT Mask); + + [PreserveSig] + new int GetOtherOutputMask( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugClient Client, + out DEBUG_OUTPUT Mask); + + [PreserveSig] + new int SetOtherOutputMask( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugClient Client, + DEBUG_OUTPUT Mask); + + [PreserveSig] + new int GetOutputWidth( + out uint Columns); + + [PreserveSig] + new int SetOutputWidth( + uint Columns); + + [PreserveSig] + new int GetOutputLinePrefix( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PrefixSize); + + [PreserveSig] + new int SetOutputLinePrefix( + [In][MarshalAs(UnmanagedType.LPStr)] string Prefix); + + [PreserveSig] + new int GetIdentity( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint IdentitySize); + + [PreserveSig] + new int OutputIdentity( + DEBUG_OUTCTL OutputControl, + uint Flags, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + /* GetEventCallbacks could a conversion thunk from the debugger engine so we can't specify a specific interface */ + + [PreserveSig] + new int GetEventCallbacks( + out IDebugEventCallbacks Callbacks); + + /* We may have to pass a debugger engine conversion thunk back in so we can't specify a specific interface */ + + [PreserveSig] + new int SetEventCallbacks( + [In] IDebugEventCallbacks Callbacks); + + [PreserveSig] + new int FlushCallbacks(); + + /* IDebugClient2 */ + + [PreserveSig] + new int WriteDumpFile2( + [In][MarshalAs(UnmanagedType.LPStr)] string DumpFile, + DEBUG_DUMP Qualifier, + DEBUG_FORMAT FormatFlags, + [In][MarshalAs(UnmanagedType.LPStr)] string Comment); + + [PreserveSig] + new int AddDumpInformationFile( + [In][MarshalAs(UnmanagedType.LPStr)] string InfoFile, + DEBUG_DUMP_FILE Type); + + [PreserveSig] + new int EndProcessServer( + ulong Server); + + [PreserveSig] + new int WaitForProcessServerEnd( + uint Timeout); + + [PreserveSig] + new int IsKernelDebuggerEnabled(); + + [PreserveSig] + new int TerminateCurrentProcess(); + + [PreserveSig] + new int DetachCurrentProcess(); + + [PreserveSig] + new int AbandonCurrentProcess(); + + /* IDebugClient3 */ + + [PreserveSig] + new int GetRunningProcessSystemIdByExecutableNameWide( + ulong Server, + [In][MarshalAs(UnmanagedType.LPWStr)] string ExeName, + DEBUG_GET_PROC Flags, + out uint Id); + + [PreserveSig] + new int GetRunningProcessDescriptionWide( + ulong Server, + uint SystemId, + DEBUG_PROC_DESC Flags, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder ExeName, + int ExeNameSize, + out uint ActualExeNameSize, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Description, + int DescriptionSize, + out uint ActualDescriptionSize); + + [PreserveSig] + new int CreateProcessWide( + ulong Server, + [In][MarshalAs(UnmanagedType.LPWStr)] string CommandLine, + DEBUG_CREATE_PROCESS CreateFlags); + + [PreserveSig] + new int CreateProcessAndAttachWide( + ulong Server, + [In][MarshalAs(UnmanagedType.LPWStr)] string CommandLine, + DEBUG_CREATE_PROCESS CreateFlags, + uint ProcessId, + DEBUG_ATTACH AttachFlags); + + /* IDebugClient4 */ + + [PreserveSig] + new int OpenDumpFileWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string FileName, + ulong FileHandle); + + [PreserveSig] + new int WriteDumpFileWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string DumpFile, + ulong FileHandle, + DEBUG_DUMP Qualifier, + DEBUG_FORMAT FormatFlags, + [In][MarshalAs(UnmanagedType.LPWStr)] string Comment); + + [PreserveSig] + new int AddDumpInformationFileWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string FileName, + ulong FileHandle, + DEBUG_DUMP_FILE Type); + + [PreserveSig] + new int GetNumberDumpFiles( + out uint Number); + + [PreserveSig] + new int GetDumpFile( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize, + out ulong Handle, + out uint Type); + + [PreserveSig] + new int GetDumpFileWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize, + out ulong Handle, + out uint Type); + + /* IDebugClient5 */ + + [PreserveSig] + new int AttachKernelWide( + DEBUG_ATTACH Flags, + [In][MarshalAs(UnmanagedType.LPWStr)] string ConnectOptions); + + [PreserveSig] + new int GetKernelConnectionOptionsWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint OptionsSize); + + [PreserveSig] + new int SetKernelConnectionOptionsWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Options); + + [PreserveSig] + new int StartProcessServerWide( + DEBUG_CLASS Flags, + [In][MarshalAs(UnmanagedType.LPWStr)] string Options, + IntPtr Reserved); + + [PreserveSig] + new int ConnectProcessServerWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string RemoteOptions, + out ulong Server); + + [PreserveSig] + new int StartServerWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Options); + + [PreserveSig] + new int OutputServersWide( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPWStr)] string Machine, + DEBUG_SERVERS Flags); + + /* GetOutputCallbacks could a conversion thunk from the debugger engine so we can't specify a specific interface */ + + [PreserveSig] + new int GetOutputCallbacksWide( + out IDebugOutputCallbacksWide Callbacks); + + /* We may have to pass a debugger engine conversion thunk back in so we can't specify a specific interface */ + + [PreserveSig] + new int SetOutputCallbacksWide( + [In] IDebugOutputCallbacksWide Callbacks); + + [PreserveSig] + new int GetOutputLinePrefixWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint PrefixSize); + + [PreserveSig] + new int SetOutputLinePrefixWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Prefix); + + [PreserveSig] + new int GetIdentityWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint IdentitySize); + + [PreserveSig] + new int OutputIdentityWide( + DEBUG_OUTCTL OutputControl, + uint Flags, + [In][MarshalAs(UnmanagedType.LPWStr)] string Machine); + + /* GetEventCallbacks could a conversion thunk from the debugger engine so we can't specify a specific interface */ + + [PreserveSig] + new int GetEventCallbacksWide( + out IDebugEventCallbacksWide Callbacks); + + /* We may have to pass a debugger engine conversion thunk back in so we can't specify a specific interface */ + + [PreserveSig] + new int SetEventCallbacksWide( + [In] IDebugEventCallbacksWide Callbacks); + + [PreserveSig] + new int CreateProcess2( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandLine, + in DEBUG_CREATE_PROCESS_OPTIONS OptionsBuffer, + uint OptionsBufferSize, + [In][MarshalAs(UnmanagedType.LPStr)] string InitialDirectory, + [In][MarshalAs(UnmanagedType.LPStr)] string Environment); + + [PreserveSig] + new int CreateProcess2Wide( + ulong Server, + [In][MarshalAs(UnmanagedType.LPWStr)] string CommandLine, + in DEBUG_CREATE_PROCESS_OPTIONS OptionsBuffer, + uint OptionsBufferSize, + [In][MarshalAs(UnmanagedType.LPWStr)] string InitialDirectory, + [In][MarshalAs(UnmanagedType.LPWStr)] string Environment); + + [PreserveSig] + new int CreateProcessAndAttach2( + ulong Server, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandLine, + in DEBUG_CREATE_PROCESS_OPTIONS OptionsBuffer, + uint OptionsBufferSize, + [In][MarshalAs(UnmanagedType.LPStr)] string InitialDirectory, + [In][MarshalAs(UnmanagedType.LPStr)] string Environment, + uint ProcessId, + DEBUG_ATTACH AttachFlags); + + [PreserveSig] + new int CreateProcessAndAttach2Wide( + ulong Server, + [In][MarshalAs(UnmanagedType.LPWStr)] string CommandLine, + in DEBUG_CREATE_PROCESS_OPTIONS OptionsBuffer, + uint OptionsBufferSize, + [In][MarshalAs(UnmanagedType.LPWStr)] string InitialDirectory, + [In][MarshalAs(UnmanagedType.LPWStr)] string Environment, + uint ProcessId, + DEBUG_ATTACH AttachFlags); + + [PreserveSig] + new int PushOutputLinePrefix( + [In][MarshalAs(UnmanagedType.LPStr)] string NewPrefix, + out ulong Handle); + + [PreserveSig] + new int PushOutputLinePrefixWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string NewPrefix, + out ulong Handle); + + [PreserveSig] + new int PopOutputLinePrefix( + ulong Handle); + + [PreserveSig] + new int GetNumberInputCallbacks( + out uint Count); + + [PreserveSig] + new int GetNumberOutputCallbacks( + out uint Count); + + [PreserveSig] + new int GetNumberEventCallbacks( + DEBUG_EVENT Flags, + out uint Count); + + [PreserveSig] + new int GetQuitLockString( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize); + + [PreserveSig] + new int SetQuitLockString( + [In][MarshalAs(UnmanagedType.LPStr)] string LockString); + + [PreserveSig] + new int GetQuitLockStringWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize); + + [PreserveSig] + new int SetQuitLockStringWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string LockString); + + /* IDebugClient6 */ + + [PreserveSig] + int SetEventContextCallbacks( + [In] IDebugEventContextCallbacks Callbacks); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl.cs new file mode 100644 index 0000000000..90d92a1f2c --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl.cs @@ -0,0 +1,537 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("5182e668-105e-416e-ad92-24ef800424ba")] + public interface IDebugControl + { + /* IDebugControl */ + + [PreserveSig] + int GetInterrupt(); + + [PreserveSig] + int SetInterrupt( + DEBUG_INTERRUPT Flags); + + [PreserveSig] + int GetInterruptTimeout( + out uint Seconds); + + [PreserveSig] + int SetInterruptTimeout( + uint Seconds); + + [PreserveSig] + int GetLogFile( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint FileSize, + [Out][MarshalAs(UnmanagedType.Bool)] out bool Append); + + [PreserveSig] + int OpenLogFile( + [In][MarshalAs(UnmanagedType.LPStr)] string File, + [In][MarshalAs(UnmanagedType.Bool)] bool Append); + + [PreserveSig] + int CloseLogFile(); + + [PreserveSig] + int GetLogMask( + out DEBUG_OUTPUT Mask); + + [PreserveSig] + int SetLogMask( + DEBUG_OUTPUT Mask); + + [PreserveSig] + int Input( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint InputSize); + + [PreserveSig] + int ReturnInput( + [In][MarshalAs(UnmanagedType.LPStr)] string Buffer); + + [PreserveSig] + int Output( + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + [PreserveSig] + int OutputVaList( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + int ControlledOutput( + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + [PreserveSig] + int ControlledOutputVaList( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + int OutputPrompt( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + [PreserveSig] + int OutputPromptVaList( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + int GetPromptText( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint TextSize); + + [PreserveSig] + int OutputCurrentState( + DEBUG_OUTCTL OutputControl, + DEBUG_CURRENT Flags); + + [PreserveSig] + int OutputVersionInformation( + DEBUG_OUTCTL OutputControl); + + [PreserveSig] + int GetNotifyEventHandle( + out ulong Handle); + + [PreserveSig] + int SetNotifyEventHandle( + ulong Handle); + + [PreserveSig] + int Assemble( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPStr)] string Instr, + out ulong EndOffset); + + [PreserveSig] + int Disassemble( + ulong Offset, + DEBUG_DISASM Flags, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint DisassemblySize, + out ulong EndOffset); + + [PreserveSig] + int GetDisassembleEffectiveOffset( + out ulong Offset); + + [PreserveSig] + int OutputDisassembly( + DEBUG_OUTCTL OutputControl, + ulong Offset, + DEBUG_DISASM Flags, + out ulong EndOffset); + + [PreserveSig] + int OutputDisassemblyLines( + DEBUG_OUTCTL OutputControl, + uint PreviousLines, + uint TotalLines, + ulong Offset, + DEBUG_DISASM Flags, + out uint OffsetLine, + out ulong StartOffset, + out ulong EndOffset, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] LineOffsets); + + [PreserveSig] + int GetNearInstruction( + ulong Offset, + int Delta, + out ulong NearOffset); + + [PreserveSig] + int GetStackTrace( + ulong FrameOffset, + ulong StackOffset, + ulong InstructionOffset, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_STACK_FRAME[] Frames, + int FrameSize, + out uint FramesFilled); + + [PreserveSig] + int GetReturnOffset( + out ulong Offset); + + [PreserveSig] + int OutputStackTrace( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_STACK_FRAME[] Frames, + int FramesSize, + DEBUG_STACK Flags); + + [PreserveSig] + int GetDebuggeeType( + out DEBUG_CLASS Class, + out DEBUG_CLASS_QUALIFIER Qualifier); + + [PreserveSig] + int GetActualProcessorType( + out IMAGE_FILE_MACHINE Type); + + [PreserveSig] + int GetExecutingProcessorType( + out IMAGE_FILE_MACHINE Type); + + [PreserveSig] + int GetNumberPossibleExecutingProcessorTypes( + out uint Number); + + [PreserveSig] + int GetPossibleExecutingProcessorTypes( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + IMAGE_FILE_MACHINE[] Types); + + [PreserveSig] + int GetNumberProcessors( + out uint Number); + + [PreserveSig] + int GetSystemVersion( + out uint PlatformId, + out uint Major, + out uint Minor, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ServicePackString, + int ServicePackStringSize, + out uint ServicePackStringUsed, + out uint ServicePackNumber, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder BuildString, + int BuildStringSize, + out uint BuildStringUsed); + + [PreserveSig] + int GetPageSize( + out uint Size); + + [PreserveSig] + int IsPointer64Bit(); + + [PreserveSig] + int ReadBugCheckData( + out uint Code, + out ulong Arg1, + out ulong Arg2, + out ulong Arg3, + out ulong Arg4); + + [PreserveSig] + int GetNumberSupportedProcessorTypes( + out uint Number); + + [PreserveSig] + int GetSupportedProcessorTypes( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + IMAGE_FILE_MACHINE[] Types); + + [PreserveSig] + int GetProcessorTypeNames( + IMAGE_FILE_MACHINE Type, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder FullNameBuffer, + int FullNameBufferSize, + out uint FullNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder AbbrevNameBuffer, + int AbbrevNameBufferSize, + out uint AbbrevNameSize); + + [PreserveSig] + int GetEffectiveProcessorType( + out IMAGE_FILE_MACHINE Type); + + [PreserveSig] + int SetEffectiveProcessorType( + IMAGE_FILE_MACHINE Type); + + [PreserveSig] + int GetExecutionStatus( + out DEBUG_STATUS Status); + + [PreserveSig] + int SetExecutionStatus( + DEBUG_STATUS Status); + + [PreserveSig] + int GetCodeLevel( + out DEBUG_LEVEL Level); + + [PreserveSig] + int SetCodeLevel( + DEBUG_LEVEL Level); + + [PreserveSig] + int GetEngineOptions( + out DEBUG_ENGOPT Options); + + [PreserveSig] + int AddEngineOptions( + DEBUG_ENGOPT Options); + + [PreserveSig] + int RemoveEngineOptions( + DEBUG_ENGOPT Options); + + [PreserveSig] + int SetEngineOptions( + DEBUG_ENGOPT Options); + + [PreserveSig] + int GetSystemErrorControl( + out ERROR_LEVEL OutputLevel, + out ERROR_LEVEL BreakLevel); + + [PreserveSig] + int SetSystemErrorControl( + ERROR_LEVEL OutputLevel, + ERROR_LEVEL BreakLevel); + + [PreserveSig] + int GetTextMacro( + uint Slot, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint MacroSize); + + [PreserveSig] + int SetTextMacro( + uint Slot, + [In][MarshalAs(UnmanagedType.LPStr)] string Macro); + + [PreserveSig] + int GetRadix( + out uint Radix); + + [PreserveSig] + int SetRadix( + uint Radix); + + [PreserveSig] + int Evaluate( + [In][MarshalAs(UnmanagedType.LPStr)] string Expression, + DEBUG_VALUE_TYPE DesiredType, + out DEBUG_VALUE Value, + out uint RemainderIndex); + + [PreserveSig] + int CoerceValue( + DEBUG_VALUE In, + DEBUG_VALUE_TYPE OutType, + out DEBUG_VALUE Out); + + [PreserveSig] + int CoerceValues( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_VALUE[] In, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_VALUE_TYPE[] OutType, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_VALUE[] Out); + + [PreserveSig] + int Execute( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Command, + DEBUG_EXECUTE Flags); + + [PreserveSig] + int ExecuteCommandFile( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandFile, + DEBUG_EXECUTE Flags); + + [PreserveSig] + int GetNumberBreakpoints( + out uint Number); + + [PreserveSig] + int GetBreakpointByIndex( + uint Index, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint bp); + + [PreserveSig] + int GetBreakpointById( + uint Id, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint bp); + + [PreserveSig] + int GetBreakpointParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Ids, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_BREAKPOINT_PARAMETERS[] Params); + + [PreserveSig] + int AddBreakpoint( + DEBUG_BREAKPOINT_TYPE Type, + uint DesiredId, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint Bp); + + [PreserveSig] + int RemoveBreakpoint( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugBreakpoint Bp); + + [PreserveSig] + int AddExtension( + [In][MarshalAs(UnmanagedType.LPStr)] string Path, + uint Flags, + out ulong Handle); + + [PreserveSig] + int RemoveExtension( + ulong Handle); + + [PreserveSig] + int GetExtensionByPath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path, + out ulong Handle); + + [PreserveSig] + int CallExtension( + ulong Handle, + [In][MarshalAs(UnmanagedType.LPStr)] string Function, + [In][MarshalAs(UnmanagedType.LPStr)] string Arguments); + + [PreserveSig] + int GetExtensionFunction( + ulong Handle, + [In][MarshalAs(UnmanagedType.LPStr)] string FuncName, + out IntPtr Function); + + [PreserveSig] + int GetWindbgExtensionApis32( + ref WINDBG_EXTENSION_APIS Api); + + /* Must be In and Out as the nSize member has to be initialized */ + + [PreserveSig] + int GetWindbgExtensionApis64( + ref WINDBG_EXTENSION_APIS Api); + + /* Must be In and Out as the nSize member has to be initialized */ + + [PreserveSig] + int GetNumberEventFilters( + out uint SpecificEvents, + out uint SpecificExceptions, + out uint ArbitraryExceptions); + + [PreserveSig] + int GetEventFilterText( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint TextSize); + + [PreserveSig] + int GetEventFilterCommand( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + int SetEventFilterCommand( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Command); + + [PreserveSig] + int GetSpecificFilterParameters( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_SPECIFIC_FILTER_PARAMETERS[] Params); + + [PreserveSig] + int SetSpecificFilterParameters( + uint Start, + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_SPECIFIC_FILTER_PARAMETERS[] Params); + + [PreserveSig] + int GetSpecificEventFilterArgument( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint ArgumentSize); + + [PreserveSig] + int SetSpecificEventFilterArgument( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Argument); + + [PreserveSig] + int GetExceptionFilterParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Codes, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_EXCEPTION_FILTER_PARAMETERS[] Params); + + [PreserveSig] + int SetExceptionFilterParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_EXCEPTION_FILTER_PARAMETERS[] Params); + + [PreserveSig] + int GetExceptionFilterSecondCommand( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + int SetExceptionFilterSecondCommand( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Command); + + [PreserveSig] + int WaitForEvent( + DEBUG_WAIT Flags, + uint Timeout); + + [PreserveSig] + int GetLastEventInformation( + out DEBUG_EVENT Type, + out uint ProcessId, + out uint ThreadId, + IntPtr ExtraInformation, + uint ExtraInformationSize, + out uint ExtraInformationUsed, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Description, + int DescriptionSize, + out uint DescriptionUsed); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl2.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl2.cs new file mode 100644 index 0000000000..b9fbbe233e --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl2.cs @@ -0,0 +1,579 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("d4366723-44df-4bed-8c7e-4c05424f4588")] + public interface IDebugControl2 : IDebugControl + { + /* IDebugControl */ + + [PreserveSig] + new int GetInterrupt(); + + [PreserveSig] + new int SetInterrupt( + DEBUG_INTERRUPT Flags); + + [PreserveSig] + new int GetInterruptTimeout( + out uint Seconds); + + [PreserveSig] + new int SetInterruptTimeout( + uint Seconds); + + [PreserveSig] + new int GetLogFile( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint FileSize, + [Out][MarshalAs(UnmanagedType.Bool)] out bool Append); + + [PreserveSig] + new int OpenLogFile( + [In][MarshalAs(UnmanagedType.LPStr)] string File, + [In][MarshalAs(UnmanagedType.Bool)] bool Append); + + [PreserveSig] + new int CloseLogFile(); + + [PreserveSig] + new int GetLogMask( + out DEBUG_OUTPUT Mask); + + [PreserveSig] + new int SetLogMask( + DEBUG_OUTPUT Mask); + + [PreserveSig] + new int Input( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint InputSize); + + [PreserveSig] + new int ReturnInput( + [In][MarshalAs(UnmanagedType.LPStr)] string Buffer); + + [PreserveSig] + new int Output( + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + [PreserveSig] + new int OutputVaList( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int ControlledOutput( + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + [PreserveSig] + new int ControlledOutputVaList( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int OutputPrompt( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + [PreserveSig] + new int OutputPromptVaList( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int GetPromptText( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint TextSize); + + [PreserveSig] + new int OutputCurrentState( + DEBUG_OUTCTL OutputControl, + DEBUG_CURRENT Flags); + + [PreserveSig] + new int OutputVersionInformation( + DEBUG_OUTCTL OutputControl); + + [PreserveSig] + new int GetNotifyEventHandle( + out ulong Handle); + + [PreserveSig] + new int SetNotifyEventHandle( + ulong Handle); + + [PreserveSig] + new int Assemble( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPStr)] string Instr, + out ulong EndOffset); + + [PreserveSig] + new int Disassemble( + ulong Offset, + DEBUG_DISASM Flags, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint DisassemblySize, + out ulong EndOffset); + + [PreserveSig] + new int GetDisassembleEffectiveOffset( + out ulong Offset); + + [PreserveSig] + new int OutputDisassembly( + DEBUG_OUTCTL OutputControl, + ulong Offset, + DEBUG_DISASM Flags, + out ulong EndOffset); + + [PreserveSig] + new int OutputDisassemblyLines( + DEBUG_OUTCTL OutputControl, + uint PreviousLines, + uint TotalLines, + ulong Offset, + DEBUG_DISASM Flags, + out uint OffsetLine, + out ulong StartOffset, + out ulong EndOffset, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] LineOffsets); + + [PreserveSig] + new int GetNearInstruction( + ulong Offset, + int Delta, + out ulong NearOffset); + + [PreserveSig] + new int GetStackTrace( + ulong FrameOffset, + ulong StackOffset, + ulong InstructionOffset, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_STACK_FRAME[] Frames, + int FrameSize, + out uint FramesFilled); + + [PreserveSig] + new int GetReturnOffset( + out ulong Offset); + + [PreserveSig] + new int OutputStackTrace( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_STACK_FRAME[] Frames, + int FramesSize, + DEBUG_STACK Flags); + + [PreserveSig] + new int GetDebuggeeType( + out DEBUG_CLASS Class, + out DEBUG_CLASS_QUALIFIER Qualifier); + + [PreserveSig] + new int GetActualProcessorType( + out IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int GetExecutingProcessorType( + out IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int GetNumberPossibleExecutingProcessorTypes( + out uint Number); + + [PreserveSig] + new int GetPossibleExecutingProcessorTypes( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + IMAGE_FILE_MACHINE[] Types); + + [PreserveSig] + new int GetNumberProcessors( + out uint Number); + + [PreserveSig] + new int GetSystemVersion( + out uint PlatformId, + out uint Major, + out uint Minor, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ServicePackString, + int ServicePackStringSize, + out uint ServicePackStringUsed, + out uint ServicePackNumber, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder BuildString, + int BuildStringSize, + out uint BuildStringUsed); + + [PreserveSig] + new int GetPageSize( + out uint Size); + + [PreserveSig] + new int IsPointer64Bit(); + + [PreserveSig] + new int ReadBugCheckData( + out uint Code, + out ulong Arg1, + out ulong Arg2, + out ulong Arg3, + out ulong Arg4); + + [PreserveSig] + new int GetNumberSupportedProcessorTypes( + out uint Number); + + [PreserveSig] + new int GetSupportedProcessorTypes( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + IMAGE_FILE_MACHINE[] Types); + + [PreserveSig] + new int GetProcessorTypeNames( + IMAGE_FILE_MACHINE Type, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder FullNameBuffer, + int FullNameBufferSize, + out uint FullNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder AbbrevNameBuffer, + int AbbrevNameBufferSize, + out uint AbbrevNameSize); + + [PreserveSig] + new int GetEffectiveProcessorType( + out IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int SetEffectiveProcessorType( + IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int GetExecutionStatus( + out DEBUG_STATUS Status); + + [PreserveSig] + new int SetExecutionStatus( + DEBUG_STATUS Status); + + [PreserveSig] + new int GetCodeLevel( + out DEBUG_LEVEL Level); + + [PreserveSig] + new int SetCodeLevel( + DEBUG_LEVEL Level); + + [PreserveSig] + new int GetEngineOptions( + out DEBUG_ENGOPT Options); + + [PreserveSig] + new int AddEngineOptions( + DEBUG_ENGOPT Options); + + [PreserveSig] + new int RemoveEngineOptions( + DEBUG_ENGOPT Options); + + [PreserveSig] + new int SetEngineOptions( + DEBUG_ENGOPT Options); + + [PreserveSig] + new int GetSystemErrorControl( + out ERROR_LEVEL OutputLevel, + out ERROR_LEVEL BreakLevel); + + [PreserveSig] + new int SetSystemErrorControl( + ERROR_LEVEL OutputLevel, + ERROR_LEVEL BreakLevel); + + [PreserveSig] + new int GetTextMacro( + uint Slot, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint MacroSize); + + [PreserveSig] + new int SetTextMacro( + uint Slot, + [In][MarshalAs(UnmanagedType.LPStr)] string Macro); + + [PreserveSig] + new int GetRadix( + out uint Radix); + + [PreserveSig] + new int SetRadix( + uint Radix); + + [PreserveSig] + new int Evaluate( + [In][MarshalAs(UnmanagedType.LPStr)] string Expression, + DEBUG_VALUE_TYPE DesiredType, + out DEBUG_VALUE Value, + out uint RemainderIndex); + + [PreserveSig] + new int CoerceValue( + DEBUG_VALUE In, + DEBUG_VALUE_TYPE OutType, + out DEBUG_VALUE Out); + + [PreserveSig] + new int CoerceValues( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_VALUE[] In, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_VALUE_TYPE[] OutType, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_VALUE[] Out); + + [PreserveSig] + new int Execute( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Command, + DEBUG_EXECUTE Flags); + + [PreserveSig] + new int ExecuteCommandFile( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandFile, + DEBUG_EXECUTE Flags); + + [PreserveSig] + new int GetNumberBreakpoints( + out uint Number); + + [PreserveSig] + new int GetBreakpointByIndex( + uint Index, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint bp); + + [PreserveSig] + new int GetBreakpointById( + uint Id, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint bp); + + [PreserveSig] + new int GetBreakpointParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Ids, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_BREAKPOINT_PARAMETERS[] Params); + + [PreserveSig] + new int AddBreakpoint( + DEBUG_BREAKPOINT_TYPE Type, + uint DesiredId, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint Bp); + + [PreserveSig] + new int RemoveBreakpoint( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugBreakpoint Bp); + + [PreserveSig] + new int AddExtension( + [In][MarshalAs(UnmanagedType.LPStr)] string Path, + uint Flags, + out ulong Handle); + + [PreserveSig] + new int RemoveExtension( + ulong Handle); + + [PreserveSig] + new int GetExtensionByPath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path, + out ulong Handle); + + [PreserveSig] + new int CallExtension( + ulong Handle, + [In][MarshalAs(UnmanagedType.LPStr)] string Function, + [In][MarshalAs(UnmanagedType.LPStr)] string Arguments); + + [PreserveSig] + new int GetExtensionFunction( + ulong Handle, + [In][MarshalAs(UnmanagedType.LPStr)] string FuncName, + out IntPtr Function); + + [PreserveSig] + new int GetWindbgExtensionApis32( + ref WINDBG_EXTENSION_APIS Api); + + /* Must be In and Out as the nSize member has to be initialized */ + + [PreserveSig] + new int GetWindbgExtensionApis64( + ref WINDBG_EXTENSION_APIS Api); + + /* Must be In and Out as the nSize member has to be initialized */ + + [PreserveSig] + new int GetNumberEventFilters( + out uint SpecificEvents, + out uint SpecificExceptions, + out uint ArbitraryExceptions); + + [PreserveSig] + new int GetEventFilterText( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint TextSize); + + [PreserveSig] + new int GetEventFilterCommand( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + new int SetEventFilterCommand( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Command); + + [PreserveSig] + new int GetSpecificFilterParameters( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_SPECIFIC_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int SetSpecificFilterParameters( + uint Start, + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_SPECIFIC_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int GetSpecificEventFilterArgument( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint ArgumentSize); + + [PreserveSig] + new int SetSpecificEventFilterArgument( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Argument); + + [PreserveSig] + new int GetExceptionFilterParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Codes, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_EXCEPTION_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int SetExceptionFilterParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_EXCEPTION_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int GetExceptionFilterSecondCommand( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + new int SetExceptionFilterSecondCommand( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Command); + + [PreserveSig] + new int WaitForEvent( + DEBUG_WAIT Flags, + uint Timeout); + + [PreserveSig] + new int GetLastEventInformation( + out DEBUG_EVENT Type, + out uint ProcessId, + out uint ThreadId, + IntPtr ExtraInformation, + uint ExtraInformationSize, + out uint ExtraInformationUsed, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Description, + int DescriptionSize, + out uint DescriptionUsed); + + /* IDebugControl2 */ + + [PreserveSig] + int GetCurrentTimeDate( + out uint TimeDate); + + [PreserveSig] + int GetCurrentSystemUpTime( + out uint UpTime); + + [PreserveSig] + int GetDumpFormatFlags( + out DEBUG_FORMAT FormatFlags); + + [PreserveSig] + int GetNumberTextReplacements( + out uint NumRepl); + + [PreserveSig] + int GetTextReplacement( + [In][MarshalAs(UnmanagedType.LPStr)] string SrcText, + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder SrcBuffer, + int SrcBufferSize, + out uint SrcSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder DstBuffer, + int DstBufferSize, + out uint DstSize); + + [PreserveSig] + int SetTextReplacement( + [In][MarshalAs(UnmanagedType.LPStr)] string SrcText, + [In][MarshalAs(UnmanagedType.LPStr)] string DstText); + + [PreserveSig] + int RemoveTextReplacements(); + + [PreserveSig] + int OutputTextReplacements( + DEBUG_OUTCTL OutputControl, + DEBUG_OUT_TEXT_REPL Flags); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl3.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl3.cs new file mode 100644 index 0000000000..f0b1bb5e3f --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl3.cs @@ -0,0 +1,603 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("7df74a86-b03f-407f-90ab-a20dadcead08")] + public interface IDebugControl3 : IDebugControl2 + { + /* IDebugControl */ + + [PreserveSig] + new int GetInterrupt(); + + [PreserveSig] + new int SetInterrupt( + DEBUG_INTERRUPT Flags); + + [PreserveSig] + new int GetInterruptTimeout( + out uint Seconds); + + [PreserveSig] + new int SetInterruptTimeout( + uint Seconds); + + [PreserveSig] + new int GetLogFile( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint FileSize, + [Out][MarshalAs(UnmanagedType.Bool)] out bool Append); + + [PreserveSig] + new int OpenLogFile( + [In][MarshalAs(UnmanagedType.LPStr)] string File, + [In][MarshalAs(UnmanagedType.Bool)] bool Append); + + [PreserveSig] + new int CloseLogFile(); + + [PreserveSig] + new int GetLogMask( + out DEBUG_OUTPUT Mask); + + [PreserveSig] + new int SetLogMask( + DEBUG_OUTPUT Mask); + + [PreserveSig] + new int Input( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint InputSize); + + [PreserveSig] + new int ReturnInput( + [In][MarshalAs(UnmanagedType.LPStr)] string Buffer); + + [PreserveSig] + new int Output( + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + [PreserveSig] + new int OutputVaList( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int ControlledOutput( + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + [PreserveSig] + new int ControlledOutputVaList( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int OutputPrompt( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + [PreserveSig] + new int OutputPromptVaList( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int GetPromptText( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint TextSize); + + [PreserveSig] + new int OutputCurrentState( + DEBUG_OUTCTL OutputControl, + DEBUG_CURRENT Flags); + + [PreserveSig] + new int OutputVersionInformation( + DEBUG_OUTCTL OutputControl); + + [PreserveSig] + new int GetNotifyEventHandle( + out ulong Handle); + + [PreserveSig] + new int SetNotifyEventHandle( + ulong Handle); + + [PreserveSig] + new int Assemble( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPStr)] string Instr, + out ulong EndOffset); + + [PreserveSig] + new int Disassemble( + ulong Offset, + DEBUG_DISASM Flags, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint DisassemblySize, + out ulong EndOffset); + + [PreserveSig] + new int GetDisassembleEffectiveOffset( + out ulong Offset); + + [PreserveSig] + new int OutputDisassembly( + DEBUG_OUTCTL OutputControl, + ulong Offset, + DEBUG_DISASM Flags, + out ulong EndOffset); + + [PreserveSig] + new int OutputDisassemblyLines( + DEBUG_OUTCTL OutputControl, + uint PreviousLines, + uint TotalLines, + ulong Offset, + DEBUG_DISASM Flags, + out uint OffsetLine, + out ulong StartOffset, + out ulong EndOffset, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] LineOffsets); + + [PreserveSig] + new int GetNearInstruction( + ulong Offset, + int Delta, + out ulong NearOffset); + + [PreserveSig] + new int GetStackTrace( + ulong FrameOffset, + ulong StackOffset, + ulong InstructionOffset, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_STACK_FRAME[] Frames, + int FrameSize, + out uint FramesFilled); + + [PreserveSig] + new int GetReturnOffset( + out ulong Offset); + + [PreserveSig] + new int OutputStackTrace( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_STACK_FRAME[] Frames, + int FramesSize, + DEBUG_STACK Flags); + + [PreserveSig] + new int GetDebuggeeType( + out DEBUG_CLASS Class, + out DEBUG_CLASS_QUALIFIER Qualifier); + + [PreserveSig] + new int GetActualProcessorType( + out IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int GetExecutingProcessorType( + out IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int GetNumberPossibleExecutingProcessorTypes( + out uint Number); + + [PreserveSig] + new int GetPossibleExecutingProcessorTypes( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + IMAGE_FILE_MACHINE[] Types); + + [PreserveSig] + new int GetNumberProcessors( + out uint Number); + + [PreserveSig] + new int GetSystemVersion( + out uint PlatformId, + out uint Major, + out uint Minor, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ServicePackString, + int ServicePackStringSize, + out uint ServicePackStringUsed, + out uint ServicePackNumber, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder BuildString, + int BuildStringSize, + out uint BuildStringUsed); + + [PreserveSig] + new int GetPageSize( + out uint Size); + + [PreserveSig] + new int IsPointer64Bit(); + + [PreserveSig] + new int ReadBugCheckData( + out uint Code, + out ulong Arg1, + out ulong Arg2, + out ulong Arg3, + out ulong Arg4); + + [PreserveSig] + new int GetNumberSupportedProcessorTypes( + out uint Number); + + [PreserveSig] + new int GetSupportedProcessorTypes( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + IMAGE_FILE_MACHINE[] Types); + + [PreserveSig] + new int GetProcessorTypeNames( + IMAGE_FILE_MACHINE Type, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder FullNameBuffer, + int FullNameBufferSize, + out uint FullNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder AbbrevNameBuffer, + int AbbrevNameBufferSize, + out uint AbbrevNameSize); + + [PreserveSig] + new int GetEffectiveProcessorType( + out IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int SetEffectiveProcessorType( + IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int GetExecutionStatus( + out DEBUG_STATUS Status); + + [PreserveSig] + new int SetExecutionStatus( + DEBUG_STATUS Status); + + [PreserveSig] + new int GetCodeLevel( + out DEBUG_LEVEL Level); + + [PreserveSig] + new int SetCodeLevel( + DEBUG_LEVEL Level); + + [PreserveSig] + new int GetEngineOptions( + out DEBUG_ENGOPT Options); + + [PreserveSig] + new int AddEngineOptions( + DEBUG_ENGOPT Options); + + [PreserveSig] + new int RemoveEngineOptions( + DEBUG_ENGOPT Options); + + [PreserveSig] + new int SetEngineOptions( + DEBUG_ENGOPT Options); + + [PreserveSig] + new int GetSystemErrorControl( + out ERROR_LEVEL OutputLevel, + out ERROR_LEVEL BreakLevel); + + [PreserveSig] + new int SetSystemErrorControl( + ERROR_LEVEL OutputLevel, + ERROR_LEVEL BreakLevel); + + [PreserveSig] + new int GetTextMacro( + uint Slot, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint MacroSize); + + [PreserveSig] + new int SetTextMacro( + uint Slot, + [In][MarshalAs(UnmanagedType.LPStr)] string Macro); + + [PreserveSig] + new int GetRadix( + out uint Radix); + + [PreserveSig] + new int SetRadix( + uint Radix); + + [PreserveSig] + new int Evaluate( + [In][MarshalAs(UnmanagedType.LPStr)] string Expression, + DEBUG_VALUE_TYPE DesiredType, + out DEBUG_VALUE Value, + out uint RemainderIndex); + + [PreserveSig] + new int CoerceValue( + DEBUG_VALUE In, + DEBUG_VALUE_TYPE OutType, + out DEBUG_VALUE Out); + + [PreserveSig] + new int CoerceValues( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_VALUE[] In, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_VALUE_TYPE[] OutType, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_VALUE[] Out); + + [PreserveSig] + new int Execute( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Command, + DEBUG_EXECUTE Flags); + + [PreserveSig] + new int ExecuteCommandFile( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandFile, + DEBUG_EXECUTE Flags); + + [PreserveSig] + new int GetNumberBreakpoints( + out uint Number); + + [PreserveSig] + new int GetBreakpointByIndex( + uint Index, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint bp); + + [PreserveSig] + new int GetBreakpointById( + uint Id, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint bp); + + [PreserveSig] + new int GetBreakpointParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Ids, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_BREAKPOINT_PARAMETERS[] Params); + + [PreserveSig] + new int AddBreakpoint( + DEBUG_BREAKPOINT_TYPE Type, + uint DesiredId, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint Bp); + + [PreserveSig] + new int RemoveBreakpoint( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugBreakpoint Bp); + + [PreserveSig] + new int AddExtension( + [In][MarshalAs(UnmanagedType.LPStr)] string Path, + uint Flags, + out ulong Handle); + + [PreserveSig] + new int RemoveExtension( + ulong Handle); + + [PreserveSig] + new int GetExtensionByPath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path, + out ulong Handle); + + [PreserveSig] + new int CallExtension( + ulong Handle, + [In][MarshalAs(UnmanagedType.LPStr)] string Function, + [In][MarshalAs(UnmanagedType.LPStr)] string Arguments); + + [PreserveSig] + new int GetExtensionFunction( + ulong Handle, + [In][MarshalAs(UnmanagedType.LPStr)] string FuncName, + out IntPtr Function); + + [PreserveSig] + new int GetWindbgExtensionApis32( + ref WINDBG_EXTENSION_APIS Api); + + /* Must be In and Out as the nSize member has to be initialized */ + + [PreserveSig] + new int GetWindbgExtensionApis64( + ref WINDBG_EXTENSION_APIS Api); + + /* Must be In and Out as the nSize member has to be initialized */ + + [PreserveSig] + new int GetNumberEventFilters( + out uint SpecificEvents, + out uint SpecificExceptions, + out uint ArbitraryExceptions); + + [PreserveSig] + new int GetEventFilterText( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint TextSize); + + [PreserveSig] + new int GetEventFilterCommand( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + new int SetEventFilterCommand( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Command); + + [PreserveSig] + new int GetSpecificFilterParameters( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_SPECIFIC_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int SetSpecificFilterParameters( + uint Start, + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_SPECIFIC_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int GetSpecificEventFilterArgument( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint ArgumentSize); + + [PreserveSig] + new int SetSpecificEventFilterArgument( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Argument); + + [PreserveSig] + new int GetExceptionFilterParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Codes, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_EXCEPTION_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int SetExceptionFilterParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_EXCEPTION_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int GetExceptionFilterSecondCommand( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + new int SetExceptionFilterSecondCommand( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Command); + + [PreserveSig] + new int WaitForEvent( + DEBUG_WAIT Flags, + uint Timeout); + + [PreserveSig] + new int GetLastEventInformation( + out DEBUG_EVENT Type, + out uint ProcessId, + out uint ThreadId, + IntPtr ExtraInformation, + uint ExtraInformationSize, + out uint ExtraInformationUsed, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Description, + int DescriptionSize, + out uint DescriptionUsed); + + /* IDebugControl3 */ + + [PreserveSig] + int GetAssemblyOptions( + out DEBUG_ASMOPT Options); + + [PreserveSig] + int AddAssemblyOptions( + DEBUG_ASMOPT Options); + + [PreserveSig] + int RemoveAssemblyOptions( + DEBUG_ASMOPT Options); + + [PreserveSig] + int SetAssemblyOptions( + DEBUG_ASMOPT Options); + + [PreserveSig] + int GetExpressionSyntax( + out DEBUG_EXPR Flags); + + [PreserveSig] + int SetExpressionSyntax( + DEBUG_EXPR Flags); + + [PreserveSig] + int SetExpressionSyntaxByName( + [In][MarshalAs(UnmanagedType.LPStr)] string AbbrevName); + + [PreserveSig] + int GetNumberExpressionSyntaxes( + out uint Number); + + [PreserveSig] + int GetExpressionSyntaxNames( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder FullNameBuffer, + int FullNameBufferSize, + out uint FullNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder AbbrevNameBuffer, + int AbbrevNameBufferSize, + out uint AbbrevNameSize); + + [PreserveSig] + int GetNumberEvents( + out uint Events); + + [PreserveSig] + int GetEventIndexDescription( + uint Index, + DEBUG_EINDEX Which, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint DescSize); + + [PreserveSig] + int GetCurrentEventIndex( + out uint Index); + + [PreserveSig] + int SetNextEventIndex( + DEBUG_EINDEX Relation, + uint Value, + out uint NextIndex); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl4.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl4.cs new file mode 100644 index 0000000000..dbaa28ebe8 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl4.cs @@ -0,0 +1,1006 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("94e60ce9-9b41-4b19-9fc0-6d9eb35272b3")] + public interface IDebugControl4 : IDebugControl3 + { + /* IDebugControl */ + + [PreserveSig] + new int GetInterrupt(); + + [PreserveSig] + new int SetInterrupt( + DEBUG_INTERRUPT Flags); + + [PreserveSig] + new int GetInterruptTimeout( + out uint Seconds); + + [PreserveSig] + new int SetInterruptTimeout( + uint Seconds); + + [PreserveSig] + new int GetLogFile( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint FileSize, + [Out][MarshalAs(UnmanagedType.Bool)] out bool Append); + + [PreserveSig] + new int OpenLogFile( + [In][MarshalAs(UnmanagedType.LPStr)] string File, + [In][MarshalAs(UnmanagedType.Bool)] bool Append); + + [PreserveSig] + new int CloseLogFile(); + + [PreserveSig] + new int GetLogMask( + out DEBUG_OUTPUT Mask); + + [PreserveSig] + new int SetLogMask( + DEBUG_OUTPUT Mask); + + [PreserveSig] + new int Input( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint InputSize); + + [PreserveSig] + new int ReturnInput( + [In][MarshalAs(UnmanagedType.LPStr)] string Buffer); + + [PreserveSig] + new int Output( + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + [PreserveSig] + new int OutputVaList( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int ControlledOutput( + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + [PreserveSig] + new int ControlledOutputVaList( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int OutputPrompt( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + [PreserveSig] + new int OutputPromptVaList( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int GetPromptText( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint TextSize); + + [PreserveSig] + new int OutputCurrentState( + DEBUG_OUTCTL OutputControl, + DEBUG_CURRENT Flags); + + [PreserveSig] + new int OutputVersionInformation( + DEBUG_OUTCTL OutputControl); + + [PreserveSig] + new int GetNotifyEventHandle( + out ulong Handle); + + [PreserveSig] + new int SetNotifyEventHandle( + ulong Handle); + + [PreserveSig] + new int Assemble( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPStr)] string Instr, + out ulong EndOffset); + + [PreserveSig] + new int Disassemble( + ulong Offset, + DEBUG_DISASM Flags, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint DisassemblySize, + out ulong EndOffset); + + [PreserveSig] + new int GetDisassembleEffectiveOffset( + out ulong Offset); + + [PreserveSig] + new int OutputDisassembly( + DEBUG_OUTCTL OutputControl, + ulong Offset, + DEBUG_DISASM Flags, + out ulong EndOffset); + + [PreserveSig] + new int OutputDisassemblyLines( + DEBUG_OUTCTL OutputControl, + uint PreviousLines, + uint TotalLines, + ulong Offset, + DEBUG_DISASM Flags, + out uint OffsetLine, + out ulong StartOffset, + out ulong EndOffset, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] LineOffsets); + + [PreserveSig] + new int GetNearInstruction( + ulong Offset, + int Delta, + out ulong NearOffset); + + [PreserveSig] + new int GetStackTrace( + ulong FrameOffset, + ulong StackOffset, + ulong InstructionOffset, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_STACK_FRAME[] Frames, + int FrameSize, + out uint FramesFilled); + + [PreserveSig] + new int GetReturnOffset( + out ulong Offset); + + [PreserveSig] + new int OutputStackTrace( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_STACK_FRAME[] Frames, + int FramesSize, + DEBUG_STACK Flags); + + [PreserveSig] + new int GetDebuggeeType( + out DEBUG_CLASS Class, + out DEBUG_CLASS_QUALIFIER Qualifier); + + [PreserveSig] + new int GetActualProcessorType( + out IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int GetExecutingProcessorType( + out IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int GetNumberPossibleExecutingProcessorTypes( + out uint Number); + + [PreserveSig] + new int GetPossibleExecutingProcessorTypes( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + IMAGE_FILE_MACHINE[] Types); + + [PreserveSig] + new int GetNumberProcessors( + out uint Number); + + [PreserveSig] + new int GetSystemVersion( + out uint PlatformId, + out uint Major, + out uint Minor, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ServicePackString, + int ServicePackStringSize, + out uint ServicePackStringUsed, + out uint ServicePackNumber, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder BuildString, + int BuildStringSize, + out uint BuildStringUsed); + + [PreserveSig] + new int GetPageSize( + out uint Size); + + [PreserveSig] + new int IsPointer64Bit(); + + [PreserveSig] + new int ReadBugCheckData( + out uint Code, + out ulong Arg1, + out ulong Arg2, + out ulong Arg3, + out ulong Arg4); + + [PreserveSig] + new int GetNumberSupportedProcessorTypes( + out uint Number); + + [PreserveSig] + new int GetSupportedProcessorTypes( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + IMAGE_FILE_MACHINE[] Types); + + [PreserveSig] + new int GetProcessorTypeNames( + IMAGE_FILE_MACHINE Type, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder FullNameBuffer, + int FullNameBufferSize, + out uint FullNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder AbbrevNameBuffer, + int AbbrevNameBufferSize, + out uint AbbrevNameSize); + + [PreserveSig] + new int GetEffectiveProcessorType( + out IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int SetEffectiveProcessorType( + IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int GetExecutionStatus( + out DEBUG_STATUS Status); + + [PreserveSig] + new int SetExecutionStatus( + DEBUG_STATUS Status); + + [PreserveSig] + new int GetCodeLevel( + out DEBUG_LEVEL Level); + + [PreserveSig] + new int SetCodeLevel( + DEBUG_LEVEL Level); + + [PreserveSig] + new int GetEngineOptions( + out DEBUG_ENGOPT Options); + + [PreserveSig] + new int AddEngineOptions( + DEBUG_ENGOPT Options); + + [PreserveSig] + new int RemoveEngineOptions( + DEBUG_ENGOPT Options); + + [PreserveSig] + new int SetEngineOptions( + DEBUG_ENGOPT Options); + + [PreserveSig] + new int GetSystemErrorControl( + out ERROR_LEVEL OutputLevel, + out ERROR_LEVEL BreakLevel); + + [PreserveSig] + new int SetSystemErrorControl( + ERROR_LEVEL OutputLevel, + ERROR_LEVEL BreakLevel); + + [PreserveSig] + new int GetTextMacro( + uint Slot, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint MacroSize); + + [PreserveSig] + new int SetTextMacro( + uint Slot, + [In][MarshalAs(UnmanagedType.LPStr)] string Macro); + + [PreserveSig] + new int GetRadix( + out uint Radix); + + [PreserveSig] + new int SetRadix( + uint Radix); + + [PreserveSig] + new int Evaluate( + [In][MarshalAs(UnmanagedType.LPStr)] string Expression, + DEBUG_VALUE_TYPE DesiredType, + out DEBUG_VALUE Value, + out uint RemainderIndex); + + [PreserveSig] + new int CoerceValue( + DEBUG_VALUE In, + DEBUG_VALUE_TYPE OutType, + out DEBUG_VALUE Out); + + [PreserveSig] + new int CoerceValues( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_VALUE[] In, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_VALUE_TYPE[] OutType, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_VALUE[] Out); + + [PreserveSig] + new int Execute( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Command, + DEBUG_EXECUTE Flags); + + [PreserveSig] + new int ExecuteCommandFile( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandFile, + DEBUG_EXECUTE Flags); + + [PreserveSig] + new int GetNumberBreakpoints( + out uint Number); + + [PreserveSig] + new int GetBreakpointByIndex( + uint Index, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint bp); + + [PreserveSig] + new int GetBreakpointById( + uint Id, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint bp); + + [PreserveSig] + new int GetBreakpointParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Ids, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_BREAKPOINT_PARAMETERS[] Params); + + [PreserveSig] + new int AddBreakpoint( + DEBUG_BREAKPOINT_TYPE Type, + uint DesiredId, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint Bp); + + [PreserveSig] + new int RemoveBreakpoint( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugBreakpoint Bp); + + [PreserveSig] + new int AddExtension( + [In][MarshalAs(UnmanagedType.LPStr)] string Path, + uint Flags, + out ulong Handle); + + [PreserveSig] + new int RemoveExtension( + ulong Handle); + + [PreserveSig] + new int GetExtensionByPath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path, + out ulong Handle); + + [PreserveSig] + new int CallExtension( + ulong Handle, + [In][MarshalAs(UnmanagedType.LPStr)] string Function, + [In][MarshalAs(UnmanagedType.LPStr)] string Arguments); + + [PreserveSig] + new int GetExtensionFunction( + ulong Handle, + [In][MarshalAs(UnmanagedType.LPStr)] string FuncName, + out IntPtr Function); + + [PreserveSig] + new int GetWindbgExtensionApis32( + ref WINDBG_EXTENSION_APIS Api); + + /* Must be In and Out as the nSize member has to be initialized */ + + [PreserveSig] + new int GetWindbgExtensionApis64( + ref WINDBG_EXTENSION_APIS Api); + + /* Must be In and Out as the nSize member has to be initialized */ + + [PreserveSig] + new int GetNumberEventFilters( + out uint SpecificEvents, + out uint SpecificExceptions, + out uint ArbitraryExceptions); + + [PreserveSig] + new int GetEventFilterText( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint TextSize); + + [PreserveSig] + new int GetEventFilterCommand( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + new int SetEventFilterCommand( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Command); + + [PreserveSig] + new int GetSpecificFilterParameters( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_SPECIFIC_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int SetSpecificFilterParameters( + uint Start, + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_SPECIFIC_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int GetSpecificEventFilterArgument( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint ArgumentSize); + + [PreserveSig] + new int SetSpecificEventFilterArgument( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Argument); + + [PreserveSig] + new int GetExceptionFilterParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Codes, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_EXCEPTION_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int SetExceptionFilterParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_EXCEPTION_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int GetExceptionFilterSecondCommand( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + new int SetExceptionFilterSecondCommand( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Command); + + [PreserveSig] + new int WaitForEvent( + DEBUG_WAIT Flags, + uint Timeout); + + [PreserveSig] + new int GetLastEventInformation( + out DEBUG_EVENT Type, + out uint ProcessId, + out uint ThreadId, + IntPtr ExtraInformation, + uint ExtraInformationSize, + out uint ExtraInformationUsed, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Description, + int DescriptionSize, + out uint DescriptionUsed); + + /* IDebugControl2 */ + + [PreserveSig] + new int GetCurrentTimeDate( + out uint TimeDate); + + [PreserveSig] + new int GetCurrentSystemUpTime( + out uint UpTime); + + [PreserveSig] + new int GetDumpFormatFlags( + out DEBUG_FORMAT FormatFlags); + + [PreserveSig] + new int GetNumberTextReplacements( + out uint NumRepl); + + [PreserveSig] + new int GetTextReplacement( + [In][MarshalAs(UnmanagedType.LPStr)] string SrcText, + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder SrcBuffer, + int SrcBufferSize, + out uint SrcSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder DstBuffer, + int DstBufferSize, + out uint DstSize); + + [PreserveSig] + new int SetTextReplacement( + [In][MarshalAs(UnmanagedType.LPStr)] string SrcText, + [In][MarshalAs(UnmanagedType.LPStr)] string DstText); + + [PreserveSig] + new int RemoveTextReplacements(); + + [PreserveSig] + new int OutputTextReplacements( + DEBUG_OUTCTL OutputControl, + DEBUG_OUT_TEXT_REPL Flags); + + /* IDebugControl3 */ + + [PreserveSig] + new int GetAssemblyOptions( + out DEBUG_ASMOPT Options); + + [PreserveSig] + new int AddAssemblyOptions( + DEBUG_ASMOPT Options); + + [PreserveSig] + new int RemoveAssemblyOptions( + DEBUG_ASMOPT Options); + + [PreserveSig] + new int SetAssemblyOptions( + DEBUG_ASMOPT Options); + + [PreserveSig] + new int GetExpressionSyntax( + out DEBUG_EXPR Flags); + + [PreserveSig] + new int SetExpressionSyntax( + DEBUG_EXPR Flags); + + [PreserveSig] + new int SetExpressionSyntaxByName( + [In][MarshalAs(UnmanagedType.LPStr)] string AbbrevName); + + [PreserveSig] + new int GetNumberExpressionSyntaxes( + out uint Number); + + [PreserveSig] + new int GetExpressionSyntaxNames( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder FullNameBuffer, + int FullNameBufferSize, + out uint FullNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder AbbrevNameBuffer, + int AbbrevNameBufferSize, + out uint AbbrevNameSize); + + [PreserveSig] + new int GetNumberEvents( + out uint Events); + + [PreserveSig] + new int GetEventIndexDescription( + uint Index, + DEBUG_EINDEX Which, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint DescSize); + + [PreserveSig] + new int GetCurrentEventIndex( + out uint Index); + + [PreserveSig] + new int SetNextEventIndex( + DEBUG_EINDEX Relation, + uint Value, + out uint NextIndex); + + /* IDebugControl4 */ + + [PreserveSig] + int GetLogFileWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint FileSize, + [Out][MarshalAs(UnmanagedType.Bool)] out bool Append); + + [PreserveSig] + int OpenLogFileWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string File, + [In][MarshalAs(UnmanagedType.Bool)] bool Append); + + [PreserveSig] + int InputWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint InputSize); + + [PreserveSig] + int ReturnInputWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Buffer); + + [PreserveSig] + int OutputWide( + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPWStr)] string Format); + + [PreserveSig] + int OutputVaListWide( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPWStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + int ControlledOutputWide( + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPWStr)] string Format); + + [PreserveSig] + int ControlledOutputVaListWide( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPWStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + int OutputPromptWide( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPWStr)] string Format); + + [PreserveSig] + int OutputPromptVaListWide( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPWStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + int GetPromptTextWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint TextSize); + + [PreserveSig] + int AssembleWide( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPWStr)] string Instr, + out ulong EndOffset); + + [PreserveSig] + int DisassembleWide( + ulong Offset, + DEBUG_DISASM Flags, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint DisassemblySize, + out ulong EndOffset); + + [PreserveSig] + int GetProcessorTypeNamesWide( + IMAGE_FILE_MACHINE Type, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder FullNameBuffer, + int FullNameBufferSize, + out uint FullNameSize, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder AbbrevNameBuffer, + int AbbrevNameBufferSize, + out uint AbbrevNameSize); + + [PreserveSig] + int GetTextMacroWide( + uint Slot, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint MacroSize); + + [PreserveSig] + int SetTextMacroWide( + uint Slot, + [In][MarshalAs(UnmanagedType.LPWStr)] string Macro); + + [PreserveSig] + int EvaluateWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Expression, + DEBUG_VALUE_TYPE DesiredType, + out DEBUG_VALUE Value, + out uint RemainderIndex); + + [PreserveSig] + int ExecuteWide( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPWStr)] string Command, + DEBUG_EXECUTE Flags); + + [PreserveSig] + int ExecuteCommandFileWide( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPWStr)] string CommandFile, + DEBUG_EXECUTE Flags); + + [PreserveSig] + int GetBreakpointByIndex2( + uint Index, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint2 bp); + + [PreserveSig] + int GetBreakpointById2( + uint Id, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint2 bp); + + [PreserveSig] + int AddBreakpoint2( + DEBUG_BREAKPOINT_TYPE Type, + uint DesiredId, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint2 Bp); + + [PreserveSig] + int RemoveBreakpoint2( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugBreakpoint2 Bp); + + [PreserveSig] + int AddExtensionWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Path, + uint Flags, + out ulong Handle); + + [PreserveSig] + int GetExtensionByPathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Path, + out ulong Handle); + + [PreserveSig] + int CallExtensionWide( + ulong Handle, + [In][MarshalAs(UnmanagedType.LPWStr)] string Function, + [In][MarshalAs(UnmanagedType.LPWStr)] string Arguments); + + [PreserveSig] + int GetExtensionFunctionWide( + ulong Handle, + [In][MarshalAs(UnmanagedType.LPWStr)] string FuncName, + out IntPtr Function); + + [PreserveSig] + int GetEventFilterTextWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint TextSize); + + [PreserveSig] + int GetEventFilterCommandWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + int SetEventFilterCommandWide( + uint Index, + [In][MarshalAs(UnmanagedType.LPWStr)] string Command); + + [PreserveSig] + int GetSpecificEventFilterArgumentWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint ArgumentSize); + + [PreserveSig] + int SetSpecificEventFilterArgumentWide( + uint Index, + [In][MarshalAs(UnmanagedType.LPWStr)] string Argument); + + [PreserveSig] + int GetExceptionFilterSecondCommandWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + int SetExceptionFilterSecondCommandWide( + uint Index, + [In][MarshalAs(UnmanagedType.LPWStr)] string Command); + + [PreserveSig] + int GetLastEventInformationWide( + out DEBUG_EVENT Type, + out uint ProcessId, + out uint ThreadId, + IntPtr ExtraInformation, + int ExtraInformationSize, + out uint ExtraInformationUsed, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Description, + int DescriptionSize, + out uint DescriptionUsed); + + [PreserveSig] + int GetTextReplacementWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string SrcText, + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder SrcBuffer, + int SrcBufferSize, + out uint SrcSize, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder DstBuffer, + int DstBufferSize, + out uint DstSize); + + [PreserveSig] + int SetTextReplacementWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string SrcText, + [In][MarshalAs(UnmanagedType.LPWStr)] string DstText); + + [PreserveSig] + int SetExpressionSyntaxByNameWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string AbbrevName); + + [PreserveSig] + int GetExpressionSyntaxNamesWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder FullNameBuffer, + int FullNameBufferSize, + out uint FullNameSize, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder AbbrevNameBuffer, + int AbbrevNameBufferSize, + out uint AbbrevNameSize); + + [PreserveSig] + int GetEventIndexDescriptionWide( + uint Index, + DEBUG_EINDEX Which, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint DescSize); + + [PreserveSig] + int GetLogFile2( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint FileSize, + out DEBUG_LOG Flags); + + [PreserveSig] + int OpenLogFile2( + [In][MarshalAs(UnmanagedType.LPStr)] string File, + out DEBUG_LOG Flags); + + [PreserveSig] + int GetLogFile2Wide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint FileSize, + out DEBUG_LOG Flags); + + [PreserveSig] + int OpenLogFile2Wide( + [In][MarshalAs(UnmanagedType.LPWStr)] string File, + out DEBUG_LOG Flags); + + [PreserveSig] + int GetSystemVersionValues( + out uint PlatformId, + out uint Win32Major, + out uint Win32Minor, + out uint KdMajor, + out uint KdMinor); + + [PreserveSig] + int GetSystemVersionString( + DEBUG_SYSVERSTR Which, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize); + + [PreserveSig] + int GetSystemVersionStringWide( + DEBUG_SYSVERSTR Which, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize); + + [PreserveSig] + int GetContextStackTrace( + IntPtr StartContext, + uint StartContextSize, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_STACK_FRAME[] Frames, + int FrameSize, + IntPtr FrameContexts, + uint FrameContextsSize, + uint FrameContextsEntrySize, + out uint FramesFilled); + + [PreserveSig] + int OutputContextStackTrace( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_STACK_FRAME[] Frames, + int FramesSize, + IntPtr FrameContexts, + uint FrameContextsSize, + uint FrameContextsEntrySize, + DEBUG_STACK Flags); + + [PreserveSig] + int GetStoredEventInformation( + out DEBUG_EVENT Type, + out uint ProcessId, + out uint ThreadId, + IntPtr Context, + uint ContextSize, + out uint ContextUsed, + IntPtr ExtraInformation, + uint ExtraInformationSize, + out uint ExtraInformationUsed); + + [PreserveSig] + int GetManagedStatus( + out DEBUG_MANAGED Flags, + DEBUG_MANSTR WhichString, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder String, + int StringSize, + out uint StringNeeded); + + [PreserveSig] + int GetManagedStatusWide( + out DEBUG_MANAGED Flags, + DEBUG_MANSTR WhichString, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder String, + int StringSize, + out uint StringNeeded); + + [PreserveSig] + int ResetManagedStatus( + DEBUG_MANRESET Flags); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl5.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl5.cs new file mode 100644 index 0000000000..10284f171d --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl5.cs @@ -0,0 +1,1053 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("b2ffe162-2412-429f-8d1d-5bf6dd824696")] + public interface IDebugControl5 : IDebugControl4 + { + /* IDebugControl */ + + [PreserveSig] + new int GetInterrupt(); + + [PreserveSig] + new int SetInterrupt( + DEBUG_INTERRUPT Flags); + + [PreserveSig] + new int GetInterruptTimeout( + out uint Seconds); + + [PreserveSig] + new int SetInterruptTimeout( + uint Seconds); + + [PreserveSig] + new int GetLogFile( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint FileSize, + [Out][MarshalAs(UnmanagedType.Bool)] out bool Append); + + [PreserveSig] + new int OpenLogFile( + [In][MarshalAs(UnmanagedType.LPStr)] string File, + [In][MarshalAs(UnmanagedType.Bool)] bool Append); + + [PreserveSig] + new int CloseLogFile(); + + [PreserveSig] + new int GetLogMask( + out DEBUG_OUTPUT Mask); + + [PreserveSig] + new int SetLogMask( + DEBUG_OUTPUT Mask); + + [PreserveSig] + new int Input( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint InputSize); + + [PreserveSig] + new int ReturnInput( + [In][MarshalAs(UnmanagedType.LPStr)] string Buffer); + + [PreserveSig] + new int Output( + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + [PreserveSig] + new int OutputVaList( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int ControlledOutput( + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + [PreserveSig] + new int ControlledOutputVaList( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int OutputPrompt( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + [PreserveSig] + new int OutputPromptVaList( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int GetPromptText( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint TextSize); + + [PreserveSig] + new int OutputCurrentState( + DEBUG_OUTCTL OutputControl, + DEBUG_CURRENT Flags); + + [PreserveSig] + new int OutputVersionInformation( + DEBUG_OUTCTL OutputControl); + + [PreserveSig] + new int GetNotifyEventHandle( + out ulong Handle); + + [PreserveSig] + new int SetNotifyEventHandle( + ulong Handle); + + [PreserveSig] + new int Assemble( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPStr)] string Instr, + out ulong EndOffset); + + [PreserveSig] + new int Disassemble( + ulong Offset, + DEBUG_DISASM Flags, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint DisassemblySize, + out ulong EndOffset); + + [PreserveSig] + new int GetDisassembleEffectiveOffset( + out ulong Offset); + + [PreserveSig] + new int OutputDisassembly( + DEBUG_OUTCTL OutputControl, + ulong Offset, + DEBUG_DISASM Flags, + out ulong EndOffset); + + [PreserveSig] + new int OutputDisassemblyLines( + DEBUG_OUTCTL OutputControl, + uint PreviousLines, + uint TotalLines, + ulong Offset, + DEBUG_DISASM Flags, + out uint OffsetLine, + out ulong StartOffset, + out ulong EndOffset, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] LineOffsets); + + [PreserveSig] + new int GetNearInstruction( + ulong Offset, + int Delta, + out ulong NearOffset); + + [PreserveSig] + new int GetStackTrace( + ulong FrameOffset, + ulong StackOffset, + ulong InstructionOffset, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_STACK_FRAME[] Frames, + int FrameSize, + out uint FramesFilled); + + [PreserveSig] + new int GetReturnOffset( + out ulong Offset); + + [PreserveSig] + new int OutputStackTrace( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_STACK_FRAME[] Frames, + int FramesSize, + DEBUG_STACK Flags); + + [PreserveSig] + new int GetDebuggeeType( + out DEBUG_CLASS Class, + out DEBUG_CLASS_QUALIFIER Qualifier); + + [PreserveSig] + new int GetActualProcessorType( + out IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int GetExecutingProcessorType( + out IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int GetNumberPossibleExecutingProcessorTypes( + out uint Number); + + [PreserveSig] + new int GetPossibleExecutingProcessorTypes( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + IMAGE_FILE_MACHINE[] Types); + + [PreserveSig] + new int GetNumberProcessors( + out uint Number); + + [PreserveSig] + new int GetSystemVersion( + out uint PlatformId, + out uint Major, + out uint Minor, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ServicePackString, + int ServicePackStringSize, + out uint ServicePackStringUsed, + out uint ServicePackNumber, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder BuildString, + int BuildStringSize, + out uint BuildStringUsed); + + [PreserveSig] + new int GetPageSize( + out uint Size); + + [PreserveSig] + new int IsPointer64Bit(); + + [PreserveSig] + new int ReadBugCheckData( + out uint Code, + out ulong Arg1, + out ulong Arg2, + out ulong Arg3, + out ulong Arg4); + + [PreserveSig] + new int GetNumberSupportedProcessorTypes( + out uint Number); + + [PreserveSig] + new int GetSupportedProcessorTypes( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + IMAGE_FILE_MACHINE[] Types); + + [PreserveSig] + new int GetProcessorTypeNames( + IMAGE_FILE_MACHINE Type, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder FullNameBuffer, + int FullNameBufferSize, + out uint FullNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder AbbrevNameBuffer, + int AbbrevNameBufferSize, + out uint AbbrevNameSize); + + [PreserveSig] + new int GetEffectiveProcessorType( + out IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int SetEffectiveProcessorType( + IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int GetExecutionStatus( + out DEBUG_STATUS Status); + + [PreserveSig] + new int SetExecutionStatus( + DEBUG_STATUS Status); + + [PreserveSig] + new int GetCodeLevel( + out DEBUG_LEVEL Level); + + [PreserveSig] + new int SetCodeLevel( + DEBUG_LEVEL Level); + + [PreserveSig] + new int GetEngineOptions( + out DEBUG_ENGOPT Options); + + [PreserveSig] + new int AddEngineOptions( + DEBUG_ENGOPT Options); + + [PreserveSig] + new int RemoveEngineOptions( + DEBUG_ENGOPT Options); + + [PreserveSig] + new int SetEngineOptions( + DEBUG_ENGOPT Options); + + [PreserveSig] + new int GetSystemErrorControl( + out ERROR_LEVEL OutputLevel, + out ERROR_LEVEL BreakLevel); + + [PreserveSig] + new int SetSystemErrorControl( + ERROR_LEVEL OutputLevel, + ERROR_LEVEL BreakLevel); + + [PreserveSig] + new int GetTextMacro( + uint Slot, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint MacroSize); + + [PreserveSig] + new int SetTextMacro( + uint Slot, + [In][MarshalAs(UnmanagedType.LPStr)] string Macro); + + [PreserveSig] + new int GetRadix( + out uint Radix); + + [PreserveSig] + new int SetRadix( + uint Radix); + + [PreserveSig] + new int Evaluate( + [In][MarshalAs(UnmanagedType.LPStr)] string Expression, + DEBUG_VALUE_TYPE DesiredType, + out DEBUG_VALUE Value, + out uint RemainderIndex); + + [PreserveSig] + new int CoerceValue( + DEBUG_VALUE In, + DEBUG_VALUE_TYPE OutType, + out DEBUG_VALUE Out); + + [PreserveSig] + new int CoerceValues( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_VALUE[] In, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_VALUE_TYPE[] OutType, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_VALUE[] Out); + + [PreserveSig] + new int Execute( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Command, + DEBUG_EXECUTE Flags); + + [PreserveSig] + new int ExecuteCommandFile( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandFile, + DEBUG_EXECUTE Flags); + + [PreserveSig] + new int GetNumberBreakpoints( + out uint Number); + + [PreserveSig] + new int GetBreakpointByIndex( + uint Index, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint bp); + + [PreserveSig] + new int GetBreakpointById( + uint Id, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint bp); + + [PreserveSig] + new int GetBreakpointParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Ids, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_BREAKPOINT_PARAMETERS[] Params); + + [PreserveSig] + new int AddBreakpoint( + DEBUG_BREAKPOINT_TYPE Type, + uint DesiredId, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint Bp); + + [PreserveSig] + new int RemoveBreakpoint( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugBreakpoint Bp); + + [PreserveSig] + new int AddExtension( + [In][MarshalAs(UnmanagedType.LPStr)] string Path, + uint Flags, + out ulong Handle); + + [PreserveSig] + new int RemoveExtension( + ulong Handle); + + [PreserveSig] + new int GetExtensionByPath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path, + out ulong Handle); + + [PreserveSig] + new int CallExtension( + ulong Handle, + [In][MarshalAs(UnmanagedType.LPStr)] string Function, + [In][MarshalAs(UnmanagedType.LPStr)] string Arguments); + + [PreserveSig] + new int GetExtensionFunction( + ulong Handle, + [In][MarshalAs(UnmanagedType.LPStr)] string FuncName, + out IntPtr Function); + + [PreserveSig] + new int GetWindbgExtensionApis32( + ref WINDBG_EXTENSION_APIS Api); + + /* Must be In and Out as the nSize member has to be initialized */ + + [PreserveSig] + new int GetWindbgExtensionApis64( + ref WINDBG_EXTENSION_APIS Api); + + /* Must be In and Out as the nSize member has to be initialized */ + + [PreserveSig] + new int GetNumberEventFilters( + out uint SpecificEvents, + out uint SpecificExceptions, + out uint ArbitraryExceptions); + + [PreserveSig] + new int GetEventFilterText( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint TextSize); + + [PreserveSig] + new int GetEventFilterCommand( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + new int SetEventFilterCommand( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Command); + + [PreserveSig] + new int GetSpecificFilterParameters( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_SPECIFIC_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int SetSpecificFilterParameters( + uint Start, + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_SPECIFIC_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int GetSpecificEventFilterArgument( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint ArgumentSize); + + [PreserveSig] + new int SetSpecificEventFilterArgument( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Argument); + + [PreserveSig] + new int GetExceptionFilterParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Codes, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_EXCEPTION_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int SetExceptionFilterParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_EXCEPTION_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int GetExceptionFilterSecondCommand( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + new int SetExceptionFilterSecondCommand( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Command); + + [PreserveSig] + new int WaitForEvent( + DEBUG_WAIT Flags, + uint Timeout); + + [PreserveSig] + new int GetLastEventInformation( + out DEBUG_EVENT Type, + out uint ProcessId, + out uint ThreadId, + IntPtr ExtraInformation, + uint ExtraInformationSize, + out uint ExtraInformationUsed, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Description, + int DescriptionSize, + out uint DescriptionUsed); + + /* IDebugControl2 */ + + [PreserveSig] + new int GetCurrentTimeDate( + out uint TimeDate); + + [PreserveSig] + new int GetCurrentSystemUpTime( + out uint UpTime); + + [PreserveSig] + new int GetDumpFormatFlags( + out DEBUG_FORMAT FormatFlags); + + [PreserveSig] + new int GetNumberTextReplacements( + out uint NumRepl); + + [PreserveSig] + new int GetTextReplacement( + [In][MarshalAs(UnmanagedType.LPStr)] string SrcText, + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder SrcBuffer, + int SrcBufferSize, + out uint SrcSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder DstBuffer, + int DstBufferSize, + out uint DstSize); + + [PreserveSig] + new int SetTextReplacement( + [In][MarshalAs(UnmanagedType.LPStr)] string SrcText, + [In][MarshalAs(UnmanagedType.LPStr)] string DstText); + + [PreserveSig] + new int RemoveTextReplacements(); + + [PreserveSig] + new int OutputTextReplacements( + DEBUG_OUTCTL OutputControl, + DEBUG_OUT_TEXT_REPL Flags); + + /* IDebugControl3 */ + + [PreserveSig] + new int GetAssemblyOptions( + out DEBUG_ASMOPT Options); + + [PreserveSig] + new int AddAssemblyOptions( + DEBUG_ASMOPT Options); + + [PreserveSig] + new int RemoveAssemblyOptions( + DEBUG_ASMOPT Options); + + [PreserveSig] + new int SetAssemblyOptions( + DEBUG_ASMOPT Options); + + [PreserveSig] + new int GetExpressionSyntax( + out DEBUG_EXPR Flags); + + [PreserveSig] + new int SetExpressionSyntax( + DEBUG_EXPR Flags); + + [PreserveSig] + new int SetExpressionSyntaxByName( + [In][MarshalAs(UnmanagedType.LPStr)] string AbbrevName); + + [PreserveSig] + new int GetNumberExpressionSyntaxes( + out uint Number); + + [PreserveSig] + new int GetExpressionSyntaxNames( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder FullNameBuffer, + int FullNameBufferSize, + out uint FullNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder AbbrevNameBuffer, + int AbbrevNameBufferSize, + out uint AbbrevNameSize); + + [PreserveSig] + new int GetNumberEvents( + out uint Events); + + [PreserveSig] + new int GetEventIndexDescription( + uint Index, + DEBUG_EINDEX Which, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint DescSize); + + [PreserveSig] + new int GetCurrentEventIndex( + out uint Index); + + [PreserveSig] + new int SetNextEventIndex( + DEBUG_EINDEX Relation, + uint Value, + out uint NextIndex); + + /* IDebugControl4 */ + + [PreserveSig] + new int GetLogFileWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint FileSize, + [Out][MarshalAs(UnmanagedType.Bool)] out bool Append); + + [PreserveSig] + new int OpenLogFileWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string File, + [In][MarshalAs(UnmanagedType.Bool)] bool Append); + + [PreserveSig] + new int InputWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint InputSize); + + [PreserveSig] + new int ReturnInputWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Buffer); + + [PreserveSig] + new int OutputWide( + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPWStr)] string Format); + + [PreserveSig] + new int OutputVaListWide( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPWStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int ControlledOutputWide( + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPWStr)] string Format); + + [PreserveSig] + new int ControlledOutputVaListWide( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPWStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int OutputPromptWide( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPWStr)] string Format); + + [PreserveSig] + new int OutputPromptVaListWide( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPWStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int GetPromptTextWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint TextSize); + + [PreserveSig] + new int AssembleWide( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPWStr)] string Instr, + out ulong EndOffset); + + [PreserveSig] + new int DisassembleWide( + ulong Offset, + DEBUG_DISASM Flags, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint DisassemblySize, + out ulong EndOffset); + + [PreserveSig] + new int GetProcessorTypeNamesWide( + IMAGE_FILE_MACHINE Type, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder FullNameBuffer, + int FullNameBufferSize, + out uint FullNameSize, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder AbbrevNameBuffer, + int AbbrevNameBufferSize, + out uint AbbrevNameSize); + + [PreserveSig] + new int GetTextMacroWide( + uint Slot, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint MacroSize); + + [PreserveSig] + new int SetTextMacroWide( + uint Slot, + [In][MarshalAs(UnmanagedType.LPWStr)] string Macro); + + [PreserveSig] + new int EvaluateWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Expression, + DEBUG_VALUE_TYPE DesiredType, + out DEBUG_VALUE Value, + out uint RemainderIndex); + + [PreserveSig] + new int ExecuteWide( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPWStr)] string Command, + DEBUG_EXECUTE Flags); + + [PreserveSig] + new int ExecuteCommandFileWide( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPWStr)] string CommandFile, + DEBUG_EXECUTE Flags); + + [PreserveSig] + new int GetBreakpointByIndex2( + uint Index, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint2 bp); + + [PreserveSig] + new int GetBreakpointById2( + uint Id, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint2 bp); + + [PreserveSig] + new int AddBreakpoint2( + DEBUG_BREAKPOINT_TYPE Type, + uint DesiredId, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint2 Bp); + + [PreserveSig] + new int RemoveBreakpoint2( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugBreakpoint2 Bp); + + [PreserveSig] + new int AddExtensionWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Path, + uint Flags, + out ulong Handle); + + [PreserveSig] + new int GetExtensionByPathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Path, + out ulong Handle); + + [PreserveSig] + new int CallExtensionWide( + ulong Handle, + [In][MarshalAs(UnmanagedType.LPWStr)] string Function, + [In][MarshalAs(UnmanagedType.LPWStr)] string Arguments); + + [PreserveSig] + new int GetExtensionFunctionWide( + ulong Handle, + [In][MarshalAs(UnmanagedType.LPWStr)] string FuncName, + out IntPtr Function); + + [PreserveSig] + new int GetEventFilterTextWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint TextSize); + + [PreserveSig] + new int GetEventFilterCommandWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + new int SetEventFilterCommandWide( + uint Index, + [In][MarshalAs(UnmanagedType.LPWStr)] string Command); + + [PreserveSig] + new int GetSpecificEventFilterArgumentWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint ArgumentSize); + + [PreserveSig] + new int SetSpecificEventFilterArgumentWide( + uint Index, + [In][MarshalAs(UnmanagedType.LPWStr)] string Argument); + + [PreserveSig] + new int GetExceptionFilterSecondCommandWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + new int SetExceptionFilterSecondCommandWide( + uint Index, + [In][MarshalAs(UnmanagedType.LPWStr)] string Command); + + [PreserveSig] + new int GetLastEventInformationWide( + out DEBUG_EVENT Type, + out uint ProcessId, + out uint ThreadId, + IntPtr ExtraInformation, + int ExtraInformationSize, + out uint ExtraInformationUsed, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Description, + int DescriptionSize, + out uint DescriptionUsed); + + [PreserveSig] + new int GetTextReplacementWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string SrcText, + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder SrcBuffer, + int SrcBufferSize, + out uint SrcSize, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder DstBuffer, + int DstBufferSize, + out uint DstSize); + + [PreserveSig] + new int SetTextReplacementWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string SrcText, + [In][MarshalAs(UnmanagedType.LPWStr)] string DstText); + + [PreserveSig] + new int SetExpressionSyntaxByNameWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string AbbrevName); + + [PreserveSig] + new int GetExpressionSyntaxNamesWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder FullNameBuffer, + int FullNameBufferSize, + out uint FullNameSize, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder AbbrevNameBuffer, + int AbbrevNameBufferSize, + out uint AbbrevNameSize); + + [PreserveSig] + new int GetEventIndexDescriptionWide( + uint Index, + DEBUG_EINDEX Which, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint DescSize); + + [PreserveSig] + new int GetLogFile2( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint FileSize, + out DEBUG_LOG Flags); + + [PreserveSig] + new int OpenLogFile2( + [In][MarshalAs(UnmanagedType.LPStr)] string File, + out DEBUG_LOG Flags); + + [PreserveSig] + new int GetLogFile2Wide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint FileSize, + out DEBUG_LOG Flags); + + [PreserveSig] + new int OpenLogFile2Wide( + [In][MarshalAs(UnmanagedType.LPWStr)] string File, + out DEBUG_LOG Flags); + + [PreserveSig] + new int GetSystemVersionValues( + out uint PlatformId, + out uint Win32Major, + out uint Win32Minor, + out uint KdMajor, + out uint KdMinor); + + [PreserveSig] + new int GetSystemVersionString( + DEBUG_SYSVERSTR Which, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize); + + [PreserveSig] + new int GetSystemVersionStringWide( + DEBUG_SYSVERSTR Which, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize); + + [PreserveSig] + new int GetContextStackTrace( + IntPtr StartContext, + uint StartContextSize, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_STACK_FRAME[] Frames, + int FrameSize, + IntPtr FrameContexts, + uint FrameContextsSize, + uint FrameContextsEntrySize, + out uint FramesFilled); + + [PreserveSig] + new int OutputContextStackTrace( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_STACK_FRAME[] Frames, + int FramesSize, + IntPtr FrameContexts, + uint FrameContextsSize, + uint FrameContextsEntrySize, + DEBUG_STACK Flags); + + [PreserveSig] + new int GetStoredEventInformation( + out DEBUG_EVENT Type, + out uint ProcessId, + out uint ThreadId, + IntPtr Context, + uint ContextSize, + out uint ContextUsed, + IntPtr ExtraInformation, + uint ExtraInformationSize, + out uint ExtraInformationUsed); + + [PreserveSig] + new int GetManagedStatus( + out DEBUG_MANAGED Flags, + DEBUG_MANSTR WhichString, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder String, + int StringSize, + out uint StringNeeded); + + [PreserveSig] + new int GetManagedStatusWide( + out DEBUG_MANAGED Flags, + DEBUG_MANSTR WhichString, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder String, + int StringSize, + out uint StringNeeded); + + [PreserveSig] + new int ResetManagedStatus( + DEBUG_MANRESET Flags); + + /* IDebugControl5 */ + + [PreserveSig] + int GetStackTraceEx( + ulong FrameOffset, + ulong StackOffset, + ulong InstructionOffset, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_STACK_FRAME_EX[] Frames, + int FramesSize, + out uint FramesFilled); + + [PreserveSig] + int OutputStackTraceEx( + uint OutputControl, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_STACK_FRAME_EX[] Frames, + int FramesSize, + DEBUG_STACK Flags); + + [PreserveSig] + int GetContextStackTraceEx( + IntPtr StartContext, + uint StartContextSize, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_STACK_FRAME_EX[] Frames, + int FramesSize, + IntPtr FrameContexts, + uint FrameContextsSize, + uint FrameContextsEntrySize, + out uint FramesFilled); + + [PreserveSig] + int OutputContextStackTraceEx( + uint OutputControl, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_STACK_FRAME_EX[] Frames, + int FramesSize, + IntPtr FrameContexts, + uint FrameContextsSize, + uint FrameContextsEntrySize, + DEBUG_STACK Flags); + + [PreserveSig] + int GetBreakpointByGuid( + [In][MarshalAs(UnmanagedType.LPStruct)] + Guid Guid, + out IDebugBreakpoint3 Bp); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl6.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl6.cs new file mode 100644 index 0000000000..bbe60d400b --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugControl6.cs @@ -0,0 +1,1063 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("bc0d583f-126d-43a1-9cc4-a860ab1d537b")] + public interface IDebugControl6 : IDebugControl5 + { + /* IDebugControl */ + + [PreserveSig] + new int GetInterrupt(); + + [PreserveSig] + new int SetInterrupt( + DEBUG_INTERRUPT Flags); + + [PreserveSig] + new int GetInterruptTimeout( + out uint Seconds); + + [PreserveSig] + new int SetInterruptTimeout( + uint Seconds); + + [PreserveSig] + new int GetLogFile( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint FileSize, + [Out][MarshalAs(UnmanagedType.Bool)] out bool Append); + + [PreserveSig] + new int OpenLogFile( + [In][MarshalAs(UnmanagedType.LPStr)] string File, + [In][MarshalAs(UnmanagedType.Bool)] bool Append); + + [PreserveSig] + new int CloseLogFile(); + + [PreserveSig] + new int GetLogMask( + out DEBUG_OUTPUT Mask); + + [PreserveSig] + new int SetLogMask( + DEBUG_OUTPUT Mask); + + [PreserveSig] + new int Input( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint InputSize); + + [PreserveSig] + new int ReturnInput( + [In][MarshalAs(UnmanagedType.LPStr)] string Buffer); + + [PreserveSig] + new int Output( + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + [PreserveSig] + new int OutputVaList( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int ControlledOutput( + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + [PreserveSig] + new int ControlledOutputVaList( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int OutputPrompt( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Format); + + [PreserveSig] + new int OutputPromptVaList( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int GetPromptText( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint TextSize); + + [PreserveSig] + new int OutputCurrentState( + DEBUG_OUTCTL OutputControl, + DEBUG_CURRENT Flags); + + [PreserveSig] + new int OutputVersionInformation( + DEBUG_OUTCTL OutputControl); + + [PreserveSig] + new int GetNotifyEventHandle( + out ulong Handle); + + [PreserveSig] + new int SetNotifyEventHandle( + ulong Handle); + + [PreserveSig] + new int Assemble( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPStr)] string Instr, + out ulong EndOffset); + + [PreserveSig] + new int Disassemble( + ulong Offset, + DEBUG_DISASM Flags, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint DisassemblySize, + out ulong EndOffset); + + [PreserveSig] + new int GetDisassembleEffectiveOffset( + out ulong Offset); + + [PreserveSig] + new int OutputDisassembly( + DEBUG_OUTCTL OutputControl, + ulong Offset, + DEBUG_DISASM Flags, + out ulong EndOffset); + + [PreserveSig] + new int OutputDisassemblyLines( + DEBUG_OUTCTL OutputControl, + uint PreviousLines, + uint TotalLines, + ulong Offset, + DEBUG_DISASM Flags, + out uint OffsetLine, + out ulong StartOffset, + out ulong EndOffset, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] LineOffsets); + + [PreserveSig] + new int GetNearInstruction( + ulong Offset, + int Delta, + out ulong NearOffset); + + [PreserveSig] + new int GetStackTrace( + ulong FrameOffset, + ulong StackOffset, + ulong InstructionOffset, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_STACK_FRAME[] Frames, + int FrameSize, + out uint FramesFilled); + + [PreserveSig] + new int GetReturnOffset( + out ulong Offset); + + [PreserveSig] + new int OutputStackTrace( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_STACK_FRAME[] Frames, + int FramesSize, + DEBUG_STACK Flags); + + [PreserveSig] + new int GetDebuggeeType( + out DEBUG_CLASS Class, + out DEBUG_CLASS_QUALIFIER Qualifier); + + [PreserveSig] + new int GetActualProcessorType( + out IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int GetExecutingProcessorType( + out IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int GetNumberPossibleExecutingProcessorTypes( + out uint Number); + + [PreserveSig] + new int GetPossibleExecutingProcessorTypes( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + IMAGE_FILE_MACHINE[] Types); + + [PreserveSig] + new int GetNumberProcessors( + out uint Number); + + [PreserveSig] + new int GetSystemVersion( + out uint PlatformId, + out uint Major, + out uint Minor, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ServicePackString, + int ServicePackStringSize, + out uint ServicePackStringUsed, + out uint ServicePackNumber, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder BuildString, + int BuildStringSize, + out uint BuildStringUsed); + + [PreserveSig] + new int GetPageSize( + out uint Size); + + [PreserveSig] + new int IsPointer64Bit(); + + [PreserveSig] + new int ReadBugCheckData( + out uint Code, + out ulong Arg1, + out ulong Arg2, + out ulong Arg3, + out ulong Arg4); + + [PreserveSig] + new int GetNumberSupportedProcessorTypes( + out uint Number); + + [PreserveSig] + new int GetSupportedProcessorTypes( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + IMAGE_FILE_MACHINE[] Types); + + [PreserveSig] + new int GetProcessorTypeNames( + IMAGE_FILE_MACHINE Type, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder FullNameBuffer, + int FullNameBufferSize, + out uint FullNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder AbbrevNameBuffer, + int AbbrevNameBufferSize, + out uint AbbrevNameSize); + + [PreserveSig] + new int GetEffectiveProcessorType( + out IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int SetEffectiveProcessorType( + IMAGE_FILE_MACHINE Type); + + [PreserveSig] + new int GetExecutionStatus( + out DEBUG_STATUS Status); + + [PreserveSig] + new int SetExecutionStatus( + DEBUG_STATUS Status); + + [PreserveSig] + new int GetCodeLevel( + out DEBUG_LEVEL Level); + + [PreserveSig] + new int SetCodeLevel( + DEBUG_LEVEL Level); + + [PreserveSig] + new int GetEngineOptions( + out DEBUG_ENGOPT Options); + + [PreserveSig] + new int AddEngineOptions( + DEBUG_ENGOPT Options); + + [PreserveSig] + new int RemoveEngineOptions( + DEBUG_ENGOPT Options); + + [PreserveSig] + new int SetEngineOptions( + DEBUG_ENGOPT Options); + + [PreserveSig] + new int GetSystemErrorControl( + out ERROR_LEVEL OutputLevel, + out ERROR_LEVEL BreakLevel); + + [PreserveSig] + new int SetSystemErrorControl( + ERROR_LEVEL OutputLevel, + ERROR_LEVEL BreakLevel); + + [PreserveSig] + new int GetTextMacro( + uint Slot, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint MacroSize); + + [PreserveSig] + new int SetTextMacro( + uint Slot, + [In][MarshalAs(UnmanagedType.LPStr)] string Macro); + + [PreserveSig] + new int GetRadix( + out uint Radix); + + [PreserveSig] + new int SetRadix( + uint Radix); + + [PreserveSig] + new int Evaluate( + [In][MarshalAs(UnmanagedType.LPStr)] string Expression, + DEBUG_VALUE_TYPE DesiredType, + out DEBUG_VALUE Value, + out uint RemainderIndex); + + [PreserveSig] + new int CoerceValue( + DEBUG_VALUE In, + DEBUG_VALUE_TYPE OutType, + out DEBUG_VALUE Out); + + [PreserveSig] + new int CoerceValues( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_VALUE[] In, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_VALUE_TYPE[] OutType, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_VALUE[] Out); + + [PreserveSig] + new int Execute( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string Command, + DEBUG_EXECUTE Flags); + + [PreserveSig] + new int ExecuteCommandFile( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPStr)] string CommandFile, + DEBUG_EXECUTE Flags); + + [PreserveSig] + new int GetNumberBreakpoints( + out uint Number); + + [PreserveSig] + new int GetBreakpointByIndex( + uint Index, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint bp); + + [PreserveSig] + new int GetBreakpointById( + uint Id, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint bp); + + [PreserveSig] + new int GetBreakpointParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Ids, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_BREAKPOINT_PARAMETERS[] Params); + + [PreserveSig] + new int AddBreakpoint( + DEBUG_BREAKPOINT_TYPE Type, + uint DesiredId, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint Bp); + + [PreserveSig] + new int RemoveBreakpoint( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugBreakpoint Bp); + + [PreserveSig] + new int AddExtension( + [In][MarshalAs(UnmanagedType.LPStr)] string Path, + uint Flags, + out ulong Handle); + + [PreserveSig] + new int RemoveExtension( + ulong Handle); + + [PreserveSig] + new int GetExtensionByPath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path, + out ulong Handle); + + [PreserveSig] + new int CallExtension( + ulong Handle, + [In][MarshalAs(UnmanagedType.LPStr)] string Function, + [In][MarshalAs(UnmanagedType.LPStr)] string Arguments); + + [PreserveSig] + new int GetExtensionFunction( + ulong Handle, + [In][MarshalAs(UnmanagedType.LPStr)] string FuncName, + out IntPtr Function); + + [PreserveSig] + new int GetWindbgExtensionApis32( + ref WINDBG_EXTENSION_APIS Api); + + /* Must be In and Out as the nSize member has to be initialized */ + + [PreserveSig] + new int GetWindbgExtensionApis64( + ref WINDBG_EXTENSION_APIS Api); + + /* Must be In and Out as the nSize member has to be initialized */ + + [PreserveSig] + new int GetNumberEventFilters( + out uint SpecificEvents, + out uint SpecificExceptions, + out uint ArbitraryExceptions); + + [PreserveSig] + new int GetEventFilterText( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint TextSize); + + [PreserveSig] + new int GetEventFilterCommand( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + new int SetEventFilterCommand( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Command); + + [PreserveSig] + new int GetSpecificFilterParameters( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_SPECIFIC_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int SetSpecificFilterParameters( + uint Start, + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_SPECIFIC_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int GetSpecificEventFilterArgument( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint ArgumentSize); + + [PreserveSig] + new int SetSpecificEventFilterArgument( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Argument); + + [PreserveSig] + new int GetExceptionFilterParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Codes, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_EXCEPTION_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int SetExceptionFilterParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_EXCEPTION_FILTER_PARAMETERS[] Params); + + [PreserveSig] + new int GetExceptionFilterSecondCommand( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + new int SetExceptionFilterSecondCommand( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Command); + + [PreserveSig] + new int WaitForEvent( + DEBUG_WAIT Flags, + uint Timeout); + + [PreserveSig] + new int GetLastEventInformation( + out DEBUG_EVENT Type, + out uint ProcessId, + out uint ThreadId, + IntPtr ExtraInformation, + uint ExtraInformationSize, + out uint ExtraInformationUsed, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Description, + int DescriptionSize, + out uint DescriptionUsed); + + /* IDebugControl2 */ + + [PreserveSig] + new int GetCurrentTimeDate( + out uint TimeDate); + + [PreserveSig] + new int GetCurrentSystemUpTime( + out uint UpTime); + + [PreserveSig] + new int GetDumpFormatFlags( + out DEBUG_FORMAT FormatFlags); + + [PreserveSig] + new int GetNumberTextReplacements( + out uint NumRepl); + + [PreserveSig] + new int GetTextReplacement( + [In][MarshalAs(UnmanagedType.LPStr)] string SrcText, + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder SrcBuffer, + int SrcBufferSize, + out uint SrcSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder DstBuffer, + int DstBufferSize, + out uint DstSize); + + [PreserveSig] + new int SetTextReplacement( + [In][MarshalAs(UnmanagedType.LPStr)] string SrcText, + [In][MarshalAs(UnmanagedType.LPStr)] string DstText); + + [PreserveSig] + new int RemoveTextReplacements(); + + [PreserveSig] + new int OutputTextReplacements( + DEBUG_OUTCTL OutputControl, + DEBUG_OUT_TEXT_REPL Flags); + + /* IDebugControl3 */ + + [PreserveSig] + new int GetAssemblyOptions( + out DEBUG_ASMOPT Options); + + [PreserveSig] + new int AddAssemblyOptions( + DEBUG_ASMOPT Options); + + [PreserveSig] + new int RemoveAssemblyOptions( + DEBUG_ASMOPT Options); + + [PreserveSig] + new int SetAssemblyOptions( + DEBUG_ASMOPT Options); + + [PreserveSig] + new int GetExpressionSyntax( + out DEBUG_EXPR Flags); + + [PreserveSig] + new int SetExpressionSyntax( + DEBUG_EXPR Flags); + + [PreserveSig] + new int SetExpressionSyntaxByName( + [In][MarshalAs(UnmanagedType.LPStr)] string AbbrevName); + + [PreserveSig] + new int GetNumberExpressionSyntaxes( + out uint Number); + + [PreserveSig] + new int GetExpressionSyntaxNames( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder FullNameBuffer, + int FullNameBufferSize, + out uint FullNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder AbbrevNameBuffer, + int AbbrevNameBufferSize, + out uint AbbrevNameSize); + + [PreserveSig] + new int GetNumberEvents( + out uint Events); + + [PreserveSig] + new int GetEventIndexDescription( + uint Index, + DEBUG_EINDEX Which, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint DescSize); + + [PreserveSig] + new int GetCurrentEventIndex( + out uint Index); + + [PreserveSig] + new int SetNextEventIndex( + DEBUG_EINDEX Relation, + uint Value, + out uint NextIndex); + + /* IDebugControl4 */ + + [PreserveSig] + new int GetLogFileWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint FileSize, + [Out][MarshalAs(UnmanagedType.Bool)] out bool Append); + + [PreserveSig] + new int OpenLogFileWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string File, + [In][MarshalAs(UnmanagedType.Bool)] bool Append); + + [PreserveSig] + new int InputWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint InputSize); + + [PreserveSig] + new int ReturnInputWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Buffer); + + [PreserveSig] + new int OutputWide( + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPWStr)] string Format); + + [PreserveSig] + new int OutputVaListWide( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPWStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int ControlledOutputWide( + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPWStr)] string Format); + + [PreserveSig] + new int ControlledOutputVaListWide( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPWStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int OutputPromptWide( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPWStr)] string Format); + + [PreserveSig] + new int OutputPromptVaListWide( /* THIS SHOULD NEVER BE CALLED FROM C# */ + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPWStr)] string Format, + IntPtr va_list_Args); + + [PreserveSig] + new int GetPromptTextWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint TextSize); + + [PreserveSig] + new int AssembleWide( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPWStr)] string Instr, + out ulong EndOffset); + + [PreserveSig] + new int DisassembleWide( + ulong Offset, + DEBUG_DISASM Flags, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint DisassemblySize, + out ulong EndOffset); + + [PreserveSig] + new int GetProcessorTypeNamesWide( + IMAGE_FILE_MACHINE Type, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder FullNameBuffer, + int FullNameBufferSize, + out uint FullNameSize, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder AbbrevNameBuffer, + int AbbrevNameBufferSize, + out uint AbbrevNameSize); + + [PreserveSig] + new int GetTextMacroWide( + uint Slot, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint MacroSize); + + [PreserveSig] + new int SetTextMacroWide( + uint Slot, + [In][MarshalAs(UnmanagedType.LPWStr)] string Macro); + + [PreserveSig] + new int EvaluateWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Expression, + DEBUG_VALUE_TYPE DesiredType, + out DEBUG_VALUE Value, + out uint RemainderIndex); + + [PreserveSig] + new int ExecuteWide( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPWStr)] string Command, + DEBUG_EXECUTE Flags); + + [PreserveSig] + new int ExecuteCommandFileWide( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPWStr)] string CommandFile, + DEBUG_EXECUTE Flags); + + [PreserveSig] + new int GetBreakpointByIndex2( + uint Index, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint2 bp); + + [PreserveSig] + new int GetBreakpointById2( + uint Id, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint2 bp); + + [PreserveSig] + new int AddBreakpoint2( + DEBUG_BREAKPOINT_TYPE Type, + uint DesiredId, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugBreakpoint2 Bp); + + [PreserveSig] + new int RemoveBreakpoint2( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugBreakpoint2 Bp); + + [PreserveSig] + new int AddExtensionWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Path, + uint Flags, + out ulong Handle); + + [PreserveSig] + new int GetExtensionByPathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Path, + out ulong Handle); + + [PreserveSig] + new int CallExtensionWide( + ulong Handle, + [In][MarshalAs(UnmanagedType.LPWStr)] string Function, + [In][MarshalAs(UnmanagedType.LPWStr)] string Arguments); + + [PreserveSig] + new int GetExtensionFunctionWide( + ulong Handle, + [In][MarshalAs(UnmanagedType.LPWStr)] string FuncName, + out IntPtr Function); + + [PreserveSig] + new int GetEventFilterTextWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint TextSize); + + [PreserveSig] + new int GetEventFilterCommandWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + new int SetEventFilterCommandWide( + uint Index, + [In][MarshalAs(UnmanagedType.LPWStr)] string Command); + + [PreserveSig] + new int GetSpecificEventFilterArgumentWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint ArgumentSize); + + [PreserveSig] + new int SetSpecificEventFilterArgumentWide( + uint Index, + [In][MarshalAs(UnmanagedType.LPWStr)] string Argument); + + [PreserveSig] + new int GetExceptionFilterSecondCommandWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint CommandSize); + + [PreserveSig] + new int SetExceptionFilterSecondCommandWide( + uint Index, + [In][MarshalAs(UnmanagedType.LPWStr)] string Command); + + [PreserveSig] + new int GetLastEventInformationWide( + out DEBUG_EVENT Type, + out uint ProcessId, + out uint ThreadId, + IntPtr ExtraInformation, + int ExtraInformationSize, + out uint ExtraInformationUsed, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Description, + int DescriptionSize, + out uint DescriptionUsed); + + [PreserveSig] + new int GetTextReplacementWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string SrcText, + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder SrcBuffer, + int SrcBufferSize, + out uint SrcSize, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder DstBuffer, + int DstBufferSize, + out uint DstSize); + + [PreserveSig] + new int SetTextReplacementWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string SrcText, + [In][MarshalAs(UnmanagedType.LPWStr)] string DstText); + + [PreserveSig] + new int SetExpressionSyntaxByNameWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string AbbrevName); + + [PreserveSig] + new int GetExpressionSyntaxNamesWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder FullNameBuffer, + int FullNameBufferSize, + out uint FullNameSize, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder AbbrevNameBuffer, + int AbbrevNameBufferSize, + out uint AbbrevNameSize); + + [PreserveSig] + new int GetEventIndexDescriptionWide( + uint Index, + DEBUG_EINDEX Which, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint DescSize); + + [PreserveSig] + new int GetLogFile2( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint FileSize, + out DEBUG_LOG Flags); + + [PreserveSig] + new int OpenLogFile2( + [In][MarshalAs(UnmanagedType.LPStr)] string File, + out DEBUG_LOG Flags); + + [PreserveSig] + new int GetLogFile2Wide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint FileSize, + out DEBUG_LOG Flags); + + [PreserveSig] + new int OpenLogFile2Wide( + [In][MarshalAs(UnmanagedType.LPWStr)] string File, + out DEBUG_LOG Flags); + + [PreserveSig] + new int GetSystemVersionValues( + out uint PlatformId, + out uint Win32Major, + out uint Win32Minor, + out uint KdMajor, + out uint KdMinor); + + [PreserveSig] + new int GetSystemVersionString( + DEBUG_SYSVERSTR Which, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize); + + [PreserveSig] + new int GetSystemVersionStringWide( + DEBUG_SYSVERSTR Which, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize); + + [PreserveSig] + new int GetContextStackTrace( + IntPtr StartContext, + uint StartContextSize, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_STACK_FRAME[] Frames, + int FrameSize, + IntPtr FrameContexts, + uint FrameContextsSize, + uint FrameContextsEntrySize, + out uint FramesFilled); + + [PreserveSig] + new int OutputContextStackTrace( + DEBUG_OUTCTL OutputControl, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_STACK_FRAME[] Frames, + int FramesSize, + IntPtr FrameContexts, + uint FrameContextsSize, + uint FrameContextsEntrySize, + DEBUG_STACK Flags); + + [PreserveSig] + new int GetStoredEventInformation( + out DEBUG_EVENT Type, + out uint ProcessId, + out uint ThreadId, + IntPtr Context, + uint ContextSize, + out uint ContextUsed, + IntPtr ExtraInformation, + uint ExtraInformationSize, + out uint ExtraInformationUsed); + + [PreserveSig] + new int GetManagedStatus( + out DEBUG_MANAGED Flags, + DEBUG_MANSTR WhichString, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder String, + int StringSize, + out uint StringNeeded); + + [PreserveSig] + new int GetManagedStatusWide( + out DEBUG_MANAGED Flags, + DEBUG_MANSTR WhichString, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder String, + int StringSize, + out uint StringNeeded); + + [PreserveSig] + new int ResetManagedStatus( + DEBUG_MANRESET Flags); + + /* IDebugControl5 */ + + [PreserveSig] + new int GetStackTraceEx( + ulong FrameOffset, + ulong StackOffset, + ulong InstructionOffset, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_STACK_FRAME_EX[] Frames, + int FramesSize, + out uint FramesFilled); + + [PreserveSig] + new int OutputStackTraceEx( + uint OutputControl, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_STACK_FRAME_EX[] Frames, + int FramesSize, + DEBUG_STACK Flags); + + [PreserveSig] + new int GetContextStackTraceEx( + IntPtr StartContext, + uint StartContextSize, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_STACK_FRAME_EX[] Frames, + int FramesSize, + IntPtr FrameContexts, + uint FrameContextsSize, + uint FrameContextsEntrySize, + out uint FramesFilled); + + [PreserveSig] + new int OutputContextStackTraceEx( + uint OutputControl, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_STACK_FRAME_EX[] Frames, + int FramesSize, + IntPtr FrameContexts, + uint FrameContextsSize, + uint FrameContextsEntrySize, + DEBUG_STACK Flags); + + [PreserveSig] + new int GetBreakpointByGuid( + [In][MarshalAs(UnmanagedType.LPStruct)] + Guid Guid, + out IDebugBreakpoint3 Bp); + + /* IDebugControl6 */ + + [PreserveSig] + int GetExecutionStatusEx(out DEBUG_STATUS Status); + + [PreserveSig] + int GetSynchronizationStatus( + out uint SendsAttempted, + out uint SecondsSinceLastResponse); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugDataSpaces.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugDataSpaces.cs new file mode 100644 index 0000000000..aedd2a3e28 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugDataSpaces.cs @@ -0,0 +1,336 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("88f7dfab-3ea7-4c3a-aefb-c4e8106173aa")] + public interface IDebugDataSpaces + { + /* IDebugDataSpaces */ + + [PreserveSig] + int ReadVirtual( + ulong Offset, + [Out] + IntPtr buffer, + int BufferSize, + out int BytesRead); + + [PreserveSig] + int WriteVirtual( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + int SearchVirtual( + ulong Offset, + ulong Length, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] pattern, + uint PatternSize, + uint PatternGranularity, + out ulong MatchOffset); + + [PreserveSig] + int ReadVirtualUncached( + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + int WriteVirtualUncached( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + int ReadPointersVirtual( + uint Count, + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] + ulong[] Ptrs); + + [PreserveSig] + int WritePointersVirtual( + uint Count, + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray)] ulong[] Ptrs); + + [PreserveSig] + int ReadPhysical( + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + int WritePhysical( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + int ReadControl( + uint Processor, + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + int BufferSize, + out uint BytesRead); + + [PreserveSig] + int WriteControl( + uint Processor, + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + int BufferSize, + out uint BytesWritten); + + [PreserveSig] + int ReadIo( + INTERFACE_TYPE InterfaceType, + uint BusNumber, + uint AddressSpace, + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + int WriteIo( + INTERFACE_TYPE InterfaceType, + uint BusNumber, + uint AddressSpace, + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + int ReadMsr( + uint Msr, + out ulong MsrValue); + + [PreserveSig] + int WriteMsr( + uint Msr, + ulong MsrValue); + + [PreserveSig] + int ReadBusData( + BUS_DATA_TYPE BusDataType, + uint BusNumber, + uint SlotNumber, + uint Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + int WriteBusData( + BUS_DATA_TYPE BusDataType, + uint BusNumber, + uint SlotNumber, + uint Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + int CheckLowMemory(); + + [PreserveSig] + int ReadDebuggerData( + uint Index, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint DataSize); + + [PreserveSig] + int ReadProcessorSystemData( + uint Processor, + DEBUG_DATA Index, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + uint BufferSize, + out uint DataSize); + } + + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("88f7dfab-3ea7-4c3a-aefb-c4e8106173aa")] + public interface IDebugDataSpacesPtr + { + /* IDebugDataSpaces */ + + [PreserveSig] + int ReadVirtual( + ulong Offset, + IntPtr buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + int WriteVirtual( + ulong Offset, + IntPtr buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + int SearchVirtual( + ulong Offset, + ulong Length, + IntPtr pattern, + uint PatternSize, + uint PatternGranularity, + out ulong MatchOffset); + + [PreserveSig] + int ReadVirtualUncached( + ulong Offset, + IntPtr buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + int WriteVirtualUncached( + ulong Offset, + IntPtr buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + int ReadPointersVirtual( + uint Count, + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] + ulong[] Ptrs); + + [PreserveSig] + int WritePointersVirtual( + uint Count, + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray)] ulong[] Ptrs); + + [PreserveSig] + int ReadPhysical( + ulong Offset, + IntPtr buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + int WritePhysical( + ulong Offset, + IntPtr buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + int ReadControl( + uint Processor, + ulong Offset, + IntPtr buffer, + int BufferSize, + out uint BytesRead); + + [PreserveSig] + int WriteControl( + uint Processor, + ulong Offset, + IntPtr buffer, + int BufferSize, + out uint BytesWritten); + + [PreserveSig] + int ReadIo( + INTERFACE_TYPE InterfaceType, + uint BusNumber, + uint AddressSpace, + ulong Offset, + IntPtr buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + int WriteIo( + INTERFACE_TYPE InterfaceType, + uint BusNumber, + uint AddressSpace, + ulong Offset, + IntPtr buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + int ReadMsr( + uint Msr, + out ulong MsrValue); + + [PreserveSig] + int WriteMsr( + uint Msr, + ulong MsrValue); + + [PreserveSig] + int ReadBusData( + BUS_DATA_TYPE BusDataType, + uint BusNumber, + uint SlotNumber, + uint Offset, + IntPtr buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + int WriteBusData( + BUS_DATA_TYPE BusDataType, + uint BusNumber, + uint SlotNumber, + uint Offset, + IntPtr buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + int CheckLowMemory(); + + [PreserveSig] + int ReadDebuggerData( + uint Index, + IntPtr buffer, + uint BufferSize, + out uint DataSize); + + [PreserveSig] + int ReadProcessorSystemData( + uint Processor, + DEBUG_DATA Index, + IntPtr buffer, + uint BufferSize, + out uint DataSize); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugDataSpaces2.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugDataSpaces2.cs new file mode 100644 index 0000000000..afd9c3477d --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugDataSpaces2.cs @@ -0,0 +1,227 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("7a5e852f-96e9-468f-ac1b-0b3addc4a049")] + public interface IDebugDataSpaces2 : IDebugDataSpaces + { + /* IDebugDataSpaces */ + + [PreserveSig] + new int ReadVirtual( + ulong Offset, + [Out] + IntPtr buffer, + int BufferSize, + out int BytesRead); + + [PreserveSig] + new int WriteVirtual( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int SearchVirtual( + ulong Offset, + ulong Length, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] pattern, + uint PatternSize, + uint PatternGranularity, + out ulong MatchOffset); + + [PreserveSig] + new int ReadVirtualUncached( + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteVirtualUncached( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int ReadPointersVirtual( + uint Count, + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] + ulong[] Ptrs); + + [PreserveSig] + new int WritePointersVirtual( + uint Count, + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray)] ulong[] Ptrs); + + [PreserveSig] + new int ReadPhysical( + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WritePhysical( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int ReadControl( + uint Processor, + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + int BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteControl( + uint Processor, + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + int BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int ReadIo( + INTERFACE_TYPE InterfaceType, + uint BusNumber, + uint AddressSpace, + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteIo( + INTERFACE_TYPE InterfaceType, + uint BusNumber, + uint AddressSpace, + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int ReadMsr( + uint Msr, + out ulong MsrValue); + + [PreserveSig] + new int WriteMsr( + uint Msr, + ulong MsrValue); + + [PreserveSig] + new int ReadBusData( + BUS_DATA_TYPE BusDataType, + uint BusNumber, + uint SlotNumber, + uint Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteBusData( + BUS_DATA_TYPE BusDataType, + uint BusNumber, + uint SlotNumber, + uint Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int CheckLowMemory(); + + [PreserveSig] + new int ReadDebuggerData( + uint Index, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint DataSize); + + [PreserveSig] + new int ReadProcessorSystemData( + uint Processor, + DEBUG_DATA Index, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + uint BufferSize, + out uint DataSize); + + /* IDebugDataSpaces2 */ + + [PreserveSig] + int VirtualToPhysical( + ulong Virtual, + out ulong Physical); + + [PreserveSig] + int GetVirtualTranslationPhysicalOffsets( + ulong Virtual, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] Offsets, + uint OffsetsSize, + out uint Levels); + + [PreserveSig] + int ReadHandleData( + ulong Handle, + DEBUG_HANDLE_DATA_TYPE DataType, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + uint BufferSize, + out uint DataSize); + + [PreserveSig] + int FillVirtual( + ulong Start, + uint Size, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + uint PatternSize, + out uint Filled); + + [PreserveSig] + int FillPhysical( + ulong Start, + uint Size, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + uint PatternSize, + out uint Filled); + + [PreserveSig] + int QueryVirtual( + ulong Offset, + out MEMORY_BASIC_INFORMATION64 Info); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugDataSpaces3.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugDataSpaces3.cs new file mode 100644 index 0000000000..e995460693 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugDataSpaces3.cs @@ -0,0 +1,258 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("23f79d6c-8aaf-4f7c-a607-9995f5407e63")] + public interface IDebugDataSpaces3 : IDebugDataSpaces2 + { + /* IDebugDataSpaces */ + + [PreserveSig] + new int ReadVirtual( + ulong Offset, + [Out] + IntPtr buffer, + int BufferSize, + out int BytesRead); + + [PreserveSig] + new int WriteVirtual( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int SearchVirtual( + ulong Offset, + ulong Length, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] pattern, + uint PatternSize, + uint PatternGranularity, + out ulong MatchOffset); + + [PreserveSig] + new int ReadVirtualUncached( + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteVirtualUncached( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int ReadPointersVirtual( + uint Count, + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] + ulong[] Ptrs); + + [PreserveSig] + new int WritePointersVirtual( + uint Count, + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray)] ulong[] Ptrs); + + [PreserveSig] + new int ReadPhysical( + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WritePhysical( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int ReadControl( + uint Processor, + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + int BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteControl( + uint Processor, + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + int BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int ReadIo( + INTERFACE_TYPE InterfaceType, + uint BusNumber, + uint AddressSpace, + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteIo( + INTERFACE_TYPE InterfaceType, + uint BusNumber, + uint AddressSpace, + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int ReadMsr( + uint Msr, + out ulong MsrValue); + + [PreserveSig] + new int WriteMsr( + uint Msr, + ulong MsrValue); + + [PreserveSig] + new int ReadBusData( + BUS_DATA_TYPE BusDataType, + uint BusNumber, + uint SlotNumber, + uint Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteBusData( + BUS_DATA_TYPE BusDataType, + uint BusNumber, + uint SlotNumber, + uint Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int CheckLowMemory(); + + [PreserveSig] + new int ReadDebuggerData( + uint Index, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint DataSize); + + [PreserveSig] + new int ReadProcessorSystemData( + uint Processor, + DEBUG_DATA Index, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + uint BufferSize, + out uint DataSize); + + /* IDebugDataSpaces2 */ + + [PreserveSig] + new int VirtualToPhysical( + ulong Virtual, + out ulong Physical); + + [PreserveSig] + new int GetVirtualTranslationPhysicalOffsets( + ulong Virtual, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] Offsets, + uint OffsetsSize, + out uint Levels); + + [PreserveSig] + new int ReadHandleData( + ulong Handle, + DEBUG_HANDLE_DATA_TYPE DataType, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + uint BufferSize, + out uint DataSize); + + [PreserveSig] + new int FillVirtual( + ulong Start, + uint Size, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + uint PatternSize, + out uint Filled); + + [PreserveSig] + new int FillPhysical( + ulong Start, + uint Size, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + uint PatternSize, + out uint Filled); + + [PreserveSig] + new int QueryVirtual( + ulong Offset, + out MEMORY_BASIC_INFORMATION64 Info); + + /* IDebugDataSpaces3 */ + + [PreserveSig] + int ReadImageNtHeaders( + ulong ImageBase, + out IMAGE_NT_HEADERS64 Headers); + + [PreserveSig] + int ReadTagged( + [In][MarshalAs(UnmanagedType.LPStruct)] + Guid Tag, + uint Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + uint BufferSize, + out uint TotalSize); + + [PreserveSig] + int StartEnumTagged( + out ulong Handle); + + [PreserveSig] + int GetNextTagged( + ulong Handle, + out Guid Tag, + out uint Size); + + [PreserveSig] + int EndEnumTagged( + ulong Handle); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugDataSpaces4.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugDataSpaces4.cs new file mode 100644 index 0000000000..4886e22167 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugDataSpaces4.cs @@ -0,0 +1,346 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("d98ada1f-29e9-4ef5-a6c0-e53349883212")] + public interface IDebugDataSpaces4 : IDebugDataSpaces3 + { + /* IDebugDataSpaces */ + + [PreserveSig] + new int ReadVirtual( + ulong Offset, + [Out] + IntPtr buffer, + int BufferSize, + out int BytesRead); + + [PreserveSig] + new int WriteVirtual( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int SearchVirtual( + ulong Offset, + ulong Length, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] pattern, + uint PatternSize, + uint PatternGranularity, + out ulong MatchOffset); + + [PreserveSig] + new int ReadVirtualUncached( + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteVirtualUncached( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int ReadPointersVirtual( + uint Count, + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] + ulong[] Ptrs); + + [PreserveSig] + new int WritePointersVirtual( + uint Count, + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray)] ulong[] Ptrs); + + [PreserveSig] + new int ReadPhysical( + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WritePhysical( + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int ReadControl( + uint Processor, + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + int BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteControl( + uint Processor, + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + int BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int ReadIo( + INTERFACE_TYPE InterfaceType, + uint BusNumber, + uint AddressSpace, + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteIo( + INTERFACE_TYPE InterfaceType, + uint BusNumber, + uint AddressSpace, + ulong Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int ReadMsr( + uint Msr, + out ulong MsrValue); + + [PreserveSig] + new int WriteMsr( + uint Msr, + ulong MsrValue); + + [PreserveSig] + new int ReadBusData( + BUS_DATA_TYPE BusDataType, + uint BusNumber, + uint SlotNumber, + uint Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteBusData( + BUS_DATA_TYPE BusDataType, + uint BusNumber, + uint SlotNumber, + uint Offset, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 5)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int CheckLowMemory(); + + [PreserveSig] + new int ReadDebuggerData( + uint Index, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] + byte[] buffer, + uint BufferSize, + out uint DataSize); + + [PreserveSig] + new int ReadProcessorSystemData( + uint Processor, + DEBUG_DATA Index, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + uint BufferSize, + out uint DataSize); + + /* IDebugDataSpaces2 */ + + [PreserveSig] + new int VirtualToPhysical( + ulong Virtual, + out ulong Physical); + + [PreserveSig] + new int GetVirtualTranslationPhysicalOffsets( + ulong Virtual, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] Offsets, + uint OffsetsSize, + out uint Levels); + + [PreserveSig] + new int ReadHandleData( + ulong Handle, + DEBUG_HANDLE_DATA_TYPE DataType, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + uint BufferSize, + out uint DataSize); + + [PreserveSig] + new int FillVirtual( + ulong Start, + uint Size, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + uint PatternSize, + out uint Filled); + + [PreserveSig] + new int FillPhysical( + ulong Start, + uint Size, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + uint PatternSize, + out uint Filled); + + [PreserveSig] + new int QueryVirtual( + ulong Offset, + out MEMORY_BASIC_INFORMATION64 Info); + + /* IDebugDataSpaces3 */ + + [PreserveSig] + new int ReadImageNtHeaders( + ulong ImageBase, + out IMAGE_NT_HEADERS64 Headers); + + [PreserveSig] + new int ReadTagged( + [In][MarshalAs(UnmanagedType.LPStruct)] + Guid Tag, + uint Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + uint BufferSize, + out uint TotalSize); + + [PreserveSig] + new int StartEnumTagged( + out ulong Handle); + + [PreserveSig] + new int GetNextTagged( + ulong Handle, + out Guid Tag, + out uint Size); + + [PreserveSig] + new int EndEnumTagged( + ulong Handle); + + /* IDebugDataSpaces4 */ + + [PreserveSig] + int GetOffsetInformation( + DEBUG_DATA_SPACE Space, + DEBUG_OFFSINFO Which, + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] + byte[] buffer, + uint BufferSize, + out uint InfoSize); + + [PreserveSig] + int GetNextDifferentlyValidOffsetVirtual( + ulong Offset, + out ulong NextOffset); + + [PreserveSig] + int GetValidRegionVirtual( + ulong Base, + uint Size, + out ulong ValidBase, + out uint ValidSize); + + [PreserveSig] + int SearchVirtual2( + ulong Offset, + ulong Length, + DEBUG_VSEARCH Flags, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] + byte[] buffer, + uint PatternSize, + uint PatternGranularity, + out ulong MatchOffset); + + [PreserveSig] + int ReadMultiByteStringVirtual( + ulong Offset, + uint MaxBytes, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + uint BufferSize, + out uint StringBytes); + + [PreserveSig] + int ReadMultiByteStringVirtualWide( + ulong Offset, + uint MaxBytes, + CODE_PAGE CodePage, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + uint BufferSize, + out uint StringBytes); + + [PreserveSig] + int ReadUnicodeStringVirtual( + ulong Offset, + uint MaxBytes, + CODE_PAGE CodePage, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + uint BufferSize, + out uint StringBytes); + + [PreserveSig] + int ReadUnicodeStringVirtualWide( + ulong Offset, + uint MaxBytes, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + uint BufferSize, + out uint StringBytes); + + [PreserveSig] + int ReadPhysical2( + ulong Offset, + DEBUG_PHYSICAL Flags, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + int WritePhysical2( + ulong Offset, + DEBUG_PHYSICAL Flags, + [In][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] + byte[] buffer, + uint BufferSize, + out uint BytesWritten); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugEventCallbacks.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugEventCallbacks.cs new file mode 100644 index 0000000000..992d16574f --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugEventCallbacks.cs @@ -0,0 +1,95 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("337be28b-5036-4d72-b6bf-c45fbb9f2eaa")] + public interface IDebugEventCallbacks + { + [PreserveSig] + int GetInterestMask( + out DEBUG_EVENT Mask); + + [PreserveSig] + int Breakpoint( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugBreakpoint Bp); + + [PreserveSig] + int Exception( + in EXCEPTION_RECORD64 Exception, + uint FirstChance); + + [PreserveSig] + int CreateThread( + ulong Handle, + ulong DataOffset, + ulong StartOffset); + + [PreserveSig] + int ExitThread( + uint ExitCode); + + [PreserveSig] + int CreateProcess( + ulong ImageFileHandle, + ulong Handle, + ulong BaseOffset, + uint ModuleSize, + [In][MarshalAs(UnmanagedType.LPStr)] string ModuleName, + [In][MarshalAs(UnmanagedType.LPStr)] string ImageName, + uint CheckSum, + uint TimeDateStamp, + ulong InitialThreadHandle, + ulong ThreadDataOffset, + ulong StartOffset); + + [PreserveSig] + int ExitProcess( + uint ExitCode); + + [PreserveSig] + int LoadModule( + ulong ImageFileHandle, + ulong BaseOffset, + uint ModuleSize, + [In][MarshalAs(UnmanagedType.LPStr)] string ModuleName, + [In][MarshalAs(UnmanagedType.LPStr)] string ImageName, + uint CheckSum, + uint TimeDateStamp); + + [PreserveSig] + int UnloadModule( + [In][MarshalAs(UnmanagedType.LPStr)] string ImageBaseName, + ulong BaseOffset); + + [PreserveSig] + int SystemError( + uint Error, + uint Level); + + [PreserveSig] + int SessionStatus( + DEBUG_SESSION Status); + + [PreserveSig] + int ChangeDebuggeeState( + DEBUG_CDS Flags, + ulong Argument); + + [PreserveSig] + int ChangeEngineState( + DEBUG_CES Flags, + ulong Argument); + + [PreserveSig] + int ChangeSymbolState( + DEBUG_CSS Flags, + ulong Argument); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugEventCallbacksWide.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugEventCallbacksWide.cs new file mode 100644 index 0000000000..ebddc71987 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugEventCallbacksWide.cs @@ -0,0 +1,95 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("0690e046-9c23-45ac-a04f-987ac29ad0d3")] + public interface IDebugEventCallbacksWide + { + [PreserveSig] + int GetInterestMask( + out DEBUG_EVENT Mask); + + [PreserveSig] + int Breakpoint( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugBreakpoint2 Bp); + + [PreserveSig] + int Exception( + in EXCEPTION_RECORD64 Exception, + uint FirstChance); + + [PreserveSig] + int CreateThread( + ulong Handle, + ulong DataOffset, + ulong StartOffset); + + [PreserveSig] + int ExitThread( + uint ExitCode); + + [PreserveSig] + int CreateProcess( + ulong ImageFileHandle, + ulong Handle, + ulong BaseOffset, + uint ModuleSize, + [In][MarshalAs(UnmanagedType.LPWStr)] string ModuleName, + [In][MarshalAs(UnmanagedType.LPWStr)] string ImageName, + uint CheckSum, + uint TimeDateStamp, + ulong InitialThreadHandle, + ulong ThreadDataOffset, + ulong StartOffset); + + [PreserveSig] + int ExitProcess( + uint ExitCode); + + [PreserveSig] + int LoadModule( + ulong ImageFileHandle, + ulong BaseOffset, + uint ModuleSize, + [In][MarshalAs(UnmanagedType.LPWStr)] string ModuleName, + [In][MarshalAs(UnmanagedType.LPWStr)] string ImageName, + uint CheckSum, + uint TimeDateStamp); + + [PreserveSig] + int UnloadModule( + [In][MarshalAs(UnmanagedType.LPWStr)] string ImageBaseName, + ulong BaseOffset); + + [PreserveSig] + int SystemError( + uint Error, + uint Level); + + [PreserveSig] + int SessionStatus( + DEBUG_SESSION Status); + + [PreserveSig] + int ChangeDebuggeeState( + DEBUG_CDS Flags, + ulong Argument); + + [PreserveSig] + int ChangeEngineState( + DEBUG_CES Flags, + ulong Argument); + + [PreserveSig] + int ChangeSymbolState( + DEBUG_CSS Flags, + ulong Argument); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugEventContextCallbacks.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugEventContextCallbacks.cs new file mode 100644 index 0000000000..0e6ad79923 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugEventContextCallbacks.cs @@ -0,0 +1,117 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("61a4905b-23f9-4247-b3c5-53d087529ab7")] + public unsafe interface IDebugEventContextCallbacks + { + [PreserveSig] + int GetInterestMask( + out DEBUG_EVENT Mask); + + [PreserveSig] + int Breakpoint( + [In][MarshalAs(UnmanagedType.Interface)] + IDebugBreakpoint2 Bp, + in DEBUG_EVENT_CONTEXT Context, + uint ContextSize); + + [PreserveSig] + int Exception( + in EXCEPTION_RECORD64 Exception, + uint FirstChance, + in DEBUG_EVENT_CONTEXT Context, + uint ContextSize); + + [PreserveSig] + int CreateThread( + ulong Handle, + ulong DataOffset, + ulong StartOffset, + in DEBUG_EVENT_CONTEXT Context, + uint ContextSize); + + [PreserveSig] + int ExitThread( + uint ExitCode, + in DEBUG_EVENT_CONTEXT Context, + uint ContextSize); + + [PreserveSig] + int CreateProcess( + ulong ImageFileHandle, + ulong Handle, + ulong BaseOffset, + uint ModuleSize, + [In][MarshalAs(UnmanagedType.LPWStr)] string ModuleName, + [In][MarshalAs(UnmanagedType.LPWStr)] string ImageName, + uint CheckSum, + uint TimeDateStamp, + ulong InitialThreadHandle, + ulong ThreadDataOffset, + ulong StartOffset, + in DEBUG_EVENT_CONTEXT Context, + uint ContextSize); + + [PreserveSig] + int ExitProcess( + uint ExitCode, + in DEBUG_EVENT_CONTEXT Context, + uint ContextSize); + + [PreserveSig] + int LoadModule( + ulong ImageFileHandle, + ulong BaseOffset, + uint ModuleSize, + [In][MarshalAs(UnmanagedType.LPWStr)] string ModuleName, + [In][MarshalAs(UnmanagedType.LPWStr)] string ImageName, + uint CheckSum, + uint TimeDateStamp, + in DEBUG_EVENT_CONTEXT Context, + uint ContextSize); + + [PreserveSig] + int UnloadModule( + [In][MarshalAs(UnmanagedType.LPWStr)] string ImageBaseName, + ulong BaseOffset, + in DEBUG_EVENT_CONTEXT Context, + uint ContextSize); + + [PreserveSig] + int SystemError( + uint Error, + uint Level, + in DEBUG_EVENT_CONTEXT Context, + uint ContextSize); + + [PreserveSig] + int SessionStatus( + DEBUG_SESSION Status); + + [PreserveSig] + int ChangeDebuggeeState( + DEBUG_CDS Flags, + ulong Argument, + in DEBUG_EVENT_CONTEXT Context, + uint ContextSize); + + [PreserveSig] + int ChangeEngineState( + DEBUG_CES Flags, + ulong Argument, + in DEBUG_EVENT_CONTEXT Context, + uint ContextSize); + + [PreserveSig] + int ChangeSymbolState( + DEBUG_CSS Flags, + ulong Argument); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugInputCallbacks.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugInputCallbacks.cs new file mode 100644 index 0000000000..ee65369df1 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugInputCallbacks.cs @@ -0,0 +1,21 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("9f50e42c-f136-499e-9a97-73036c94ed2d")] + public interface IDebugInputCallbacks + { + [PreserveSig] + int StartInput( + uint BufferSize); + + [PreserveSig] + int EndInput(); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugOutputCallbacks.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugOutputCallbacks.cs new file mode 100644 index 0000000000..cca6eb5729 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugOutputCallbacks.cs @@ -0,0 +1,19 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("4bf58045-d654-4c40-b0af-683090f356dc")] + public interface IDebugOutputCallbacks + { + [PreserveSig] + int Output( + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Text); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugOutputCallbacks2.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugOutputCallbacks2.cs new file mode 100644 index 0000000000..0637901f58 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugOutputCallbacks2.cs @@ -0,0 +1,37 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("67721fe9-56d2-4a44-a325-2b65513ce6eb")] + public interface IDebugOutputCallbacks2 : IDebugOutputCallbacks + { + /* IDebugOutputCallbacks */ + + /// <summary> + /// This method is not used. + /// </summary> + [PreserveSig] + new int Output( + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPStr)] string Text); + + /* IDebugOutputCallbacks2 */ + + [PreserveSig] + int GetInterestMask( + out DEBUG_OUTCBI Mask); + + [PreserveSig] + int Output2( + DEBUG_OUTCB Which, + DEBUG_OUTCBF Flags, + ulong Arg, + [In][MarshalAs(UnmanagedType.LPWStr)] string Text); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugOutputCallbacksWide.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugOutputCallbacksWide.cs new file mode 100644 index 0000000000..9fefcaab82 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugOutputCallbacksWide.cs @@ -0,0 +1,19 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("4c7fd663-c394-4e26-8ef1-34ad5ed3764c")] + public interface IDebugOutputCallbacksWide + { + [PreserveSig] + int Output( + DEBUG_OUTPUT Mask, + [In][MarshalAs(UnmanagedType.LPWStr)] string Text); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugRegisters.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugRegisters.cs new file mode 100644 index 0000000000..5f4b718e85 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugRegisters.cs @@ -0,0 +1,74 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("ce289126-9e84-45a7-937e-67bb18691493")] + public interface IDebugRegisters + { + [PreserveSig] + int GetNumberRegisters( + out uint Number); + + [PreserveSig] + int GetDescription( + uint Register, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out DEBUG_REGISTER_DESCRIPTION Desc); + + [PreserveSig] + int GetIndexByName( + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + out uint Index); + + [PreserveSig] + int GetValue( + uint Register, + out DEBUG_VALUE Value); + + [PreserveSig] + int SetValue( + uint Register, + in DEBUG_VALUE Value); + + [PreserveSig] + int GetValues( //FIX ME!!! This needs to be tested + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Indices, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_VALUE[] Values); + + [PreserveSig] + int SetValues( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Indices, + uint Start, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_VALUE[] Values); + + [PreserveSig] + int OutputRegisters( + DEBUG_OUTCTL OutputControl, + DEBUG_REGISTERS Flags); + + [PreserveSig] + int GetInstructionOffset( + out ulong Offset); + + [PreserveSig] + int GetStackOffset( + out ulong Offset); + + [PreserveSig] + int GetFrameOffset( + out ulong Offset); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugRegisters2.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugRegisters2.cs new file mode 100644 index 0000000000..ffe3f0f2ff --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugRegisters2.cs @@ -0,0 +1,189 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("1656afa9-19c6-4e3a-97e7-5dc9160cf9c4")] + public interface IDebugRegisters2 : IDebugRegisters + { + [PreserveSig] + new int GetNumberRegisters( + out uint Number); + + [PreserveSig] + new int GetDescription( + uint Register, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out DEBUG_REGISTER_DESCRIPTION Desc); + + [PreserveSig] + new int GetIndexByName( + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + out uint Index); + + [PreserveSig] + new int GetValue( + uint Register, + out DEBUG_VALUE Value); + + [PreserveSig] + new int SetValue( + uint Register, + in DEBUG_VALUE Value); + + [PreserveSig] + new int GetValues( //FIX ME!!! This needs to be tested + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Indices, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_VALUE[] Values); + + [PreserveSig] + new int SetValues( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Indices, + uint Start, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_VALUE[] Values); + + [PreserveSig] + new int OutputRegisters( + DEBUG_OUTCTL OutputControl, + DEBUG_REGISTERS Flags); + + [PreserveSig] + new int GetInstructionOffset( + out ulong Offset); + + [PreserveSig] + new int GetStackOffset( + out ulong Offset); + + [PreserveSig] + new int GetFrameOffset( + out ulong Offset); + + /* IDebugRegisters2 */ + + [PreserveSig] + int GetDescriptionWide( + uint Register, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out DEBUG_REGISTER_DESCRIPTION Desc); + + [PreserveSig] + int GetIndexByNameWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Name, + out uint Index); + + [PreserveSig] + int GetNumberPseudoRegisters( + out uint Number + ); + + [PreserveSig] + int GetPseudoDescription( + uint Register, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong TypeModule, + out uint TypeId + ); + + [PreserveSig] + int GetPseudoDescriptionWide( + uint Register, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong TypeModule, + out uint TypeId + ); + + [PreserveSig] + int GetPseudoIndexByName( + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + out uint Index + ); + + [PreserveSig] + int GetPseudoIndexByNameWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Name, + out uint Index + ); + + [PreserveSig] + int GetPseudoValues( + uint Source, + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Indices, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_VALUE[] Values + ); + + [PreserveSig] + int SetPseudoValues( + uint Source, + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Indices, + uint Start, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_VALUE[] Values + ); + + [PreserveSig] + int GetValues2( + DEBUG_REGSRC Source, + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Indices, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_VALUE[] Values + ); + + [PreserveSig] + int SetValues2( + uint Source, + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] uint[] Indices, + uint Start, + [In][MarshalAs(UnmanagedType.LPArray)] DEBUG_VALUE[] Values + ); + + [PreserveSig] + int OutputRegisters2( + uint OutputControl, + uint Source, + uint Flags + ); + + [PreserveSig] + int GetInstructionOffset2( + uint Source, + out ulong Offset + ); + + [PreserveSig] + int GetStackOffset2( + uint Source, + out ulong Offset + ); + + [PreserveSig] + int GetFrameOffset2( + uint Source, + out ulong Offset + ); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbolGroup.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbolGroup.cs new file mode 100644 index 0000000000..a4c6952b6a --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbolGroup.cs @@ -0,0 +1,70 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("f2528316-0f1a-4431-aeed-11d096e1e2ab")] + public interface IDebugSymbolGroup + { + /* IDebugSymbolGroup */ + + [PreserveSig] + int GetNumberSymbols( + out uint Number); + + [PreserveSig] + int AddSymbol( + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + ref uint Index); + + [PreserveSig] + int RemoveSymbolByName( + [In][MarshalAs(UnmanagedType.LPStr)] string Name); + + [PreserveSig] + int RemoveSymbolsByIndex( + uint Index); + + [PreserveSig] + int GetSymbolName( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + int GetSymbolParameters( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_SYMBOL_PARAMETERS[] Params); + + [PreserveSig] + int ExpandSymbol( + uint Index, + [In][MarshalAs(UnmanagedType.Bool)] bool Expand); + + [PreserveSig] + int OutputSymbols( + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT_SYMBOLS Flags, + uint Start, + uint Count); + + [PreserveSig] + int WriteSymbol( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Value); + + [PreserveSig] + int OutputAsType( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Type); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbolGroup2.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbolGroup2.cs new file mode 100644 index 0000000000..46b3cf515e --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbolGroup2.cs @@ -0,0 +1,146 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("6a7ccc5f-fb5e-4dcc-b41c-6c20307bccc7")] + public interface IDebugSymbolGroup2 : IDebugSymbolGroup + { + /* IDebugSymbolGroup */ + + [PreserveSig] + new int GetNumberSymbols( + out uint Number); + + [PreserveSig] + new int AddSymbol( + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + ref uint Index); + + [PreserveSig] + new int RemoveSymbolByName( + [In][MarshalAs(UnmanagedType.LPStr)] string Name); + + [PreserveSig] + new int RemoveSymbolsByIndex( + uint Index); + + [PreserveSig] + new int GetSymbolName( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + new int GetSymbolParameters( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_SYMBOL_PARAMETERS[] Params); + + [PreserveSig] + new int ExpandSymbol( + uint Index, + [In][MarshalAs(UnmanagedType.Bool)] bool Expand); + + [PreserveSig] + new int OutputSymbols( + DEBUG_OUTCTL OutputControl, + DEBUG_OUTPUT_SYMBOLS Flags, + uint Start, + uint Count); + + [PreserveSig] + new int WriteSymbol( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Value); + + [PreserveSig] + new int OutputAsType( + uint Index, + [In][MarshalAs(UnmanagedType.LPStr)] string Type); + + /* IDebugSymbolGroup2 */ + + [PreserveSig] + int AddSymbolWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Name, + ref uint Index); + + [PreserveSig] + int RemoveSymbolByNameWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Name); + + [PreserveSig] + int GetSymbolNameWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + int WriteSymbolWide( + uint Index, + [In][MarshalAs(UnmanagedType.LPWStr)] string Value); + + [PreserveSig] + int OutputAsTypeWide( + uint Index, + [In][MarshalAs(UnmanagedType.LPWStr)] string Type); + + [PreserveSig] + int GetSymbolTypeName( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + int GetSymbolTypeNameWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + int GetSymbolSize( + uint Index, + out uint Size); + + [PreserveSig] + int GetSymbolOffset( + uint Index, + out ulong Offset); + + [PreserveSig] + int GetSymbolRegister( + uint Index, + out uint Register); + + [PreserveSig] + int GetSymbolValueText( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + int GetSymbolValueTextWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + int GetSymbolEntryInformation( + uint Index, + out DEBUG_SYMBOL_ENTRY Info); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols.cs new file mode 100644 index 0000000000..20b2c28e09 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols.cs @@ -0,0 +1,332 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("8c31e98c-983a-48a5-9016-6fe5d667a950")] + public interface IDebugSymbols + { + /* IDebugSymbols */ + + [PreserveSig] + int GetSymbolOptions( + out SYMOPT Options); + + [PreserveSig] + int AddSymbolOptions( + SYMOPT Options); + + [PreserveSig] + int RemoveSymbolOptions( + SYMOPT Options); + + [PreserveSig] + int SetSymbolOptions( + SYMOPT Options); + + [PreserveSig] + int GetNameByOffset( + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement); + + [PreserveSig] + int GetOffsetByName( + [In][MarshalAs(UnmanagedType.LPStr)] string Symbol, + out ulong Offset); + + [PreserveSig] + int GetNearNameByOffset( + ulong Offset, + int Delta, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement); + + [PreserveSig] + int GetLineByOffset( + ulong Offset, + out uint Line, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder FileBuffer, + int FileBufferSize, + out uint FileSize, + out ulong Displacement); + + [PreserveSig] + int GetOffsetByLine( + uint Line, + [In][MarshalAs(UnmanagedType.LPStr)] string File, + out ulong Offset); + + [PreserveSig] + int GetNumberModules( + out uint Loaded, + out uint Unloaded); + + [PreserveSig] + int GetModuleByIndex( + uint Index, + out ulong Base); + + [PreserveSig] + int GetModuleByModuleName( + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + uint StartIndex, + out uint Index, + out ulong Base); + + [PreserveSig] + int GetModuleByOffset( + ulong Offset, + uint StartIndex, + out uint Index, + out ulong Base); + + [PreserveSig] + int GetModuleNames( + uint Index, + ulong Base, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ImageNameBuffer, + int ImageNameBufferSize, + out uint ImageNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ModuleNameBuffer, + int ModuleNameBufferSize, + out uint ModuleNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder LoadedImageNameBuffer, + int LoadedImageNameBufferSize, + out uint LoadedImageNameSize); + + [PreserveSig] + int GetModuleParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] ulong[] Bases, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_MODULE_PARAMETERS[] Params); + + [PreserveSig] + int GetSymbolModule( + [In][MarshalAs(UnmanagedType.LPStr)] string Symbol, + out ulong Base); + + [PreserveSig] + int GetTypeName( + ulong Module, + uint TypeId, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize); + + [PreserveSig] + int GetTypeId( + ulong Module, + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + out uint TypeId); + + [PreserveSig] + int GetTypeSize( + ulong Module, + uint TypeId, + out uint Size); + + [PreserveSig] + int GetFieldOffset( + ulong Module, + uint TypeId, + [In][MarshalAs(UnmanagedType.LPStr)] string Field, + out uint Offset); + + [PreserveSig] + int GetSymbolTypeId( + [In][MarshalAs(UnmanagedType.LPStr)] string Symbol, + out uint TypeId, + out ulong Module); + + [PreserveSig] + int GetOffsetTypeId( + ulong Offset, + out uint TypeId, + out ulong Module); + + [PreserveSig] + int ReadTypedDataVirtual( + ulong Offset, + ulong Module, + uint TypeId, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] + byte[] Buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + int WriteTypedDataVirtual( + ulong Offset, + ulong Module, + uint TypeId, + IntPtr Buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + int OutputTypedDataVirtual( + DEBUG_OUTCTL OutputControl, + ulong Offset, + ulong Module, + uint TypeId, + DEBUG_TYPEOPTS Flags); + + [PreserveSig] + int ReadTypedDataPhysical( + ulong Offset, + ulong Module, + uint TypeId, + IntPtr Buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + int WriteTypedDataPhysical( + ulong Offset, + ulong Module, + uint TypeId, + IntPtr Buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + int OutputTypedDataPhysical( + DEBUG_OUTCTL OutputControl, + ulong Offset, + ulong Module, + uint TypeId, + DEBUG_TYPEOPTS Flags); + + [PreserveSig] + int GetScope( + out ulong InstructionOffset, + out DEBUG_STACK_FRAME ScopeFrame, + IntPtr ScopeContext, + uint ScopeContextSize); + + [PreserveSig] + int SetScope( + ulong InstructionOffset, + in DEBUG_STACK_FRAME ScopeFrame, + IntPtr ScopeContext, + uint ScopeContextSize); + + [PreserveSig] + int ResetScope(); + + [PreserveSig] + int GetScopeSymbolGroup( + DEBUG_SCOPE_GROUP Flags, + [In][MarshalAs(UnmanagedType.Interface)] + IDebugSymbolGroup Update, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugSymbolGroup Symbols); + + [PreserveSig] + int CreateSymbolGroup( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugSymbolGroup Group); + + [PreserveSig] + int StartSymbolMatch( + [In][MarshalAs(UnmanagedType.LPStr)] string Pattern, + out ulong Handle); + + [PreserveSig] + int GetNextSymbolMatch( + ulong Handle, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint MatchSize, + out ulong Offset); + + [PreserveSig] + int EndSymbolMatch( + ulong Handle); + + [PreserveSig] + int Reload( + [In][MarshalAs(UnmanagedType.LPStr)] string Module); + + [PreserveSig] + int GetSymbolPath( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + int SetSymbolPath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path); + + [PreserveSig] + int AppendSymbolPath( + [In][MarshalAs(UnmanagedType.LPStr)] string Addition); + + [PreserveSig] + int GetImagePath( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + int SetImagePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path); + + [PreserveSig] + int AppendImagePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Addition); + + [PreserveSig] + int GetSourcePath( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + int GetSourcePathElement( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint ElementSize); + + [PreserveSig] + int SetSourcePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path); + + [PreserveSig] + int AppendSourcePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Addition); + + [PreserveSig] + int FindSourceFile( + uint StartElement, + [In][MarshalAs(UnmanagedType.LPStr)] string File, + DEBUG_FIND_SOURCE Flags, + out uint FoundElement, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint FoundSize); + + [PreserveSig] + int GetSourceFileLineOffsets( + [In][MarshalAs(UnmanagedType.LPStr)] string File, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] Buffer, + int BufferLines, + out uint FileLines); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols2.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols2.cs new file mode 100644 index 0000000000..7a82114b2f --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols2.cs @@ -0,0 +1,387 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("3a707211-afdd-4495-ad4f-56fecdf8163f")] + public interface IDebugSymbols2 : IDebugSymbols + { + /* IDebugSymbols */ + + [PreserveSig] + new int GetSymbolOptions( + out SYMOPT Options); + + [PreserveSig] + new int AddSymbolOptions( + SYMOPT Options); + + [PreserveSig] + new int RemoveSymbolOptions( + SYMOPT Options); + + [PreserveSig] + new int SetSymbolOptions( + SYMOPT Options); + + [PreserveSig] + new int GetNameByOffset( + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement); + + [PreserveSig] + new int GetOffsetByName( + [In][MarshalAs(UnmanagedType.LPStr)] string Symbol, + out ulong Offset); + + [PreserveSig] + new int GetNearNameByOffset( + ulong Offset, + int Delta, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement); + + [PreserveSig] + new int GetLineByOffset( + ulong Offset, + out uint Line, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder FileBuffer, + int FileBufferSize, + out uint FileSize, + out ulong Displacement); + + [PreserveSig] + new int GetOffsetByLine( + uint Line, + [In][MarshalAs(UnmanagedType.LPStr)] string File, + out ulong Offset); + + [PreserveSig] + new int GetNumberModules( + out uint Loaded, + out uint Unloaded); + + [PreserveSig] + new int GetModuleByIndex( + uint Index, + out ulong Base); + + [PreserveSig] + new int GetModuleByModuleName( + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + uint StartIndex, + out uint Index, + out ulong Base); + + [PreserveSig] + new int GetModuleByOffset( + ulong Offset, + uint StartIndex, + out uint Index, + out ulong Base); + + [PreserveSig] + new int GetModuleNames( + uint Index, + ulong Base, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ImageNameBuffer, + int ImageNameBufferSize, + out uint ImageNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ModuleNameBuffer, + int ModuleNameBufferSize, + out uint ModuleNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder LoadedImageNameBuffer, + int LoadedImageNameBufferSize, + out uint LoadedImageNameSize); + + [PreserveSig] + new int GetModuleParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] ulong[] Bases, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_MODULE_PARAMETERS[] Params); + + [PreserveSig] + new int GetSymbolModule( + [In][MarshalAs(UnmanagedType.LPStr)] string Symbol, + out ulong Base); + + [PreserveSig] + new int GetTypeName( + ulong Module, + uint TypeId, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize); + + [PreserveSig] + new int GetTypeId( + ulong Module, + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + out uint TypeId); + + [PreserveSig] + new int GetTypeSize( + ulong Module, + uint TypeId, + out uint Size); + + [PreserveSig] + new int GetFieldOffset( + ulong Module, + uint TypeId, + [In][MarshalAs(UnmanagedType.LPStr)] string Field, + out uint Offset); + + [PreserveSig] + new int GetSymbolTypeId( + [In][MarshalAs(UnmanagedType.LPStr)] string Symbol, + out uint TypeId, + out ulong Module); + + [PreserveSig] + new int GetOffsetTypeId( + ulong Offset, + out uint TypeId, + out ulong Module); + + [PreserveSig] + new int ReadTypedDataVirtual( + ulong Offset, + ulong Module, + uint TypeId, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] + byte[] Buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteTypedDataVirtual( + ulong Offset, + ulong Module, + uint TypeId, + IntPtr Buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int OutputTypedDataVirtual( + DEBUG_OUTCTL OutputControl, + ulong Offset, + ulong Module, + uint TypeId, + DEBUG_TYPEOPTS Flags); + + [PreserveSig] + new int ReadTypedDataPhysical( + ulong Offset, + ulong Module, + uint TypeId, + IntPtr Buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteTypedDataPhysical( + ulong Offset, + ulong Module, + uint TypeId, + IntPtr Buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int OutputTypedDataPhysical( + DEBUG_OUTCTL OutputControl, + ulong Offset, + ulong Module, + uint TypeId, + DEBUG_TYPEOPTS Flags); + + [PreserveSig] + new int GetScope( + out ulong InstructionOffset, + out DEBUG_STACK_FRAME ScopeFrame, + IntPtr ScopeContext, + uint ScopeContextSize); + + [PreserveSig] + new int SetScope( + ulong InstructionOffset, + in DEBUG_STACK_FRAME ScopeFrame, + IntPtr ScopeContext, + uint ScopeContextSize); + + [PreserveSig] + new int ResetScope(); + + [PreserveSig] + new int GetScopeSymbolGroup( + DEBUG_SCOPE_GROUP Flags, + [In][MarshalAs(UnmanagedType.Interface)] + IDebugSymbolGroup Update, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugSymbolGroup Symbols); + + [PreserveSig] + new int CreateSymbolGroup( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugSymbolGroup Group); + + [PreserveSig] + new int StartSymbolMatch( + [In][MarshalAs(UnmanagedType.LPStr)] string Pattern, + out ulong Handle); + + [PreserveSig] + new int GetNextSymbolMatch( + ulong Handle, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint MatchSize, + out ulong Offset); + + [PreserveSig] + new int EndSymbolMatch( + ulong Handle); + + [PreserveSig] + new int Reload( + [In][MarshalAs(UnmanagedType.LPStr)] string Module); + + [PreserveSig] + new int GetSymbolPath( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + new int SetSymbolPath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path); + + [PreserveSig] + new int AppendSymbolPath( + [In][MarshalAs(UnmanagedType.LPStr)] string Addition); + + [PreserveSig] + new int GetImagePath( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + new int SetImagePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path); + + [PreserveSig] + new int AppendImagePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Addition); + + [PreserveSig] + new int GetSourcePath( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + new int GetSourcePathElement( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint ElementSize); + + [PreserveSig] + new int SetSourcePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path); + + [PreserveSig] + new int AppendSourcePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Addition); + + [PreserveSig] + new int FindSourceFile( + uint StartElement, + [In][MarshalAs(UnmanagedType.LPStr)] string File, + DEBUG_FIND_SOURCE Flags, + out uint FoundElement, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint FoundSize); + + [PreserveSig] + new int GetSourceFileLineOffsets( + [In][MarshalAs(UnmanagedType.LPStr)] string File, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] Buffer, + int BufferLines, + out uint FileLines); + + /* IDebugSymbols2 */ + + [PreserveSig] + int GetModuleVersionInformation( + uint Index, + ulong Base, + [In][MarshalAs(UnmanagedType.LPStr)] string Item, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] + byte[] buffer, + uint BufferSize, + out uint VerInfoSize); + + [PreserveSig] + int GetModuleNameString( + DEBUG_MODNAME Which, + uint Index, + ulong Base, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + uint BufferSize, + out uint NameSize); + + [PreserveSig] + int GetConstantName( + ulong Module, + uint TypeId, + ulong Value, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + int GetFieldName( + ulong Module, + uint TypeId, + uint FieldIndex, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + int GetTypeOptions( + out DEBUG_TYPEOPTS Options); + + [PreserveSig] + int AddTypeOptions( + DEBUG_TYPEOPTS Options); + + [PreserveSig] + int RemoveTypeOptions( + DEBUG_TYPEOPTS Options); + + [PreserveSig] + int SetTypeOptions( + DEBUG_TYPEOPTS Options); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols3.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols3.cs new file mode 100644 index 0000000000..7df1ad12a7 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols3.cs @@ -0,0 +1,889 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("f02fbecc-50ac-4f36-9ad9-c975e8f32ff8")] + public interface IDebugSymbols3 : IDebugSymbols2 + { + /* IDebugSymbols */ + + [PreserveSig] + new int GetSymbolOptions( + out SYMOPT Options); + + [PreserveSig] + new int AddSymbolOptions( + SYMOPT Options); + + [PreserveSig] + new int RemoveSymbolOptions( + SYMOPT Options); + + [PreserveSig] + new int SetSymbolOptions( + SYMOPT Options); + + [PreserveSig] + new int GetNameByOffset( + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement); + + [PreserveSig] + new int GetOffsetByName( + [In][MarshalAs(UnmanagedType.LPStr)] string Symbol, + out ulong Offset); + + [PreserveSig] + new int GetNearNameByOffset( + ulong Offset, + int Delta, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement); + + [PreserveSig] + new int GetLineByOffset( + ulong Offset, + out uint Line, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder FileBuffer, + int FileBufferSize, + out uint FileSize, + out ulong Displacement); + + [PreserveSig] + new int GetOffsetByLine( + uint Line, + [In][MarshalAs(UnmanagedType.LPStr)] string File, + out ulong Offset); + + [PreserveSig] + new int GetNumberModules( + out uint Loaded, + out uint Unloaded); + + [PreserveSig] + new int GetModuleByIndex( + uint Index, + out ulong Base); + + [PreserveSig] + new int GetModuleByModuleName( + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + uint StartIndex, + out uint Index, + out ulong Base); + + [PreserveSig] + new int GetModuleByOffset( + ulong Offset, + uint StartIndex, + out uint Index, + out ulong Base); + + [PreserveSig] + new int GetModuleNames( + uint Index, + ulong Base, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ImageNameBuffer, + int ImageNameBufferSize, + out uint ImageNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ModuleNameBuffer, + int ModuleNameBufferSize, + out uint ModuleNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder LoadedImageNameBuffer, + int LoadedImageNameBufferSize, + out uint LoadedImageNameSize); + + [PreserveSig] + new int GetModuleParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] ulong[] Bases, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_MODULE_PARAMETERS[] Params); + + [PreserveSig] + new int GetSymbolModule( + [In][MarshalAs(UnmanagedType.LPStr)] string Symbol, + out ulong Base); + + [PreserveSig] + new int GetTypeName( + ulong Module, + uint TypeId, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize); + + [PreserveSig] + new int GetTypeId( + ulong Module, + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + out uint TypeId); + + [PreserveSig] + new int GetTypeSize( + ulong Module, + uint TypeId, + out uint Size); + + [PreserveSig] + new int GetFieldOffset( + ulong Module, + uint TypeId, + [In][MarshalAs(UnmanagedType.LPStr)] string Field, + out uint Offset); + + [PreserveSig] + new int GetSymbolTypeId( + [In][MarshalAs(UnmanagedType.LPStr)] string Symbol, + out uint TypeId, + out ulong Module); + + [PreserveSig] + new int GetOffsetTypeId( + ulong Offset, + out uint TypeId, + out ulong Module); + + [PreserveSig] + new int ReadTypedDataVirtual( + ulong Offset, + ulong Module, + uint TypeId, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] + byte[] Buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteTypedDataVirtual( + ulong Offset, + ulong Module, + uint TypeId, + IntPtr Buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int OutputTypedDataVirtual( + DEBUG_OUTCTL OutputControl, + ulong Offset, + ulong Module, + uint TypeId, + DEBUG_TYPEOPTS Flags); + + [PreserveSig] + new int ReadTypedDataPhysical( + ulong Offset, + ulong Module, + uint TypeId, + IntPtr Buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteTypedDataPhysical( + ulong Offset, + ulong Module, + uint TypeId, + IntPtr Buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int OutputTypedDataPhysical( + DEBUG_OUTCTL OutputControl, + ulong Offset, + ulong Module, + uint TypeId, + DEBUG_TYPEOPTS Flags); + + [PreserveSig] + new int GetScope( + out ulong InstructionOffset, + out DEBUG_STACK_FRAME ScopeFrame, + IntPtr ScopeContext, + uint ScopeContextSize); + + [PreserveSig] + new int SetScope( + ulong InstructionOffset, + in DEBUG_STACK_FRAME ScopeFrame, + IntPtr ScopeContext, + uint ScopeContextSize); + + [PreserveSig] + new int ResetScope(); + + [PreserveSig] + new int GetScopeSymbolGroup( + DEBUG_SCOPE_GROUP Flags, + [In][MarshalAs(UnmanagedType.Interface)] + IDebugSymbolGroup Update, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugSymbolGroup Symbols); + + [PreserveSig] + new int CreateSymbolGroup( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugSymbolGroup Group); + + [PreserveSig] + new int StartSymbolMatch( + [In][MarshalAs(UnmanagedType.LPStr)] string Pattern, + out ulong Handle); + + [PreserveSig] + new int GetNextSymbolMatch( + ulong Handle, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint MatchSize, + out ulong Offset); + + [PreserveSig] + new int EndSymbolMatch( + ulong Handle); + + [PreserveSig] + new int Reload( + [In][MarshalAs(UnmanagedType.LPStr)] string Module); + + [PreserveSig] + new int GetSymbolPath( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + new int SetSymbolPath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path); + + [PreserveSig] + new int AppendSymbolPath( + [In][MarshalAs(UnmanagedType.LPStr)] string Addition); + + [PreserveSig] + new int GetImagePath( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + new int SetImagePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path); + + [PreserveSig] + new int AppendImagePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Addition); + + [PreserveSig] + new int GetSourcePath( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + new int GetSourcePathElement( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint ElementSize); + + [PreserveSig] + new int SetSourcePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path); + + [PreserveSig] + new int AppendSourcePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Addition); + + [PreserveSig] + new int FindSourceFile( + uint StartElement, + [In][MarshalAs(UnmanagedType.LPStr)] string File, + DEBUG_FIND_SOURCE Flags, + out uint FoundElement, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint FoundSize); + + [PreserveSig] + new int GetSourceFileLineOffsets( + [In][MarshalAs(UnmanagedType.LPStr)] string File, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] Buffer, + int BufferLines, + out uint FileLines); + + /* IDebugSymbols2 */ + + [PreserveSig] + new int GetModuleVersionInformation( + uint Index, + ulong Base, + [In][MarshalAs(UnmanagedType.LPStr)] string Item, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] + byte[] buffer, + uint BufferSize, + out uint VerInfoSize); + + [PreserveSig] + new int GetModuleNameString( + DEBUG_MODNAME Which, + uint Index, + ulong Base, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + uint BufferSize, + out uint NameSize); + + [PreserveSig] + new int GetConstantName( + ulong Module, + uint TypeId, + ulong Value, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + new int GetFieldName( + ulong Module, + uint TypeId, + uint FieldIndex, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + new int GetTypeOptions( + out DEBUG_TYPEOPTS Options); + + [PreserveSig] + new int AddTypeOptions( + DEBUG_TYPEOPTS Options); + + [PreserveSig] + new int RemoveTypeOptions( + DEBUG_TYPEOPTS Options); + + [PreserveSig] + new int SetTypeOptions( + DEBUG_TYPEOPTS Options); + + /* IDebugSymbols3 */ + + [PreserveSig] + int GetNameByOffsetWide( + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement); + + [PreserveSig] + int GetOffsetByNameWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Symbol, + out ulong Offset); + + [PreserveSig] + int GetNearNameByOffsetWide( + ulong Offset, + int Delta, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement); + + [PreserveSig] + int GetLineByOffsetWide( + ulong Offset, + out uint Line, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder FileBuffer, + int FileBufferSize, + out uint FileSize, + out ulong Displacement); + + [PreserveSig] + int GetOffsetByLineWide( + uint Line, + [In][MarshalAs(UnmanagedType.LPWStr)] string File, + out ulong Offset); + + [PreserveSig] + int GetModuleByModuleNameWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Name, + uint StartIndex, + out uint Index, + out ulong Base); + + [PreserveSig] + int GetSymbolModuleWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Symbol, + out ulong Base); + + [PreserveSig] + int GetTypeNameWide( + ulong Module, + uint TypeId, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize); + + [PreserveSig] + int GetTypeIdWide( + ulong Module, + [In][MarshalAs(UnmanagedType.LPWStr)] string Name, + out uint TypeId); + + [PreserveSig] + int GetFieldOffsetWide( + ulong Module, + uint TypeId, + [In][MarshalAs(UnmanagedType.LPWStr)] string Field, + out uint Offset); + + [PreserveSig] + int GetSymbolTypeIdWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Symbol, + out uint TypeId, + out ulong Module); + + [PreserveSig] + int GetScopeSymbolGroup2( + DEBUG_SCOPE_GROUP Flags, + [In][MarshalAs(UnmanagedType.Interface)] + IDebugSymbolGroup2 Update, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugSymbolGroup2 Symbols); + + [PreserveSig] + int CreateSymbolGroup2( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugSymbolGroup2 Group); + + [PreserveSig] + int StartSymbolMatchWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Pattern, + out ulong Handle); + + [PreserveSig] + int GetNextSymbolMatchWide( + ulong Handle, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint MatchSize, + out ulong Offset); + + [PreserveSig] + int ReloadWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Module); + + [PreserveSig] + int GetSymbolPathWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + int SetSymbolPathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Path); + + [PreserveSig] + int AppendSymbolPathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Addition); + + [PreserveSig] + int GetImagePathWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + int SetImagePathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Path); + + [PreserveSig] + int AppendImagePathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Addition); + + [PreserveSig] + int GetSourcePathWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + int GetSourcePathElementWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint ElementSize); + + [PreserveSig] + int SetSourcePathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Path); + + [PreserveSig] + int AppendSourcePathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Addition); + + [PreserveSig] + int FindSourceFileWide( + uint StartElement, + [In][MarshalAs(UnmanagedType.LPWStr)] string File, + DEBUG_FIND_SOURCE Flags, + out uint FoundElement, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint FoundSize); + + [PreserveSig] + int GetSourceFileLineOffsetsWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string File, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] Buffer, + int BufferLines, + out uint FileLines); + + [PreserveSig] + int GetModuleVersionInformationWide( + uint Index, + ulong Base, + [In][MarshalAs(UnmanagedType.LPWStr)] string Item, + IntPtr Buffer, + int BufferSize, + out uint VerInfoSize); + + [PreserveSig] + int GetModuleNameStringWide( + DEBUG_MODNAME Which, + uint Index, + ulong Base, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + int GetConstantNameWide( + ulong Module, + uint TypeId, + ulong Value, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + int GetFieldNameWide( + ulong Module, + uint TypeId, + uint FieldIndex, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + int IsManagedModule( + uint Index, + ulong Base + ); + + [PreserveSig] + int GetModuleByModuleName2( + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + uint StartIndex, + DEBUG_GETMOD Flags, + out uint Index, + out ulong Base + ); + + [PreserveSig] + int GetModuleByModuleName2Wide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Name, + uint StartIndex, + DEBUG_GETMOD Flags, + out uint Index, + out ulong Base + ); + + [PreserveSig] + int GetModuleByOffset2( + ulong Offset, + uint StartIndex, + DEBUG_GETMOD Flags, + out uint Index, + out ulong Base + ); + + [PreserveSig] + int AddSyntheticModule( + ulong Base, + uint Size, + [In][MarshalAs(UnmanagedType.LPStr)] string ImagePath, + [In][MarshalAs(UnmanagedType.LPStr)] string ModuleName, + DEBUG_ADDSYNTHMOD Flags + ); + + [PreserveSig] + int AddSyntheticModuleWide( + ulong Base, + uint Size, + [In][MarshalAs(UnmanagedType.LPWStr)] string ImagePath, + [In][MarshalAs(UnmanagedType.LPWStr)] string ModuleName, + DEBUG_ADDSYNTHMOD Flags + ); + + [PreserveSig] + int RemoveSyntheticModule( + ulong Base + ); + + [PreserveSig] + int GetCurrentScopeFrameIndex( + out uint Index + ); + + [PreserveSig] + int SetScopeFrameByIndex( + uint Index + ); + + [PreserveSig] + int SetScopeFromJitDebugInfo( + uint OutputControl, + ulong InfoOffset + ); + + [PreserveSig] + int SetScopeFromStoredEvent( + ); + + [PreserveSig] + int OutputSymbolByOffset( + uint OutputControl, + DEBUG_OUTSYM Flags, + ulong Offset + ); + + [PreserveSig] + int GetFunctionEntryByOffset( + ulong Offset, + DEBUG_GETFNENT Flags, + IntPtr Buffer, + uint BufferSize, + out uint BufferNeeded + ); + + [PreserveSig] + int GetFieldTypeAndOffset( + ulong Module, + uint ContainerTypeId, + [In][MarshalAs(UnmanagedType.LPStr)] string Field, + out uint FieldTypeId, + out uint Offset + ); + + [PreserveSig] + int GetFieldTypeAndOffsetWide( + ulong Module, + uint ContainerTypeId, + [In][MarshalAs(UnmanagedType.LPWStr)] string Field, + out uint FieldTypeId, + out uint Offset + ); + + [PreserveSig] + int AddSyntheticSymbol( + ulong Offset, + uint Size, + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + DEBUG_ADDSYNTHSYM Flags, + out DEBUG_MODULE_AND_ID Id + ); + + [PreserveSig] + int AddSyntheticSymbolWide( + ulong Offset, + uint Size, + [In][MarshalAs(UnmanagedType.LPWStr)] string Name, + DEBUG_ADDSYNTHSYM Flags, + out DEBUG_MODULE_AND_ID Id + ); + + [PreserveSig] + int RemoveSyntheticSymbol( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_MODULE_AND_ID Id + ); + + [PreserveSig] + int GetSymbolEntriesByOffset( + ulong Offset, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_MODULE_AND_ID[] Ids, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] Displacements, + uint IdsCount, + out uint Entries + ); + + [PreserveSig] + int GetSymbolEntriesByName( + [In][MarshalAs(UnmanagedType.LPStr)] string Symbol, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_MODULE_AND_ID[] Ids, + uint IdsCount, + out uint Entries + ); + + [PreserveSig] + int GetSymbolEntriesByNameWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Symbol, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_MODULE_AND_ID[] Ids, + uint IdsCount, + out uint Entries + ); + + [PreserveSig] + int GetSymbolEntryByToken( + ulong ModuleBase, + uint Token, + out DEBUG_MODULE_AND_ID Id + ); + + [PreserveSig] + int GetSymbolEntryInformation( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_MODULE_AND_ID Id, + out DEBUG_SYMBOL_ENTRY Info + ); + + [PreserveSig] + int GetSymbolEntryString( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_MODULE_AND_ID Id, + uint Which, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize + ); + + [PreserveSig] + int GetSymbolEntryStringWide( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_MODULE_AND_ID Id, + uint Which, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize + ); + + [PreserveSig] + int GetSymbolEntryOffsetRegions( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_MODULE_AND_ID Id, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_OFFSET_REGION[] Regions, + uint RegionsCount, + out uint RegionsAvail + ); + + [Obsolete("Do not use: no longer implemented.", true)] + [PreserveSig] + int GetSymbolEntryBySymbolEntry( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_MODULE_AND_ID FromId, + uint Flags, + out DEBUG_MODULE_AND_ID ToId + ); + + [PreserveSig] + int GetSourceEntriesByOffset( + ulong Offset, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_SYMBOL_SOURCE_ENTRY[] Entries, + uint EntriesCount, + out uint EntriesAvail + ); + + [PreserveSig] + int GetSourceEntriesByLine( + uint Line, + [In][MarshalAs(UnmanagedType.LPStr)] string File, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_SYMBOL_SOURCE_ENTRY[] Entries, + uint EntriesCount, + out uint EntriesAvail + ); + + [PreserveSig] + int GetSourceEntriesByLineWide( + uint Line, + [In][MarshalAs(UnmanagedType.LPWStr)] string File, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_SYMBOL_SOURCE_ENTRY[] Entries, + uint EntriesCount, + out uint EntriesAvail + ); + + [PreserveSig] + int GetSourceEntryString( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_SYMBOL_SOURCE_ENTRY Entry, + uint Which, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize + ); + + [PreserveSig] + int GetSourceEntryStringWide( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_SYMBOL_SOURCE_ENTRY Entry, + uint Which, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize + ); + + [PreserveSig] + int GetSourceEntryOffsetRegions( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_SYMBOL_SOURCE_ENTRY Entry, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_OFFSET_REGION[] Regions, + uint RegionsCount, + out uint RegionsAvail + ); + + [PreserveSig] + int GetSourceEntryBySourceEntry( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_SYMBOL_SOURCE_ENTRY FromEntry, + uint Flags, + out DEBUG_SYMBOL_SOURCE_ENTRY ToEntry + ); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols4.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols4.cs new file mode 100644 index 0000000000..463704e475 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols4.cs @@ -0,0 +1,958 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("e391bbd8-9d8c-4418-840b-c006592a1752")] + public interface IDebugSymbols4 : IDebugSymbols3 + { + /* IDebugSymbols */ + + [PreserveSig] + new int GetSymbolOptions( + out SYMOPT Options); + + [PreserveSig] + new int AddSymbolOptions( + SYMOPT Options); + + [PreserveSig] + new int RemoveSymbolOptions( + SYMOPT Options); + + [PreserveSig] + new int SetSymbolOptions( + SYMOPT Options); + + [PreserveSig] + new int GetNameByOffset( + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement); + + [PreserveSig] + new int GetOffsetByName( + [In][MarshalAs(UnmanagedType.LPStr)] string Symbol, + out ulong Offset); + + [PreserveSig] + new int GetNearNameByOffset( + ulong Offset, + int Delta, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement); + + [PreserveSig] + new int GetLineByOffset( + ulong Offset, + out uint Line, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder FileBuffer, + int FileBufferSize, + out uint FileSize, + out ulong Displacement); + + [PreserveSig] + new int GetOffsetByLine( + uint Line, + [In][MarshalAs(UnmanagedType.LPStr)] string File, + out ulong Offset); + + [PreserveSig] + new int GetNumberModules( + out uint Loaded, + out uint Unloaded); + + [PreserveSig] + new int GetModuleByIndex( + uint Index, + out ulong Base); + + [PreserveSig] + new int GetModuleByModuleName( + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + uint StartIndex, + out uint Index, + out ulong Base); + + [PreserveSig] + new int GetModuleByOffset( + ulong Offset, + uint StartIndex, + out uint Index, + out ulong Base); + + [PreserveSig] + new int GetModuleNames( + uint Index, + ulong Base, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ImageNameBuffer, + int ImageNameBufferSize, + out uint ImageNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ModuleNameBuffer, + int ModuleNameBufferSize, + out uint ModuleNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder LoadedImageNameBuffer, + int LoadedImageNameBufferSize, + out uint LoadedImageNameSize); + + [PreserveSig] + new int GetModuleParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] ulong[] Bases, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_MODULE_PARAMETERS[] Params); + + [PreserveSig] + new int GetSymbolModule( + [In][MarshalAs(UnmanagedType.LPStr)] string Symbol, + out ulong Base); + + [PreserveSig] + new int GetTypeName( + ulong Module, + uint TypeId, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize); + + [PreserveSig] + new int GetTypeId( + ulong Module, + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + out uint TypeId); + + [PreserveSig] + new int GetTypeSize( + ulong Module, + uint TypeId, + out uint Size); + + [PreserveSig] + new int GetFieldOffset( + ulong Module, + uint TypeId, + [In][MarshalAs(UnmanagedType.LPStr)] string Field, + out uint Offset); + + [PreserveSig] + new int GetSymbolTypeId( + [In][MarshalAs(UnmanagedType.LPStr)] string Symbol, + out uint TypeId, + out ulong Module); + + [PreserveSig] + new int GetOffsetTypeId( + ulong Offset, + out uint TypeId, + out ulong Module); + + [PreserveSig] + new int ReadTypedDataVirtual( + ulong Offset, + ulong Module, + uint TypeId, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] + byte[] Buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteTypedDataVirtual( + ulong Offset, + ulong Module, + uint TypeId, + IntPtr Buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int OutputTypedDataVirtual( + DEBUG_OUTCTL OutputControl, + ulong Offset, + ulong Module, + uint TypeId, + DEBUG_TYPEOPTS Flags); + + [PreserveSig] + new int ReadTypedDataPhysical( + ulong Offset, + ulong Module, + uint TypeId, + IntPtr Buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteTypedDataPhysical( + ulong Offset, + ulong Module, + uint TypeId, + IntPtr Buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int OutputTypedDataPhysical( + DEBUG_OUTCTL OutputControl, + ulong Offset, + ulong Module, + uint TypeId, + DEBUG_TYPEOPTS Flags); + + [PreserveSig] + new int GetScope( + out ulong InstructionOffset, + out DEBUG_STACK_FRAME ScopeFrame, + IntPtr ScopeContext, + uint ScopeContextSize); + + [PreserveSig] + new int SetScope( + ulong InstructionOffset, + in DEBUG_STACK_FRAME ScopeFrame, + IntPtr ScopeContext, + uint ScopeContextSize); + + [PreserveSig] + new int ResetScope(); + + [PreserveSig] + new int GetScopeSymbolGroup( + DEBUG_SCOPE_GROUP Flags, + [In][MarshalAs(UnmanagedType.Interface)] + IDebugSymbolGroup Update, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugSymbolGroup Symbols); + + [PreserveSig] + new int CreateSymbolGroup( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugSymbolGroup Group); + + [PreserveSig] + new int StartSymbolMatch( + [In][MarshalAs(UnmanagedType.LPStr)] string Pattern, + out ulong Handle); + + [PreserveSig] + new int GetNextSymbolMatch( + ulong Handle, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint MatchSize, + out ulong Offset); + + [PreserveSig] + new int EndSymbolMatch( + ulong Handle); + + [PreserveSig] + new int Reload( + [In][MarshalAs(UnmanagedType.LPStr)] string Module); + + [PreserveSig] + new int GetSymbolPath( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + new int SetSymbolPath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path); + + [PreserveSig] + new int AppendSymbolPath( + [In][MarshalAs(UnmanagedType.LPStr)] string Addition); + + [PreserveSig] + new int GetImagePath( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + new int SetImagePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path); + + [PreserveSig] + new int AppendImagePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Addition); + + [PreserveSig] + new int GetSourcePath( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + new int GetSourcePathElement( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint ElementSize); + + [PreserveSig] + new int SetSourcePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path); + + [PreserveSig] + new int AppendSourcePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Addition); + + [PreserveSig] + new int FindSourceFile( + uint StartElement, + [In][MarshalAs(UnmanagedType.LPStr)] string File, + DEBUG_FIND_SOURCE Flags, + out uint FoundElement, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint FoundSize); + + [PreserveSig] + new int GetSourceFileLineOffsets( + [In][MarshalAs(UnmanagedType.LPStr)] string File, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] Buffer, + int BufferLines, + out uint FileLines); + + /* IDebugSymbols2 */ + + [PreserveSig] + new int GetModuleVersionInformation( + uint Index, + ulong Base, + [In][MarshalAs(UnmanagedType.LPStr)] string Item, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] + byte[] buffer, + uint BufferSize, + out uint VerInfoSize); + + [PreserveSig] + new int GetModuleNameString( + DEBUG_MODNAME Which, + uint Index, + ulong Base, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + uint BufferSize, + out uint NameSize); + + [PreserveSig] + new int GetConstantName( + ulong Module, + uint TypeId, + ulong Value, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + new int GetFieldName( + ulong Module, + uint TypeId, + uint FieldIndex, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + new int GetTypeOptions( + out DEBUG_TYPEOPTS Options); + + [PreserveSig] + new int AddTypeOptions( + DEBUG_TYPEOPTS Options); + + [PreserveSig] + new int RemoveTypeOptions( + DEBUG_TYPEOPTS Options); + + [PreserveSig] + new int SetTypeOptions( + DEBUG_TYPEOPTS Options); + + /* IDebugSymbols3 */ + + [PreserveSig] + new int GetNameByOffsetWide( + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement); + + [PreserveSig] + new int GetOffsetByNameWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Symbol, + out ulong Offset); + + [PreserveSig] + new int GetNearNameByOffsetWide( + ulong Offset, + int Delta, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement); + + [PreserveSig] + new int GetLineByOffsetWide( + ulong Offset, + out uint Line, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder FileBuffer, + int FileBufferSize, + out uint FileSize, + out ulong Displacement); + + [PreserveSig] + new int GetOffsetByLineWide( + uint Line, + [In][MarshalAs(UnmanagedType.LPWStr)] string File, + out ulong Offset); + + [PreserveSig] + new int GetModuleByModuleNameWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Name, + uint StartIndex, + out uint Index, + out ulong Base); + + [PreserveSig] + new int GetSymbolModuleWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Symbol, + out ulong Base); + + [PreserveSig] + new int GetTypeNameWide( + ulong Module, + uint TypeId, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize); + + [PreserveSig] + new int GetTypeIdWide( + ulong Module, + [In][MarshalAs(UnmanagedType.LPWStr)] string Name, + out uint TypeId); + + [PreserveSig] + new int GetFieldOffsetWide( + ulong Module, + uint TypeId, + [In][MarshalAs(UnmanagedType.LPWStr)] string Field, + out uint Offset); + + [PreserveSig] + new int GetSymbolTypeIdWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Symbol, + out uint TypeId, + out ulong Module); + + [PreserveSig] + new int GetScopeSymbolGroup2( + DEBUG_SCOPE_GROUP Flags, + [In][MarshalAs(UnmanagedType.Interface)] + IDebugSymbolGroup2 Update, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugSymbolGroup2 Symbols); + + [PreserveSig] + new int CreateSymbolGroup2( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugSymbolGroup2 Group); + + [PreserveSig] + new int StartSymbolMatchWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Pattern, + out ulong Handle); + + [PreserveSig] + new int GetNextSymbolMatchWide( + ulong Handle, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint MatchSize, + out ulong Offset); + + [PreserveSig] + new int ReloadWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Module); + + [PreserveSig] + new int GetSymbolPathWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + new int SetSymbolPathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Path); + + [PreserveSig] + new int AppendSymbolPathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Addition); + + [PreserveSig] + new int GetImagePathWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + new int SetImagePathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Path); + + [PreserveSig] + new int AppendImagePathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Addition); + + [PreserveSig] + new int GetSourcePathWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + new int GetSourcePathElementWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint ElementSize); + + [PreserveSig] + new int SetSourcePathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Path); + + [PreserveSig] + new int AppendSourcePathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Addition); + + [PreserveSig] + new int FindSourceFileWide( + uint StartElement, + [In][MarshalAs(UnmanagedType.LPWStr)] string File, + DEBUG_FIND_SOURCE Flags, + out uint FoundElement, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint FoundSize); + + [PreserveSig] + new int GetSourceFileLineOffsetsWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string File, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] Buffer, + int BufferLines, + out uint FileLines); + + [PreserveSig] + new int GetModuleVersionInformationWide( + uint Index, + ulong Base, + [In][MarshalAs(UnmanagedType.LPWStr)] string Item, + IntPtr Buffer, + int BufferSize, + out uint VerInfoSize); + + [PreserveSig] + new int GetModuleNameStringWide( + DEBUG_MODNAME Which, + uint Index, + ulong Base, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + new int GetConstantNameWide( + ulong Module, + uint TypeId, + ulong Value, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + new int GetFieldNameWide( + ulong Module, + uint TypeId, + uint FieldIndex, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + new int IsManagedModule( + uint Index, + ulong Base + ); + + [PreserveSig] + new int GetModuleByModuleName2( + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + uint StartIndex, + DEBUG_GETMOD Flags, + out uint Index, + out ulong Base + ); + + [PreserveSig] + new int GetModuleByModuleName2Wide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Name, + uint StartIndex, + DEBUG_GETMOD Flags, + out uint Index, + out ulong Base + ); + + [PreserveSig] + new int GetModuleByOffset2( + ulong Offset, + uint StartIndex, + DEBUG_GETMOD Flags, + out uint Index, + out ulong Base + ); + + [PreserveSig] + new int AddSyntheticModule( + ulong Base, + uint Size, + [In][MarshalAs(UnmanagedType.LPStr)] string ImagePath, + [In][MarshalAs(UnmanagedType.LPStr)] string ModuleName, + DEBUG_ADDSYNTHMOD Flags + ); + + [PreserveSig] + new int AddSyntheticModuleWide( + ulong Base, + uint Size, + [In][MarshalAs(UnmanagedType.LPWStr)] string ImagePath, + [In][MarshalAs(UnmanagedType.LPWStr)] string ModuleName, + DEBUG_ADDSYNTHMOD Flags + ); + + [PreserveSig] + new int RemoveSyntheticModule( + ulong Base + ); + + [PreserveSig] + new int GetCurrentScopeFrameIndex( + out uint Index + ); + + [PreserveSig] + new int SetScopeFrameByIndex( + uint Index + ); + + [PreserveSig] + new int SetScopeFromJitDebugInfo( + uint OutputControl, + ulong InfoOffset + ); + + [PreserveSig] + new int SetScopeFromStoredEvent( + ); + + [PreserveSig] + new int OutputSymbolByOffset( + uint OutputControl, + DEBUG_OUTSYM Flags, + ulong Offset + ); + + [PreserveSig] + new int GetFunctionEntryByOffset( + ulong Offset, + DEBUG_GETFNENT Flags, + IntPtr Buffer, + uint BufferSize, + out uint BufferNeeded + ); + + [PreserveSig] + new int GetFieldTypeAndOffset( + ulong Module, + uint ContainerTypeId, + [In][MarshalAs(UnmanagedType.LPStr)] string Field, + out uint FieldTypeId, + out uint Offset + ); + + [PreserveSig] + new int GetFieldTypeAndOffsetWide( + ulong Module, + uint ContainerTypeId, + [In][MarshalAs(UnmanagedType.LPWStr)] string Field, + out uint FieldTypeId, + out uint Offset + ); + + [PreserveSig] + new int AddSyntheticSymbol( + ulong Offset, + uint Size, + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + DEBUG_ADDSYNTHSYM Flags, + out DEBUG_MODULE_AND_ID Id + ); + + [PreserveSig] + new int AddSyntheticSymbolWide( + ulong Offset, + uint Size, + [In][MarshalAs(UnmanagedType.LPWStr)] string Name, + DEBUG_ADDSYNTHSYM Flags, + out DEBUG_MODULE_AND_ID Id + ); + + [PreserveSig] + new int RemoveSyntheticSymbol( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_MODULE_AND_ID Id + ); + + [PreserveSig] + new int GetSymbolEntriesByOffset( + ulong Offset, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_MODULE_AND_ID[] Ids, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] Displacements, + uint IdsCount, + out uint Entries + ); + + [PreserveSig] + new int GetSymbolEntriesByName( + [In][MarshalAs(UnmanagedType.LPStr)] string Symbol, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_MODULE_AND_ID[] Ids, + uint IdsCount, + out uint Entries + ); + + [PreserveSig] + new int GetSymbolEntriesByNameWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Symbol, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_MODULE_AND_ID[] Ids, + uint IdsCount, + out uint Entries + ); + + [PreserveSig] + new int GetSymbolEntryByToken( + ulong ModuleBase, + uint Token, + out DEBUG_MODULE_AND_ID Id + ); + + [PreserveSig] + new int GetSymbolEntryInformation( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_MODULE_AND_ID Id, + out DEBUG_SYMBOL_ENTRY Info + ); + + [PreserveSig] + new int GetSymbolEntryString( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_MODULE_AND_ID Id, + uint Which, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize + ); + + [PreserveSig] + new int GetSymbolEntryStringWide( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_MODULE_AND_ID Id, + uint Which, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize + ); + + [PreserveSig] + new int GetSymbolEntryOffsetRegions( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_MODULE_AND_ID Id, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_OFFSET_REGION[] Regions, + uint RegionsCount, + out uint RegionsAvail + ); + + [Obsolete("Do not use: no longer implemented.", true)] + [PreserveSig] + new int GetSymbolEntryBySymbolEntry( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_MODULE_AND_ID FromId, + uint Flags, + out DEBUG_MODULE_AND_ID ToId + ); + + [PreserveSig] + new int GetSourceEntriesByOffset( + ulong Offset, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_SYMBOL_SOURCE_ENTRY[] Entries, + uint EntriesCount, + out uint EntriesAvail + ); + + [PreserveSig] + new int GetSourceEntriesByLine( + uint Line, + [In][MarshalAs(UnmanagedType.LPStr)] string File, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_SYMBOL_SOURCE_ENTRY[] Entries, + uint EntriesCount, + out uint EntriesAvail + ); + + [PreserveSig] + new int GetSourceEntriesByLineWide( + uint Line, + [In][MarshalAs(UnmanagedType.LPWStr)] string File, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_SYMBOL_SOURCE_ENTRY[] Entries, + uint EntriesCount, + out uint EntriesAvail + ); + + [PreserveSig] + new int GetSourceEntryString( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_SYMBOL_SOURCE_ENTRY Entry, + uint Which, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize + ); + + [PreserveSig] + new int GetSourceEntryStringWide( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_SYMBOL_SOURCE_ENTRY Entry, + uint Which, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize + ); + + [PreserveSig] + new int GetSourceEntryOffsetRegions( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_SYMBOL_SOURCE_ENTRY Entry, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_OFFSET_REGION[] Regions, + uint RegionsCount, + out uint RegionsAvail + ); + + [PreserveSig] + new int GetSourceEntryBySourceEntry( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_SYMBOL_SOURCE_ENTRY FromEntry, + uint Flags, + out DEBUG_SYMBOL_SOURCE_ENTRY ToEntry + ); + + /* IDebugSymbols4 */ + + [PreserveSig] + int GetScopeEx( + out ulong InstructionOffset, + out DEBUG_STACK_FRAME_EX ScopeFrame, + IntPtr ScopeContext, + uint ScopeContextSize + ); + + [PreserveSig] + int SetScopeEx( + ulong InstructionOffset, + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_STACK_FRAME_EX ScopeFrame, + IntPtr ScopeContext, + uint ScopeContextSize + ); + + [PreserveSig] + int GetNameByInlineContext( + ulong Offset, + uint InlineContext, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement + ); + + [PreserveSig] + int GetNameByInlineContextWide( + ulong Offset, + uint InlineContext, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement + ); + + [PreserveSig] + int GetLineByInlineContext( + ulong Offset, + uint InlineContext, + out uint Line, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder FileBuffer, + int FileBufferSize, + out uint FileSize, + out ulong Displacement + ); + + [PreserveSig] + int GetLineByInlineContextWide( + ulong Offset, + uint InlineContext, + out uint Line, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder FileBuffer, + int FileBufferSize, + out uint FileSize, + out ulong Displacement + ); + + [PreserveSig] + int OutputSymbolByInlineContext( + uint OutputControl, + uint Flags, + ulong Offset, + uint InlineContext + ); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols5.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols5.cs new file mode 100644 index 0000000000..1246471467 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSymbols5.cs @@ -0,0 +1,972 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("c65fa83e-1e69-475e-8e0e-b5d79e9cc17e")] + public interface IDebugSymbols5 : IDebugSymbols4 + { + /* IDebugSymbols */ + + [PreserveSig] + new int GetSymbolOptions( + out SYMOPT Options); + + [PreserveSig] + new int AddSymbolOptions( + SYMOPT Options); + + [PreserveSig] + new int RemoveSymbolOptions( + SYMOPT Options); + + [PreserveSig] + new int SetSymbolOptions( + SYMOPT Options); + + [PreserveSig] + new int GetNameByOffset( + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement); + + [PreserveSig] + new int GetOffsetByName( + [In][MarshalAs(UnmanagedType.LPStr)] string Symbol, + out ulong Offset); + + [PreserveSig] + new int GetNearNameByOffset( + ulong Offset, + int Delta, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement); + + [PreserveSig] + new int GetLineByOffset( + ulong Offset, + out uint Line, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder FileBuffer, + int FileBufferSize, + out uint FileSize, + out ulong Displacement); + + [PreserveSig] + new int GetOffsetByLine( + uint Line, + [In][MarshalAs(UnmanagedType.LPStr)] string File, + out ulong Offset); + + [PreserveSig] + new int GetNumberModules( + out uint Loaded, + out uint Unloaded); + + [PreserveSig] + new int GetModuleByIndex( + uint Index, + out ulong Base); + + [PreserveSig] + new int GetModuleByModuleName( + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + uint StartIndex, + out uint Index, + out ulong Base); + + [PreserveSig] + new int GetModuleByOffset( + ulong Offset, + uint StartIndex, + out uint Index, + out ulong Base); + + [PreserveSig] + new int GetModuleNames( + uint Index, + ulong Base, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ImageNameBuffer, + int ImageNameBufferSize, + out uint ImageNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder ModuleNameBuffer, + int ModuleNameBufferSize, + out uint ModuleNameSize, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder LoadedImageNameBuffer, + int LoadedImageNameBufferSize, + out uint LoadedImageNameSize); + + [PreserveSig] + new int GetModuleParameters( + uint Count, + [In][MarshalAs(UnmanagedType.LPArray)] ulong[] Bases, + uint Start, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_MODULE_PARAMETERS[] Params); + + [PreserveSig] + new int GetSymbolModule( + [In][MarshalAs(UnmanagedType.LPStr)] string Symbol, + out ulong Base); + + [PreserveSig] + new int GetTypeName( + ulong Module, + uint TypeId, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize); + + [PreserveSig] + new int GetTypeId( + ulong Module, + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + out uint TypeId); + + [PreserveSig] + new int GetTypeSize( + ulong Module, + uint TypeId, + out uint Size); + + [PreserveSig] + new int GetFieldOffset( + ulong Module, + uint TypeId, + [In][MarshalAs(UnmanagedType.LPStr)] string Field, + out uint Offset); + + [PreserveSig] + new int GetSymbolTypeId( + [In][MarshalAs(UnmanagedType.LPStr)] string Symbol, + out uint TypeId, + out ulong Module); + + [PreserveSig] + new int GetOffsetTypeId( + ulong Offset, + out uint TypeId, + out ulong Module); + + [PreserveSig] + new int ReadTypedDataVirtual( + ulong Offset, + ulong Module, + uint TypeId, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] + byte[] Buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteTypedDataVirtual( + ulong Offset, + ulong Module, + uint TypeId, + IntPtr Buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int OutputTypedDataVirtual( + DEBUG_OUTCTL OutputControl, + ulong Offset, + ulong Module, + uint TypeId, + DEBUG_TYPEOPTS Flags); + + [PreserveSig] + new int ReadTypedDataPhysical( + ulong Offset, + ulong Module, + uint TypeId, + IntPtr Buffer, + uint BufferSize, + out uint BytesRead); + + [PreserveSig] + new int WriteTypedDataPhysical( + ulong Offset, + ulong Module, + uint TypeId, + IntPtr Buffer, + uint BufferSize, + out uint BytesWritten); + + [PreserveSig] + new int OutputTypedDataPhysical( + DEBUG_OUTCTL OutputControl, + ulong Offset, + ulong Module, + uint TypeId, + DEBUG_TYPEOPTS Flags); + + [PreserveSig] + new int GetScope( + out ulong InstructionOffset, + out DEBUG_STACK_FRAME ScopeFrame, + IntPtr ScopeContext, + uint ScopeContextSize); + + [PreserveSig] + new int SetScope( + ulong InstructionOffset, + in DEBUG_STACK_FRAME ScopeFrame, + IntPtr ScopeContext, + uint ScopeContextSize); + + [PreserveSig] + new int ResetScope(); + + [PreserveSig] + new int GetScopeSymbolGroup( + DEBUG_SCOPE_GROUP Flags, + [In][MarshalAs(UnmanagedType.Interface)] + IDebugSymbolGroup Update, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugSymbolGroup Symbols); + + [PreserveSig] + new int CreateSymbolGroup( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugSymbolGroup Group); + + [PreserveSig] + new int StartSymbolMatch( + [In][MarshalAs(UnmanagedType.LPStr)] string Pattern, + out ulong Handle); + + [PreserveSig] + new int GetNextSymbolMatch( + ulong Handle, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint MatchSize, + out ulong Offset); + + [PreserveSig] + new int EndSymbolMatch( + ulong Handle); + + [PreserveSig] + new int Reload( + [In][MarshalAs(UnmanagedType.LPStr)] string Module); + + [PreserveSig] + new int GetSymbolPath( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + new int SetSymbolPath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path); + + [PreserveSig] + new int AppendSymbolPath( + [In][MarshalAs(UnmanagedType.LPStr)] string Addition); + + [PreserveSig] + new int GetImagePath( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + new int SetImagePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path); + + [PreserveSig] + new int AppendImagePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Addition); + + [PreserveSig] + new int GetSourcePath( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + new int GetSourcePathElement( + uint Index, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint ElementSize); + + [PreserveSig] + new int SetSourcePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Path); + + [PreserveSig] + new int AppendSourcePath( + [In][MarshalAs(UnmanagedType.LPStr)] string Addition); + + [PreserveSig] + new int FindSourceFile( + uint StartElement, + [In][MarshalAs(UnmanagedType.LPStr)] string File, + DEBUG_FIND_SOURCE Flags, + out uint FoundElement, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint FoundSize); + + [PreserveSig] + new int GetSourceFileLineOffsets( + [In][MarshalAs(UnmanagedType.LPStr)] string File, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] Buffer, + int BufferLines, + out uint FileLines); + + /* IDebugSymbols2 */ + + [PreserveSig] + new int GetModuleVersionInformation( + uint Index, + ulong Base, + [In][MarshalAs(UnmanagedType.LPStr)] string Item, + [Out][MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] + byte[] buffer, + uint BufferSize, + out uint VerInfoSize); + + [PreserveSig] + new int GetModuleNameString( + DEBUG_MODNAME Which, + uint Index, + ulong Base, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + uint BufferSize, + out uint NameSize); + + [PreserveSig] + new int GetConstantName( + ulong Module, + uint TypeId, + ulong Value, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + new int GetFieldName( + ulong Module, + uint TypeId, + uint FieldIndex, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + new int GetTypeOptions( + out DEBUG_TYPEOPTS Options); + + [PreserveSig] + new int AddTypeOptions( + DEBUG_TYPEOPTS Options); + + [PreserveSig] + new int RemoveTypeOptions( + DEBUG_TYPEOPTS Options); + + [PreserveSig] + new int SetTypeOptions( + DEBUG_TYPEOPTS Options); + + /* IDebugSymbols3 */ + + [PreserveSig] + new int GetNameByOffsetWide( + ulong Offset, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement); + + [PreserveSig] + new int GetOffsetByNameWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Symbol, + out ulong Offset); + + [PreserveSig] + new int GetNearNameByOffsetWide( + ulong Offset, + int Delta, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement); + + [PreserveSig] + new int GetLineByOffsetWide( + ulong Offset, + out uint Line, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder FileBuffer, + int FileBufferSize, + out uint FileSize, + out ulong Displacement); + + [PreserveSig] + new int GetOffsetByLineWide( + uint Line, + [In][MarshalAs(UnmanagedType.LPWStr)] string File, + out ulong Offset); + + [PreserveSig] + new int GetModuleByModuleNameWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Name, + uint StartIndex, + out uint Index, + out ulong Base); + + [PreserveSig] + new int GetSymbolModuleWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Symbol, + out ulong Base); + + [PreserveSig] + new int GetTypeNameWide( + ulong Module, + uint TypeId, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize); + + [PreserveSig] + new int GetTypeIdWide( + ulong Module, + [In][MarshalAs(UnmanagedType.LPWStr)] string Name, + out uint TypeId); + + [PreserveSig] + new int GetFieldOffsetWide( + ulong Module, + uint TypeId, + [In][MarshalAs(UnmanagedType.LPWStr)] string Field, + out uint Offset); + + [PreserveSig] + new int GetSymbolTypeIdWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Symbol, + out uint TypeId, + out ulong Module); + + [PreserveSig] + new int GetScopeSymbolGroup2( + DEBUG_SCOPE_GROUP Flags, + [In][MarshalAs(UnmanagedType.Interface)] + IDebugSymbolGroup2 Update, + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugSymbolGroup2 Symbols); + + [PreserveSig] + new int CreateSymbolGroup2( + [Out][MarshalAs(UnmanagedType.Interface)] + out IDebugSymbolGroup2 Group); + + [PreserveSig] + new int StartSymbolMatchWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Pattern, + out ulong Handle); + + [PreserveSig] + new int GetNextSymbolMatchWide( + ulong Handle, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint MatchSize, + out ulong Offset); + + [PreserveSig] + new int ReloadWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Module); + + [PreserveSig] + new int GetSymbolPathWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + new int SetSymbolPathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Path); + + [PreserveSig] + new int AppendSymbolPathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Addition); + + [PreserveSig] + new int GetImagePathWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + new int SetImagePathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Path); + + [PreserveSig] + new int AppendImagePathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Addition); + + [PreserveSig] + new int GetSourcePathWide( + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint PathSize); + + [PreserveSig] + new int GetSourcePathElementWide( + uint Index, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint ElementSize); + + [PreserveSig] + new int SetSourcePathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Path); + + [PreserveSig] + new int AppendSourcePathWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Addition); + + [PreserveSig] + new int FindSourceFileWide( + uint StartElement, + [In][MarshalAs(UnmanagedType.LPWStr)] string File, + DEBUG_FIND_SOURCE Flags, + out uint FoundElement, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint FoundSize); + + [PreserveSig] + new int GetSourceFileLineOffsetsWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string File, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] Buffer, + int BufferLines, + out uint FileLines); + + [PreserveSig] + new int GetModuleVersionInformationWide( + uint Index, + ulong Base, + [In][MarshalAs(UnmanagedType.LPWStr)] string Item, + IntPtr Buffer, + int BufferSize, + out uint VerInfoSize); + + [PreserveSig] + new int GetModuleNameStringWide( + DEBUG_MODNAME Which, + uint Index, + ulong Base, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + new int GetConstantNameWide( + ulong Module, + uint TypeId, + ulong Value, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + new int GetFieldNameWide( + ulong Module, + uint TypeId, + uint FieldIndex, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint NameSize); + + [PreserveSig] + new int IsManagedModule( + uint Index, + ulong Base + ); + + [PreserveSig] + new int GetModuleByModuleName2( + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + uint StartIndex, + DEBUG_GETMOD Flags, + out uint Index, + out ulong Base + ); + + [PreserveSig] + new int GetModuleByModuleName2Wide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Name, + uint StartIndex, + DEBUG_GETMOD Flags, + out uint Index, + out ulong Base + ); + + [PreserveSig] + new int GetModuleByOffset2( + ulong Offset, + uint StartIndex, + DEBUG_GETMOD Flags, + out uint Index, + out ulong Base + ); + + [PreserveSig] + new int AddSyntheticModule( + ulong Base, + uint Size, + [In][MarshalAs(UnmanagedType.LPStr)] string ImagePath, + [In][MarshalAs(UnmanagedType.LPStr)] string ModuleName, + DEBUG_ADDSYNTHMOD Flags + ); + + [PreserveSig] + new int AddSyntheticModuleWide( + ulong Base, + uint Size, + [In][MarshalAs(UnmanagedType.LPWStr)] string ImagePath, + [In][MarshalAs(UnmanagedType.LPWStr)] string ModuleName, + DEBUG_ADDSYNTHMOD Flags + ); + + [PreserveSig] + new int RemoveSyntheticModule( + ulong Base + ); + + [PreserveSig] + new int GetCurrentScopeFrameIndex( + out uint Index + ); + + [PreserveSig] + new int SetScopeFrameByIndex( + uint Index + ); + + [PreserveSig] + new int SetScopeFromJitDebugInfo( + uint OutputControl, + ulong InfoOffset + ); + + [PreserveSig] + new int SetScopeFromStoredEvent( + ); + + [PreserveSig] + new int OutputSymbolByOffset( + uint OutputControl, + DEBUG_OUTSYM Flags, + ulong Offset + ); + + [PreserveSig] + new int GetFunctionEntryByOffset( + ulong Offset, + DEBUG_GETFNENT Flags, + IntPtr Buffer, + uint BufferSize, + out uint BufferNeeded + ); + + [PreserveSig] + new int GetFieldTypeAndOffset( + ulong Module, + uint ContainerTypeId, + [In][MarshalAs(UnmanagedType.LPStr)] string Field, + out uint FieldTypeId, + out uint Offset + ); + + [PreserveSig] + new int GetFieldTypeAndOffsetWide( + ulong Module, + uint ContainerTypeId, + [In][MarshalAs(UnmanagedType.LPWStr)] string Field, + out uint FieldTypeId, + out uint Offset + ); + + [PreserveSig] + new int AddSyntheticSymbol( + ulong Offset, + uint Size, + [In][MarshalAs(UnmanagedType.LPStr)] string Name, + DEBUG_ADDSYNTHSYM Flags, + out DEBUG_MODULE_AND_ID Id + ); + + [PreserveSig] + new int AddSyntheticSymbolWide( + ulong Offset, + uint Size, + [In][MarshalAs(UnmanagedType.LPWStr)] string Name, + DEBUG_ADDSYNTHSYM Flags, + out DEBUG_MODULE_AND_ID Id + ); + + [PreserveSig] + new int RemoveSyntheticSymbol( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_MODULE_AND_ID Id + ); + + [PreserveSig] + new int GetSymbolEntriesByOffset( + ulong Offset, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_MODULE_AND_ID[] Ids, + [Out][MarshalAs(UnmanagedType.LPArray)] + ulong[] Displacements, + uint IdsCount, + out uint Entries + ); + + [PreserveSig] + new int GetSymbolEntriesByName( + [In][MarshalAs(UnmanagedType.LPStr)] string Symbol, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_MODULE_AND_ID[] Ids, + uint IdsCount, + out uint Entries + ); + + [PreserveSig] + new int GetSymbolEntriesByNameWide( + [In][MarshalAs(UnmanagedType.LPWStr)] string Symbol, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_MODULE_AND_ID[] Ids, + uint IdsCount, + out uint Entries + ); + + [PreserveSig] + new int GetSymbolEntryByToken( + ulong ModuleBase, + uint Token, + out DEBUG_MODULE_AND_ID Id + ); + + [PreserveSig] + new int GetSymbolEntryInformation( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_MODULE_AND_ID Id, + out DEBUG_SYMBOL_ENTRY Info + ); + + [PreserveSig] + new int GetSymbolEntryString( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_MODULE_AND_ID Id, + uint Which, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize + ); + + [PreserveSig] + new int GetSymbolEntryStringWide( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_MODULE_AND_ID Id, + uint Which, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize + ); + + [PreserveSig] + new int GetSymbolEntryOffsetRegions( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_MODULE_AND_ID Id, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_OFFSET_REGION[] Regions, + uint RegionsCount, + out uint RegionsAvail + ); + + [Obsolete("Do not use: no longer implemented.", true)] + [PreserveSig] + new int GetSymbolEntryBySymbolEntry( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_MODULE_AND_ID FromId, + uint Flags, + out DEBUG_MODULE_AND_ID ToId + ); + + [PreserveSig] + new int GetSourceEntriesByOffset( + ulong Offset, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_SYMBOL_SOURCE_ENTRY[] Entries, + uint EntriesCount, + out uint EntriesAvail + ); + + [PreserveSig] + new int GetSourceEntriesByLine( + uint Line, + [In][MarshalAs(UnmanagedType.LPStr)] string File, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_SYMBOL_SOURCE_ENTRY[] Entries, + uint EntriesCount, + out uint EntriesAvail + ); + + [PreserveSig] + new int GetSourceEntriesByLineWide( + uint Line, + [In][MarshalAs(UnmanagedType.LPWStr)] string File, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_SYMBOL_SOURCE_ENTRY[] Entries, + uint EntriesCount, + out uint EntriesAvail + ); + + [PreserveSig] + new int GetSourceEntryString( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_SYMBOL_SOURCE_ENTRY Entry, + uint Which, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize + ); + + [PreserveSig] + new int GetSourceEntryStringWide( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_SYMBOL_SOURCE_ENTRY Entry, + uint Which, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder Buffer, + int BufferSize, + out uint StringSize + ); + + [PreserveSig] + new int GetSourceEntryOffsetRegions( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_SYMBOL_SOURCE_ENTRY Entry, + uint Flags, + [Out][MarshalAs(UnmanagedType.LPArray)] + DEBUG_OFFSET_REGION[] Regions, + uint RegionsCount, + out uint RegionsAvail + ); + + [PreserveSig] + new int GetSourceEntryBySourceEntry( + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_SYMBOL_SOURCE_ENTRY FromEntry, + uint Flags, + out DEBUG_SYMBOL_SOURCE_ENTRY ToEntry + ); + + /* IDebugSymbols4 */ + + [PreserveSig] + new int GetScopeEx( + out ulong InstructionOffset, + out DEBUG_STACK_FRAME_EX ScopeFrame, + IntPtr ScopeContext, + uint ScopeContextSize + ); + + [PreserveSig] + new int SetScopeEx( + ulong InstructionOffset, + [In][MarshalAs(UnmanagedType.LPStruct)] + DEBUG_STACK_FRAME_EX ScopeFrame, + IntPtr ScopeContext, + uint ScopeContextSize + ); + + [PreserveSig] + new int GetNameByInlineContext( + ulong Offset, + uint InlineContext, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement + ); + + [PreserveSig] + new int GetNameByInlineContextWide( + ulong Offset, + uint InlineContext, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder NameBuffer, + int NameBufferSize, + out uint NameSize, + out ulong Displacement + ); + + [PreserveSig] + new int GetLineByInlineContext( + ulong Offset, + uint InlineContext, + out uint Line, + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder FileBuffer, + int FileBufferSize, + out uint FileSize, + out ulong Displacement + ); + + [PreserveSig] + new int GetLineByInlineContextWide( + ulong Offset, + uint InlineContext, + out uint Line, + [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder FileBuffer, + int FileBufferSize, + out uint FileSize, + out ulong Displacement + ); + + [PreserveSig] + new int OutputSymbolByInlineContext( + uint OutputControl, + uint Flags, + ulong Offset, + uint InlineContext + ); + + /* IDebugSymbols5 */ + + [PreserveSig] + int GetCurrentScopeFrameIndexEx( + DEBUG_FRAME Flags, + out uint Index + ); + + [PreserveSig] + int SetScopeFrameByIndexEx( + DEBUG_FRAME Flags, + uint Index + ); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSystemObjects.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSystemObjects.cs new file mode 100644 index 0000000000..c861ab80f8 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSystemObjects.cs @@ -0,0 +1,153 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("6b86fe2c-2c4f-4f0c-9da2-174311acc327")] + public interface IDebugSystemObjects + { + [PreserveSig] + int GetEventThread( + out uint Id); + + [PreserveSig] + int GetEventProcess( + out uint Id); + + [PreserveSig] + int GetCurrentThreadId( + out uint Id); + + [PreserveSig] + int SetCurrentThreadId( + uint Id); + + [PreserveSig] + int GetCurrentProcessId( + out uint Id); + + [PreserveSig] + int SetCurrentProcessId( + uint Id); + + [PreserveSig] + int GetNumberThreads( + out uint Number); + + [PreserveSig] + int GetTotalNumberThreads( + out uint Total, + out uint LargestProcess); + + [PreserveSig] + int GetThreadIdsByIndex( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + uint[] Ids, + [Out][MarshalAs(UnmanagedType.LPArray)] + uint[] SysIds); + + [PreserveSig] + int GetThreadIdByProcessor( + uint Processor, + out uint Id); + + [PreserveSig] + int GetCurrentThreadDataOffset( + out ulong Offset); + + [PreserveSig] + int GetThreadIdByDataOffset( + ulong Offset, + out uint Id); + + [PreserveSig] + int GetCurrentThreadTeb( + out ulong Offset); + + [PreserveSig] + int GetThreadIdByTeb( + ulong Offset, + out uint Id); + + [PreserveSig] + int GetCurrentThreadSystemId( + out uint SysId); + + [PreserveSig] + int GetThreadIdBySystemId( + uint SysId, + out uint Id); + + [PreserveSig] + int GetCurrentThreadHandle( + out ulong Handle); + + [PreserveSig] + int GetThreadIdByHandle( + ulong Handle, + out uint Id); + + [PreserveSig] + int GetNumberProcesses( + out uint Number); + + [PreserveSig] + int GetProcessIdsByIndex( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + uint[] Ids, + [Out][MarshalAs(UnmanagedType.LPArray)] + uint[] SysIds); + + [PreserveSig] + int GetCurrentProcessDataOffset( + out ulong Offset); + + [PreserveSig] + int GetProcessIdByDataOffset( + ulong Offset, + out uint Id); + + [PreserveSig] + int GetCurrentProcessPeb( + out ulong Offset); + + [PreserveSig] + int GetProcessIdByPeb( + ulong Offset, + out uint Id); + + [PreserveSig] + int GetCurrentProcessSystemId( + out uint SysId); + + [PreserveSig] + int GetProcessIdBySystemId( + uint SysId, + out uint Id); + + [PreserveSig] + int GetCurrentProcessHandle( + out ulong Handle); + + [PreserveSig] + int GetProcessIdByHandle( + ulong Handle, + out uint Id); + + [PreserveSig] + int GetCurrentProcessExecutableName( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint ExeSize); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSystemObjects2.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSystemObjects2.cs new file mode 100644 index 0000000000..d7cf7052f0 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSystemObjects2.cs @@ -0,0 +1,177 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("0ae9f5ff-1852-4679-b055-494bee6407ee")] + public interface IDebugSystemObjects2 : IDebugSystemObjects + { + /* IDebugSystemObjects */ + + [PreserveSig] + new int GetEventThread( + out uint Id); + + [PreserveSig] + new int GetEventProcess( + out uint Id); + + [PreserveSig] + new int GetCurrentThreadId( + out uint Id); + + [PreserveSig] + new int SetCurrentThreadId( + uint Id); + + [PreserveSig] + new int GetCurrentProcessId( + out uint Id); + + [PreserveSig] + new int SetCurrentProcessId( + uint Id); + + [PreserveSig] + new int GetNumberThreads( + out uint Number); + + [PreserveSig] + new int GetTotalNumberThreads( + out uint Total, + out uint LargestProcess); + + [PreserveSig] + new int GetThreadIdsByIndex( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + uint[] Ids, + [Out][MarshalAs(UnmanagedType.LPArray)] + uint[] SysIds); + + [PreserveSig] + new int GetThreadIdByProcessor( + uint Processor, + out uint Id); + + [PreserveSig] + new int GetCurrentThreadDataOffset( + out ulong Offset); + + [PreserveSig] + new int GetThreadIdByDataOffset( + ulong Offset, + out uint Id); + + [PreserveSig] + new int GetCurrentThreadTeb( + out ulong Offset); + + [PreserveSig] + new int GetThreadIdByTeb( + ulong Offset, + out uint Id); + + [PreserveSig] + new int GetCurrentThreadSystemId( + out uint SysId); + + [PreserveSig] + new int GetThreadIdBySystemId( + uint SysId, + out uint Id); + + [PreserveSig] + new int GetCurrentThreadHandle( + out ulong Handle); + + [PreserveSig] + new int GetThreadIdByHandle( + ulong Handle, + out uint Id); + + [PreserveSig] + new int GetNumberProcesses( + out uint Number); + + [PreserveSig] + new int GetProcessIdsByIndex( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + uint[] Ids, + [Out][MarshalAs(UnmanagedType.LPArray)] + uint[] SysIds); + + [PreserveSig] + new int GetCurrentProcessDataOffset( + out ulong Offset); + + [PreserveSig] + new int GetProcessIdByDataOffset( + ulong Offset, + out uint Id); + + [PreserveSig] + new int GetCurrentProcessPeb( + out ulong Offset); + + [PreserveSig] + new int GetProcessIdByPeb( + ulong Offset, + out uint Id); + + [PreserveSig] + new int GetCurrentProcessSystemId( + out uint SysId); + + [PreserveSig] + new int GetProcessIdBySystemId( + uint SysId, + out uint Id); + + [PreserveSig] + new int GetCurrentProcessHandle( + out ulong Handle); + + [PreserveSig] + new int GetProcessIdByHandle( + ulong Handle, + out uint Id); + + [PreserveSig] + new int GetCurrentProcessExecutableName( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint ExeSize); + + /* IDebugSystemObjects2 */ + + [PreserveSig] + int GetCurrentProcessUpTime( + out uint UpTime); + + [PreserveSig] + int GetImplicitThreadDataOffset( + out ulong Offset); + + [PreserveSig] + int SetImplicitThreadDataOffset( + ulong Offset); + + [PreserveSig] + int GetImplicitProcessDataOffset( + out ulong Offset); + + [PreserveSig] + int SetImplicitProcessDataOffset( + ulong Offset); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSystemObjects3.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSystemObjects3.cs new file mode 100644 index 0000000000..e995a0a248 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/IDebugSystemObjects3.cs @@ -0,0 +1,214 @@ +// 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.Runtime.InteropServices; +using System.Text; + +namespace SOS.Hosting.DbgEng.Interop +{ + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("e9676e2f-e286-4ea3-b0f9-dfe5d9fc330e")] + public interface IDebugSystemObjects3 : IDebugSystemObjects + { + /* IDebugSystemObjects */ + + [PreserveSig] + new int GetEventThread( + out uint Id); + + [PreserveSig] + new int GetEventProcess( + out uint Id); + + [PreserveSig] + new int GetCurrentThreadId( + out uint Id); + + [PreserveSig] + new int SetCurrentThreadId( + uint Id); + + [PreserveSig] + new int GetCurrentProcessId( + out uint Id); + + [PreserveSig] + new int SetCurrentProcessId( + uint Id); + + [PreserveSig] + new int GetNumberThreads( + out uint Number); + + [PreserveSig] + new int GetTotalNumberThreads( + out uint Total, + out uint LargestProcess); + + [PreserveSig] + new int GetThreadIdsByIndex( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + uint[] Ids, + [Out][MarshalAs(UnmanagedType.LPArray)] + uint[] SysIds); + + [PreserveSig] + new int GetThreadIdByProcessor( + uint Processor, + out uint Id); + + [PreserveSig] + new int GetCurrentThreadDataOffset( + out ulong Offset); + + [PreserveSig] + new int GetThreadIdByDataOffset( + ulong Offset, + out uint Id); + + [PreserveSig] + new int GetCurrentThreadTeb( + out ulong Offset); + + [PreserveSig] + new int GetThreadIdByTeb( + ulong Offset, + out uint Id); + + [PreserveSig] + new int GetCurrentThreadSystemId( + out uint SysId); + + [PreserveSig] + new int GetThreadIdBySystemId( + uint SysId, + out uint Id); + + [PreserveSig] + new int GetCurrentThreadHandle( + out ulong Handle); + + [PreserveSig] + new int GetThreadIdByHandle( + ulong Handle, + out uint Id); + + [PreserveSig] + new int GetNumberProcesses( + out uint Number); + + [PreserveSig] + new int GetProcessIdsByIndex( + uint Start, + uint Count, + [Out][MarshalAs(UnmanagedType.LPArray)] + uint[] Ids, + [Out][MarshalAs(UnmanagedType.LPArray)] + uint[] SysIds); + + [PreserveSig] + new int GetCurrentProcessDataOffset( + out ulong Offset); + + [PreserveSig] + new int GetProcessIdByDataOffset( + ulong Offset, + out uint Id); + + [PreserveSig] + new int GetCurrentProcessPeb( + out ulong Offset); + + [PreserveSig] + new int GetProcessIdByPeb( + ulong Offset, + out uint Id); + + [PreserveSig] + new int GetCurrentProcessSystemId( + out uint SysId); + + [PreserveSig] + new int GetProcessIdBySystemId( + uint SysId, + out uint Id); + + [PreserveSig] + new int GetCurrentProcessHandle( + out ulong Handle); + + [PreserveSig] + new int GetProcessIdByHandle( + ulong Handle, + out uint Id); + + [PreserveSig] + new int GetCurrentProcessExecutableName( + [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder Buffer, + int BufferSize, + out uint ExeSize); + + /* IDebugSystemObjects2 */ + + [PreserveSig] + int GetCurrentProcessUpTime( + out uint UpTime); + + [PreserveSig] + int GetImplicitThreadDataOffset( + out ulong Offset); + + [PreserveSig] + int SetImplicitThreadDataOffset( + ulong Offset); + + [PreserveSig] + int GetImplicitProcessDataOffset( + out ulong Offset); + + [PreserveSig] + int SetImplicitProcessDataOffset( + ulong Offset); + + /* IDebugSystemObjects3 */ + [PreserveSig] + int GetEventSystem(out uint id); + + [PreserveSig] + int GetCurrentSystemId(out uint id); + + [PreserveSig] + int SetCurrentSystemId(uint id); + + [PreserveSig] + int GetNumberSystems(out uint count); + + [PreserveSig] + int GetSystemIdsByIndex( + uint start, + uint count, + [Out][MarshalAs(UnmanagedType.LPArray)] + uint[] Ids); + + [PreserveSig] + int GetTotalNumberThreadsAndProcesses( + out uint totalThreads, + out uint totalProcesses, + out uint largestProcessThreads, + out uint largestSystemThreads, + out uint largestSystemProcesses); + + [PreserveSig] + int GetCurrentSystemServer(out ulong server); + + [PreserveSig] + int GetSystemByServer(ulong server, out uint id); + + [PreserveSig] + int GetCurrentSystemServerName([Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder buffer, uint size, out uint needed); + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugBreakpointParameters.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugBreakpointParameters.cs new file mode 100644 index 0000000000..411667c536 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugBreakpointParameters.cs @@ -0,0 +1,25 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_BREAKPOINT_PARAMETERS + { + public ulong Offset; + public uint Id; + public DEBUG_BREAKPOINT_TYPE BreakType; + public uint ProcType; + public DEBUG_BREAKPOINT_FLAG Flags; + public uint DataSize; + public DEBUG_BREAKPOINT_ACCESS_TYPE DataAccessType; + public uint PassCount; + public uint CurrentPassCount; + public uint MatchThread; + public uint CommandSize; + public uint OffsetExpressionSize; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugCachedSymbolInfo.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugCachedSymbolInfo.cs new file mode 100644 index 0000000000..315826be3b --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugCachedSymbolInfo.cs @@ -0,0 +1,18 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_CACHED_SYMBOL_INFO + { + public ulong ModBase; + public ulong Arg1; + public ulong Arg2; + public uint Id; + public uint Arg3; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugCreateProcessOptions.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugCreateProcessOptions.cs new file mode 100644 index 0000000000..7bf036c91f --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugCreateProcessOptions.cs @@ -0,0 +1,17 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_CREATE_PROCESS_OPTIONS + { + public DEBUG_CREATE_PROCESS CreateFlags; + public DEBUG_ECREATE_PROCESS EngCreateFlags; + public uint VerifierFlags; + public uint Reserved; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugEventContext.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugEventContext.cs new file mode 100644 index 0000000000..460e29c8ab --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugEventContext.cs @@ -0,0 +1,17 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_EVENT_CONTEXT + { + public uint Size; + public uint ProcessEngineId; + public uint ThreadEngineId; + public uint FrameEngineId; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugExceptionFilterParameters.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugExceptionFilterParameters.cs new file mode 100644 index 0000000000..16b6fecb37 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugExceptionFilterParameters.cs @@ -0,0 +1,19 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_EXCEPTION_FILTER_PARAMETERS + { + public DEBUG_FILTER_EXEC_OPTION ExecutionOption; + public DEBUG_FILTER_CONTINUE_OPTION ContinueOption; + public uint TextSize; + public uint CommandSize; + public uint SecondCommandSize; + public uint ExceptionCode; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugGetTextCompletionsIn.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugGetTextCompletionsIn.cs new file mode 100644 index 0000000000..e9ff2ba4af --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugGetTextCompletionsIn.cs @@ -0,0 +1,18 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_GET_TEXT_COMPLETIONS_IN + { + public DEBUG_GET_TEXT_COMPLETIONS Flags; + public uint MatchCountLimit; + public ulong Reserved0; + public ulong Reserved1; + public ulong Reserved2; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugGetTextCompletionsOut.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugGetTextCompletionsOut.cs new file mode 100644 index 0000000000..c70463aaef --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugGetTextCompletionsOut.cs @@ -0,0 +1,19 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_GET_TEXT_COMPLETIONS_OUT + { + public DEBUG_GET_TEXT_COMPLETIONS Flags; + public uint ReplaceIndex; + public uint MatchCount; + public uint Reserved1; + public ulong Reserved2; + public ulong Reserved3; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugHandleDataBasic.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugHandleDataBasic.cs new file mode 100644 index 0000000000..b5db002e5e --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugHandleDataBasic.cs @@ -0,0 +1,19 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_HANDLE_DATA_BASIC + { + public uint TypeNameSize; + public uint ObjectNameSize; + public uint Attributes; + public uint GrantedAccess; + public uint HandleCount; + public uint PointerCount; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfo.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfo.cs new file mode 100644 index 0000000000..af922e63d4 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfo.cs @@ -0,0 +1,27 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Explicit)] + public struct DEBUG_LAST_EVENT_INFO + { + [FieldOffset(0)] + public DEBUG_LAST_EVENT_INFO_BREAKPOINT Breakpoint; + [FieldOffset(0)] + public DEBUG_LAST_EVENT_INFO_EXCEPTION Exception; + [FieldOffset(0)] + public DEBUG_LAST_EVENT_INFO_EXIT_THREAD ExitThread; + [FieldOffset(0)] + public DEBUG_LAST_EVENT_INFO_EXIT_PROCESS ExitProcess; + [FieldOffset(0)] + public DEBUG_LAST_EVENT_INFO_LOAD_MODULE LoadModule; + [FieldOffset(0)] + public DEBUG_LAST_EVENT_INFO_UNLOAD_MODULE UnloadModule; + [FieldOffset(0)] + public DEBUG_LAST_EVENT_INFO_SYSTEM_ERROR SystemError; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoBreakpoint.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoBreakpoint.cs new file mode 100644 index 0000000000..f159112ad7 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoBreakpoint.cs @@ -0,0 +1,14 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_LAST_EVENT_INFO_BREAKPOINT + { + public uint Id; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoException.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoException.cs new file mode 100644 index 0000000000..8ec1a30abf --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoException.cs @@ -0,0 +1,15 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_LAST_EVENT_INFO_EXCEPTION + { + public EXCEPTION_RECORD64 ExceptionRecord; + public uint FirstChance; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoExitProcess.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoExitProcess.cs new file mode 100644 index 0000000000..0cfa5fdd27 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoExitProcess.cs @@ -0,0 +1,14 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_LAST_EVENT_INFO_EXIT_PROCESS + { + public uint ExitCode; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoExitThread.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoExitThread.cs new file mode 100644 index 0000000000..eb01311c8a --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoExitThread.cs @@ -0,0 +1,14 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_LAST_EVENT_INFO_EXIT_THREAD + { + public uint ExitCode; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoLoadModule.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoLoadModule.cs new file mode 100644 index 0000000000..3e984511a1 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoLoadModule.cs @@ -0,0 +1,14 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_LAST_EVENT_INFO_LOAD_MODULE + { + public ulong Base; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoSystemError.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoSystemError.cs new file mode 100644 index 0000000000..3ce01d4c18 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoSystemError.cs @@ -0,0 +1,15 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_LAST_EVENT_INFO_SYSTEM_ERROR + { + public uint Error; + public uint Level; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoUnloadModule.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoUnloadModule.cs new file mode 100644 index 0000000000..dbf5ebfaba --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugLastEventInfoUnloadModule.cs @@ -0,0 +1,14 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_LAST_EVENT_INFO_UNLOAD_MODULE + { + public ulong Base; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugModuleAndId.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugModuleAndId.cs new file mode 100644 index 0000000000..bb91ac4967 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugModuleAndId.cs @@ -0,0 +1,25 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + /// <summary> + /// Describes a symbol within a module. + /// </summary> + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_MODULE_AND_ID + { + /// <summary> + /// The location in the target's virtual address space of the module's base address. + /// </summary> + public ulong ModuleBase; + + /// <summary> + /// The symbol ID of the symbol within the module. + /// </summary> + public ulong Id; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugModuleParameters.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugModuleParameters.cs new file mode 100644 index 0000000000..807bdcbeed --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugModuleParameters.cs @@ -0,0 +1,25 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct DEBUG_MODULE_PARAMETERS + { + public ulong Base; + public uint Size; + public uint TimeDateStamp; + public uint Checksum; + public DEBUG_MODULE Flags; + public DEBUG_SYMTYPE SymbolType; + public uint ImageNameSize; + public uint ModuleNameSize; + public uint LoadedImageNameSize; + public uint SymbolFileNameSize; + public uint MappedImageNameSize; + public fixed ulong Reserved[2]; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugOffsetRegion.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugOffsetRegion.cs new file mode 100644 index 0000000000..8e55a14a0d --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugOffsetRegion.cs @@ -0,0 +1,15 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public readonly struct DEBUG_OFFSET_REGION + { + private readonly ulong _base; + private readonly ulong _size; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugReadUserMinidumpStream.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugReadUserMinidumpStream.cs new file mode 100644 index 0000000000..5d512b7a80 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugReadUserMinidumpStream.cs @@ -0,0 +1,20 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_READ_USER_MINIDUMP_STREAM + { + public uint StreamType; + public uint Flags; + public ulong Offset; + public IntPtr Buffer; + public uint BufferSize; + public uint BufferUsed; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugRegisterDescription.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugRegisterDescription.cs new file mode 100644 index 0000000000..7001b0f11e --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugRegisterDescription.cs @@ -0,0 +1,20 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_REGISTER_DESCRIPTION + { + public DEBUG_VALUE_TYPE Type; + public DEBUG_REGISTER Flags; + public ulong SubregMaster; + public ulong SubregLength; + public ulong SubregMask; + public ulong SubregShift; + public ulong Reserved0; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugSpecificFilterParameters.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugSpecificFilterParameters.cs new file mode 100644 index 0000000000..64f410cae5 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugSpecificFilterParameters.cs @@ -0,0 +1,18 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_SPECIFIC_FILTER_PARAMETERS + { + public DEBUG_FILTER_EXEC_OPTION ExecutionOption; + public DEBUG_FILTER_CONTINUE_OPTION ContinueOption; + public uint TextSize; + public uint CommandSize; + public uint ArgumentSize; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugStackFrame.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugStackFrame.cs new file mode 100644 index 0000000000..8c49521184 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugStackFrame.cs @@ -0,0 +1,22 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct DEBUG_STACK_FRAME + { + public ulong InstructionOffset; + public ulong ReturnOffset; + public ulong FrameOffset; + public ulong StackOffset; + public ulong FuncTableEntry; + public fixed ulong Params[4]; + public fixed ulong Reserved[6]; + public uint Virtual; + public uint FrameNumber; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugStackFrameEx.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugStackFrameEx.cs new file mode 100644 index 0000000000..3f6a181dcb --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugStackFrameEx.cs @@ -0,0 +1,49 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct DEBUG_STACK_FRAME_EX + { + /* DEBUG_STACK_FRAME */ + public ulong InstructionOffset; + public ulong ReturnOffset; + public ulong FrameOffset; + public ulong StackOffset; + public ulong FuncTableEntry; + public fixed ulong Params[4]; + public fixed ulong Reserved[6]; + public uint Virtual; + public uint FrameNumber; + + /* DEBUG_STACK_FRAME_EX */ + public uint InlineFrameContext; + public uint Reserved1; + + public DEBUG_STACK_FRAME_EX(DEBUG_STACK_FRAME dsf) + { + InstructionOffset = dsf.InstructionOffset; + ReturnOffset = dsf.ReturnOffset; + FrameOffset = dsf.FrameOffset; + StackOffset = dsf.StackOffset; + FuncTableEntry = dsf.FuncTableEntry; + + fixed (ulong* pParams = Params) + for (int i = 0; i < 4; ++i) + pParams[i] = dsf.Params[i]; + + fixed (ulong* pReserved = Params) + for (int i = 0; i < 6; ++i) + pReserved[i] = dsf.Reserved[i]; + + Virtual = dsf.Virtual; + FrameNumber = dsf.FrameNumber; + InlineFrameContext = 0xFFFFFFFF; + Reserved1 = 0; + } + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugSymbolEntry.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugSymbolEntry.cs new file mode 100644 index 0000000000..de2d955d9f --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugSymbolEntry.cs @@ -0,0 +1,25 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_SYMBOL_ENTRY + { + public ulong ModuleBase; + public ulong Offset; + public ulong Id; + public ulong Arg64; + public uint Size; + public uint Flags; + public uint TypeId; + public uint NameSize; + public uint Token; + public SymTag Tag; + public uint Arg32; + public uint Reserved; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugSymbolParameters.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugSymbolParameters.cs new file mode 100644 index 0000000000..168f47f5cb --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugSymbolParameters.cs @@ -0,0 +1,19 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_SYMBOL_PARAMETERS + { + public ulong Module; + public uint TypeId; + public uint ParentSymbol; + public uint SubElements; + public DEBUG_SYMBOL Flags; + public ulong Reserved; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugSymbolSourceEntry.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugSymbolSourceEntry.cs new file mode 100644 index 0000000000..8a4b6f4983 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugSymbolSourceEntry.cs @@ -0,0 +1,29 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public readonly struct DEBUG_SYMBOL_SOURCE_ENTRY + { + private readonly ulong _moduleBase; + private readonly ulong _offset; + private readonly ulong _fileNameId; + private readonly ulong _engineInternal; + private readonly uint _size; + private readonly uint _flags; + private readonly uint _fileNameSize; + // Line numbers are one-based. + // May be DEBUG_ANY_ID if unknown. + private readonly uint _startLine; + private readonly uint _endLine; + // Column numbers are one-based byte indices. + // May be DEBUG_ANY_ID if unknown. + private readonly uint _startColumn; + private readonly uint _endColumn; + private readonly uint _reserved; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugThreadBasicInformation.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugThreadBasicInformation.cs new file mode 100644 index 0000000000..7e78376028 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugThreadBasicInformation.cs @@ -0,0 +1,23 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct DEBUG_THREAD_BASIC_INFORMATION + { + public DEBUG_TBINFO Valid; + public uint ExitStatus; + public uint PriorityClass; + public uint Priority; + public ulong CreateTime; + public ulong ExitTime; + public ulong KernelTime; + public ulong UserTime; + public ulong StartOffset; + public ulong Affinity; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugTypedData.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugTypedData.cs new file mode 100644 index 0000000000..6bd40eb51d --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugTypedData.cs @@ -0,0 +1,24 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct _DEBUG_TYPED_DATA + { + public ulong ModBase; + public ulong Offset; + public ulong EngineHandle; + public ulong Data; + public uint Size; + public uint Flags; + public uint TypeId; + public uint BaseTypeId; + public uint Tag; + public uint Register; + public fixed ulong Internal[9]; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugValue.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugValue.cs new file mode 100644 index 0000000000..0a7db56ecc --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/DebugValue.cs @@ -0,0 +1,55 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe struct DEBUG_VALUE + { + [FieldOffset(0)] + public byte I8; + [FieldOffset(0)] + public ushort I16; + [FieldOffset(0)] + public uint I32; + [FieldOffset(0)] + public ulong I64; + [FieldOffset(8)] + public uint Nat; + [FieldOffset(0)] + public float F32; + [FieldOffset(0)] + public double F64; + [FieldOffset(0)] + public fixed byte F80Bytes[10]; + [FieldOffset(0)] + public fixed byte F82Bytes[11]; + [FieldOffset(0)] + public fixed byte F128Bytes[16]; + [FieldOffset(0)] + public fixed byte VI8[16]; + [FieldOffset(0)] + public fixed ushort VI16[8]; + [FieldOffset(0)] + public fixed uint VI32[4]; + [FieldOffset(0)] + public fixed ulong VI64[2]; + [FieldOffset(0)] + public fixed float VF32[4]; + [FieldOffset(0)] + public fixed double VF64[2]; + [FieldOffset(0)] + public I64PARTS32 I64Parts32; + [FieldOffset(0)] + public F128PARTS64 F128Parts64; + [FieldOffset(0)] + public fixed byte RawBytes[24]; + [FieldOffset(24)] + public uint TailOfRawBytes; + [FieldOffset(28)] + public DEBUG_VALUE_TYPE Type; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ExceptionRecord64.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ExceptionRecord64.cs new file mode 100644 index 0000000000..6768177618 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ExceptionRecord64.cs @@ -0,0 +1,20 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct EXCEPTION_RECORD64 + { + public uint ExceptionCode; + public uint ExceptionFlags; + public ulong ExceptionRecord; + public ulong ExceptionAddress; + public uint NumberParameters; + public uint __unusedAlignment; + public fixed ulong ExceptionInformation[15]; //EXCEPTION_MAXIMUM_PARAMETERS + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ExtTypedData.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ExtTypedData.cs new file mode 100644 index 0000000000..e14bafee20 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ExtTypedData.cs @@ -0,0 +1,51 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct _EXT_TYPED_DATA + { + public _EXT_TDOP Operation; + public uint Flags; + public _DEBUG_TYPED_DATA InData; + public _DEBUG_TYPED_DATA OutData; + public uint InStrIndex; + public uint In32; + public uint Out32; + public ulong In64; + public ulong Out64; + public uint StrBufferIndex; + public uint StrBufferChars; + public uint StrCharsNeeded; + public uint DataBufferIndex; + public uint DataBufferBytes; + public uint DataBytesNeeded; + public uint Status; + public fixed ulong Reserved[8]; + } + + [StructLayout(LayoutKind.Sequential)] + public class EXT_TYPED_DATA + { + public _EXT_TDOP Operation; + public uint Flags; + public _DEBUG_TYPED_DATA InData; + public _DEBUG_TYPED_DATA OutData; + public uint InStrIndex; + public uint In32; + public uint Out32; + public ulong In64; + public ulong Out64; + public uint StrBufferIndex; + public uint StrBufferChars; + public uint StrCharsNeeded; + public uint DataBufferIndex; + public uint DataBufferBytes; + public uint DataBytesNeeded; + public uint Status; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/F128Parts64.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/F128Parts64.cs new file mode 100644 index 0000000000..1b028e5a38 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/F128Parts64.cs @@ -0,0 +1,17 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Explicit)] + public struct F128PARTS64 + { + [FieldOffset(0)] + public ulong LowPart; + [FieldOffset(8)] + public ulong HighPart; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/I64Parts32.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/I64Parts32.cs new file mode 100644 index 0000000000..0083645951 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/I64Parts32.cs @@ -0,0 +1,17 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Explicit)] + public struct I64PARTS32 + { + [FieldOffset(0)] + public uint LowPart; + [FieldOffset(4)] + public uint HighPart; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageCor20Header.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageCor20Header.cs new file mode 100644 index 0000000000..4bb0662b5f --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageCor20Header.cs @@ -0,0 +1,44 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct IMAGE_COR20_HEADER + { + // Header versioning + public uint cb; + public ushort MajorRuntimeVersion; + public ushort MinorRuntimeVersion; + + // Symbol table and startup information + public IMAGE_DATA_DIRECTORY MetaData; + public uint Flags; + + // The main program if it is an EXE (not used if a DLL?) + // If COMIMAGE_FLAGS_NATIVE_ENTRYPOINT is not set, EntryPointToken represents a managed entrypoint. + // If COMIMAGE_FLAGS_NATIVE_ENTRYPOINT is set, EntryPointRVA represents an RVA to a native entrypoint + // (deprecated for DLLs, use modules constructors instead). + public IMAGE_COR20_HEADER_ENTRYPOINT EntryPoint; + + // This is the blob of managed resources. Fetched using code:AssemblyNative.GetResource and + // code:PEFile.GetResource and accessible from managed code from + // System.Assembly.GetManifestResourceStream. The meta data has a table that maps names to offsets into + // this blob, so logically the blob is a set of resources. + public IMAGE_DATA_DIRECTORY Resources; + // IL assemblies can be signed with a public-private key to validate who created it. The signature goes + // here if this feature is used. + public IMAGE_DATA_DIRECTORY StrongNameSignature; + + public IMAGE_DATA_DIRECTORY CodeManagerTable; // Deprecated, not used + // Used for managed code that has unmanaged code inside it (or exports methods as unmanaged entry points) + public IMAGE_DATA_DIRECTORY VTableFixups; + public IMAGE_DATA_DIRECTORY ExportAddressTableJumps; + + // null for ordinary IL images. NGEN images it points at a code:CORCOMPILE_HEADER structure + public IMAGE_DATA_DIRECTORY ManagedNativeHeader; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageCor20HeaderEntryPoint.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageCor20HeaderEntryPoint.cs new file mode 100644 index 0000000000..fad1546439 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageCor20HeaderEntryPoint.cs @@ -0,0 +1,17 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Explicit)] + public readonly struct IMAGE_COR20_HEADER_ENTRYPOINT + { + [FieldOffset(0)] + public readonly uint Token; + [FieldOffset(0)] + public readonly uint RVA; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageDataDirectory.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageDataDirectory.cs new file mode 100644 index 0000000000..92f5eec3b3 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageDataDirectory.cs @@ -0,0 +1,15 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct IMAGE_DATA_DIRECTORY + { + public uint VirtualAddress; + public uint Size; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageDosHeader.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageDosHeader.cs new file mode 100644 index 0000000000..5e1c26e022 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageDosHeader.cs @@ -0,0 +1,51 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe struct IMAGE_DOS_HEADER + { + [FieldOffset(0)] + public ushort e_magic; // Magic number + [FieldOffset(2)] + public ushort e_cblp; // Bytes on last page of file + [FieldOffset(4)] + public ushort e_cp; // Pages in file + [FieldOffset(6)] + public ushort e_crlc; // Relocations + [FieldOffset(8)] + public ushort e_cparhdr; // Size of header in paragraphs + [FieldOffset(10)] + public ushort e_minalloc; // Minimum extra paragraphs needed + [FieldOffset(12)] + public ushort e_maxalloc; // Maximum extra paragraphs needed + [FieldOffset(14)] + public ushort e_ss; // Initial (relative) SS value + [FieldOffset(16)] + public ushort e_sp; // Initial SP value + [FieldOffset(18)] + public ushort e_csum; // Checksum + [FieldOffset(20)] + public ushort e_ip; // Initial IP value + [FieldOffset(22)] + public ushort e_cs; // Initial (relative) CS value + [FieldOffset(24)] + public ushort e_lfarlc; // File address of relocation table + [FieldOffset(26)] + public ushort e_ovno; // Overlay number + [FieldOffset(28)] + public fixed ushort e_res[4]; // Reserved words + [FieldOffset(36)] + public ushort e_oemid; // OEM identifier (for e_oeminfo) + [FieldOffset(38)] + public ushort e_oeminfo; // OEM information; e_oemid specific + [FieldOffset(40)] + public fixed ushort e_res2[10]; // Reserved words + [FieldOffset(60)] + public uint e_lfanew; // File address of new exe header + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageFileHeader.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageFileHeader.cs new file mode 100644 index 0000000000..1890b4812e --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageFileHeader.cs @@ -0,0 +1,27 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Explicit)] + public struct IMAGE_FILE_HEADER + { + [FieldOffset(0)] + public ushort Machine; + [FieldOffset(2)] + public ushort NumberOfSections; + [FieldOffset(4)] + public uint TimeDateStamp; + [FieldOffset(8)] + public uint PointerToSymbolTable; + [FieldOffset(12)] + public uint NumberOfSymbols; + [FieldOffset(16)] + public ushort SizeOfOptionalHeader; + [FieldOffset(18)] + public ushort Characteristics; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageHlpModule64.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageHlpModule64.cs new file mode 100644 index 0000000000..75168937d1 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageHlpModule64.cs @@ -0,0 +1,125 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct IMAGEHLP_MODULE64 + { + private const int MAX_PATH = 260; + + public uint SizeOfStruct; + public ulong BaseOfImage; + public uint ImageSize; + public uint TimeDateStamp; + public uint CheckSum; + public uint NumSyms; + public DEBUG_SYMTYPE SymType; + private fixed char _ModuleName[32]; + private fixed char _ImageName[256]; + private fixed char _LoadedImageName[256]; + private fixed char _LoadedPdbName[256]; + public uint CVSig; + public fixed char CVData[MAX_PATH * 3]; + public uint PdbSig; + public Guid PdbSig70; + public uint PdbAge; + private uint _bPdbUnmatched; /* BOOL */ + private uint _bDbgUnmatched; /* BOOL */ + private uint _bLineNumbers; /* BOOL */ + private uint _bGlobalSymbols; /* BOOL */ + private uint _bTypeInfo; /* BOOL */ + private uint _bSourceIndexed; /* BOOL */ + private uint _bPublics; /* BOOL */ + + public bool PdbUnmatched + { + get => _bPdbUnmatched != 0; + set => _bPdbUnmatched = value ? 1U : 0U; + } + + public bool DbgUnmatched + { + get => _bDbgUnmatched != 0; + set => _bDbgUnmatched = value ? 1U : 0U; + } + + public bool LineNumbers + { + get => _bLineNumbers != 0; + set => _bLineNumbers = value ? 1U : 0U; + } + + public bool GlobalSymbols + { + get => _bGlobalSymbols != 0; + set => _bGlobalSymbols = value ? 1U : 0U; + } + + public bool TypeInfo + { + get => _bTypeInfo != 0; + set => _bTypeInfo = value ? 1U : 0U; + } + + public bool SourceIndexed + { + get => _bSourceIndexed != 0; + set => _bSourceIndexed = value ? 1U : 0U; + } + + public bool Publics + { + get => _bPublics != 0; + set => _bPublics = value ? 1U : 0U; + } + + public string ModuleName + { + get + { + fixed (char* moduleNamePtr = _ModuleName) + { + return Marshal.PtrToStringUni((IntPtr)moduleNamePtr, 32); + } + } + } + + public string ImageName + { + get + { + fixed (char* imageNamePtr = _ImageName) + { + return Marshal.PtrToStringUni((IntPtr)imageNamePtr, 256); + } + } + } + + public string LoadedImageName + { + get + { + fixed (char* loadedImageNamePtr = _LoadedImageName) + { + return Marshal.PtrToStringUni((IntPtr)loadedImageNamePtr, 256); + } + } + } + + public string LoadedPdbName + { + get + { + fixed (char* loadedPdbNamePtr = _LoadedPdbName) + { + return Marshal.PtrToStringUni((IntPtr)loadedPdbNamePtr, 256); + } + } + } + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageImportDescriptor.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageImportDescriptor.cs new file mode 100644 index 0000000000..6de40c5671 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageImportDescriptor.cs @@ -0,0 +1,29 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Explicit)] + public struct IMAGE_IMPORT_DESCRIPTOR + { + [FieldOffset(0)] + public uint Characteristics; // 0 for terminating null import descriptor + [FieldOffset(0)] + public uint OriginalFirstThunk; // RVA to original unbound IAT (PIMAGE_THUNK_DATA) + [FieldOffset(4)] + public uint TimeDateStamp; // 0 if not bound, + // -1 if bound, and real date\time stamp + // in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT (new BIND) + // O.W. date/time stamp of DLL bound to (Old BIND) + + [FieldOffset(8)] + public uint ForwarderChain; // -1 if no forwarders + [FieldOffset(12)] + public uint Name; + [FieldOffset(16)] + public uint FirstThunk; // RVA to IAT (if bound this IAT has actual addresses) + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageNtHeaders32.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageNtHeaders32.cs new file mode 100644 index 0000000000..6a890682c1 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageNtHeaders32.cs @@ -0,0 +1,19 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Explicit)] + public struct IMAGE_NT_HEADERS32 + { + [FieldOffset(0)] + public uint Signature; + [FieldOffset(4)] + public IMAGE_FILE_HEADER FileHeader; + [FieldOffset(24)] + public IMAGE_OPTIONAL_HEADER32 OptionalHeader; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageNtHeaders64.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageNtHeaders64.cs new file mode 100644 index 0000000000..b7914ecb16 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageNtHeaders64.cs @@ -0,0 +1,19 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Explicit)] + public struct IMAGE_NT_HEADERS64 + { + [FieldOffset(0)] + public uint Signature; + [FieldOffset(4)] + public IMAGE_FILE_HEADER FileHeader; + [FieldOffset(24)] + public IMAGE_OPTIONAL_HEADER64 OptionalHeader; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageOptionalHeader32.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageOptionalHeader32.cs new file mode 100644 index 0000000000..dc0fa8703d --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageOptionalHeader32.cs @@ -0,0 +1,110 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Explicit)] + public struct IMAGE_OPTIONAL_HEADER32 + { + [FieldOffset(0)] + public ushort Magic; + [FieldOffset(2)] + public byte MajorLinkerVersion; + [FieldOffset(3)] + public byte MinorLinkerVersion; + [FieldOffset(4)] + public uint SizeOfCode; + [FieldOffset(8)] + public uint SizeOfInitializedData; + [FieldOffset(12)] + public uint SizeOfUninitializedData; + [FieldOffset(16)] + public uint AddressOfEntryPoint; + [FieldOffset(20)] + public uint BaseOfCode; + [FieldOffset(24)] + public uint BaseOfData; + [FieldOffset(28)] + public uint ImageBase; + [FieldOffset(32)] + public uint SectionAlignment; + [FieldOffset(36)] + public uint FileAlignment; + [FieldOffset(40)] + public ushort MajorOperatingSystemVersion; + [FieldOffset(42)] + public ushort MinorOperatingSystemVersion; + [FieldOffset(44)] + public ushort MajorImageVersion; + [FieldOffset(46)] + public ushort MinorImageVersion; + [FieldOffset(48)] + public ushort MajorSubsystemVersion; + [FieldOffset(50)] + public ushort MinorSubsystemVersion; + [FieldOffset(52)] + public uint Win32VersionValue; + [FieldOffset(56)] + public uint SizeOfImage; + [FieldOffset(60)] + public uint SizeOfHeaders; + [FieldOffset(64)] + public uint CheckSum; + [FieldOffset(68)] + public ushort Subsystem; + [FieldOffset(70)] + public ushort DllCharacteristics; + [FieldOffset(72)] + public uint SizeOfStackReserve; + [FieldOffset(76)] + public uint SizeOfStackCommit; + [FieldOffset(80)] + public uint SizeOfHeapReserve; + [FieldOffset(84)] + public uint SizeOfHeapCommit; + [FieldOffset(88)] + public uint LoaderFlags; + [FieldOffset(92)] + public uint NumberOfRvaAndSizes; + [FieldOffset(96)] + public IMAGE_DATA_DIRECTORY DataDirectory0; + [FieldOffset(104)] + public IMAGE_DATA_DIRECTORY DataDirectory1; + [FieldOffset(112)] + public IMAGE_DATA_DIRECTORY DataDirectory2; + [FieldOffset(120)] + public IMAGE_DATA_DIRECTORY DataDirectory3; + [FieldOffset(128)] + public IMAGE_DATA_DIRECTORY DataDirectory4; + [FieldOffset(136)] + public IMAGE_DATA_DIRECTORY DataDirectory5; + [FieldOffset(144)] + public IMAGE_DATA_DIRECTORY DataDirectory6; + [FieldOffset(152)] + public IMAGE_DATA_DIRECTORY DataDirectory7; + [FieldOffset(160)] + public IMAGE_DATA_DIRECTORY DataDirectory8; + [FieldOffset(168)] + public IMAGE_DATA_DIRECTORY DataDirectory9; + [FieldOffset(176)] + public IMAGE_DATA_DIRECTORY DataDirectory10; + [FieldOffset(284)] + public IMAGE_DATA_DIRECTORY DataDirectory11; + [FieldOffset(292)] + public IMAGE_DATA_DIRECTORY DataDirectory12; + [FieldOffset(300)] + public IMAGE_DATA_DIRECTORY DataDirectory13; + [FieldOffset(308)] + public IMAGE_DATA_DIRECTORY DataDirectory14; + [FieldOffset(316)] + public IMAGE_DATA_DIRECTORY DataDirectory15; + + public static unsafe IMAGE_DATA_DIRECTORY* GetDataDirectory(IMAGE_OPTIONAL_HEADER32* header, int zeroBasedIndex) + { + return &header->DataDirectory0 + zeroBasedIndex; + } + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageOptionalHeader64.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageOptionalHeader64.cs new file mode 100644 index 0000000000..1b7076fd96 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageOptionalHeader64.cs @@ -0,0 +1,108 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Explicit)] + public struct IMAGE_OPTIONAL_HEADER64 + { + [FieldOffset(0)] + public ushort Magic; + [FieldOffset(2)] + public byte MajorLinkerVersion; + [FieldOffset(3)] + public byte MinorLinkerVersion; + [FieldOffset(4)] + public uint SizeOfCode; + [FieldOffset(8)] + public uint SizeOfInitializedData; + [FieldOffset(12)] + public uint SizeOfUninitializedData; + [FieldOffset(16)] + public uint AddressOfEntryPoint; + [FieldOffset(20)] + public uint BaseOfCode; + [FieldOffset(24)] + public ulong ImageBase; + [FieldOffset(32)] + public uint SectionAlignment; + [FieldOffset(36)] + public uint FileAlignment; + [FieldOffset(40)] + public ushort MajorOperatingSystemVersion; + [FieldOffset(42)] + public ushort MinorOperatingSystemVersion; + [FieldOffset(44)] + public ushort MajorImageVersion; + [FieldOffset(46)] + public ushort MinorImageVersion; + [FieldOffset(48)] + public ushort MajorSubsystemVersion; + [FieldOffset(50)] + public ushort MinorSubsystemVersion; + [FieldOffset(52)] + public uint Win32VersionValue; + [FieldOffset(56)] + public uint SizeOfImage; + [FieldOffset(60)] + public uint SizeOfHeaders; + [FieldOffset(64)] + public uint CheckSum; + [FieldOffset(68)] + public ushort Subsystem; + [FieldOffset(70)] + public ushort DllCharacteristics; + [FieldOffset(72)] + public ulong SizeOfStackReserve; + [FieldOffset(80)] + public ulong SizeOfStackCommit; + [FieldOffset(88)] + public ulong SizeOfHeapReserve; + [FieldOffset(96)] + public ulong SizeOfHeapCommit; + [FieldOffset(104)] + public uint LoaderFlags; + [FieldOffset(108)] + public uint NumberOfRvaAndSizes; + [FieldOffset(112)] + public IMAGE_DATA_DIRECTORY DataDirectory0; + [FieldOffset(120)] + public IMAGE_DATA_DIRECTORY DataDirectory1; + [FieldOffset(128)] + public IMAGE_DATA_DIRECTORY DataDirectory2; + [FieldOffset(136)] + public IMAGE_DATA_DIRECTORY DataDirectory3; + [FieldOffset(144)] + public IMAGE_DATA_DIRECTORY DataDirectory4; + [FieldOffset(152)] + public IMAGE_DATA_DIRECTORY DataDirectory5; + [FieldOffset(160)] + public IMAGE_DATA_DIRECTORY DataDirectory6; + [FieldOffset(168)] + public IMAGE_DATA_DIRECTORY DataDirectory7; + [FieldOffset(176)] + public IMAGE_DATA_DIRECTORY DataDirectory8; + [FieldOffset(184)] + public IMAGE_DATA_DIRECTORY DataDirectory9; + [FieldOffset(192)] + public IMAGE_DATA_DIRECTORY DataDirectory10; + [FieldOffset(200)] + public IMAGE_DATA_DIRECTORY DataDirectory11; + [FieldOffset(208)] + public IMAGE_DATA_DIRECTORY DataDirectory12; + [FieldOffset(216)] + public IMAGE_DATA_DIRECTORY DataDirectory13; + [FieldOffset(224)] + public IMAGE_DATA_DIRECTORY DataDirectory14; + [FieldOffset(232)] + public IMAGE_DATA_DIRECTORY DataDirectory15; + + public static unsafe IMAGE_DATA_DIRECTORY* GetDataDirectory(IMAGE_OPTIONAL_HEADER64* header, int zeroBasedIndex) + { + return &header->DataDirectory0 + zeroBasedIndex; + } + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageThunkData32.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageThunkData32.cs new file mode 100644 index 0000000000..028e9afd3b --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageThunkData32.cs @@ -0,0 +1,21 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Explicit)] + public struct IMAGE_THUNK_DATA32 + { + [FieldOffset(0)] + public uint ForwarderString; // PBYTE + [FieldOffset(0)] + public uint Function; // PDWORD + [FieldOffset(0)] + public uint Ordinal; + [FieldOffset(0)] + public uint AddressOfData; // PIMAGE_IMPORT_BY_NAME + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageThunkData64.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageThunkData64.cs new file mode 100644 index 0000000000..0211ef8432 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/ImageThunkData64.cs @@ -0,0 +1,21 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Explicit)] + public struct IMAGE_THUNK_DATA64 + { + [FieldOffset(0)] + public ulong ForwarderString; // PBYTE + [FieldOffset(0)] + public ulong Function; // PDWORD + [FieldOffset(0)] + public ulong Ordinal; + [FieldOffset(0)] + public ulong AddressOfData; // PIMAGE_IMPORT_BY_NAME + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/LandAndCodePage.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/LandAndCodePage.cs new file mode 100644 index 0000000000..eddc5ae273 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/LandAndCodePage.cs @@ -0,0 +1,17 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Explicit)] + public struct LANGANDCODEPAGE + { + [FieldOffset(0)] + public ushort wLanguage; + [FieldOffset(2)] + public ushort wCodePage; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/MemoryBasicInformation64.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/MemoryBasicInformation64.cs new file mode 100644 index 0000000000..75e6f751bc --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/MemoryBasicInformation64.cs @@ -0,0 +1,22 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct MEMORY_BASIC_INFORMATION64 + { + public ulong BaseAddress; + public ulong AllocationBase; + public PAGE AllocationProtect; + public uint __alignment1; + public ulong RegionSize; + public MEM State; + public PAGE Protect; + public MEM Type; + public uint __alignment2; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/Rect.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/Rect.cs new file mode 100644 index 0000000000..8e250b6f72 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/Rect.cs @@ -0,0 +1,17 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct RECT + { + public int left; + public int top; + public int right; + public int bottom; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/VsFixedFileInfo.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/VsFixedFileInfo.cs new file mode 100644 index 0000000000..6c5418f53e --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/VsFixedFileInfo.cs @@ -0,0 +1,26 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct VS_FIXEDFILEINFO + { + public uint dwSignature; + public uint dwStrucVersion; + public uint dwFileVersionMS; + public uint dwFileVersionLS; + public uint dwProductVersionMS; + public uint dwProductVersionLS; + public uint dwFileFlagsMask; + public VS_FF dwFileFlags; + public uint dwFileOS; + public uint dwFileType; + public uint dwFileSubtype; + public uint dwFileDateMS; + public uint dwFileDateLS; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/WdbgExtsClrDataInterface.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/WdbgExtsClrDataInterface.cs new file mode 100644 index 0000000000..b5060c3e5c --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/WdbgExtsClrDataInterface.cs @@ -0,0 +1,24 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public unsafe struct WDBGEXTS_CLR_DATA_INTERFACE + { + public Guid* Iid; + private readonly void* _iface; + + public WDBGEXTS_CLR_DATA_INTERFACE(Guid* iid) + { + Iid = iid; + _iface = null; + } + + public object Interface => _iface != null ? Marshal.GetObjectForIUnknown((IntPtr)_iface) : null; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/WdbgExtsThreadOsInfo.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/WdbgExtsThreadOsInfo.cs new file mode 100644 index 0000000000..809188866f --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/WdbgExtsThreadOsInfo.cs @@ -0,0 +1,23 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct WDBGEXTS_THREAD_OS_INFO + { + public uint ThreadId; + public uint ExitStatus; + public uint PriorityClass; + public uint Priority; + public ulong CreateTime; + public ulong ExitTime; + public ulong KernelTime; + public ulong UserTime; + public ulong StartOffset; + public ulong Affinity; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/WinDbgExtensionApis.cs b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/WinDbgExtensionApis.cs new file mode 100644 index 0000000000..bbd6375340 --- /dev/null +++ b/src/SOS/SOS.Hosting/DbgEng/Interop/Structs/WinDbgExtensionApis.cs @@ -0,0 +1,26 @@ +// 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.Runtime.InteropServices; + +namespace SOS.Hosting.DbgEng.Interop +{ + [StructLayout(LayoutKind.Sequential)] + public struct WINDBG_EXTENSION_APIS /*32 or 64; both are defined the same in managed code*/ + { + public uint nSize; + public IntPtr lpOutputRoutine; + public IntPtr lpGetExpressionRoutine; + public IntPtr lpGetSymbolRoutine; + public IntPtr lpDisasmRoutine; + public IntPtr lpCheckControlCRoutine; + public IntPtr lpReadProcessMemoryRoutine; + public IntPtr lpWriteProcessMemoryRoutine; + public IntPtr lpGetThreadContextRoutine; + public IntPtr lpSetThreadContextRoutine; + public IntPtr lpIoctlRoutine; + public IntPtr lpStackTraceRoutine; + } +} \ No newline at end of file diff --git a/src/SOS/SOS.Hosting/HostWrapper.cs b/src/SOS/SOS.Hosting/HostWrapper.cs index e1fb16bb27..5b9a2c17de 100644 --- a/src/SOS/SOS.Hosting/HostWrapper.cs +++ b/src/SOS/SOS.Hosting/HostWrapper.cs @@ -48,7 +48,7 @@ public HostWrapper(IHost host, Func<TargetWrapper> getTarget) /// </summary> /// <param name="targetWrapper">target wrapper address returned</param> /// <returns>S_OK</returns> - private HResult GetCurrentTarget(IntPtr self, out IntPtr targetWrapper) + private int GetCurrentTarget(IntPtr self, out IntPtr targetWrapper) { TargetWrapper wrapper = _getTarget(); if (wrapper == null) @@ -70,13 +70,13 @@ private delegate HostType GetHostTypeDelegate( [In] IntPtr self); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - internal delegate HResult GetServiceDelegate( + internal delegate int GetServiceDelegate( [In] IntPtr self, [In] in Guid guid, [Out] out IntPtr ptr); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult GetCurrentTargetDelegate( + private delegate int GetCurrentTargetDelegate( [In] IntPtr self, [Out] out IntPtr target); diff --git a/src/SOS/SOS.Hosting/LLDBServices.cs b/src/SOS/SOS.Hosting/LLDBServices.cs index f954c39919..d10050fc5a 100644 --- a/src/SOS/SOS.Hosting/LLDBServices.cs +++ b/src/SOS/SOS.Hosting/LLDBServices.cs @@ -3,14 +3,12 @@ // See the LICENSE file in the project root for more information. using Microsoft.Diagnostics.DebugServices; -using Microsoft.Diagnostics.Runtime; -using Microsoft.Diagnostics.Runtime.Interop; using Microsoft.Diagnostics.Runtime.Utilities; +using SOS.Hosting.DbgEng.Interop; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Linq; using System.Runtime.InteropServices; using System.Text; diff --git a/src/SOS/SOS.Hosting/RuntimeWrapper.cs b/src/SOS/SOS.Hosting/RuntimeWrapper.cs index 4cd6d655df..4306f83d43 100644 --- a/src/SOS/SOS.Hosting/RuntimeWrapper.cs +++ b/src/SOS/SOS.Hosting/RuntimeWrapper.cs @@ -4,8 +4,8 @@ using Microsoft.Diagnostics.DebugServices; using Microsoft.Diagnostics.Runtime; -using Microsoft.Diagnostics.Runtime.Interop; using Microsoft.Diagnostics.Runtime.Utilities; +using SOS.Hosting.DbgEng.Interop; using System; using System.Diagnostics; using System.IO; @@ -252,8 +252,8 @@ private int GetEEVersion( { return HResult.E_FAIL; } - VersionData versionData = module.GetVersionData(); - if (versionData is null) + Version version = module.GetVersionData(); + if (version is null) { return HResult.E_FAIL; } @@ -261,8 +261,8 @@ private int GetEEVersion( pFileInfo->dwStrucVersion = 0; pFileInfo->dwFileFlagsMask = 0; pFileInfo->dwFileFlags = 0; - pFileInfo->dwFileVersionMS = (uint)versionData.Minor | (uint)versionData.Major << 16; - pFileInfo->dwFileVersionLS = (uint)versionData.Patch | (uint)versionData.Revision << 16; + pFileInfo->dwFileVersionMS = (uint)version.Minor & 0xffff | (uint)version.Major << 16; + pFileInfo->dwFileVersionLS = (uint)version.Revision & 0xffff | (uint)version.Build << 16; // Attempt to get the FileVersion string that contains version and the "built by" and commit id info if (fileVersionBuffer != null) diff --git a/src/SOS/SOS.Hosting/SOS.Hosting.csproj b/src/SOS/SOS.Hosting/SOS.Hosting.csproj index 5eab9ca5bc..1050596453 100644 --- a/src/SOS/SOS.Hosting/SOS.Hosting.csproj +++ b/src/SOS/SOS.Hosting/SOS.Hosting.csproj @@ -11,7 +11,6 @@ <ItemGroup> <PackageReference Include="Microsoft.Diagnostics.Runtime" Version="$(MicrosoftDiagnosticsRuntimeVersion)" /> - <PackageReference Include="Microsoft.Diagnostics.Runtime.Utilities" Version="$(MicrosoftDiagnosticsRuntimeUtilitiesVersion)" /> </ItemGroup> <ItemGroup> diff --git a/src/SOS/SOS.Hosting/SOSHost.cs b/src/SOS/SOS.Hosting/SOSHost.cs index bc46c91bb1..18cc0ae387 100644 --- a/src/SOS/SOS.Hosting/SOSHost.cs +++ b/src/SOS/SOS.Hosting/SOSHost.cs @@ -3,9 +3,9 @@ // See the LICENSE file in the project root for more information. using Microsoft.Diagnostics.DebugServices; -using Microsoft.Diagnostics.Runtime; -using Microsoft.Diagnostics.Runtime.Interop; using Microsoft.Diagnostics.Runtime.Utilities; +using SOS.Hosting.DbgEng; +using SOS.Hosting.DbgEng.Interop; using System; using System.Diagnostics; using System.IO; @@ -480,8 +480,8 @@ internal unsafe int GetModuleVersionInformation( { return HResult.E_INVALIDARG; } - VersionData versionData = module.GetVersionData(); - if (versionData is null) + Version version = module.GetVersionData(); + if (version is null) { return HResult.E_FAIL; } @@ -490,8 +490,8 @@ internal unsafe int GetModuleVersionInformation( fileInfo->dwStrucVersion = 0; fileInfo->dwFileFlagsMask = 0; fileInfo->dwFileFlags = 0; - fileInfo->dwFileVersionMS = (uint)versionData.Minor | (uint)versionData.Major << 16; - fileInfo->dwFileVersionLS = (uint)versionData.Patch | (uint)versionData.Revision << 16; + fileInfo->dwFileVersionMS = (uint)version.Minor & 0xffff | (uint)version.Major << 16; + fileInfo->dwFileVersionLS = (uint)version.Revision & 0xffff | (uint)version.Build << 16; } else if (item == "\\StringFileInfo\\040904B0\\FileVersion") { diff --git a/src/SOS/SOS.Hosting/SOSLibrary.cs b/src/SOS/SOS.Hosting/SOSLibrary.cs index 1009e5a7be..a43683f7c3 100644 --- a/src/SOS/SOS.Hosting/SOSLibrary.cs +++ b/src/SOS/SOS.Hosting/SOSLibrary.cs @@ -159,7 +159,7 @@ public void ExecuteCommand(IntPtr client, string command, string arguments) var commandFunc = SOSHost.GetDelegateFunction<SOSCommandDelegate>(_sosLibrary, command); if (commandFunc == null) { - throw new EntryPointNotFoundException($"Can not find SOS command: {command}"); + throw new DiagnosticsException($"SOS command not found: {command}"); } int result = commandFunc(client, arguments ?? ""); if (result != HResult.S_OK) diff --git a/src/SOS/SOS.Hosting/ServiceWrapper.cs b/src/SOS/SOS.Hosting/ServiceWrapper.cs index 7dbf7dc016..43ac85e9a6 100644 --- a/src/SOS/SOS.Hosting/ServiceWrapper.cs +++ b/src/SOS/SOS.Hosting/ServiceWrapper.cs @@ -87,7 +87,7 @@ public COMCallableIUnknown GetServiceWrapper(in Guid serviceId) /// <param name="serviceId">guid of the service</param> /// <param name="service">pointer to return service instance</param> /// <returns>S_OK or E_NOINTERFACE</returns> - public HResult GetService(IntPtr self, in Guid guid, out IntPtr ptr) + public int GetService(IntPtr self, in Guid guid, out IntPtr ptr) { ptr = IntPtr.Zero; diff --git a/src/SOS/SOS.Hosting/SymbolServiceExtensions.cs b/src/SOS/SOS.Hosting/SymbolServiceExtensions.cs index 285b1cace5..2317f10981 100644 --- a/src/SOS/SOS.Hosting/SymbolServiceExtensions.cs +++ b/src/SOS/SOS.Hosting/SymbolServiceExtensions.cs @@ -120,18 +120,26 @@ public static int GetICorDebugMetadataLocator( { SymbolStoreKey key = PEFileKeyGenerator.GetKey(imagePath, imageTimestamp, imageSize); string localFilePath = symbolService.DownloadFile(key); - localFilePath += "\0"; // null terminate the string - actualSize = localFilePath.Length; - - if (pathBufferSize > actualSize) + if (!string.IsNullOrWhiteSpace(localFilePath)) { - Trace.TraceInformation($"GetICorDebugMetadataLocator: SUCCEEDED {localFilePath}"); - Marshal.Copy(localFilePath.ToCharArray(), 0, pwszPathBuffer, actualSize); + localFilePath += "\0"; // null terminate the string + actualSize = localFilePath.Length; + + if (pathBufferSize > actualSize) + { + Trace.TraceInformation($"GetICorDebugMetadataLocator: SUCCEEDED {localFilePath}"); + Marshal.Copy(localFilePath.ToCharArray(), 0, pwszPathBuffer, actualSize); + } + else + { + Trace.TraceError("GetICorDebugMetadataLocator: E_INSUFFICIENT_BUFFER"); + hr = E_INSUFFICIENT_BUFFER; + } } - else + else { - Trace.TraceError("GetICorDebugMetadataLocator: E_INSUFFICIENT_BUFFER"); - hr = E_INSUFFICIENT_BUFFER; + Trace.TraceError($"GetICorDebugMetadataLocator: {imagePath} {imageTimestamp:X8} {imageSize:X8} download FAILED"); + hr = HResult.E_FAIL; } } else diff --git a/src/SOS/SOS.Hosting/TargetWrapper.cs b/src/SOS/SOS.Hosting/TargetWrapper.cs index e20be17d98..6a5531814f 100644 --- a/src/SOS/SOS.Hosting/TargetWrapper.cs +++ b/src/SOS/SOS.Hosting/TargetWrapper.cs @@ -82,7 +82,7 @@ private string GetTempDirectory( return _target.GetTempDirectory(); } - private HResult GetRuntime( + private int GetRuntime( IntPtr self, IntPtr* ppRuntime) { @@ -120,7 +120,7 @@ private delegate string GetTempDirectoryDelegate( [In] IntPtr self); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult GetRuntimeDelegate( + private delegate int GetRuntimeDelegate( [In] IntPtr self, [Out] IntPtr* ppRuntime); diff --git a/src/SOS/SOS.UnitTests/ConfigFiles/Unix/Debugger.Tests.Config.txt b/src/SOS/SOS.UnitTests/ConfigFiles/Unix/Debugger.Tests.Config.txt index 38cab1529a..3e76b20f05 100644 --- a/src/SOS/SOS.UnitTests/ConfigFiles/Unix/Debugger.Tests.Config.txt +++ b/src/SOS/SOS.UnitTests/ConfigFiles/Unix/Debugger.Tests.Config.txt @@ -24,19 +24,19 @@ <TestWebApp3>true</TestWebApp3> <TestWebApp3 Condition="'$(InternalReleaseTesting)' == 'true'">false</TestWebApp3> - <!-- Build the debuggee for this framework version but run it on latest --> - <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '6')">net6.0</BuildProjectFrameworkLatest> + <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '7')">net7.0</BuildProjectFrameworkLatest> <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '5')">net5.0</BuildProjectFrameworkLatest> + <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '6')">net6.0</BuildProjectFrameworkLatest> <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '3.1')">netcoreapp3.1</BuildProjectFrameworkLatest> <DebuggeeSourceRoot>$(RepoRootDir)/src/SOS/SOS.UnitTests/Debuggees</DebuggeeSourceRoot> <DebuggeeBuildProcess>sdk.prebuilt</DebuggeeBuildProcess> <DebuggeeBuildRoot>$(RootBinDir)</DebuggeeBuildRoot> - <!-- Use the global.json SDK to build and the test SDK/runtime to run --> - <CliPath>$(RepoRootDir)/.dotnet/dotnet</CliPath> + <CliPath>$(DotNetRoot)/dotnet</CliPath> <NuGetPackageFeeds> + dotnet7=https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet7/nuget/v3/index.json; dotnet6=https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet6/nuget/v3/index.json; dotnet-core=https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json; dotnet-public=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json @@ -50,7 +50,7 @@ <DebuggeeBuildProcess>cli</DebuggeeBuildProcess> <DebuggeeBuildRoot>$(RootBinDir)/Debuggees/SingleFile</DebuggeeBuildRoot> <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework> - <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion> + <RuntimeFrameworkVersion>$(SingleFileRuntimeLatestVersion)</RuntimeFrameworkVersion> <PublishSingleFile>true</PublishSingleFile> <!-- Add the symbol server so SOS can find DAC/DBI for single file apps which may not have been built with the runtime pointed by RuntimeSymbolsPath @@ -58,6 +58,15 @@ <SetSymbolServer>-ms</SetSymbolServer> <BuildProjectRuntime>$(TargetRid)</BuildProjectRuntime> </Option> + <Option Condition="'$(RuntimeVersion60)' != ''"> + <DebuggeeBuildProcess>cli</DebuggeeBuildProcess> + <DebuggeeBuildRoot>$(RootBinDir)/Debuggees/SingleFile</DebuggeeBuildRoot> + <BuildProjectFramework>net6.0</BuildProjectFramework> + <RuntimeFrameworkVersion>$(SingleFileRuntime60Version)</RuntimeFrameworkVersion> + <PublishSingleFile>true</PublishSingleFile> + <SetSymbolServer>-ms</SetSymbolServer> + <BuildProjectRuntime>$(TargetRid)</BuildProjectRuntime> + </Option> <!-- Default (prebuilt) --> @@ -66,9 +75,9 @@ <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion> <SetHostRuntime>$(DotNetRoot)/shared/Microsoft.NETCore.App/$(RuntimeFrameworkVersion)</SetHostRuntime> </Option> - <Option Condition="'$(RuntimeVersion50)' != ''"> - <BuildProjectFramework>net5.0</BuildProjectFramework> - <RuntimeFrameworkVersion>$(RuntimeVersion50)</RuntimeFrameworkVersion> + <Option Condition="'$(RuntimeVersion60)' != ''"> + <BuildProjectFramework>net6.0</BuildProjectFramework> + <RuntimeFrameworkVersion>$(RuntimeVersion60)</RuntimeFrameworkVersion> </Option> <Option Condition="'$(RuntimeVersion31)' != ''"> <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework> @@ -86,7 +95,15 @@ <Option Condition="'$(RuntimeVersionLatest)' != ''"> <DebuggeeBuildRoot>$(RootBinDir)/Debuggees/SingleFile</DebuggeeBuildRoot> <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework> - <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion> + <RuntimeFrameworkVersion>$(SingleFileRuntimeLatestVersion)</RuntimeFrameworkVersion> + <PublishSingleFile>true</PublishSingleFile> + <SetSymbolServer>-ms</SetSymbolServer> + <BuildProjectRuntime>$(TargetRid)</BuildProjectRuntime> + </Option> + <Option Condition="'$(RuntimeVersion60)' != ''"> + <DebuggeeBuildRoot>$(RootBinDir)/Debuggees/SingleFile</DebuggeeBuildRoot> + <BuildProjectFramework>net6.0</BuildProjectFramework> + <RuntimeFrameworkVersion>$(SingleFileRuntime60Version)</RuntimeFrameworkVersion> <PublishSingleFile>true</PublishSingleFile> <SetSymbolServer>-ms</SetSymbolServer> <BuildProjectRuntime>$(TargetRid)</BuildProjectRuntime> @@ -95,9 +112,9 @@ <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework> <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion> </Option> - <Option Condition="'$(RuntimeVersion50)' != ''"> - <BuildProjectFramework>net5.0</BuildProjectFramework> - <RuntimeFrameworkVersion>$(RuntimeVersion50)</RuntimeFrameworkVersion> + <Option Condition="'$(RuntimeVersion60)' != ''"> + <BuildProjectFramework>net6.0</BuildProjectFramework> + <RuntimeFrameworkVersion>$(RuntimeVersion60)</RuntimeFrameworkVersion> </Option> <Option Condition="'$(RuntimeVersion31)' != ''"> <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework> @@ -115,10 +132,10 @@ <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework> <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion> </Option> - <Option Condition="'$(AspNetCoreVersion50)' != ''"> - <BuildProjectFramework>net5.0</BuildProjectFramework> - <RuntimeFrameworkVersion>$(RuntimeVersion50)</RuntimeFrameworkVersion> - <FrameworkVersion>$(AspNetCoreVersion50)</FrameworkVersion> + <Option Condition="'$(AspNetCoreVersion60)' != ''"> + <BuildProjectFramework>net6.0</BuildProjectFramework> + <RuntimeFrameworkVersion>$(RuntimeVersion60)</RuntimeFrameworkVersion> + <FrameworkVersion>$(AspNetCoreVersion60)</FrameworkVersion> </Option> <Option Condition="'$(AspNetCoreVersion31)' != ''"> <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework> diff --git a/src/SOS/SOS.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt b/src/SOS/SOS.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt index 7824b28205..cc7ae9f566 100644 --- a/src/SOS/SOS.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt +++ b/src/SOS/SOS.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt @@ -30,7 +30,7 @@ <TestDesktop Condition="'$(InternalReleaseTesting)' == 'true'">false</TestDesktop> <TestDesktop Condition="'$(TargetArchitecture)' == 'arm64'">false</TestDesktop> - <!-- Build the debuggee for this framework version but run it on latest --> + <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '7')">net7.0</BuildProjectFrameworkLatest> <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '6')">net6.0</BuildProjectFrameworkLatest> <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '5')">net5.0</BuildProjectFrameworkLatest> <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '3.1')">netcoreapp3.1</BuildProjectFrameworkLatest> @@ -43,10 +43,10 @@ <DebuggeeBuildProcess>sdk.prebuilt</DebuggeeBuildProcess> <DebuggeeBuildRoot>$(RootBinDir)</DebuggeeBuildRoot> - <!-- Use the global.json SDK to build and the test SDK/runtime to run --> - <CliPath>$(RepoRootDir)\.dotnet\dotnet.exe</CliPath> + <CliPath>$(DotNetRoot)\dotnet.exe</CliPath> <NuGetPackageFeeds> + dotnet7=https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet7/nuget/v3/index.json; dotnet6=https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet6/nuget/v3/index.json; dotnet-core=https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json; dotnet-public=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json @@ -66,7 +66,7 @@ <DebuggeeBuildProcess>cli</DebuggeeBuildProcess> <DebuggeeBuildRoot>$(RootBinDir)\Debuggees\SingleFile</DebuggeeBuildRoot> <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework> - <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion> + <RuntimeFrameworkVersion>$(SingleFileRuntimeLatestVersion)</RuntimeFrameworkVersion> <PublishSingleFile>true</PublishSingleFile> <!-- Add the symbol server so SOS can find DAC/DBI for single file apps which may not have been built with the runtime pointed by RuntimeSymbolsPath @@ -74,6 +74,15 @@ <SetSymbolServer>-ms</SetSymbolServer> <BuildProjectRuntime>$(TargetRid)</BuildProjectRuntime> </Option> + <Option Condition="'$(RuntimeVersion60)' != ''"> + <DebuggeeBuildProcess>cli</DebuggeeBuildProcess> + <DebuggeeBuildRoot>$(RootBinDir)\Debuggees\SingleFile</DebuggeeBuildRoot> + <BuildProjectFramework>net6.0</BuildProjectFramework> + <RuntimeFrameworkVersion>$(SingleFileRuntime60Version)</RuntimeFrameworkVersion> + <PublishSingleFile>true</PublishSingleFile> + <SetSymbolServer>-ms</SetSymbolServer> + <BuildProjectRuntime>$(TargetRid)</BuildProjectRuntime> + </Option> <!-- Default (prebuilt) --> @@ -82,9 +91,9 @@ <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion> <SetHostRuntime>$(DotNetRoot)/shared/Microsoft.NETCore.App/$(RuntimeFrameworkVersion)</SetHostRuntime> </Option> - <Option Condition="'$(RuntimeVersion50)' != ''"> - <BuildProjectFramework>net5.0</BuildProjectFramework> - <RuntimeFrameworkVersion>$(RuntimeVersion50)</RuntimeFrameworkVersion> + <Option Condition="'$(RuntimeVersion60)' != ''"> + <BuildProjectFramework>net6.0</BuildProjectFramework> + <RuntimeFrameworkVersion>$(RuntimeVersion60)</RuntimeFrameworkVersion> </Option> <Option Condition="'$(RuntimeVersion31)' != ''"> <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework> @@ -102,7 +111,15 @@ <Option Condition="'$(RuntimeVersionLatest)' != ''"> <DebuggeeBuildRoot>$(RootBinDir)\Debuggees\SingleFile</DebuggeeBuildRoot> <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework> - <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion> + <RuntimeFrameworkVersion>$(SingleFileRuntimeLatestVersion)</RuntimeFrameworkVersion> + <PublishSingleFile>true</PublishSingleFile> + <SetSymbolServer>-ms</SetSymbolServer> + <BuildProjectRuntime>$(TargetRid)</BuildProjectRuntime> + </Option> + <Option Condition="'$(RuntimeVersion60)' != ''"> + <DebuggeeBuildRoot>$(RootBinDir)\Debuggees\SingleFile</DebuggeeBuildRoot> + <BuildProjectFramework>net6.0</BuildProjectFramework> + <RuntimeFrameworkVersion>$(SingleFileRuntime60Version)</RuntimeFrameworkVersion> <PublishSingleFile>true</PublishSingleFile> <SetSymbolServer>-ms</SetSymbolServer> <BuildProjectRuntime>$(TargetRid)</BuildProjectRuntime> @@ -111,9 +128,9 @@ <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework> <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion> </Option> - <Option Condition="'$(RuntimeVersion50)' != ''"> - <BuildProjectFramework>net5.0</BuildProjectFramework> - <RuntimeFrameworkVersion>$(RuntimeVersion50)</RuntimeFrameworkVersion> + <Option Condition="'$(RuntimeVersion60)' != ''"> + <BuildProjectFramework>net6.0</BuildProjectFramework> + <RuntimeFrameworkVersion>$(RuntimeVersion60)</RuntimeFrameworkVersion> </Option> <Option Condition="'$(RuntimeVersion31)' != ''"> <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework> @@ -141,19 +158,19 @@ <DebuggeeBuildProcess>cli</DebuggeeBuildProcess> <DebuggeeBuildRoot>$(RootBinDir)\Debuggees\SingleFile</DebuggeeBuildRoot> <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework> - <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion> + <RuntimeFrameworkVersion>$(SingleFileRuntimeLatestVersion)</RuntimeFrameworkVersion> <PublishSingleFile>true</PublishSingleFile> <SetSymbolServer>-ms</SetSymbolServer> <BuildProjectRuntime>$(TargetRid)</BuildProjectRuntime> - </Option> + </Option> <Option Condition="'$(AspNetCoreVersionLatest)' != ''"> <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework> <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion> </Option> - <Option Condition="'$(AspNetCoreVersion50)' != ''"> - <BuildProjectFramework>net5.0</BuildProjectFramework> - <RuntimeFrameworkVersion>$(RuntimeVersion50)</RuntimeFrameworkVersion> - <FrameworkVersion>$(AspNetCoreVersion50)</FrameworkVersion> + <Option Condition="'$(AspNetCoreVersion60)' != ''"> + <BuildProjectFramework>net6.0</BuildProjectFramework> + <RuntimeFrameworkVersion>$(RuntimeVersion60)</RuntimeFrameworkVersion> + <FrameworkVersion>$(AspNetCoreVersion60)</FrameworkVersion> </Option> <Option Condition="'$(AspNetCoreVersion31)' != ''"> <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework> diff --git a/src/SOS/SOS.UnitTests/Debuggees/DesktopClrHost/CMakeLists.txt b/src/SOS/SOS.UnitTests/Debuggees/DesktopClrHost/CMakeLists.txt index 9584de7acb..80ed07d8d5 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/DesktopClrHost/CMakeLists.txt +++ b/src/SOS/SOS.UnitTests/Debuggees/DesktopClrHost/CMakeLists.txt @@ -33,5 +33,5 @@ add_library_clr(DesktopClrHost SHARED ${DESKTOPCLRHOST_SOURCES}) target_link_libraries(DesktopClrHost ${DESKTOPCLRHOST_LIBRARY}) install(TARGETS DesktopClrHost DESTINATION ${CLR_MANAGED_BINARY_DIR}/WebApp3/${CLR_BUILD_TYPE}/netcoreapp3.1) -install(TARGETS DesktopClrHost DESTINATION ${CLR_MANAGED_BINARY_DIR}/WebApp3/${CLR_BUILD_TYPE}/net5.0) install(TARGETS DesktopClrHost DESTINATION ${CLR_MANAGED_BINARY_DIR}/WebApp3/${CLR_BUILD_TYPE}/net6.0) +install(TARGETS DesktopClrHost DESTINATION ${CLR_MANAGED_BINARY_DIR}/WebApp3/${CLR_BUILD_TYPE}/net7.0) diff --git a/src/SOS/SOS.UnitTests/Debuggees/Directory.Build.props b/src/SOS/SOS.UnitTests/Debuggees/Directory.Build.props index 84fd31988e..95a0a487ff 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/Directory.Build.props +++ b/src/SOS/SOS.UnitTests/Debuggees/Directory.Build.props @@ -5,6 +5,6 @@ <DebugType Condition="'$(TargetFramework)' == 'net462'">full</DebugType> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <Optimize>false</Optimize> - <BuildTargetFrameworks>netcoreapp3.1;net5.0;net6.0</BuildTargetFrameworks> + <BuildTargetFrameworks>netcoreapp3.1;net6.0;net7.0</BuildTargetFrameworks> </PropertyGroup> </Project> diff --git a/src/SOS/SOS.UnitTests/Debuggees/WebApp3/WebApp3.csproj b/src/SOS/SOS.UnitTests/Debuggees/WebApp3/WebApp3.csproj index efd2369d3a..9474bd6558 100644 --- a/src/SOS/SOS.UnitTests/Debuggees/WebApp3/WebApp3.csproj +++ b/src/SOS/SOS.UnitTests/Debuggees/WebApp3/WebApp3.csproj @@ -1,7 +1,8 @@ <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> - <TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks> + <TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework> + <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">$(BuildTargetFrameworks)</TargetFrameworks> </PropertyGroup> <ItemGroup> diff --git a/src/SOS/SOS.UnitTests/SOS.cs b/src/SOS/SOS.UnitTests/SOS.cs index 87afc46554..a2ca729366 100644 --- a/src/SOS/SOS.UnitTests/SOS.cs +++ b/src/SOS/SOS.UnitTests/SOS.cs @@ -366,6 +366,8 @@ public async Task DumpGen(TestConfiguration config) [SkippableTheory, MemberData(nameof(Configurations))] public async Task LLDBPluginTests(TestConfiguration config) { + SkipIfArm(config); + if (OS.Kind == OSKind.Windows || config.IsDesktop || config.RuntimeFrameworkVersionMajor == 1 || OS.IsAlpine) { throw new SkipTestException("lldb plugin tests not supported on Windows, Alpine Linux or .NET Core 1.1"); @@ -421,7 +423,7 @@ public async Task LLDBPluginTests(TestConfiguration config) // Create the python script process runner ProcessRunner processRunner = new ProcessRunner(program, arguments.ToString()). - WithEnvironmentVariable("DOTNET_ROOT", config.DotNetRoot()). + WithEnvironmentVariable("DOTNET_ROOT", config.DotNetRoot). WithLog(new TestRunner.TestLogger(outputHelper.IndentedOutput)). WithTimeout(TimeSpan.FromMinutes(10)). WithExpectedExitCode(0). @@ -450,4 +452,4 @@ public async Task LLDBPluginTests(TestConfiguration config) outputHelper?.Dispose(); } } -} \ No newline at end of file +} diff --git a/src/SOS/SOS.UnitTests/SOSRunner.cs b/src/SOS/SOS.UnitTests/SOSRunner.cs index 7c6c3243e8..92e59229d1 100644 --- a/src/SOS/SOS.UnitTests/SOSRunner.cs +++ b/src/SOS/SOS.UnitTests/SOSRunner.cs @@ -317,7 +317,7 @@ public static async Task<string> CreateDump(TestInformation information) // Create the debuggee process runner ProcessRunner processRunner = new ProcessRunner(exePath, ReplaceVariables(variables, arguments.ToString())). WithEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0"). - WithEnvironmentVariable("DOTNET_ROOT", config.DotNetRoot()). + WithEnvironmentVariable("DOTNET_ROOT", config.DotNetRoot). WithEnvironmentVariable("COMPlus_DbgEnableElfDumpOnMacOS", "1"). WithLog(new TestRunner.TestLogger(outputHelper.IndentedOutput)). WithTimeout(TimeSpan.FromMinutes(10)); @@ -672,7 +672,7 @@ public static async Task<SOSRunner> StartDebugger(TestInformation information, D // Create the native debugger process running ProcessRunner processRunner = new ProcessRunner(debuggerPath, ReplaceVariables(variables, arguments.ToString())). WithEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0"). - WithEnvironmentVariable("DOTNET_ROOT", config.DotNetRoot()). + WithEnvironmentVariable("DOTNET_ROOT", config.DotNetRoot). WithLog(scriptLogger). WithTimeout(TimeSpan.FromMinutes(10)); @@ -682,6 +682,10 @@ public static async Task<SOSRunner> StartDebugger(TestInformation information, D processRunner.WithExpectedExitCode(0); } + // Disable W^E so that the bpmd command and the tests pass + // Issue: https://github.com/dotnet/diagnostics/issues/3126 + processRunner.WithEnvironmentVariable("COMPlus_EnableWriteXorExecute", "0"); + DumpType? dumpType = null; if (action == DebuggerAction.LoadDump || action == DebuggerAction.LoadDumpWithDotNetDump) { @@ -901,9 +905,8 @@ public async Task LoadSosExtension() { commands.Add($"!SetHostRuntime {setHostRuntime}"); } - // If there is no host runtime and a single-file app or a triage dump, add the path to runtime so SOS can find DAC/DBI. - if ((isHostRuntimeNone && _config.PublishSingleFile) || - (_dumpType.HasValue && _dumpType.Value == DumpType.Triage)) + // If a single-file app or a triage dump, add the path to runtime so SOS can find DAC/DBI locally. + if (_config.PublishSingleFile || (_dumpType.HasValue && _dumpType.Value == DumpType.Triage)) { if (!string.IsNullOrEmpty(runtimeSymbolsPath)) { @@ -921,14 +924,17 @@ public async Task LoadSosExtension() { commands.Add($"sethostruntime {setHostRuntime}"); } - // If there is no host runtime and a single-file app, add the path to runtime so SOS can find DAC/DBI. - if (isHostRuntimeNone && _config.PublishSingleFile) + // Disabled until https://github.com/dotnet/diagnostics/issues/3265 is fixed. +#if DISABLED + // If a single-file app, add the path to runtime so SOS can find DAC/DBI locally. + if (_config.PublishSingleFile) { if (!string.IsNullOrEmpty(runtimeSymbolsPath)) { commands.Add($"setclrpath {runtimeSymbolsPath}"); } } +#endif if (!isHostRuntimeNone && !string.IsNullOrEmpty(setSymbolServer)) { commands.Add($"setsymbolserver {setSymbolServer}"); @@ -938,6 +944,14 @@ public async Task LoadSosExtension() case NativeDebugger.Gdb: break; case NativeDebugger.DotNetDump: + // If a single-file app, add the path to runtime so SOS can find DAC/DBI locally. + if (_config.PublishSingleFile) + { + if (!string.IsNullOrEmpty(runtimeSymbolsPath)) + { + commands.Add($"setclrpath {runtimeSymbolsPath}"); + } + } if (!string.IsNullOrEmpty(setSymbolServer)) { commands.Add($"setsymbolserver {setSymbolServer}"); @@ -1004,7 +1018,7 @@ public async Task<bool> RunSosCommand(string command, bool extensionCommand = fa case NativeDebugger.Cdb: if (extensionCommand) { - command = "!ext " + command; + command = "!sos " + command; } else { @@ -1012,20 +1026,26 @@ public async Task<bool> RunSosCommand(string command, bool extensionCommand = fa } break; case NativeDebugger.Lldb: - if (!extensionCommand) - { - command = "sos " + command; - } + command = "sos " + command; break; case NativeDebugger.DotNetDump: - int index = command.IndexOf(' '); - if (index != -1) { - // lowercase just the command name not the rest of the command line - command = command.Substring(0, index).ToLowerInvariant() + command.Substring(index); + if (extensionCommand) + { + command = "sos " + command; } - else { - // it is only the command name - command = command.ToLowerInvariant(); + else + { + int index = command.IndexOf(' '); + if (index != -1) + { + // lowercase just the command name not the rest of the command line + command = command.Substring(0, index).ToLowerInvariant() + command.Substring(index); + } + else + { + // it is only the command name + command = command.ToLowerInvariant(); + } } break; default: @@ -1392,6 +1412,9 @@ private static Dictionary<string, string> GenerateVariables(TestInformation info vars.Add("%DUMP_NAME%", dumpFileName); } vars.Add("%DEBUG_ROOT%", debuggeeConfig.BinaryDirPath); + vars.Add("%TEST_NAME%", information.TestName); + vars.Add("%LOG_PATH%", information.TestConfiguration.LogDirPath); + vars.Add("%LOG_SUFFIX%", information.TestConfiguration.LogSuffix); vars.Add("%SOS_PATH%", information.TestConfiguration.SOSPath()); vars.Add("%DESKTOP_RUNTIME_PATH%", information.TestConfiguration.DesktopRuntimePath()); @@ -1582,12 +1605,6 @@ public static string GDBPath(this TestConfiguration config) return TestConfiguration.MakeCanonicalPath(gdbPath); } - public static string DotNetRoot(this TestConfiguration config) - { - string dotnetRoot = config.GetValue("DotNetRoot"); - return TestConfiguration.MakeCanonicalPath(dotnetRoot); - } - public static string DotNetDumpHost(this TestConfiguration config) { string dotnetDumpHost = config.GetValue("DotNetDumpHost"); diff --git a/src/SOS/SOS.UnitTests/Scripts/ConcurrentDictionaries.script b/src/SOS/SOS.UnitTests/Scripts/ConcurrentDictionaries.script index 8e513c3e09..cc08b813e1 100644 --- a/src/SOS/SOS.UnitTests/Scripts/ConcurrentDictionaries.script +++ b/src/SOS/SOS.UnitTests/Scripts/ConcurrentDictionaries.script @@ -8,6 +8,9 @@ !IFDEF:LLDB IFDEF:NETCORE_OR_DOTNETDUMP +# Load SOS even though it doesn't actually load the sos module on dotnet-dump but it runs some initial settings/commands. +LOADSOS + COMMAND: dcd VERIFY: Missing ConcurrentDictionary address diff --git a/src/SOS/SOS.UnitTests/Scripts/DumpGen.script b/src/SOS/SOS.UnitTests/Scripts/DumpGen.script index 1f8e489cb5..23b894e450 100644 --- a/src/SOS/SOS.UnitTests/Scripts/DumpGen.script +++ b/src/SOS/SOS.UnitTests/Scripts/DumpGen.script @@ -8,6 +8,9 @@ !IFDEF:LLDB IFDEF:NETCORE_OR_DOTNETDUMP +# Load SOS even though it doesn't actually load the sos module on dotnet-dump but it runs some initial settings/commands. +LOADSOS + COMMAND: dumpgen VERIFY: Generation argument is missing diff --git a/src/SOS/SOS.UnitTests/Scripts/GCPOH.script b/src/SOS/SOS.UnitTests/Scripts/GCPOH.script index ea211230ab..fb0e5138c1 100644 --- a/src/SOS/SOS.UnitTests/Scripts/GCPOH.script +++ b/src/SOS/SOS.UnitTests/Scripts/GCPOH.script @@ -24,6 +24,8 @@ SOSCOMMAND:DumpObj <POUT>\w+\s+(<HEXVAL>)\s+(System.Byte\[\]!\$0_)*System.Byte\[ VERIFY:\s+Name: System.Byte\[\]\s+ VERIFY:\s+Array: Rank 1, Number of elements 100, Type Byte\s+ +SOSCOMMAND:ObjSize <PREVPOUT> + SOSCOMMAND:GCWhere <PREVPOUT> # we care that the Gen is 4 (POH) VERIFY:<HEXVAL>\s+4\s+\d\s+<HEXVAL>\s+<HEXVAL>\s+<HEXVAL>\s+0x<HEXVAL>\s*\(\d+\) @@ -36,6 +38,11 @@ SOSCOMMAND:GCRoot -all <PREVPOUT> VERIFY:.*Thread <HEXVAL>: VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+GCPOH\.Main\(\)\s+\[.*[Gg][Cc][Pp][Oo][Hh]\.cs\s+@\s+19\]\s+ +SOSCOMMAND:VerifyHeap +VERIFY:\s*No heap corruption detected.\s* + +SOSCOMMAND:GCHeapStat + SOSCOMMAND:DumpHeap VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+<DECVAL>\s+ diff --git a/src/SOS/SOS.UnitTests/Scripts/NestedExceptionTest.script b/src/SOS/SOS.UnitTests/Scripts/NestedExceptionTest.script index 4edba2d505..2c13f641df 100644 --- a/src/SOS/SOS.UnitTests/Scripts/NestedExceptionTest.script +++ b/src/SOS/SOS.UnitTests/Scripts/NestedExceptionTest.script @@ -41,7 +41,7 @@ SOSCOMMAND:PrintException VERIFY:Exception object:\s+<HEXVAL>\s+ VERIFY:Exception type:\s+System\.InvalidOperationException\s+ VERIFY:Message:\s+(<Invalid Object>|Invalid operation exception, outer)\s+ -VERIFY:InnerException:\s+System\.FormatException, Use !PrintException <HEXVAL> to see more.\s+ +VERIFY:InnerException:\s+System\.FormatException, Use !?printexception <HEXVAL> to see more.\s+ VERIFY:StackTrace \(generated\):\s+ VERIFY:\s+SP\s+IP\s+\s+Function\s+ VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+[Nn]ested[Ee]xception[Tt]est.*!NestedExceptionTest\.Program\.Main(\(.*\))?\+0x<HEXVAL>\s+ @@ -54,7 +54,7 @@ SOSCOMMAND:PrintException -nested VERIFY:Exception object:\s+<HEXVAL>\s+ VERIFY:Exception type:\s+System\.InvalidOperationException\s+ VERIFY:Message:\s+(<Invalid Object>|Invalid operation exception, outer)\s+ -VERIFY:InnerException:\s+System\.FormatException, Use !PrintException <HEXVAL> to see more.\s+ +VERIFY:InnerException:\s+System\.FormatException, Use !?printexception <HEXVAL> to see more.\s+ VERIFY:StackTrace \(generated\):\s+ VERIFY:\s+SP\s+IP\s+Function\s+ VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+[Nn]ested[Ee]xception[Tt]est.*!NestedExceptionTest\.Program\.Main(\(.*\))?\+0x<HEXVAL>\s+ @@ -72,7 +72,7 @@ VERIFY:(StackTraceString: <none>\s+)? VERIFY:HResult:\s+80131537 # 6) Verifying that the Exception Object/ID gives us the same output about the reflected exception. -SOSCOMMAND:PrintException <POUT>InnerException:\s+System\.FormatException, Use !PrintException (<HEXVAL>) to see more<POUT> +SOSCOMMAND:PrintException <POUT>InnerException:\s+System\.FormatException, Use !?printexception (<HEXVAL>) to see more<POUT> VERIFY:Exception object:\s+<HEXVAL>\s+ VERIFY:Exception type:\s+System\.FormatException\s+ VERIFY:Message:\s+(<Invalid Object>|Bad format exception, inner)\s+ @@ -89,7 +89,7 @@ SOSCOMMAND:PrintException -lines VERIFY:Exception object:\s+<HEXVAL>\s+ VERIFY:Exception type:\s+System\.InvalidOperationException\s+ VERIFY:Message:\s+(<Invalid Object>|Invalid operation exception, outer)\s+ -VERIFY:InnerException:\s+System\.FormatException, Use !PrintException <HEXVAL> to see more.\s+ +VERIFY:InnerException:\s+System\.FormatException, Use !?printexception <HEXVAL> to see more.\s+ VERIFY:StackTrace \(generated\): VERIFY:\s+SP\s+IP\s+Function\s+ VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+[Nn]ested[Ee]xception[Tt]est.*!NestedExceptionTest\.Program\.Main(\(.*\))?\+0x<HEXVAL>\s* diff --git a/src/SOS/SOS.UnitTests/Scripts/OtherCommands.script b/src/SOS/SOS.UnitTests/Scripts/OtherCommands.script index c26430486b..f90ca8f5b0 100644 --- a/src/SOS/SOS.UnitTests/Scripts/OtherCommands.script +++ b/src/SOS/SOS.UnitTests/Scripts/OtherCommands.script @@ -56,9 +56,6 @@ ENDIF:LIVE CONTINUE -EXTCOMMAND:clrmodules -VERIFY:\s*<HEXVAL>.* - EXTCOMMAND:modules -v VERIFY:\s*<HEXVAL>\s+<HEXVAL>.* @@ -68,6 +65,12 @@ VERIFY:\s*<DECVAL>\s+0x<HEXVAL>\s+\(<DECVAL>\)\s+ EXTCOMMAND:registers VERIFY:\s*([r|e]ip|pc) = 0x<HEXVAL>\s+ +EXTCOMMAND:ClrStack + +EXTCOMMAND:ThreadPool + +EXTCOMMAND:VerifyHeap + SOSCOMMAND:DumpHeap VERIFY:\s+Address\s+MT\s+Size\s+ VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+<DECVAL>.* @@ -123,6 +126,12 @@ VERIFY:\s+MT\s+Count\s+TotalSize\s+Class Name\s+ VERIFY:(\s*<HEXVAL>\s+<DECVAL>\s+<DECVAL>\s+.*)? VERIFY:\s*Total\s+<DECVAL>\s+objects\s+ +EXTCOMMAND:logopen %LOG_PATH%/%TEST_NAME%.%LOG_SUFFIX%.consolelog +EXTCOMMAND:logging %LOG_PATH%/%TEST_NAME%.%LOG_SUFFIX%.diaglog + +EXTCOMMAND:clrmodules -v +VERIFY:\s*<HEXVAL>.* + SOSCOMMAND:SyncBlk # On Linux/MacOS we sometimes get "Error requesting SyncBlk data" error from the DAC. IFDEF:WINDOWS @@ -131,3 +140,12 @@ VERIFY:\s*Total\s+<DECVAL> VERIFY:\s*CCW\s+<DECVAL> VERIFY:\s*RCW\s+<DECVAL> ENDIF:WINDOWS + +SOSCOMMAND:GCHandles + +SOSCOMMAND:DumpGCData + +SOSCOMMAND:DumpRuntimeTypes + +EXTCOMMAND:logclose +EXTCOMMAND:logging --disable diff --git a/src/SOS/SOS.UnitTests/Scripts/Reflection.script b/src/SOS/SOS.UnitTests/Scripts/Reflection.script index 96d755177c..6a85c32d0d 100644 --- a/src/SOS/SOS.UnitTests/Scripts/Reflection.script +++ b/src/SOS/SOS.UnitTests/Scripts/Reflection.script @@ -14,14 +14,14 @@ SOSCOMMAND:PrintException VERIFY:Exception object:\s+<HEXVAL>\s+ VERIFY:Exception type:\s+System\.Reflection\.TargetInvocationException\s+ VERIFY:Message:\s+(<Invalid Object>|Exception has been thrown by the target of an invocation\.)\s+ -VERIFY:InnerException:\s+System\.Exception, Use !PrintException <HEXVAL> to see more.\s+ +VERIFY:InnerException:\s+System\.Exception, Use !?printexception <HEXVAL> to see more.\s+ VERIFY:StackTrace \(generated\):\s+ VERIFY:<HEXVAL>\s+<HEXVAL>\s+[Rr]eflection[Tt]est.*!(\$0_)?RefLoader(\.|::)Loader\.Main(\(\))?\+0x<HEXVAL> VERIFY:(StackTraceString: <none>\s+)? VERIFY:HResult:\s+80131604 # 6) Verifying that the Exception Object/ID gives us the same output about the reflected exception. -SOSCOMMAND:PrintException <POUT>InnerException:\s+System\.Exception, Use !PrintException (<HEXVAL>) to see more<POUT> +SOSCOMMAND:PrintException <POUT>InnerException:\s+System\.Exception, Use !?printexception (<HEXVAL>) to see more<POUT> VERIFY:Exception object:\s+<HEXVAL>\s+ VERIFY:Exception type:\s+System\.Exception\s+ VERIFY:Message:\s+(<Invalid Object>|Exception from InvokedCode\.Invoked\.ExceptionNoHandler(\(\))?)\s+ @@ -35,7 +35,7 @@ VERIFY:HResult:\s+80131500 SOSCOMMAND:PrintException -lines VERIFY:Exception type:\s+System\.Reflection\.TargetInvocationException\s+ VERIFY:Message:\s+(<Invalid Object>|Exception has been thrown by the target of an invocation\.)\s+ -VERIFY:InnerException:\s+System\.Exception, Use !PrintException <HEXVAL> to see more\.\s+ +VERIFY:InnerException:\s+System\.Exception, Use !?printexception <HEXVAL> to see more\.\s+ VERIFY:StackTrace \(generated\):\s+ VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+[Rr]eflection[Tt]est.*!(\$0_)?RefLoader\.Loader\.Main(\(\))?\+0x<HEXVAL>\s* VERIFY:[.*[\\|/]Debuggees[\\|/].*[Rr]eflection[Tt]est[\\|/][Rr]eflection[Tt]est\.cs @ 32\s*\] diff --git a/src/SOS/SOS.UnitTests/Scripts/StackAndOtherTests.script b/src/SOS/SOS.UnitTests/Scripts/StackAndOtherTests.script index f9026c031e..a05ce1cfef 100644 --- a/src/SOS/SOS.UnitTests/Scripts/StackAndOtherTests.script +++ b/src/SOS/SOS.UnitTests/Scripts/StackAndOtherTests.script @@ -82,9 +82,12 @@ ENDIF:DESKTOP SOSCOMMAND:SOSStatus +# Issue:https://github.com/dotnet/diagnostics/issues/3155 +!IFDEF:MAJOR_RUNTIME_VERSION_GE_7 # Test eeversion command SOSCOMMAND:EEVersion VERIFY:\s+<DECVAL>.<DECVAL>.<DECVAL>.<DECVAL>.* +ENDIF:MAJOR_RUNTIME_VERSION_GE_7 # Verify that ClrStack with managed/native mixed works SOSCOMMAND:ClrStack -f @@ -193,18 +196,21 @@ VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+System\.String\[\].* ENDIF:NETCORE_OR_DOTNETDUMP +# Issue: https://github.com/dotnet/diagnostics/issues/2947 !IFDEF:DOTNETDUMP +!IFDEF:ARM64 !IFDEF:ARM +!IFDEF:MAJOR_RUNTIME_VERSION_GE_7 # Verify DumpStack works SOSCOMMAND:DumpStack -VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.* +VERIFY:.*OS Thread Id:\s+0x<HEXVAL>.*\s+.* VERIFY:.*Child(-SP|EBP|FP)\s+RetAddr\s+Caller, Callee\s+ VERIFY:(.*\s+<HEXVAL>\s+<HEXVAL>\s+\(MethodDesc\s+<HEXVAL>\s+(\+\s*0x<HEXVAL>\s+)?SymbolTestApp\.Program\.Foo4\(System\.String\)\),\s+calling.*\s+)|(.*\s+<HEXVAL>\s+<HEXVAL>\s+\(MethodDesc\s+<HEXVAL>\s+(\+\s*0x<HEXVAL>\s+)?SymbolTestApp\.Program\.Foo2\(Int32, System\.String\)\),\s+calling.*\s+) # Verify DumpStack -EE works SOSCOMMAND:DumpStack -EE -VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.* +VERIFY:.*OS Thread Id:\s+0x<HEXVAL>.*\s+.* VERIFY:.*Child(-SP|EBP|FP)\s+RetAddr\s+Caller, Callee\s+ VERIFY:(.*\s+<HEXVAL>\s+<HEXVAL>\s+\(MethodDesc\s+<HEXVAL>\s+(\+\s*0x<HEXVAL>\s+)?SymbolTestApp\.Program\.Foo4\(System\.String\)\)\s+)|(.*\s+<HEXVAL>\s+<HEXVAL>\s+\(MethodDesc\s+<HEXVAL>\s+(\+\s*0x<HEXVAL>\s+)?SymbolTestApp\.Program\.Foo2\(Int32, System\.String\)\)\s+) @@ -213,7 +219,9 @@ SOSCOMMAND:EEStack VERIFY:.*Child(-SP|EBP|FP)\s+RetAddr\s+Caller, Callee\s+ VERIFY:(.*\s+<HEXVAL>\s+<HEXVAL>\s+\(MethodDesc\s+<HEXVAL>\s+(\+\s*0x<HEXVAL>\s+)?SymbolTestApp\.Program\.Foo4\(System\.String\)\),\s+calling.*\s+)|(.*\s+<HEXVAL>\s+<HEXVAL>\s+\(MethodDesc\s+<HEXVAL>\s+(\+\s*0x<HEXVAL>\s+)?SymbolTestApp\.Program\.Foo2\(Int32, System\.String\)\),\s+calling.*\s+) +ENDIF:MAJOR_RUNTIME_VERSION_GE_7 ENDIF:ARM +ENDIF:ARM64 ENDIF:DOTNETDUMP # Verify that IP2MD works (uses IP from ClrStack) diff --git a/src/SOS/SOS.UnitTests/Scripts/StackTests.script b/src/SOS/SOS.UnitTests/Scripts/StackTests.script index 90d04f6578..f233a3d3c6 100644 --- a/src/SOS/SOS.UnitTests/Scripts/StackTests.script +++ b/src/SOS/SOS.UnitTests/Scripts/StackTests.script @@ -8,9 +8,12 @@ LOADSOS # Issue: https://github.com/dotnet/diagnostics/issues/1567 !IFDEF:ALPINE +# Issue:https://github.com/dotnet/diagnostics/issues/3155 +!IFDEF:MAJOR_RUNTIME_VERSION_GE_7 # Test eeversion command SOSCOMMAND:EEVersion VERIFY:\s+<DECVAL>.<DECVAL>.<DECVAL>.<DECVAL>.* +ENDIF:MAJOR_RUNTIME_VERSION_GE_7 ENDIF:ALPINE # 1) Verifying that ClrStack with no options works @@ -147,18 +150,21 @@ VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+System\.FormatException\s+ VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+System\.InvalidOperationException\s+ VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+System\.String.* +# Issue: https://github.com/dotnet/diagnostics/issues/2947 !IFDEF:DOTNETDUMP +!IFDEF:ARM64 !IFDEF:ARM +!IFDEF:MAJOR_RUNTIME_VERSION_GE_7 # 9) Verify DumpStack works SOSCOMMAND:DumpStack -VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.* +VERIFY:.*OS Thread Id:\s+0x<HEXVAL>.*\s+.* VERIFY:.*Child(-SP|EBP|FP)\s+RetAddr\s+Caller, Callee\s+ VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+\(MethodDesc\s+<HEXVAL>\s+\+\s*0x<HEXVAL>\s+NestedExceptionTest\.Program\.Main\(System\.String\[\]\)\),\s+calling.* # 10) Verify DumpStack -EE works SOSCOMMAND:DumpStack -EE -VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.* +VERIFY:.*OS Thread Id:\s+0x<HEXVAL>.*\s+.* VERIFY:.*Child(-SP|EBP|FP)\s+RetAddr\s+Caller, Callee\s+ VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+\(MethodDesc\s+<HEXVAL>\s+\+\s*0x<HEXVAL>\s+NestedExceptionTest\.Program\.Main\(System\.String\[\]\)\)\s+ @@ -167,5 +173,7 @@ SOSCOMMAND:EEStack VERIFY:.*Child(-SP|EBP|FP)\s+RetAddr\s+Caller, Callee\s+ VERIFY:.*\s+<HEXVAL>\s+<HEXVAL>\s+\(MethodDesc\s+<HEXVAL>\s+\+\s*0x<HEXVAL>\s+NestedExceptionTest\.Program\.Main\(System\.String\[\]\)\),\s+calling.* +ENDIF:MAJOR_RUNTIME_VERSION_GE_7 ENDIF:ARM +ENDIF:ARM64 ENDIF:DOTNETDUMP diff --git a/src/SOS/SOS.UnitTests/Scripts/TaskNestedException.script b/src/SOS/SOS.UnitTests/Scripts/TaskNestedException.script index a85c0447c4..4ffbd05303 100644 --- a/src/SOS/SOS.UnitTests/Scripts/TaskNestedException.script +++ b/src/SOS/SOS.UnitTests/Scripts/TaskNestedException.script @@ -13,18 +13,18 @@ SOSCOMMAND:PrintException VERIFY:Exception object:\s+<HEXVAL>\s+ VERIFY:Exception type:\s+System\.AggregateException\s+ VERIFY:Message:\s+(<Invalid Object>|One or more errors occurred\.)\s+ -VERIFY:InnerException:\s+System\.FormatException, Use !PrintException <HEXVAL> to see more\.\s+ +VERIFY:InnerException:\s+System\.FormatException, Use !?printexception <HEXVAL> to see more\.\s+ VERIFY:StackTrace \(generated\):\s+ VERIFY:\s+SP\s+IP\s+Function\s+ VERIFY:\s+<HEXVAL>\s+<HEXVAL>.+System(::|\.)Threading(::|\.)Tasks(::|\.)Task\.Wait(\(\))?\+0x<HEXVAL>\s+ VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+.*RandomUserTask\.WaitTask(\(\))?\+0x<HEXVAL>\s+ VERIFY:\s+<HEXVAL>\s+<HEXVAL>\s+.*SosTests(::|\.)TaskException\.Main(\(\))?\+0x<HEXVAL>\s+ -SOSCOMMAND:PrintException -lines <POUT>InnerException:\s+System\.FormatException, Use !PrintException (<HEXVAL>) to see more<POUT> +SOSCOMMAND:PrintException -lines <POUT>InnerException:\s+System\.FormatException, Use !?printexception (<HEXVAL>) to see more<POUT> VERIFY:Exception object:\s+<HEXVAL>\s+ VERIFY:Exception type:\s+System\.FormatException\s+ VERIFY:Message:\s+(<Invalid Object>|Bad format exception, outer\.)\s+ -VERIFY:InnerException:\s+System\.InvalidOperationException, Use !PrintException <HEXVAL> to see more\.\s+ +VERIFY:InnerException:\s+System\.InvalidOperationException, Use !?printexception <HEXVAL> to see more\.\s+ VERIFY:StackTrace \(generated\):\s+ VERIFY:\s+SP\s+IP\s+Function\s+ VERIFY:\s+<HEXVAL>\s+<HEXVAL>.+RandomTest(::|\.)RandomUserTask\.<\.ctor>.+\+0x<HEXVAL>\s* @@ -34,7 +34,7 @@ VERIFY:[.+[\\|/]Debuggees[\\|/].*[Tt]ask[Nn]ested[Ee]xception[\\|/][Rr]andom[Uu] ENDIF:TRIAGE_DUMP ENDIF:DESKTOP -SOSCOMMAND:PrintException -lines <POUT>InnerException:\s+System\.InvalidOperationException, Use !PrintException (<HEXVAL>) to see more<POUT> +SOSCOMMAND:PrintException -lines <POUT>InnerException:\s+System\.InvalidOperationException, Use !?printexception (<HEXVAL>) to see more<POUT> VERIFY:Exception object:\s+<HEXVAL>\s+ VERIFY:Exception type:\s+System\.InvalidOperationException\s+ VERIFY:Message:\s+(<Invalid Object>|This is an Inner InvalidOperationException\.)\s+ diff --git a/src/SOS/SOS.UnitTests/Scripts/WebApp.script b/src/SOS/SOS.UnitTests/Scripts/WebApp.script index f5e7e5eef7..a59a8a7562 100644 --- a/src/SOS/SOS.UnitTests/Scripts/WebApp.script +++ b/src/SOS/SOS.UnitTests/Scripts/WebApp.script @@ -1,8 +1,6 @@ # # Tests the various SOS stack and other commands against a webapp 3.x app # -# Commands Verified: ClrStack, DumpStackObjects, DumpStack, EEStack, IP2MD, u, Name2EE, Threads (clrthreads) -# CONTINUE @@ -34,11 +32,19 @@ EXTCOMMAND:parallelstacks EXTCOMMAND:timerinfo VERIFY:\s*<DECVAL>\s*timers\s* +SOSCOMMAND:runtimes + +EXTCOMMAND:runtimes + # Verify that ClrStack with no options works SOSCOMMAND:ClrStack VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.* VERIFY:\s+Child\s+SP\s+IP\s+Call Site\s+ +EXTCOMMAND:ClrStack +VERIFY:.*OS Thread Id:\s+0x<HEXVAL>\s+.* +VERIFY:\s+Child\s+SP\s+IP\s+Call Site\s+ + # Verify that ClrStack for all threads works SOSCOMMAND:ClrStack -all diff --git a/src/SOS/Strike/CMakeLists.txt b/src/SOS/Strike/CMakeLists.txt index e3a11abb5d..6299c27391 100644 --- a/src/SOS/Strike/CMakeLists.txt +++ b/src/SOS/Strike/CMakeLists.txt @@ -131,11 +131,11 @@ if(WIN32) ntdll.lib ) - if(NOT CLR_CMAKE_HOST_ARCH_ARM64) + if(NOT CLR_CMAKE_HOST_ARCH_ARM64 AND NOT CLR_CMAKE_HOST_ARCH_ARM) list(APPEND SOS_LIBRARY mscoree.lib) - endif(NOT CLR_CMAKE_HOST_ARCH_ARM64) + endif(NOT CLR_CMAKE_HOST_ARCH_ARM64 AND NOT CLR_CMAKE_HOST_ARCH_ARM) else(WIN32) add_definitions(-DFEATURE_ENABLE_HARDWARE_EXCEPTIONS) diff --git a/src/SOS/Strike/Strike.vcxproj b/src/SOS/Strike/Strike.vcxproj index c6d52839b2..be63febcfb 100644 --- a/src/SOS/Strike/Strike.vcxproj +++ b/src/SOS/Strike/Strike.vcxproj @@ -108,7 +108,7 @@ <StringPooling>true</StringPooling> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4640</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4640</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UndefinePreprocessorDefinitions>_MT</UndefinePreprocessorDefinitions> @@ -184,7 +184,7 @@ <StringPooling>true</StringPooling> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4640</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4640</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UndefinePreprocessorDefinitions>_MT</UndefinePreprocessorDefinitions> @@ -258,14 +258,14 @@ <StringPooling>true</StringPooling> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4640</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4640</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UndefinePreprocessorDefinitions>_MT</UndefinePreprocessorDefinitions> <UseFullPaths>true</UseFullPaths> <WarningLevel>Level3</WarningLevel> <WholeProgramOptimization>true</WholeProgramOptimization> - <PreprocessorDefinitions>NDEBUG;URTBLDENV_FRIENDLY=Retail;_AMD64_;_WIN64;AMD64;BIT64=1;_TARGET_64BIT_=1;_TARGET_AMD64_=1;DBG_TARGET_64BIT=1;DBG_TARGET_AMD64=1;DBG_TARGET_WIN64=1;WIN32;_WIN32;WINVER=0x0602;_WIN32_WINNT=0x0602;WIN32_LEAN_AND_MEAN=1;_CRT_SECURE_NO_WARNINGS;;FEATURE_COMINTEROP;FEATURE_HIJACK;_SECURE_SCL=0;_TARGET_WIN64_=1;SOS_TARGET_AMD64=1;SOS_TARGET_ARM64=1;STRIKE;USE_STL;FX_VER_INTERNALNAME_STR=SOS.dll;CMAKE_INTDIR="Release";sos_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>HOST_WINDOWS;NDEBUG;URTBLDENV_FRIENDLY=Retail;_AMD64_;_WIN64;AMD64;BIT64=1;_TARGET_64BIT_=1;_TARGET_AMD64_=1;DBG_TARGET_64BIT=1;DBG_TARGET_AMD64=1;DBG_TARGET_WIN64=1;WIN32;_WIN32;WINVER=0x0602;_WIN32_WINNT=0x0602;WIN32_LEAN_AND_MEAN=1;_CRT_SECURE_NO_WARNINGS;FEATURE_COMINTEROP;FEATURE_HIJACK;_SECURE_SCL=0;_TARGET_WIN64_=1;SOS_TARGET_AMD64=1;SOS_TARGET_ARM64=1;STRIKE;USE_STL;FX_VER_INTERNALNAME_STR=SOS.dll;CMAKE_INTDIR="Release";sos_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <ObjectFileName>$(IntDir)</ObjectFileName> </ClCompile> <ResourceCompile> @@ -334,7 +334,7 @@ <StringPooling>true</StringPooling> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4640</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4640</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UndefinePreprocessorDefinitions>_MT</UndefinePreprocessorDefinitions> diff --git a/src/SOS/Strike/eeheap.cpp b/src/SOS/Strike/eeheap.cpp index 7bb21cf8b0..2eb5d99319 100644 --- a/src/SOS/Strike/eeheap.cpp +++ b/src/SOS/Strike/eeheap.cpp @@ -12,7 +12,6 @@ #include "safemath.h" #include "releaseholder.h" - // This is the increment for the segment lookup data const int nSegLookupStgIncrement = 100; @@ -519,7 +518,7 @@ void GCPrintSegmentInfo(const GCHeapDetails &heap, DWORD_PTR &total_allocated_si dwAddrSeg = (DWORD_PTR)heap.generation_table[GetMaxGeneration()].start_segment; total_allocated_size = 0; total_committed_size = 0; - // the loop below will terminate, because we retrieved at most nMaxHeapSegmentCount segments + while (dwAddrSeg != (DWORD_PTR)heap.generation_table[0].start_segment) { if (IsInterrupt()) @@ -568,7 +567,6 @@ void GCPrintLargeHeapSegmentInfo(const GCHeapDetails &heap, DWORD_PTR &total_all dwAddrSeg = (DWORD_PTR)heap.generation_table[GetMaxGeneration()+1].start_segment; // total_size = 0; - // the loop below will terminate, because we retrieved at most nMaxHeapSegmentCount segments while (dwAddrSeg != NULL) { if (IsInterrupt()) @@ -599,7 +597,6 @@ void GCPrintPinnedHeapSegmentInfo(const GCHeapDetails &heap, DWORD_PTR &total_al DacpHeapSegmentData segment; dwAddrSeg = (DWORD_PTR)heap.generation_table[GetMaxGeneration() + 2].start_segment; - // the loop below will terminate, because we retrieved at most nMaxHeapSegmentCount segments while (dwAddrSeg != NULL) { if (IsInterrupt()) @@ -690,7 +687,6 @@ BOOL GCObjInSegment(TADDR taddrObj, const GCHeapDetails &heap, { taddrSeg = (TADDR)heap.generation_table[gen_num].start_segment; - // the loop below will terminate, because we retrieved at most nMaxHeapSegmentCount segments while (taddrSeg != NULL) { if (IsInterrupt()) @@ -716,7 +712,7 @@ BOOL GCObjInSegment(TADDR taddrObj, const GCHeapDetails &heap, else { taddrSeg = (TADDR)heap.generation_table[GetMaxGeneration()].start_segment; - // the loop below will terminate, because we retrieved at most nMaxHeapSegmentCount segments + while (taddrSeg != (TADDR)heap.generation_table[0].start_segment) { if (IsInterrupt()) @@ -766,7 +762,6 @@ BOOL GCObjInLargeSegment(TADDR taddrObj, const GCHeapDetails &heap, TADDR_SEGINF DacpHeapSegmentData dacpSeg; taddrSeg = (TADDR)heap.generation_table[GetMaxGeneration()+1].start_segment; - // the loop below will terminate, because we retrieved at most nMaxHeapSegmentCount segments while (taddrSeg != NULL) { if (IsInterrupt()) @@ -799,7 +794,6 @@ BOOL GCObjInPinnedObjectSegment(TADDR taddrObj, const GCHeapDetails &heap, TADDR DacpHeapSegmentData dacpSeg; taddrSeg = (TADDR)heap.generation_table[GetMaxGeneration() + 2].start_segment; - // the loop below will terminate, because we retrieved at most nMaxHeapSegmentCount segments while (taddrSeg != NULL) { if (IsInterrupt()) @@ -849,7 +843,6 @@ BOOL GCObjInHeap(TADDR taddrObj, const GCHeapDetails &heap, TADDR_SEGINFO& rngSe return FALSE; } -#ifndef FEATURE_PAL // this function updates genUsage to reflect statistics from the range defined by [start, end) void GCGenUsageStats(TADDR start, TADDR alloc_end, TADDR commit_end, const std::unordered_set<TADDR> &liveObjs, const GCHeapDetails &heap, BOOL bLarge, BOOL bPinned, const AllocInfo *pAllocInfo, GenUsageStat *genUsage) @@ -943,7 +936,6 @@ void GCGenUsageStats(TADDR start, TADDR alloc_end, TADDR commit_end, const std:: } } } -#endif // !FEATURE_PAL BOOL GCHeapUsageStats(const GCHeapDetails& heap, BOOL bIncUnreachable, HeapUsageStat *hpUsage) { @@ -977,9 +969,7 @@ BOOL GCHeapUsageStats(const GCHeapDetails& heap, BOOL bIncUnreachable, HeapUsage ExtErr("Error requesting heap segment %p\n", SOS_PTR(taddrSeg)); return FALSE; } -#ifndef FEATURE_PAL GCGenUsageStats((TADDR)dacpSeg.mem, (TADDR)dacpSeg.highAllocMark, (TADDR)dacpSeg.committed, liveObjs, heap, FALSE, FALSE, &allocInfo, &hpUsage->genUsage[n]); -#endif taddrSeg = (TADDR)dacpSeg.next; } } @@ -989,7 +979,6 @@ BOOL GCHeapUsageStats(const GCHeapDetails& heap, BOOL bIncUnreachable, HeapUsage // 1. Start with small object segments taddrSeg = (TADDR)heap.generation_table[GetMaxGeneration()].start_segment; -#ifndef FEATURE_PAL // 1a. enumerate all non-ephemeral segments while (taddrSeg != (TADDR)heap.generation_table[0].start_segment) { @@ -1004,7 +993,6 @@ BOOL GCHeapUsageStats(const GCHeapDetails& heap, BOOL bIncUnreachable, HeapUsage GCGenUsageStats((TADDR)dacpSeg.mem, (TADDR)dacpSeg.allocated, (TADDR)dacpSeg.committed, liveObjs, heap, FALSE, FALSE, &allocInfo, &hpUsage->genUsage[2]); taddrSeg = (TADDR)dacpSeg.next; } -#endif // 1b. now handle the ephemeral segment if (dacpSeg.Request(g_sos, taddrSeg, heap.original_heap_details) != S_OK) @@ -1028,9 +1016,7 @@ BOOL GCHeapUsageStats(const GCHeapDetails& heap, BOOL bIncUnreachable, HeapUsage startGen = TO_TADDR(heap.generation_table[n].allocation_start); } -#ifndef FEATURE_PAL GCGenUsageStats(startGen, endGen, (TADDR)dacpSeg.committed, liveObjs, heap, FALSE, FALSE, &allocInfo, &hpUsage->genUsage[n]); -#endif endGen = startGen; } } @@ -1048,9 +1034,7 @@ BOOL GCHeapUsageStats(const GCHeapDetails& heap, BOOL bIncUnreachable, HeapUsage return FALSE; } -#ifndef FEATURE_PAL GCGenUsageStats((TADDR) dacpSeg.mem, (TADDR) dacpSeg.allocated, (TADDR) dacpSeg.committed, liveObjs, heap, TRUE, FALSE, NULL, &hpUsage->genUsage[3]); -#endif taddrSeg = (TADDR)dacpSeg.next; } @@ -1069,9 +1053,7 @@ BOOL GCHeapUsageStats(const GCHeapDetails& heap, BOOL bIncUnreachable, HeapUsage return FALSE; } -#ifndef FEATURE_PAL GCGenUsageStats((TADDR) dacpSeg.mem, (TADDR) dacpSeg.allocated, (TADDR) dacpSeg.committed, liveObjs, heap, FALSE, TRUE, NULL, &hpUsage->genUsage[4]); -#endif taddrSeg = (TADDR)dacpSeg.next; } } @@ -1197,7 +1179,7 @@ void GatherOneHeapFinalization(DacpGcHeapDetails& heapDetails, HeapStat *stat, B SOS_PTR(SegQueueLimit(heapDetails,gen_segment(m)))); } } -#ifndef FEATURE_PAL + if (bAllReady) { if (!bShort) @@ -1210,7 +1192,6 @@ void GatherOneHeapFinalization(DacpGcHeapDetails& heapDetails, HeapStat *stat, B PrintNotReachableInRange(rngStart, rngEnd, TRUE, bAllReady ? stat : NULL, bShort); } -#endif if (!bShort) { @@ -1585,6 +1566,7 @@ BOOL GCHeapTraverse(const GCHeapDetails &heap, AllocInfo* pallocInfo, VISITGCHEA } dwAddrCurrObj = (DWORD_PTR)segment.mem; + continue; } else { @@ -1934,12 +1916,6 @@ BOOL GCHeapSnapshot::AddSegments(const GCHeapDetails& details) ExtOut("Error requesting heap segment %p\n", SOS_PTR(AddrSeg)); return FALSE; } - if (n++ > nMaxHeapSegmentCount && !details.has_regions) // that would be insane - { - ExtOut("More than %d heap segments, there must be an error\n", nMaxHeapSegmentCount); - return FALSE; - } - // add the new segment to the array of segments. This will expand the array if necessary if (!m_segments.AddSegment(&segment)) { diff --git a/src/SOS/Strike/exts.cpp b/src/SOS/Strike/exts.cpp index adede7e4c4..c6603051b8 100644 --- a/src/SOS/Strike/exts.cpp +++ b/src/SOS/Strike/exts.cpp @@ -217,6 +217,7 @@ void __cdecl _SOS_invalid_parameter( } bool g_Initialized = false; +const char* g_sosPrefix = ""; bool IsInitializedByDbgEng() { @@ -238,6 +239,7 @@ DebugExtensionInitialize(PULONG Version, PULONG Flags) return S_OK; } g_Initialized = true; + g_sosPrefix = "!"; ReleaseHolder<IDebugClient> debugClient; if ((hr = DebugCreate(__uuidof(IDebugClient), (void **)&debugClient)) != S_OK) diff --git a/src/SOS/Strike/gcroot.cpp b/src/SOS/Strike/gcroot.cpp index b4cfe56615..22f50ed23d 100644 --- a/src/SOS/Strike/gcroot.cpp +++ b/src/SOS/Strike/gcroot.cpp @@ -1934,11 +1934,10 @@ size_t HeapTraverser::getID(size_t mTable) return 0; } -#ifndef FEATURE_PAL -void replace(std::wstring &str, const WCHAR *toReplace, const WCHAR *replaceWith) +void replace(std::string &str, const char* toReplace, const char* replaceWith) { - const size_t replaceLen = _wcslen(toReplace); - const size_t replaceWithLen = _wcslen(replaceWith); + const size_t replaceLen = strlen(toReplace); + const size_t replaceWithLen = strlen(replaceWith); size_t i = str.find(toReplace); while (i != std::wstring::npos) @@ -1947,31 +1946,34 @@ void replace(std::wstring &str, const WCHAR *toReplace, const WCHAR *replaceWith i = str.find(toReplace, i + replaceWithLen); } } -#endif -void HeapTraverser::PrintType(size_t ID,LPCWSTR name) +void HeapTraverser::PrintType(size_t ID, LPCWSTR wname) { if (m_format==FORMAT_XML) { -#ifndef FEATURE_PAL + int len = (int)_wcslen(wname); + int size = WideCharToMultiByte(CP_ACP, 0, wname, len, NULL, 0, NULL, NULL); + char *buffer = (char*)_alloca(size + 1); + WideCharToMultiByte(CP_ACP, 0, wname, len, buffer, size, NULL, NULL); + buffer[size] = '\0'; + // Sanitize name based on XML spec. - std::wstring wname = name; - replace(wname, W("&"), W("&")); - replace(wname, W("\""), W(""")); - replace(wname, W("'"), W("'")); - replace(wname, W("<"), W("<")); - replace(wname, W(">"), W(">")); - name = wname.c_str(); -#endif + std::string name(buffer); + replace(name, "&", "&"); + replace(name, "\"", """); + replace(name, "'", "'"); + replace(name, "<", "<"); + replace(name, ">", ">"); + fprintf(m_file, - "<type id=\"%d\" name=\"%S\"/>\n", - ID, name); + "<type id=\"%d\" name=\"%s\"/>\n", + ID, name.c_str()); } else if (m_format==FORMAT_CLRPROFILER) { fprintf(m_file, "t %d 0 %S\n", - ID,name); + ID, wname); } } diff --git a/src/SOS/Strike/sos.cpp b/src/SOS/Strike/sos.cpp index f2052cfa2e..4040947155 100644 --- a/src/SOS/Strike/sos.cpp +++ b/src/SOS/Strike/sos.cpp @@ -4,21 +4,9 @@ #include "strike.h" #include "util.h" - #include "sos.h" - - -#ifdef _ASSERTE -#undef _ASSERTE -#endif - -#define _ASSERTE(a) {;} - #include "gcdesc.h" - -#undef _ASSERTE - namespace sos { template <class T> @@ -505,7 +493,7 @@ namespace sos int entries = 0; if (FAILED(MOVE(entries, mt-sizeof(TADDR)))) - Throw<DataRead>("Failed to request number of entries."); + Throw<DataRead>("Failed to request number of entries for %p MT %p", mObject, mt); // array of vc? if (entries < 0) @@ -598,11 +586,13 @@ namespace sos mCurrObj = mStart < TO_TADDR(mSegment.mem) ? TO_TADDR(mSegment.mem) : mStart; mSegmentEnd = TO_TADDR(mSegment.highAllocMark); - CheckSegmentRange(); + TryAlignToObjectInRange(); } - bool ObjectIterator::NextSegment() + bool ObjectIterator::TryMoveNextSegment() { + CheckInterrupt(); + if (mCurrHeap >= mNumHeaps) { return false; @@ -660,16 +650,30 @@ namespace sos mLastObj = 0; mCurrObj = mStart < TO_TADDR(mSegment.mem) ? TO_TADDR(mSegment.mem) : mStart; mSegmentEnd = TO_TADDR(mSegment.highAllocMark); - return CheckSegmentRange(); + return true; } - bool ObjectIterator::CheckSegmentRange() + bool ObjectIterator::TryMoveToObjectInNextSegmentInRange() { - CheckInterrupt(); + if (TryMoveNextSegment()) + { + return TryAlignToObjectInRange(); + } + return false; + } + + bool ObjectIterator::TryAlignToObjectInRange() + { + CheckInterrupt(); while (!MemOverlap(mStart, mEnd, TO_TADDR(mSegment.mem), mSegmentEnd)) - if (!NextSegment()) + { + CheckInterrupt(); + if (!TryMoveNextSegment()) + { return false; + } + } // At this point we know that the current segment contains objects in // the correct range. However, there's no telling if the user gave us @@ -736,7 +740,7 @@ namespace sos } catch(const sos::Exception &) { - NextSegment(); + TryMoveToObjectInNextSegmentInRange(); } } @@ -754,6 +758,8 @@ namespace sos void ObjectIterator::MoveToNextObject() { + CheckInterrupt(); + // Object::GetSize can be unaligned, so we must align it ourselves. size_t size = (bLarge || bPinned) ? AlignLarge(mCurrObj.GetSize()) : Align(mCurrObj.GetSize()); @@ -785,7 +791,9 @@ namespace sos } if (mCurrObj > mEnd || mCurrObj >= mSegmentEnd) - NextSegment(); + { + TryMoveToObjectInNextSegmentInRange(); + } } SyncBlkIterator::SyncBlkIterator() diff --git a/src/SOS/Strike/sos.def b/src/SOS/Strike/sos.def index e548eac314..0e9876503f 100644 --- a/src/SOS/Strike/sos.def +++ b/src/SOS/Strike/sos.def @@ -74,7 +74,9 @@ EXPORTS EHInfo ehinfo=EHInfo Ehinfo=EHInfo + enummem ext + sos=ext FinalizeQueue finalizequeue=FinalizeQueue fq=FinalizeQueue diff --git a/src/SOS/Strike/sos.h b/src/SOS/Strike/sos.h index 98a71b678e..e4335daa28 100644 --- a/src/SOS/Strike/sos.h +++ b/src/SOS/Strike/sos.h @@ -627,8 +627,27 @@ namespace sos void BuildError(__out_ecount(count) char *out, size_t count, const char *format, ...) const; void AssertSanity() const; - bool NextSegment(); - bool CheckSegmentRange(); + + /* + This function moves to the next segment/region without checking any restrictions + on the range. Returns true if it was able to move to a new segment/region. + */ + bool TryMoveNextSegment(); + + /* + Aligns the iterator to the object that falls in the requested range, moving to + the next segment/region as necessary. The iterator state doesn't change if the + current object already lies in the requested range. Returns true if aligning + to such an object was possible. + */ + bool TryAlignToObjectInRange(); + + /* + Moves to the next segment/region that contains an object in the requested + range and align it to such object. This operation always moves the iterator. + Returns false if no such move was possible. + */ + bool TryMoveToObjectInNextSegmentInRange(); void MoveToNextObject(); private: @@ -721,7 +740,7 @@ namespace sos inline const SyncBlkIterator &operator++() { SOS_Assert(mCurr <= mTotal); - mSyncBlk = ++mCurr; + mSyncBlk = mCurr++; return *this; } diff --git a/src/SOS/Strike/sos_unixexports.src b/src/SOS/Strike/sos_unixexports.src index 6e5eebe9e7..ab7ecd7e4d 100644 --- a/src/SOS/Strike/sos_unixexports.src +++ b/src/SOS/Strike/sos_unixexports.src @@ -2,14 +2,13 @@ ; The .NET Foundation licenses this file to you under the MIT license. ; See the LICENSE file in the project root for more information. +AnalyzeOOM bpmd -clrmodules ClrStack dbgout DumpALC DumpArray DumpAssembly -DumpAsync DumpClass DumpDelegate DumpDomain @@ -29,14 +28,17 @@ DumpStackObjects DumpVC EEHeap EEVersion -GCWhere EEStack EHInfo -ext +enummem FinalizeQueue FindAppDomain +FindRoots +GCHandles +GCHeapStat GCInfo GCRoot +GCWhere Help HistClear HistInit @@ -45,13 +47,14 @@ HistObjFind HistRoot HistStats IP2MD -logging +ListNearObj Name2EE +ObjSize PrintException PathTo +runtimes StopOnCatch SetClrPath -SetSymbolServer SOSFlush SOSStatus runtimes @@ -61,8 +64,10 @@ Threads ThreadPool ThreadState Token2EE +TraverseHeap u VerifyHeap +VerifyObj SOSInitializeByHost SOSUninitializeByHost diff --git a/src/SOS/Strike/sosdocsunix.txt b/src/SOS/Strike/sosdocsunix.txt index e72ea0a77b..e61e5b8715 100644 --- a/src/SOS/Strike/sosdocsunix.txt +++ b/src/SOS/Strike/sosdocsunix.txt @@ -32,7 +32,9 @@ DumpHeap (dumpheap) EEStack (eestack) DumpVC ClrStack (clrstack) FinalizeQueue (finalizequeue) GCInfo GCRoot (gcroot) EHInfo -PrintException (pe) bpmd (bpmd) +ObjSize (objsize) bpmd (bpmd) +PrintException (pe) +TraverseHeap (traverseheap) Examining CLR data structures Diagnostic Utilities ----------------------------- ----------------------------- @@ -41,12 +43,12 @@ EEHeap (eeheap) FindAppDomain Name2EE (name2ee) DumpLog (dumplog) SyncBlk (syncblk) SuppressJitOptimization DumpMT (dumpmt) ThreadPool (threadpool) -DumpClass (dumpclass) -DumpMD (dumpmd) -Token2EE +DumpClass (dumpclass) AnalyzeOOM (analyzeoom) +DumpMD (dumpmd) VerifyObj (verifyobj) +Token2EE GCHandles (gchandles) DumpModule (dumpmodule) DumpAssembly (dumpassembly) -DumpRuntimeTypes +DumpRuntimeTypes (dumpruntimetypes) DumpIL (dumpil) DumpSig DumpSigElem @@ -442,27 +444,6 @@ DumpVC is quite a specialized function. Some managed programs make heavy use of value classes, while others do not. \\ -COMMAND: finalizequeue -FinalizeQueue [-detail] | [-allReady] [-short] - -Displays all objects registered for finalization. -The "-detail" option displays extra information about any SyncBlocks that need -to be cleaned up. This data structure is cached and cleaned up by the -finalizer thread when it runs. - -The "-allReady" option displays all objects that are ready for finalization, -regardless of whether they are already marked by the garbage collection -as such, or will be marked by the next garbage collection. The objects that -are in the "ready for finalization" list are finalizable objects that are -no longer rooted. This option can be very expensive, because it verifies -whether all the objects in the finalizable queues are still rooted. - -The "-short" option limits the output to the address of each object. If it is -used in conjunction with -allReady, it enumerates all objects that have -a finalizer that are no longer rooted. If it is used independently, it lists -all objects in the finalizable and "ready for finalization" queues. -\\ - COMMAND: gcroot. GCRoot [-nostacks] [-all] <Object address> @@ -487,6 +468,99 @@ objects, there is a -nostacks option. The -all option forces all roots to be displayed instead of just the unique roots. \\ +COMMAND: objsize. +ObjSize [<Object address>] + +With no parameters, ObjSize lists the size of all objects found on managed +threads. It also enumerates all GCHandles in the process, and totals the size +of any objects pointed to by those handles. In calculating object size, +ObjSize includes the size of all child objects in addition to the parent. + +For example, DumpObj lists a size of 20 bytes for this Customer object: + + (lldb) dumpobj a79d40 + Name: Customer + MethodTable: 009038ec + EEClass: 03ee1b84 + Size: 20(0x14) bytes + (C:\pub\unittest.exe) + Fields: + MT Field Offset Type Attr Value Name + 009038ec 4000008 4 CLASS instance 00a79ce4 name + 009038ec 4000009 8 CLASS instance 00a79d2c bank + 009038ec 400000a c System.Boolean instance 1 valid + +but ObjSize lists 152 bytes: + + (lldb) ObjSize a79d40 + sizeof(00a79d40) = 152 ( 0x98) bytes (Customer) + +This is because a Customer points to a Bank, has a name, and the Bank points to +an Address string. You can use ObjSize to identify any particularly large +objects, such as a managed cache in a web server. + +While running ObjSize with no arguments may point to specific roots that hold +onto large amounts of memory it does not provide information regarding the +amount of managed memory that is still alive. This is due to the fact that a +number of roots can share a common subgraph, and that part will be reported in +the size of all the roots that reference the subgraph. +\\ + +COMMAND: finalizequeue. +FinalizeQueue [-detail] | [-allReady] [-short] + +This command lists the objects registered for finalization. Here is output from +a simple program: + + (lldb) finalizequeue + SyncBlocks to be cleaned up: 0 + MTA Interfaces to be released: 0 + STA Interfaces to be released: 1 + generation 0 has 4 finalizable objects (0015bc90->0015bca0) + generation 1 has 0 finalizable objects (0015bc90->0015bc90) + generation 2 has 0 finalizable objects (0015bc90->0015bc90) + Ready for finalization 0 objects (0015bca0->0015bca0) + Statistics: + MT Count TotalSize Class Name + 5ba6cf78 1 24 Microsoft.Win32.SafeHandles.SafeFileHandle + 5ba5db04 1 68 System.Threading.Thread + 5ba73e28 2 112 System.IO.StreamWriter + Total 4 objects + +The GC heap is divided into generations, and objects are listed accordingly. We +see that only generation 0 (the youngest generation) has any objects registered +for finalization. The notation "(0015bc90->0015bca0)" means that if you look at +memory in that range, you'll see the object pointers that are registered: + +0:000> dd 15bc90 15bca0-4 +0015bc90 00a743f4 00a79f00 00a7b3d8 00a7b47c + +You could run dumpobj on any of those pointers to learn more. In this example, +there are no objects ready for finalization, presumably because they still have +roots (You can use gcroot to find out). The statistics section provides a +higher-level summary of the objects registered for finalization. Note that +objects ready for finalization are also included in the statistics (if any). + +Specifying -short will inhibit any display related to SyncBlocks or RCWs. + +The arguments in detail: + +-allReady Specifying this argument will allow for the display of all objects + that are ready for finalization, whether they are already marked by + the GC as such, or whether the next GC will. The objects that are + not in the "Ready for finalization" list are finalizable objects that + are no longer rooted. This option can be very expensive, as it + verifies whether all the objects in the finalizable queues are still + rooted or not. +-short Limits the output to just the address of each object. If used in + conjunction with -allReady it enumerates all objects that have a + finalizer that are no longer rooted. If used independently it lists + all objects in the finalizable and "ready for finalization" queues. +-detail Will display extra information on any SyncBlocks that need to be + cleaned up, and on any RuntimeCallableWrappers (RCWs) that await + cleanup. Both of these data structures are cached and cleaned up by + the finalizer thread when it gets a chance to run. +\\ COMMAND: pe. COMMAND: printexception. PrintException [-nested] [-lines] [-ccw] [<Exception object address>] [<CCW pointer>] @@ -517,6 +591,48 @@ which can be specified using the -ccw option. The abbreviation 'pe' can be used for brevity. \\ +COMMAND: traverseheap. +Traverseheap [-xml] [-verify] <filename> + +traverseheap writes out a file in a format understood by the CLR Profiler. +You can download the CLR Profiler from this link: + +http://www.microsoft.com/downloads/details.aspx?FamilyId=86CE6052-D7F4-4AEB- +9B7A-94635BEEBDDA&displaylang=en + +It creates a graphical display of the GC heap to help you analyze the state of +your application. + +If you pass the -verify option it will do more sanity checking of the heap +as it dumps it. Use this option if heap corruption is suspected. + +If you pass the "-xml" flag, the file is instead written out in an easy to +understand xml format: + + <gcheap> + <types> + <type id="1" name="System.String"> + ... + </types> + <roots> + <root kind="handle" address="0x00a73ff0"/> + <root kind="stack" address="0x0069f0e0"/> + ... + </roots> + <objects> + <object address="0x00b73030" typeid="1" size="300"/> + <object address="0x00b75054" typeid="5" size="20"> + <member address="0x00b75088" /> + ... + </object> + ... + </objects> + </gcheap> + +You can break into your process, load SOS, take a snapshot of your heap with +this function, then continue. + +\\ COMMAND: threadstate. ThreadState value @@ -1253,14 +1369,14 @@ It means that Thread e04 owns object 00a7a194, and Thread ab8 owns object 0404ea04 77f5c524 SharedUserData!SystemCallStub+0x4 0404ea08 77e75ee0 ntdll!NtWaitForMultipleObjects+0xc 0404eaa4 5d9de9d6 KERNEL32!WaitForMultipleObjectsEx+0x12c - 0404eb38 5d9def80 clr!Thread::DoAppropriateAptStateWait+0x156 - 0404ecc4 5d9dd8bb clr!Thread::DoAppropriateWaitWorker+0x360 - 0404ed20 5da628dd clr!Thread::DoAppropriateWait+0xbb - 0404ede4 5da4e2e2 clr!CLREvent::Wait+0x29d - 0404ee70 5da4dd41 clr!AwareLock::EnterEpilog+0x132 - 0404ef34 5da4efa3 clr!AwareLock::Enter+0x2c1 - 0404f09c 5d767880 clr!AwareLock::Contention+0x483 - 0404f1c4 03f00229 clr!JITutil_MonContention+0x2c0 + 0404eb38 5d9def80 coreclr!Thread::DoAppropriateAptStateWait+0x156 + 0404ecc4 5d9dd8bb coreclr!Thread::DoAppropriateWaitWorker+0x360 + 0404ed20 5da628dd coreclr!Thread::DoAppropriateWait+0xbb + 0404ede4 5da4e2e2 coreclr!CLREvent::Wait+0x29d + 0404ee70 5da4dd41 coreclr!AwareLock::EnterEpilog+0x132 + 0404ef34 5da4efa3 coreclr!AwareLock::Enter+0x2c1 + 0404f09c 5d767880 coreclr!AwareLock::Contention+0x483 + 0404f1c4 03f00229 coreclr!JITutil_MonContention+0x2c0 0404f1f4 5b6ef077 image00400000!Worker.Work()+0x79 ... @@ -1583,6 +1699,7 @@ is a simple example of the output for a dynamic method: IL_0010: stloc.0 IL_0011: ldloc.0 IL_0012: ret + \\ COMMAND: verifyheap. @@ -1623,6 +1740,127 @@ in the CLR. In user code, an error in constructing PInvoke calls can cause this problem, and running with Managed Debugging Assistants is advised. If that possibility is eliminated, consider contacting Microsoft Product Support for help. + +\\ + +COMMAND: verifyobj. +VerifyObj <object address> + +VerifyObj is a diagnostic tool that checks the object that is passed as an +argument for signs of corruption. + + 0:002> verifyobj 028000ec + object 0x28000ec does not have valid method table + + 0:002> verifyobj 0680017c + object 0x680017c: bad member 00000001 at 06800184 + +\\ + +COMMAND: findroots. +FindRoots -gen <N> | -gen any | <object address> + +The "-gen" form causes the debugger to break in the debuggee on the next +collection of the specified generation. The effect is reset as soon as the +break occurs, in other words, if you need to break on the next collection you +would need to reissue the command. + +The last form of this command is meant to be used after the break caused by the +other forms has occurred. Now the debuggee is in the right state for +findroots to be able to identify roots for objects from the current condemned +generations. + +FindRoots is a diagnostic command that is meant to answer the following +question: + +"I see that GCs are happening, however my objects have still not been +collected. Why? Who is holding onto them?" + +The process of answering the question would go something like this: + +1. Find out the generation of the object of interest using the gcwhere +command, say it is gen 1: + (lldb) gcwhere <object address> + +2. Instruct the runtime to stop the next time it collects that generation using +the findroots command: + findroots -gen 1 + g + +3. When the next GC starts, and has proceeded past the mark phase a CLR +notification will cause a break in the debugger: + (fd0.ec4): CLR notification exception - code e0444143 (first chance) + CLR notification: GC - end of mark phase. + Condemned generation: 1. + +4. Now we can use the findroots <object address> to find out the cross +generational references to the object of interest. In other words, even if the +object is not referenced by any "proper" root it may still be referenced by an +older object (from an older generation), from a generation that has not yet been +scheduled for collection. At this point findroots will search those older +generations too, and report those roots. + (lldb) findroots 06808094 + older generations::Root: 068012f8(AAA.Test+a)-> + 06808094(AAA.Test+b) + +\\ + +COMMAND: analyzeoom. +analyzeoom + +AnalyzeOOM displays the info of the last OOM occurred on an allocation request to +the GC heap (in Server GC it displays OOM, if any, on each GC heap). + +To see the managed exception(s) use the clrthreads command which will show you +managed exception(s), if any, on each managed thread. If you do see an +OutOfMemoryException exception you can use the printexception command on it. +To get the full callstack use the "kb" command in the debugger for that thread. +For example, to display thread 3's stack use ~3kb. + +OOM exceptions could be because of the following reasons: + +1) allocation request to GC heap + in which case you will see JIT_New* on the call stack because managed code called new. +2) other runtime allocation failure + for example, failure to expand the finalize queue when GC.ReRegisterForFinalize is + called. +3) some other code you use throws a managed OOM exception + for example, some .NET framework code converts a native OOM exception to managed + and throws it. + +The analyzeoom command aims to help you with investigating 1) which is the most +difficult because it requires some internal info from GC. The only exception is +we don't support allocating objects larger than 2GB on CLR v2.0 or prior. And this +command will not display any managed OOM because we will throw OOM right away +instead of even trying to allocate it on the GC heap. + +There are 2 legitimate scenarios where GC would return OOM to allocation requests - +one is if the process is running out of VM space to reserve a segment; the other +is if the system is running out physical memory (+ page file if you have one) so +GC can not commit memory it needs. You can look at these scenarios by using performance +counters or debugger commands. For example for the former scenario the "!address +-summary" debugger command will show you the largest free region in the VM. For +the latter scenario you can look at the "Memory% Committed Bytes In Use" see +if you are running low on commit space. One important thing to keep in mind is +when you do this kind of memory analysis it could an aftereffect and doesn't +completely agree with what this command tells you, in which case the command should +be respected because it truly reflects what happened during GC. + +The other cases should be fairly obvious from the callstack. + +Sample output: + +0:011> analyzeoom +---------Heap 2 --------- +Managed OOM occurred after GC #28 (Requested to allocate 1234 bytes) +Reason: Didn't have enough memory to commit +Detail: SOH: Didn't have enough memory to grow the internal GC datastructures (800000 bytes) - + on GC entry available commit space was 500 MB +---------Heap 4 --------- +Managed OOM occurred after GC #12 (Requested to allocate 100000 bytes) +Reason: Didn't have enough memory to allocate an LOH segment +Detail: LOH: Failed to reserve memory (16777216 bytes) + \\ COMMAND: gcwhere. @@ -1642,6 +1880,40 @@ the "size" is displayed as 0: 0280003c 2 0 02800000 02800038 0282b740 0 \\ +COMMAND: listnearobj. +ListNearObj <object address> + +ListNearObj is a diagnostic tool that displays the object preceeding and +succeeding the address passed in: + +The command looks for the address in the GC heap that looks like a valid +beginning of a managed object (based on a valid method table) and the object +following the argument address. + + 0:002> listnearobj 028000ec + Before: 0x28000a4 72 (0x48 ) System.StackOverflowException + After: 0x2800134 72 (0x48 ) System.Threading.ThreadAbortException + Heap local consistency confirmed. + + 0:002> listnearobj 028000f0 + Before: 0x28000ec 72 (0x48 ) System.ExecutionEngineException + After: 0x2800134 72 (0x48 ) System.Threading.ThreadAbortException + Heap local consistency confirmed. + +The command considers the heap as "locally consistent" if: + prev_obj_addr + prev_obj_size = arg_addr && arg_obj + arg_size = next_obj_addr +OR + prev_obj_addr + prev_obj_size = next_obj_addr + +When the condition is not satisfied: + + 0:002> listnearobj 028000ec + Before: 0x28000a4 72 (0x48 ) System.StackOverflowException + After: 0x2800134 72 (0x48 ) System.Threading.ThreadAbortException + Heap local consistency not confirmed. + +\\ + COMMAND: dumplog. DumpLog [-addr <addressOfStressLog>] [<Filename>] @@ -1763,6 +2035,84 @@ Objects with Finalizers are the easiest case, as the CLR needs to be able to call those when an AppDomain shuts down. \\ +COMMAND: gchandles. +GCHandles [-type handletype] [-stat] [-perdomain] + +GCHandles provides statistics about GCHandles in the process. + +Paremeters: + stat - Only display the statistics and not the list of handles and + what they point to. + perdomain - Break down the statistics by the app domain in which + the handles reside. + type - A type of handle to filter it by. The handle types are: + Pinned + RefCounted + WeakShort + WeakLong + Strong + Variable + AsyncPinned + SizedRef + +Sometimes the source of a memory leak is a GCHandle leak. For example, code +might keep a 50 Megabyte array alive because a strong GCHandle points to it, +and the handle was discarded without freeing it. + +The most common handles are "Strong Handles," which keep the object they point +to alive until the handle is explicitly freed. "Pinned Handles" are used to +prevent the garbage collector from moving an object during collection. These +should be used sparingly, and for short periods of time. If you don't follow +that precept, the gc heap can become very fragmented. + +Here is sample output from a very simple program. Note that the "RefCount" +field only applies to RefCount Handles, and this field will contain the +reference count: + + 0:000> gchandles + Handle Type Object Size RefCount Type + 001611c0 Strong 01d00b58 84 System.IndexOutOfRangeException + 001611c4 Strong 01d00b58 84 System.IndexOutOfRangeException + 001611c8 Strong 01d1b48c 40 System.Diagnostics.LogSwitch + 001611d0 Strong 01cfd2c0 36 System.Security.PermissionSet + 001611d4 Strong 01cf7484 56 System.Object[] + 001611d8 Strong 01cf1238 32 System.SharedStatics + 001611dc Strong 01cf11c8 84 System.Threading.ThreadAbortException + 001611e0 Strong 01cf1174 84 System.Threading.ThreadAbortException + 001611e4 Strong 01cf1120 84 System.ExecutionEngineException + 001611e8 Strong 01cf10cc 84 System.StackOverflowException + 001611ec Strong 01cf1078 84 System.OutOfMemoryException + 001611f0 Strong 01cf1024 84 System.Exception + 001611f8 Strong 01cf2068 48 System.Threading.Thread + 001611fc Strong 01cf1328 112 System.AppDomain + 001613ec Pinned 02cf3268 8176 System.Object[] + 001613f0 Pinned 02cf2258 4096 System.Object[] + 001613f4 Pinned 02cf2038 528 System.Object[] + 001613f8 Pinned 01cf121c 12 System.Object + 001613fc Pinned 02cf1010 4116 System.Object[] + + Statistics: + MT Count TotalSize Class Name + 563266dc 1 12 System.Object + 56329708 1 32 System.SharedStatics + 5632bc38 1 36 System.Security.PermissionSet + 5635f934 1 40 System.Diagnostics.LogSwitch + 5632759c 1 48 System.Threading.Thread + 5632735c 1 84 System.ExecutionEngineException + 56327304 1 84 System.StackOverflowException + 563272ac 1 84 System.OutOfMemoryException + 563270c4 1 84 System.Exception + 56328914 1 112 System.AppDomain + 56335f78 2 168 System.IndexOutOfRangeException + 563273b4 2 168 System.Threading.ThreadAbortException + 563208d0 5 16972 System.Object[] + Total 19 objects + + Handles: + Strong Handles: 14 + Pinned Handles: 5 +\\ + COMMAND: histinit. HistInit @@ -1920,8 +2270,7 @@ You can use the "dotnet --info" in a command shell to find the path of an instal COMMAND: setsymbolserver. COMMAND: loadsymbols. -COMMAND: sympath. -SetSymbolServer [-ms] [-disable] [-log] [-loadsymbols] [-cache <cache-path>] [-directory <search-directory>] [-timeout <minutes> ] [-pat <token>] [-sympath <windows-symbol-path>] [<symbol-server-URL>] +SetSymbolServer [-ms] [-disable] [-log] [-loadsymbols] [-cache <cache-path>] [-directory <search-directory>] [-timeout <minutes> ] [-pat <token>] [<symbol-server-URL>] -ms - Use the public Microsoft symbol server. -disable - Disable symbol download support. @@ -1929,7 +2278,6 @@ SetSymbolServer [-ms] [-disable] [-log] [-loadsymbols] [-cache <cache-path>] [- -timeout - Specify the symbol server timeout in minutes -pat - Access token to the authenticated server. -cache - Specific a symbol cache directory. The default is $HOME/.dotnet/symbolcache if not specified. --sympath - Add server, cache and directory paths in the Windows symbol path format. -loadsymbols - Attempts to download the native .NET Core symbols for the runtime <symbol-server-URL> - Symbol server URL. @@ -1953,10 +2301,6 @@ To add a directory to search for symbols: This command can be used so the module/symbol file structure does not have to match the machine file structure that the core dump was generated. -The "sympath" option/command alias allows Windows symbol paths to be parsed: - - (lldb) sympath "/home/mikem/localsymbols;srv*/home/mikem/symbolcache*https://msdl.microsoft.com/download/symbols". - To clear the default cache run "rm -r $HOME/.dotnet/symbolcache" in a command shell. If you receive an error like the one below on a core dump, you need to set the .NET Core diff --git a/src/SOS/Strike/strike.cpp b/src/SOS/Strike/strike.cpp index 0796420ceb..268e5508d5 100644 --- a/src/SOS/Strike/strike.cpp +++ b/src/SOS/Strike/strike.cpp @@ -105,6 +105,7 @@ #include "cordebug.h" #include "dacprivate.h" #include "corexcep.h" +#include <dumpcommon.h> #define CORHANDLE_MASK 0x1 #define SWITCHED_OUT_FIBER_OSID 0xbaadf00d; @@ -161,10 +162,6 @@ WCHAR g_mdName[mdNameLen]; HMODULE g_hInstance = NULL; #endif // !FEATURE_PAL -#if !defined(FEATURE_PAL) && !defined(_TARGET_ARM64_) -extern bool g_useDesktopClrHost; -#endif - #ifdef _MSC_VER #pragma warning(disable:4244) // conversion from 'unsigned int' to 'unsigned short', possible loss of data #pragma warning(disable:4189) // local variable is initialized but not referenced @@ -172,10 +169,9 @@ extern bool g_useDesktopClrHost; #ifdef FEATURE_PAL #define SOSPrefix "" -#define SOSThreads "clrthreads" #else -#define SOSPrefix "!" -#define SOSThreads "!threads" +extern const char* g_sosPrefix; +#define SOSPrefix g_sosPrefix #endif #if defined _X86_ && !defined FEATURE_PAL @@ -950,9 +946,9 @@ DECLARE_API(DumpIL) // Now we have a local copy of the IL, and a managed array for token resolution. // Visit our IL parser with this info. ExtOut("This is dynamic IL. Exception info is not reported at this time.\n"); - ExtOut("If a token is unresolved, run \"!do <addr>\" on the addr given\n"); + ExtOut("If a token is unresolved, run \"%sdumpobj <addr>\" on the addr given\n", SOSPrefix); ExtOut("in parenthesis. You can also look at the token table yourself, by\n"); - ExtOut("running \"!DumpArray %p\".\n\n", SOS_PTR(tokenArrayAddr)); + ExtOut("running \"%sdumparray %p\".\n\n", SOSPrefix, SOS_PTR(tokenArrayAddr)); DecodeDynamicIL(pArray, (ULONG)codeArray.dwNumComponents, tokenArray); delete [] pArray; @@ -960,6 +956,7 @@ DECLARE_API(DumpIL) return Status; } + void DumpSigWorker ( DWORD_PTR dwSigAddr, DWORD_PTR dwModuleAddr, @@ -1044,7 +1041,6 @@ DECLARE_API(DumpSig) INIT_API(); MINIDUMP_NOT_SUPPORTED(); - ONLY_SUPPORTED_ON_WINDOWS_TARGET(); // // Fetch arguments @@ -1064,7 +1060,7 @@ DECLARE_API(DumpSig) } if (nArg != 2) { - ExtOut("!DumpSig <sigaddr> <moduleaddr>\n"); + ExtOut("%sdumpsig <sigaddr> <moduleaddr>\n", SOSPrefix); return Status; } @@ -1092,7 +1088,6 @@ DECLARE_API(DumpSigElem) INIT_API(); MINIDUMP_NOT_SUPPORTED(); - ONLY_SUPPORTED_ON_WINDOWS_TARGET(); // // Fetch arguments @@ -1113,7 +1108,7 @@ DECLARE_API(DumpSigElem) if (nArg != 2) { - ExtOut("!DumpSigElem <sigaddr> <moduleaddr>\n"); + ExtOut("%sdumpsigelem <sigaddr> <moduleaddr>\n", SOSPrefix); return Status; } @@ -1449,6 +1444,9 @@ HRESULT PrintVC(TADDR taMT, TADDR taObject, BOOL bPrintFields = TRUE) return S_OK; } +// If this bit is set in the RuntimeType.m_handle field, the value is a TypeDesc pointer, otherwise it is a MethodTable pointer. +#define RUNTIMETYPE_HANDLE_IS_TYPEDESC 0x2 + void PrintRuntimeTypeInfo(TADDR p_rtObject, const DacpObjectData & rtObjectData) { // Get the method table @@ -1456,11 +1454,19 @@ void PrintRuntimeTypeInfo(TADDR p_rtObject, const DacpObjectData & rtObjectData) if (iOffset > 0) { TADDR mtPtr; - if (SUCCEEDED(GetMTOfObject(p_rtObject + iOffset, &mtPtr))) + if (MOVE(mtPtr, p_rtObject + iOffset) == S_OK) { - sos::MethodTable mt = mtPtr; - ExtOut("Type Name: %S\n", mt.GetName()); - DMLOut("Type MT: %s\n", DMLMethodTable(mtPtr)); + // Check if TypeDesc + if ((mtPtr & RUNTIMETYPE_HANDLE_IS_TYPEDESC) != 0) + { + ExtOut("TypeDesc: %p\n", mtPtr & ~RUNTIMETYPE_HANDLE_IS_TYPEDESC); + } + else + { + sos::MethodTable mt = mtPtr; + ExtOut("Type Name: %S\n", mt.GetName()); + DMLOut("Type MT: %s\n", DMLMethodTable(mtPtr)); + } } } } @@ -1469,9 +1475,9 @@ void DisplayInvalidStructuresMessage() { ExtOut("The garbage collector data structures are not in a valid state for traversal.\n"); ExtOut("It is either in the \"plan phase,\" where objects are being moved around, or\n"); - ExtOut("we are at the initialization or shutdown of the gc heap. Commands related to \n"); - ExtOut("displaying, finding or traversing objects as well as gc heap segments may not \n"); - ExtOut("work properly. !dumpheap and !verifyheap may incorrectly complain of heap \n"); + ExtOut("we are at the initialization or shutdown of the gc heap. Commands related to\n"); + ExtOut("displaying, finding or traversing objects as well as gc heap segments may not\n"); + ExtOut("work properly. %sdumpheap and %sverifyheap may incorrectly complain of heap\n", SOSPrefix, SOSPrefix); ExtOut("consistency errors.\n"); } @@ -1941,7 +1947,7 @@ DECLARE_API(DumpArray) if (objData.ObjectType != OBJ_ARRAY) { - ExtOut("Not an array, please use !DumpObj instead\n"); + ExtOut("Not an array, please use %sdumpobj instead\n", SOSPrefix); return S_OK; } return PrintArray(objData, flags, FALSE); @@ -2247,7 +2253,7 @@ DECLARE_API(DumpDelegate) } if (nArg != 1) { - ExtOut("Usage: !DumpDelegate <delegate object address>\n"); + ExtOut("Usage: %sdumpdelegate <delegate object address>\n", SOSPrefix); return Status; } @@ -2591,7 +2597,7 @@ size_t FormatGeneratedException (DWORD_PTR dataPtr, // (It doesn't matter that it's not a valid instruction). (see /vm/excep.cpp) // // This "counterhack" is not 100% accurate - // The biggest issue is that !PrintException must work with exception objects + // The biggest issue is that PrintException must work with exception objects // that may not be currently active; as a consequence we cannot rely on the // state of some "current thread" to infer whether the IP values stored in // the exception object have been adjusted or not. If we could, we may examine @@ -2796,7 +2802,7 @@ HRESULT FormatException(CLRDATA_ADDRESS taObj, BOOL bLineNumbers = FALSE) if (IsDMLEnabled()) DMLOut("Use <exec cmd=\"!PrintException /d %p\">!PrintException %p</exec> to see more.\n", SOS_PTR(taInnerExc), SOS_PTR(taInnerExc)); else - ExtOut("Use !PrintException %p to see more.\n", SOS_PTR(taInnerExc)); + ExtOut("Use %sprintexception %p to see more.\n", SOSPrefix, SOS_PTR(taInnerExc)); } else { @@ -3134,7 +3140,7 @@ DECLARE_API(DumpVC) EnableDMLHolder dmlHolder(dml); if (nArg!=2) { - ExtOut("Usage: !DumpVC <Method Table> <Value object start addr>\n"); + ExtOut("Usage: %sdumpvc <Method Table> <Value object start addr>\n", SOSPrefix); return Status; } @@ -3558,7 +3564,7 @@ DECLARE_API(DumpPermissionSet) } if (nArg!=1) { - ExtOut("Usage: !DumpPermissionSet <PermissionSet object addr>\n"); + ExtOut("Usage: %sdumppermissionset <PermissionSet object addr>\n", SOSPrefix); return Status; } @@ -3797,8 +3803,6 @@ void PrintGCStat(HeapStat *inStat, const char* label=NULL) } } -#ifndef FEATURE_PAL - DECLARE_API(TraverseHeap) { INIT_API(); @@ -3826,7 +3830,7 @@ DECLARE_API(TraverseHeap) if (nArg != 1) { - ExtOut("usage: HeapTraverse [-xml] filename\n"); + ExtOut("usage: %straverseheap [-xml] filename\n", SOSPrefix); return Status; } @@ -3836,9 +3840,9 @@ DECLARE_API(TraverseHeap) return Status; } - FILE* file = NULL; - if (fopen_s(&file, Filename.data, "w") != 0) { - ExtOut("Unable to open file\n"); + FILE* file = fopen(Filename.data, "w"); + if (file == nullptr) { + ExtOut("Unable to open file %s (%d)\n", strerror(errno), errno); return Status; } @@ -3855,7 +3859,7 @@ DECLARE_API(TraverseHeap) // tree structure to a sorted list of methodtables, and the index is the ID. // TODO: "Traversing object members" code should be generalized and shared between - // !gcroot and !traverseheap. Also !dumpheap can begin using GCHeapsTraverse. + // gcroot and traverseheap. Also dumpheap can begin using GCHeapsTraverse. if (!traverser.Initialize()) { @@ -3877,8 +3881,6 @@ DECLARE_API(TraverseHeap) return Status; } -#endif // FEATURE_PAL - struct PrintRuntimeTypeArgs { DWORD_PTR mtOfRuntimeType; @@ -3913,24 +3915,34 @@ void PrintRuntimeTypes(DWORD_PTR objAddr,size_t Size,DWORD_PTR methodTable,LPVOI { DMLOut(DMLObject(objAddr)); - CLRDATA_ADDRESS appDomain = GetAppDomainForMT(mtPtr); - if (appDomain != NULL) + // Check if TypeDesc + if ((mtPtr & RUNTIMETYPE_HANDLE_IS_TYPEDESC) != 0) { - if (appDomain == pArgs->adstore.sharedDomain) - ExtOut(" %" POINTERSIZE "s", "Shared"); - - else if (appDomain == pArgs->adstore.systemDomain) - ExtOut(" %" POINTERSIZE "s", "System"); - else - DMLOut(" %s", DMLDomain(appDomain)); + ExtOut(" %p\n", mtPtr & ~RUNTIMETYPE_HANDLE_IS_TYPEDESC); } else { - ExtOut(" %" POINTERSIZE "s", "?"); - } + CLRDATA_ADDRESS appDomain = GetAppDomainForMT(mtPtr); + if (appDomain != NULL) + { + if (appDomain == pArgs->adstore.sharedDomain) + ExtOut(" %" POINTERSIZE "s", "Shared"); - NameForMT_s(mtPtr, g_mdName, mdNameLen); - DMLOut(" %s %S\n", DMLMethodTable(mtPtr), g_mdName); + else if (appDomain == pArgs->adstore.systemDomain) + ExtOut(" %" POINTERSIZE "s", "System"); + else + DMLOut(" %s", DMLDomain(appDomain)); + } + else + { + ExtOut(" %" POINTERSIZE "s", "?"); + } + + if (NameForMT_s(mtPtr, g_mdName, mdNameLen)) + { + DMLOut(" %s %S\n", DMLMethodTable(mtPtr), g_mdName); + } + } } } } @@ -3940,7 +3952,6 @@ DECLARE_API(DumpRuntimeTypes) { INIT_API(); MINIDUMP_NOT_SUPPORTED(); - ONLY_SUPPORTED_ON_WINDOWS_TARGET(); BOOL dml = FALSE; @@ -3958,10 +3969,25 @@ DECLARE_API(DumpRuntimeTypes) "Address", "Domain", "MT"); ExtOut("------------------------------------------------------------------------------\n"); + if (!g_snapshot.Build()) + { + ExtOut("Unable to build snapshot of the garbage collector state\n"); + return E_FAIL; + } + PrintRuntimeTypeArgs pargs; ZeroMemory(&pargs, sizeof(PrintRuntimeTypeArgs)); - GCHeapsTraverse(PrintRuntimeTypes, (LPVOID)&pargs); + try + { + GCHeapsTraverse(PrintRuntimeTypes, (LPVOID)&pargs); + } + catch(const sos::Exception &e) + { + ExtOut("%s\n", e.what()); + return E_FAIL; + } + return Status; } @@ -4021,7 +4047,7 @@ class DumpHeapImpl {"-type", &type, COSTRING, TRUE}, // list objects of specified type {"-stat", &mStat, COBOOL, FALSE}, // dump a summary of types and the number of instances of each {"-strings", &mStrings, COBOOL, FALSE}, // dump a summary of string objects - {"-verify", &mVerify, COBOOL, FALSE}, // verify heap objects (!heapverify) + {"-verify", &mVerify, COBOOL, FALSE}, // verify heap objects (heapverify) {"-thinlock", &mThinlock, COBOOL, FALSE},// list only thinlocks {"-short", &mShort, COBOOL, FALSE}, // list only addresses {"-min", &mMinSize, COHEX, TRUE}, // min size of objects to display (hex) @@ -4495,7 +4521,6 @@ DECLARE_API(VerifyHeap) { INIT_API(); MINIDUMP_NOT_SUPPORTED(); - ONLY_SUPPORTED_ON_WINDOWS_TARGET(); if (!g_snapshot.Build()) { @@ -4539,8 +4564,6 @@ DECLARE_API(VerifyHeap) } } -#ifndef FEATURE_PAL - enum failure_get_memory { fgm_no_failure = 0, @@ -4631,9 +4654,6 @@ DECLARE_API(AnalyzeOOM) { INIT_API(); MINIDUMP_NOT_SUPPORTED(); - ONLY_SUPPORTED_ON_WINDOWS_TARGET(); - -#ifndef FEATURE_PAL if (!InitializeHeapData ()) { @@ -4699,17 +4719,12 @@ DECLARE_API(AnalyzeOOM) } return S_OK; -#else - _ASSERTE(false); - return E_FAIL; -#endif // FEATURE_PAL } DECLARE_API(VerifyObj) { INIT_API(); MINIDUMP_NOT_SUPPORTED(); - ONLY_SUPPORTED_ON_WINDOWS_TARGET(); TADDR taddrObj = 0; TADDR taddrMT; @@ -4748,10 +4763,17 @@ DECLARE_API(VerifyObj) ExtOut("Unable to build snapshot of the garbage collector state\n"); goto Exit; } + + try { GCHeapDetails *pheapDetails = g_snapshot.GetHeap(taddrObj); bValid = VerifyObject(*pheapDetails, taddrObj, taddrMT, objSize, TRUE); } + catch(const sos::Exception &e) + { + ExtOut("%s\n", e.what()); + return E_FAIL; + } Exit: if (bValid) @@ -4772,9 +4794,6 @@ DECLARE_API(ListNearObj) { INIT_API(); MINIDUMP_NOT_SUPPORTED(); - ONLY_SUPPORTED_ON_WINDOWS_TARGET(); - -#if !defined(FEATURE_PAL) TADDR taddrArg = 0; TADDR taddrObj = 0; @@ -4946,23 +4965,12 @@ DECLARE_API(ListNearObj) } return Status; - -#else - - _ASSERTE(false); - return E_FAIL; - -#endif // FEATURE_PAL } - DECLARE_API(GCHeapStat) { INIT_API(); MINIDUMP_NOT_SUPPORTED(); - ONLY_SUPPORTED_ON_WINDOWS_TARGET(); - -#ifndef FEATURE_PAL BOOL bIncUnreachable = FALSE; BOOL dml = FALSE; @@ -5026,7 +5034,7 @@ DECLARE_API(GCHeapStat) pohUnrootedUsage, "%"); } - ExtOut("\nCommitted space:"); + ExtOut("\nCommitted space:\n"); ExtOut("Heap%-4d %12" POINTERSIZE_TYPE "u %12" POINTERSIZE_TYPE "u %12" POINTERSIZE_TYPE "u %12" POINTERSIZE_TYPE "u %12" POINTERSIZE_TYPE "u\n", 0, hpUsage.genUsage[0].committed, hpUsage.genUsage[1].committed, hpUsage.genUsage[2].committed, hpUsage.genUsage[3].committed, @@ -5066,7 +5074,9 @@ DECLARE_API(GCHeapStat) } // aggregate stats across heaps / generation - GenUsageStat genUsageStat[5] = {0, 0, 0, 0, 0}; + GenUsageStat genUsageStat[5]; + memset(genUsageStat, 0, sizeof(genUsageStat)); + bool hasPoh = false; for (DWORD n = 0; n < dwNHeaps; n ++) { @@ -5151,17 +5161,8 @@ DECLARE_API(GCHeapStat) } return Status; - -#else - - _ASSERTE(false); - return E_FAIL; - -#endif // FEATURE_PAL } -#endif // FEATURE_PAL - /**********************************************************************\ * Routine Description: * * * @@ -6863,7 +6864,7 @@ class Breakpoints { PendingBreakpoint *pCur = m_breakpoints; size_t iBreakpointIndex = 1; - ExtOut(SOSPrefix "bpmd pending breakpoint list\n Breakpoint index - Location, ModuleID, Method Token\n"); + ExtOut("%sbpmd pending breakpoint list\n Breakpoint index - Location, ModuleID, Method Token\n", SOSPrefix); while(pCur) { //windbg likes to format %p as always being 64 bits @@ -7643,7 +7644,7 @@ DECLARE_API(bpmd) if (IsDumpFile()) { - ExtOut(SOSPrefix "bpmd is not supported on a dump file.\n"); + ExtOut("%sbpmd is not supported on a dump file.\n", SOSPrefix); return Status; } @@ -7745,17 +7746,13 @@ DECLARE_API(bpmd) if (fBadParam || (commandsParsed != 1)) { - ExtOut("Usage: " SOSPrefix "bpmd -md <MethodDesc pointer>\n"); - ExtOut("Usage: " SOSPrefix "bpmd [-nofuturemodule] <module name> <managed function name> [<il offset>]\n"); - ExtOut("Usage: " SOSPrefix "bpmd <filename>:<line number>\n"); - ExtOut("Usage: " SOSPrefix "bpmd -list\n"); - ExtOut("Usage: " SOSPrefix "bpmd -clear <pending breakpoint number>\n"); - ExtOut("Usage: " SOSPrefix "bpmd -clearall\n"); -#ifdef FEATURE_PAL - ExtOut("See \"soshelp bpmd\" for more details.\n"); -#else - ExtOut("See \"!help bpmd\" for more details.\n"); -#endif + ExtOut("Usage: %sbpmd -md <MethodDesc pointer>\n", SOSPrefix); + ExtOut("Usage: %sbpmd [-nofuturemodule] <module name> <managed function name> [<il offset>]\n", SOSPrefix); + ExtOut("Usage: %sbpmd <filename>:<line number>\n", SOSPrefix); + ExtOut("Usage: %sbpmd -list\n", SOSPrefix); + ExtOut("Usage: %sbpmd -clear <pending breakpoint number>\n", SOSPrefix); + ExtOut("Usage: %sbpmd -clearall\n", SOSPrefix); + ExtOut("See \"%ssoshelp bpmd\" for more details.\n", SOSPrefix); return Status; } @@ -8025,9 +8022,9 @@ DECLARE_API(ThreadPool) { INIT_API(); MINIDUMP_NOT_SUPPORTED(); - ONLY_SUPPORTED_ON_WINDOWS_TARGET(); BOOL doHCDump = FALSE, doWorkItemDump = FALSE, dml = FALSE; + BOOL mustBePortableThreadPool = FALSE; CMDOption option[] = { // name, vptr, type, hasValue @@ -8044,7 +8041,12 @@ DECLARE_API(ThreadPool) EnableDMLHolder dmlHolder(dml); DacpThreadpoolData threadpool; - if ((Status = threadpool.Request(g_sos)) != S_OK) + Status = threadpool.Request(g_sos); + if (Status == E_NOTIMPL) + { + mustBePortableThreadPool = TRUE; + } + else if (Status != S_OK) { ExtOut(" %s\n", "Failed to request ThreadpoolMgr information"); return FAILED(Status) ? Status : E_FAIL; @@ -8074,19 +8076,22 @@ DECLARE_API(ThreadPool) int portableTpHcLogEntry_lastHistoryMeanOffset = 0; do // while (false) { - // Determine if the portable thread pool is enabled - if (FAILED( + if (!mustBePortableThreadPool) + { + // Determine if the portable thread pool is enabled + if (FAILED( GetNonSharedStaticFieldValueFromName( &ui64Value, corelibModule, "System.Threading.ThreadPool", W("UsePortableThreadPool"), ELEMENT_TYPE_BOOLEAN)) || - ui64Value == 0) - { - // The type was not loaded yet, or the static field was not found, etc. For now assume that the portable thread pool - // is not being used. - break; + ui64Value == 0) + { + // The type was not loaded yet, or the static field was not found, etc. For now assume that the portable thread pool + // is not being used. + break; + } } // Get the thread pool instance @@ -8371,6 +8376,29 @@ DECLARE_API(ThreadPool) } } + // Enumerate assignable normal-priority work items. + offset = GetObjFieldOffset(itr->GetAddress(), itr->GetMT(), W("_assignableWorkItemQueues")); + if (offset > 0) + { + DWORD_PTR workItemsConcurrentQueueArrayPtr; + MOVE(workItemsConcurrentQueueArrayPtr, itr->GetAddress() + offset); + DacpObjectData workItemsConcurrentQueueArray; + if (workItemsConcurrentQueueArray.Request(g_sos, TO_CDADDR(workItemsConcurrentQueueArrayPtr)) == S_OK && + workItemsConcurrentQueueArray.ObjectType == OBJ_ARRAY) + { + for (int i = 0; i < workItemsConcurrentQueueArray.dwNumComponents; i++) + { + DWORD_PTR workItemsConcurrentQueuePtr; + MOVE(workItemsConcurrentQueuePtr, workItemsConcurrentQueueArray.ArrayDataPtr + (i * workItemsConcurrentQueueArray.dwComponentSize)); + if (workItemsConcurrentQueuePtr != NULL && sos::IsObject(TO_CDADDR(workItemsConcurrentQueuePtr), false)) + { + // We got the ConcurrentQueue. Enumerate it. + EnumerateThreadPoolGlobalWorkItemConcurrentQueue(workItemsConcurrentQueuePtr, "[Global]", &stats); + } + } + } + } + // Enumerate normal-priority work items. offset = GetObjFieldOffset(itr->GetAddress(), itr->GetMT(), W("workItems")); if (offset > 0) @@ -8398,9 +8426,9 @@ DECLARE_API(ThreadPool) { for (int i = 0; i < workItemArray.dwNumComponents; i++) { - CLRDATA_ADDRESS workItemPtr; - MOVE(workItemPtr, TO_CDADDR(workItemArray.ArrayDataPtr + (i * workItemArray.dwComponentSize))); - if (workItemPtr != NULL && sos::IsObject(workItemPtr, false)) + DWORD_PTR workItemPtr; + MOVE(workItemPtr, workItemArray.ArrayDataPtr + (i * workItemArray.dwComponentSize)); + if (workItemPtr != NULL && sos::IsObject(TO_CDADDR(workItemPtr), false)) { sos::Object workItem = TO_TADDR(workItemPtr); stats.Add((DWORD_PTR)workItem.GetMT(), (DWORD)workItem.GetSize()); @@ -8408,10 +8436,10 @@ DECLARE_API(ThreadPool) if ((offset = GetObjFieldOffset(workItem.GetAddress(), workItem.GetMT(), W("_callback"))) > 0 || (offset = GetObjFieldOffset(workItem.GetAddress(), workItem.GetMT(), W("m_action"))) > 0) { - CLRDATA_ADDRESS delegatePtr; + DWORD_PTR delegatePtr; MOVE(delegatePtr, workItem.GetAddress() + offset); CLRDATA_ADDRESS md; - if (TryGetMethodDescriptorForDelegate(delegatePtr, &md)) + if (TryGetMethodDescriptorForDelegate(TO_CDADDR(delegatePtr), &md)) { NameForMD_s((DWORD_PTR)md, g_mdName, mdNameLen); ExtOut(" => %S", g_mdName); @@ -8587,7 +8615,6 @@ DECLARE_API(FindAppDomain) { INIT_API(); MINIDUMP_NOT_SUPPORTED(); - ONLY_SUPPORTED_ON_WINDOWS_TARGET(); DWORD_PTR p_Object = NULL; BOOL dml = FALSE; @@ -8658,8 +8685,8 @@ DECLARE_API(FindAppDomain) if (IsDMLEnabled()) DMLOut("<exec cmd=\"!gcroot /d %p\">!gcroot %p</exec>, and if you find a root on a\n", SOS_PTR(p_Object), SOS_PTR(p_Object)); else - ExtOut(SOSPrefix "gcroot %p, and if you find a root on a\n", SOS_PTR(p_Object)); - ExtOut("stack, check the AppDomain of that stack with " SOSThreads ".\n"); + ExtOut("%sgcroot %p, and if you find a root on a\n", SOSPrefix, SOS_PTR(p_Object)); + ExtOut("stack, check the AppDomain of that stack with %sclrthreads.\n", SOSPrefix); ExtOut("Note that the Thread could have transitioned between\n"); ExtOut("multiple AppDomains.\n"); } @@ -8856,7 +8883,6 @@ DECLARE_API(EHInfo) { INIT_API(); MINIDUMP_NOT_SUPPORTED(); - ONLY_SUPPORTED_ON_WINDOWS_TARGET(); DWORD_PTR dwStartAddr = NULL; BOOL dml = FALSE; @@ -8938,7 +8964,6 @@ DECLARE_API(GCInfo) { INIT_API(); MINIDUMP_NOT_SUPPORTED(); - ONLY_SUPPORTED_ON_WINDOWS_TARGET(); TADDR taStartAddr = NULL; TADDR taGCInfoAddr; @@ -10181,7 +10206,6 @@ DECLARE_API(DumpGCData) #ifdef GC_CONFIG_DRIVEN MINIDUMP_NOT_SUPPORTED(); - ONLY_SUPPORTED_ON_WINDOWS_TARGET(); if (!InitializeHeapData ()) { @@ -10190,16 +10214,17 @@ DECLARE_API(DumpGCData) } DacpGCInterestingInfoData interestingInfo; - interestingInfo.RequestGlobal(g_sos); - for (int i = 0; i < DAC_MAX_GLOBAL_GC_MECHANISMS_COUNT; i++) + if (!IsServerBuild()) { - ExtOut("%-30s: %d\n", str_gc_global_mechanisms[i], interestingInfo.globalMechanisms[i]); - } + // Doesn't work (segfaults) for server GCs + interestingInfo.RequestGlobal(g_sos); + for (int i = 0; i < DAC_MAX_GLOBAL_GC_MECHANISMS_COUNT; i++) + { + ExtOut("%-30s: %d\n", str_gc_global_mechanisms[i], interestingInfo.globalMechanisms[i]); + } - ExtOut("\n[info per heap]\n"); + ExtOut("\n[info per heap]\n"); - if (!IsServerBuild()) - { if (interestingInfo.Request(g_sos) != S_OK) { ExtOut("Error requesting interesting GC info\n"); @@ -10210,6 +10235,8 @@ DECLARE_API(DumpGCData) } else { + ExtOut("\n[info per heap]\n"); + DWORD dwNHeaps = GetGcHeapCount(); DWORD dwAllocSize; if (!ClrSafeInt<DWORD>::multiply(sizeof(CLRDATA_ADDRESS), dwNHeaps, dwAllocSize)) @@ -10355,9 +10382,7 @@ DECLARE_API(SOSStatus) IHostServices* hostServices = GetHostServices(); if (hostServices != nullptr) { - std::string command("sosstatus "); - command.append(args); - Status = hostServices->DispatchCommand(command.c_str()); + Status = hostServices->DispatchCommand("sosstatus", args); } else { @@ -10698,7 +10723,7 @@ DECLARE_API(Token2EE) } if (nArg!=2) { - ExtOut("Usage: " SOSPrefix "Token2EE module_name mdToken\n"); + ExtOut("Usage: %stoken2ee module_name mdToken\n", SOSPrefix); ExtOut(" You can pass * for module_name to search all modules.\n"); return Status; } @@ -10824,11 +10849,11 @@ DECLARE_API(Name2EE) if (nArg != 2) { - ExtOut("Usage: " SOSPrefix "name2ee module_name item_name\n"); - ExtOut(" or " SOSPrefix "name2ee module_name!item_name\n"); + ExtOut("Usage: %sname2ee module_name item_name\n", SOSPrefix); + ExtOut(" or %sname2ee module_name!item_name\n", SOSPrefix); ExtOut(" use * for module_name to search all loaded modules\n"); - ExtOut("Examples: " SOSPrefix "name2ee mscorlib.dll System.String.ToString\n"); - ExtOut(" " SOSPrefix "name2ee *!System.String\n"); + ExtOut("Examples: %sname2ee mscorlib.dll System.String.ToString\n", SOSPrefix); + ExtOut(" %sname2ee *!System.String\n", SOSPrefix); return Status; } @@ -10889,7 +10914,6 @@ DECLARE_API(PathTo) { INIT_API(); MINIDUMP_NOT_SUPPORTED(); - ONLY_SUPPORTED_ON_WINDOWS_TARGET(); DWORD_PTR root = NULL; DWORD_PTR target = NULL; @@ -10975,7 +10999,7 @@ DECLARE_API(GCRoot) if (all) ExtOut("Found %d roots.\n", i); else - ExtOut("Found %d unique roots (run '" SOSPrefix "gcroot -all' to see all roots).\n", i); + ExtOut("Found %d unique roots (run '%sgcroot -all' to see all roots).\n", i, SOSPrefix); return Status; } @@ -11030,6 +11054,7 @@ DECLARE_API(GCWhere) } } + DWORD heapIdx = 0; if (!IsServerBuild()) { DacpGcHeapDetails heapDetails; @@ -11039,13 +11064,7 @@ DECLARE_API(GCWhere) return Status; } - if (GCObjInHeap(taddrObj, heapDetails, trngSeg, gen, allocCtx, bLarge)) - { - ExtOut("Address " WIN64_8SPACES " Gen Heap segment " WIN64_8SPACES " begin " WIN64_8SPACES " allocated " WIN64_8SPACES " size\n"); - ExtOut("%p %d %2d %p %p %p 0x%x(%d)\n", - SOS_PTR(taddrObj), gen, 0, SOS_PTR(trngSeg.segAddr), SOS_PTR(trngSeg.start), SOS_PTR(trngSeg.end), size, size); - bFound = TRUE; - } + bFound = GCObjInHeap(taddrObj, heapDetails, trngSeg, gen, allocCtx, bLarge); } else { @@ -11071,24 +11090,17 @@ DECLARE_API(GCWhere) return Status; } - for (DWORD n = 0; n < dwNHeaps; n ++) + for (heapIdx = 0; heapIdx < dwNHeaps && !bFound; heapIdx++) { DacpGcHeapDetails dacHeapDetails; - if (dacHeapDetails.Request(g_sos, heapAddrs[n]) != S_OK) + if (dacHeapDetails.Request(g_sos, heapAddrs[heapIdx]) != S_OK) { ExtOut("Error requesting details\n"); return Status; } - GCHeapDetails heapDetails(dacHeapDetails, heapAddrs[n]); - if (GCObjInHeap(taddrObj, heapDetails, trngSeg, gen, allocCtx, bLarge)) - { - ExtOut("Address " WIN64_8SPACES " Gen Heap segment " WIN64_8SPACES " begin " WIN64_8SPACES " allocated" WIN64_8SPACES " size\n"); - ExtOut("%p %d %2d %p %p %p 0x%x(%d)\n", - SOS_PTR(taddrObj), gen, n, SOS_PTR(trngSeg.segAddr), SOS_PTR(trngSeg.start), SOS_PTR(trngSeg.end), size, size); - bFound = TRUE; - break; - } + GCHeapDetails heapDetails(dacHeapDetails, heapAddrs[heapIdx]); + bFound = GCObjInHeap(taddrObj, heapDetails, trngSeg, gen, allocCtx, bLarge); } } @@ -11096,22 +11108,24 @@ DECLARE_API(GCWhere) { ExtOut("Address %#p not found in the managed heap.\n", SOS_PTR(taddrObj)); } + else + { + ExtOut("Address " WIN64_8SPACES " Gen Heap segment " WIN64_8SPACES " begin " WIN64_8SPACES " allocated" WIN64_8SPACES " size\n"); + ExtOut("%p %d %2d %p %p %p 0x%x(%d)\n", + SOS_PTR(taddrObj), gen, heapIdx, SOS_PTR(trngSeg.segAddr), SOS_PTR(trngSeg.start), SOS_PTR(trngSeg.end), size, size); + } return Status; } -#ifndef FEATURE_PAL - DECLARE_API(FindRoots) { -#ifndef FEATURE_PAL INIT_API(); MINIDUMP_NOT_SUPPORTED(); - ONLY_SUPPORTED_ON_WINDOWS_TARGET(); if (IsDumpFile()) { - ExtOut("!FindRoots is not supported on a dump file.\n"); + ExtOut("%sfindroots is not supported on a dump file.\n", SOSPrefix); return Status; } @@ -11149,7 +11163,7 @@ DECLARE_API(FindRoots) } if ((gen < -1 || gen > 2) && (taObj == 0)) { - ExtOut("Incorrect options. Usage:\n\t!FindRoots -gen <N>\n\t\twhere N is 0, 1, 2, or \"any\". OR\n\t!FindRoots <obj>\n"); + ExtOut("Incorrect options. Usage:\n\t%sfindroots -gen <N>\n\t\twhere N is 0, 1, 2, or \"any\". OR\n\t%sfindroots <obj>\n", SOSPrefix, SOSPrefix); return Status; } @@ -11166,7 +11180,11 @@ DECLARE_API(FindRoots) GcEvtArgs gea = { GC_MARK_END, { ((gen == -1) ? 7 : (1 << gen)) } }; idp2->SetGcNotification(gea); // ... and register the notification handler +#ifndef FEATURE_PAL g_ExtControl->Execute(DEBUG_EXECUTE_NOT_LOGGED, "sxe -c \"!SOSHandleCLRN\" clrn", 0); +#else + g_ExtServices->SetExceptionCallback(HandleExceptionNotification); +#endif // FEATURE_PAL // the above notification is removed in CNotification::OnGcEvent() } else @@ -11177,8 +11195,8 @@ DECLARE_API(FindRoots) if (!CheckCLRNotificationEvent(&dle)) { - ExtOut("The command !FindRoots can only be used after the debugger stopped on a CLRN GC notification.\n"); - ExtOut("At this time !GCRoot should be used instead.\n"); + ExtOut("The command %sfindroots can only be used after the debugger stopped on a CLRN GC notification.\n", SOSPrefix); + ExtOut("At this time %sgcroot should be used instead.\n", SOSPrefix); return Status; } // validate argument @@ -11209,9 +11227,6 @@ DECLARE_API(FindRoots) } return Status; -#else - return E_NOTIMPL; -#endif } class GCHandleStatsForDomains @@ -11356,7 +11371,7 @@ class GCHandlesImpl if (!GetCMDOption(args,option,ARRAY_SIZE(option),NULL,0,NULL)) sos::Throw<sos::Exception>("Failed to parse command line arguments."); - if (type != NULL) + if (type != NULL) { if (_stricmp(type, "Pinned") == 0) mType = HNDTYPE_PINNED; else if (_stricmp(type, "RefCounted") == 0) @@ -11379,6 +11394,7 @@ class GCHandlesImpl mType = HNDTYPE_WEAK_WINRT; else sos::Throw<sos::Exception>("Unknown handle type '%s'.", type.GetPtr()); + } } void Run() @@ -11962,10 +11978,8 @@ DECLARE_API(StopOnException) \**********************************************************************/ DECLARE_API(ObjSize) { -#ifndef FEATURE_PAL INIT_API(); MINIDUMP_NOT_SUPPORTED(); - ONLY_SUPPORTED_ON_WINDOWS_TARGET(); BOOL dml = FALSE; StringHolder str_Object; @@ -12008,10 +12022,6 @@ DECLARE_API(ObjSize) ExtOut("sizeof(%p) = %d (0x%x) bytes (%S)\n", SOS_PTR(obj), size, size, methodTable.GetName()); } return Status; -#else - return E_NOTIMPL; -#endif - } #ifndef FEATURE_PAL @@ -12214,8 +12224,6 @@ DECLARE_API(GCHandleLeaks) } #endif // FEATURE_PAL -#endif // FEATURE_PAL - class ClrStackImplWithICorDebug { private: @@ -13124,7 +13132,7 @@ class ClrStackImplWithICorDebug ICorDebugProcess* pCorDebugProcess; if (FAILED(Status = g_pRuntime->GetCorDebugInterface(&pCorDebugProcess))) { - ExtOut("\n" SOSPrefix "clrstack -i is unsupported on this target.\nThe ICorDebug interface cannot be constructed.\n\n"); + ExtOut("\n%sclrstack -i is unsupported on this target.\nThe ICorDebug interface cannot be constructed.\n\n", SOSPrefix); return Status; } @@ -13744,7 +13752,7 @@ class ClrStackImpl if ((hr = g_clrData->GetTaskByOSThreadID(osID, &pTask)) != S_OK) { ExtOut("Unable to walk the managed stack. The current thread is likely not a \n"); - ExtOut("managed thread. You can run " SOSThreads " to get a list of managed threads in\n"); + ExtOut("managed thread. You can run %sclrthreads to get a list of managed threads in\n", SOSPrefix); ExtOut("the process\n"); return hr; } @@ -15558,7 +15566,7 @@ DECLARE_API(SuppressJitOptimization) } else { - ExtOut("Usage: !SuppressJitOptimization <on|off>\n"); + ExtOut("Usage: %ssuppressjitoptimization <on|off>\n", SOSPrefix); } return S_OK; @@ -15706,6 +15714,133 @@ DECLARE_API(StopOnCatch) return S_OK; } +class EnumMemoryCallback : public ICLRDataEnumMemoryRegionsCallback, ICLRDataLoggingCallback +{ +private: + LONG m_ref; + bool m_log; + bool m_valid; + +public: + EnumMemoryCallback(bool log, bool valid) : + m_ref(1), + m_log(log), + m_valid(valid) + { + } + + virtual ~EnumMemoryCallback() + { + } + + STDMETHODIMP QueryInterface( + ___in REFIID InterfaceId, + ___out PVOID* Interface) + { + if (InterfaceId == IID_IUnknown || + InterfaceId == IID_ICLRDataEnumMemoryRegionsCallback) + { + *Interface = (ICLRDataEnumMemoryRegionsCallback*)this; + AddRef(); + return S_OK; + } + else if (InterfaceId == IID_ICLRDataLoggingCallback) + { + *Interface = (ICLRDataLoggingCallback*)this; + AddRef(); + return S_OK; + } + else + { + *Interface = nullptr; + return E_NOINTERFACE; + } + } + + STDMETHODIMP_(ULONG) AddRef() + { + LONG ref = InterlockedIncrement(&m_ref); + return ref; + } + + STDMETHODIMP_(ULONG) Release() + { + LONG ref = InterlockedDecrement(&m_ref); + if (ref == 0) + { + delete this; + } + return ref; + } + + HRESULT STDMETHODCALLTYPE EnumMemoryRegion( + /* [in] */ CLRDATA_ADDRESS address, + /* [in] */ ULONG32 size) + { + if (m_log) + { + ExtOut("%016llx %08x\n", address, size); + } + if (m_valid) + { + uint64_t start = address; + uint64_t numberPages = (size + DT_OS_PAGE_SIZE - 1) / DT_OS_PAGE_SIZE; + for (size_t p = 0; p < numberPages; p++, start += DT_OS_PAGE_SIZE) + { + BYTE buffer[1]; + ULONG read; + if (FAILED(g_ExtData->ReadVirtual(start, buffer, ARRAY_SIZE(buffer), &read))) + { + ExtOut("Invalid: %016llx %08x start %016llx\n", address, size, start); + break; + } + } + } + if (IsInterrupt()) + { + return COR_E_OPERATIONCANCELED; + } + return S_OK; + } + + HRESULT STDMETHODCALLTYPE LogMessage( + /* [in] */ LPCSTR message) + { + ExtOut("%s", message); + if (IsInterrupt()) + { + return COR_E_OPERATIONCANCELED; + } + return S_OK; + } +}; + +DECLARE_API(enummem) +{ + INIT_API(); + + ToRelease<ICLRDataEnumMemoryRegions> enumMemoryRegions; + Status = g_clrData->QueryInterface(__uuidof(ICLRDataEnumMemoryRegions), (void**)&enumMemoryRegions); + if (SUCCEEDED(Status)) + { + ToRelease<ICLRDataEnumMemoryRegionsCallback> callback = new EnumMemoryCallback(false, true); + ULONG32 minidumpType = + (MiniDumpWithPrivateReadWriteMemory | + MiniDumpWithDataSegs | + MiniDumpWithHandleData | + MiniDumpWithUnloadedModules | + MiniDumpWithFullMemoryInfo | + MiniDumpWithThreadInfo | + MiniDumpWithTokenInformation); + Status = enumMemoryRegions->EnumMemoryRegions(callback, minidumpType, CLRDataEnumMemoryFlags::CLRDATA_ENUM_MEM_DEFAULT); + if (FAILED(Status)) + { + ExtErr("EnumMemoryRegions FAILED %08x\n", Status); + } + } + return Status; +} + #ifndef FEATURE_PAL // This is an undocumented SOS extension command intended to help test SOS @@ -16017,9 +16152,7 @@ DECLARE_API(SetClrPath) IHostServices* hostServices = GetHostServices(); if (hostServices != nullptr) { - std::string command("setclrpath "); - command.append(args); - return hostServices->DispatchCommand(command.c_str()); + return hostServices->DispatchCommand("setclrpath", args); } else { @@ -16063,9 +16196,7 @@ DECLARE_API(runtimes) IHostServices* hostServices = GetHostServices(); if (hostServices != nullptr) { - std::string command("runtimes "); - command.append(args); - Status = hostServices->DispatchCommand(command.c_str()); + Status = hostServices->DispatchCommand("runtimes", args); } else { @@ -16108,31 +16239,22 @@ DECLARE_API(runtimes) return Status; } +#ifdef HOST_WINDOWS + // // Executes managed extension commands // -HRESULT ExecuteCommand(PCSTR command, PCSTR args) +HRESULT ExecuteCommand(PCSTR commandName, PCSTR args) { IHostServices* hostServices = GetHostServices(); if (hostServices != nullptr) { - std::string commandLine(command); - if (args != nullptr && strlen(args) > 0) - { - commandLine.append(" "); - commandLine.append(args); - } - if (!commandLine.empty()) + if (commandName != nullptr && strlen(commandName) > 0) { - return hostServices->DispatchCommand(commandLine.c_str()); + return hostServices->DispatchCommand(commandName, args); } } - else - { - ExtErr("Command not loaded\n"); - return E_FAIL; - } - return S_OK; + return E_NOTIMPL; } // @@ -16171,15 +16293,44 @@ DECLARE_API(logging) return ExecuteCommand("logging", args); } +typedef HRESULT (*PFN_COMMAND)(PDEBUG_CLIENT client, PCSTR args); + // // Executes managed extension commands // DECLARE_API(ext) { INIT_API_EXT(); - return ExecuteCommand("", args); + + if (args == nullptr || strlen(args) <= 0) + { + args = "Help"; + } + std::string arguments(args); + size_t pos = arguments.find(' '); + std::string commandName = arguments.substr(0, pos); + if (pos != std::string::npos) + { + arguments = arguments.substr(pos + 1); + } + else + { + arguments.clear(); + } + Status = ExecuteCommand(commandName.c_str(), arguments.c_str()); + if (Status == E_NOTIMPL) + { + PFN_COMMAND commandFunc = (PFN_COMMAND)GetProcAddress(g_hInstance, commandName.c_str()); + if (commandFunc != nullptr) + { + Status = (*commandFunc)(client, arguments.c_str()); + } + } + return Status; } +#endif // HOST_WINDOWS + void PrintHelp (__in_z LPCSTR pszCmdName) { static LPSTR pText = NULL; diff --git a/src/SOS/Strike/util.cpp b/src/SOS/Strike/util.cpp index fe69ec024f..3c55c64420 100644 --- a/src/SOS/Strike/util.cpp +++ b/src/SOS/Strike/util.cpp @@ -4333,7 +4333,7 @@ void GetAllocContextPtrs(AllocInfo *pallocInfo) CLRDATA_ADDRESS allocLimit; ReleaseHolder<ISOSDacInterface12> sos12; - if (SUCCEEDED(g_sos->QueryInterface(__uuidof(ISOSDacInterface12), &sos12)) && + if (SUCCEEDED(g_sos->QueryInterface(__uuidof(ISOSDacInterface12), &sos12)) && SUCCEEDED(sos12->GetGlobalAllocationContext(&allocPtr, &allocLimit)) && allocPtr != 0) { @@ -4406,7 +4406,7 @@ HRESULT GetMTOfObject(TADDR obj, TADDR *mt) // Read the MethodTable and if we succeed, get rid of the mark bits. HRESULT hr = rvCache->Read(obj, mt, sizeof(TADDR), NULL); if (SUCCEEDED(hr)) - *mt &= ~3; + *mt &= ~sos::Object::METHODTABLE_PTR_LOW_BITMASK; return hr; } @@ -4656,7 +4656,16 @@ OutputVaList( int length = _vsnprintf_s((char* const)&g_printBuffer, sizeof(g_printBuffer), _TRUNCATE, format, args); if (length > 0) { - return g_ExtControl->OutputVaList(mask, (char* const)&g_printBuffer, args); +#ifdef HOST_WINDOWS + if (IsInitializedByDbgEng()) + { + return g_ExtControl->Output(mask, "%s", g_printBuffer); + } + else +#endif + { + return g_ExtControl->OutputVaList(mask, (char* const)&g_printBuffer, args); + } } return E_FAIL; } @@ -4671,7 +4680,16 @@ ControlledOutputVaList( int length = _vsnprintf_s((char* const)&g_printBuffer, sizeof(g_printBuffer), _TRUNCATE, format, args); if (length > 0) { - return g_ExtControl->ControlledOutputVaList(outputControl, mask, (char* const)&g_printBuffer, args); +#ifdef HOST_WINDOWS + if (IsInitializedByDbgEng()) + { + return g_ExtControl->ControlledOutput(outputControl, mask, "%s", g_printBuffer); + } + else +#endif + { + return g_ExtControl->ControlledOutputVaList(outputControl, mask, (char* const)&g_printBuffer, args); + } } return E_FAIL; } @@ -4822,12 +4840,15 @@ const char * const DMLFormats[] = "<exec cmd=\"!DumpRCW /d %s\">%s</exec>", // DML_RCWrapper "<exec cmd=\"!DumpCCW /d %s\">%s</exec>", // DML_CCWrapper "<exec cmd=\"!ClrStack -i %S %d\">%S</exec>", // DML_ManagedVar + "<exec cmd=\"!DumpObj /d %s\">%s</exec>", // DML_Async "<exec cmd=\"!DumpIL /i %s\">%s</exec>", // DML_IL "<exec cmd=\"!DumpRCW -cw /d %s\">%s</exec>", // DML_ComWrapperRCW "<exec cmd=\"!DumpCCW -cw /d %s\">%s</exec>", // DML_ComWrapperCCW "<exec cmd=\"dps %s L%d\">%s</exec>", // DML_TaggedMemory }; +static_assert(ARRAY_SIZE(DMLFormats) == Output::DML_Last, "Output types and formats must match in length"); + void ConvertToLower(__out_ecount(len) char *buffer, size_t len) { for (size_t i = 0; i < len && buffer[i]; ++i) @@ -6035,9 +6056,9 @@ void EnumerateThreadPoolGlobalWorkItemConcurrentQueue( { for (int i = 0; i < slotsArray.dwNumComponents; i++) { - CLRDATA_ADDRESS workItemPtr; - MOVE(workItemPtr, TO_CDADDR(slotsArray.ArrayDataPtr + (i * slotsArray.dwComponentSize))); // the item object reference is at the beginning of the Slot - if (workItemPtr != NULL && sos::IsObject(workItemPtr, false)) + DWORD_PTR workItemPtr; + MOVE(workItemPtr, slotsArray.ArrayDataPtr + (i * slotsArray.dwComponentSize)); // the item object reference is at the beginning of the Slot + if (workItemPtr != NULL && sos::IsObject(TO_CDADDR(workItemPtr), false)) { sos::Object workItem = TO_TADDR(workItemPtr); stats->Add((DWORD_PTR)workItem.GetMT(), (DWORD)workItem.GetSize()); @@ -6045,10 +6066,10 @@ void EnumerateThreadPoolGlobalWorkItemConcurrentQueue( if ((offset = GetObjFieldOffset(workItem.GetAddress(), workItem.GetMT(), W("_callback"))) > 0 || (offset = GetObjFieldOffset(workItem.GetAddress(), workItem.GetMT(), W("m_action"))) > 0) { - CLRDATA_ADDRESS delegatePtr; + DWORD_PTR delegatePtr; MOVE(delegatePtr, workItem.GetAddress() + offset); CLRDATA_ADDRESS md; - if (TryGetMethodDescriptorForDelegate(delegatePtr, &md)) + if (TryGetMethodDescriptorForDelegate(TO_CDADDR(delegatePtr), &md)) { NameForMD_s((DWORD_PTR)md, g_mdName, mdNameLen); ExtOut(" => %S", g_mdName); diff --git a/src/SOS/Strike/util.h b/src/SOS/Strike/util.h index d301972795..f4183780a6 100644 --- a/src/SOS/Strike/util.h +++ b/src/SOS/Strike/util.h @@ -123,15 +123,11 @@ class MethodTable; #define HNDTYPE_SIZEDREF (8) #define HNDTYPE_WEAK_WINRT (9) -// Anything above this we consider abnormal and stop processing heap information -const int nMaxHeapSegmentCount = 1000; - class BaseObject { MethodTable *m_pMethTab; }; - const BYTE gElementTypeInfo[] = { #define TYPEINFO(e,ns,c,s,g,ia,ip,if,im,gv) s, #include "cortypeinfo.h" @@ -526,7 +522,9 @@ namespace Output DML_IL, DML_ComWrapperRCW, DML_ComWrapperCCW, - DML_TaggedMemory + DML_TaggedMemory, + + DML_Last }; /**********************************************************************\ @@ -656,9 +654,8 @@ inline void ExtOutIndent() { WhitespaceOut(Output::g_Indent << 2); } bool IsDMLEnabled(); - #ifndef SOS_Assert -#define SOS_Assert(x) +#define SOS_Assert _ASSERTE #endif void ConvertToLower(__out_ecount(len) char *buffer, size_t len); diff --git a/src/SOS/extensions/CMakeLists.txt b/src/SOS/extensions/CMakeLists.txt index 1ffba4df66..faff991739 100644 --- a/src/SOS/extensions/CMakeLists.txt +++ b/src/SOS/extensions/CMakeLists.txt @@ -15,11 +15,11 @@ set(SOURCES extensions.cpp ) -if(WIN32 AND NOT CLR_CMAKE_HOST_ARCH_ARM64) +if(WIN32 AND NOT CLR_CMAKE_HOST_ARCH_ARM64 AND NOT CLR_CMAKE_HOST_ARCH_ARM) list(APPEND SOURCES hostdesktop.cpp ) -endif(WIN32 AND NOT CLR_CMAKE_HOST_ARCH_ARM64) +endif(WIN32 AND NOT CLR_CMAKE_HOST_ARCH_ARM64 AND NOT CLR_CMAKE_HOST_ARCH_ARM) if(CLR_CMAKE_HOST_UNIX) add_definitions(-DHOST_UNIX) diff --git a/src/SOS/extensions/extensions.vcxproj b/src/SOS/extensions/extensions.vcxproj index 117d973477..1940d49c63 100644 --- a/src/SOS/extensions/extensions.vcxproj +++ b/src/SOS/extensions/extensions.vcxproj @@ -100,7 +100,7 @@ <StringPooling>true</StringPooling> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4640</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4640</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UndefinePreprocessorDefinitions>_MT</UndefinePreprocessorDefinitions> @@ -160,7 +160,7 @@ <StringPooling>true</StringPooling> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4640</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4640</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UndefinePreprocessorDefinitions>_MT</UndefinePreprocessorDefinitions> @@ -216,7 +216,7 @@ <StringPooling>true</StringPooling> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4640</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4640</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UndefinePreprocessorDefinitions>_MT</UndefinePreprocessorDefinitions> @@ -274,7 +274,7 @@ <StringPooling>true</StringPooling> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4640</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4640</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UndefinePreprocessorDefinitions>_MT</UndefinePreprocessorDefinitions> diff --git a/src/SOS/extensions/hostcoreclr.cpp b/src/SOS/extensions/hostcoreclr.cpp index bd42a0b492..2cfb5e0979 100644 --- a/src/SOS/extensions/hostcoreclr.cpp +++ b/src/SOS/extensions/hostcoreclr.cpp @@ -45,7 +45,7 @@ #define DT_LNK 10 #endif -#if !defined(FEATURE_PAL) && !defined(_TARGET_ARM64_) +#if !defined(FEATURE_PAL) && !defined(HOST_ARM64) && !defined(HOST_ARM) extern HRESULT InitializeDesktopClrHost(); #endif @@ -750,7 +750,7 @@ HRESULT InitializeHosting() return hr; } } -#if !defined(FEATURE_PAL) && !defined(_TARGET_ARM64_) +#if !defined(FEATURE_PAL) && !defined(HOST_ARM64) && !defined(HOST_ARM) hr = InitializeDesktopClrHost(); if (SUCCEEDED(hr)) { diff --git a/src/SOS/inc/hostservices.h b/src/SOS/inc/hostservices.h index 6b7c19eb6f..bf4403845f 100644 --- a/src/SOS/inc/hostservices.h +++ b/src/SOS/inc/hostservices.h @@ -76,18 +76,20 @@ IHostServices : public IUnknown /// <summary> /// Dispatches the command line to managed extension /// </summary> - /// <param name="commandLine">full command line</param> + /// <param name="commandName">command name</param> + /// <param name="arguments">command arguments</param> /// <returns>error code</returns> virtual HRESULT STDMETHODCALLTYPE DispatchCommand( - PCSTR commandLine) = 0; + PCSTR commandName, + PCSTR arguments) = 0; /// <summary> /// Displays the help for a managed extension command /// </summary> - /// <param name="command"></param> + /// <param name="commandName"></param> /// <returns>error code</returns> virtual HRESULT STDMETHODCALLTYPE DisplayHelp( - PCSTR command) = 0; + PCSTR commandName) = 0; /// <summary> /// Uninitialize the extension infrastructure diff --git a/src/SOS/lldbplugin/services.cpp b/src/SOS/lldbplugin/services.cpp index c278558289..ffdadb0b61 100644 --- a/src/SOS/lldbplugin/services.cpp +++ b/src/SOS/lldbplugin/services.cpp @@ -19,6 +19,13 @@ #define InvalidTimeStamp 0xFFFFFFFE; #define InvalidChecksum 0xFFFFFFFF; +#ifndef PAGE_SIZE +#define PAGE_SIZE 0x1000 +#endif + +#undef PAGE_MASK +#define PAGE_MASK (~(PAGE_SIZE-1)) + char *g_coreclrDirectory = nullptr; char *g_pluginModuleDirectory = nullptr; @@ -432,7 +439,7 @@ HRESULT LLDBServices::GetPageSize( PULONG size) { - *size = 4096; + *size = PAGE_SIZE; return S_OK; } @@ -762,10 +769,21 @@ LLDBServices::ReadVirtual( ULONG64 offset, PVOID buffer, ULONG bufferSize, - PULONG bytesRead) + PULONG pbytesRead) { lldb::SBError error; - size_t read = 0; + size_t bytesRead = 0; + ULONG64 nextPageStart; + + // Reading 0 bytes must succeed + if (bufferSize == 0) + { + if (pbytesRead) + { + *pbytesRead = 0; + } + return S_OK; + } // lldb doesn't expect sign-extended address offset = CONVERT_FROM_SIGN_EXTENDED(offset); @@ -776,9 +794,41 @@ LLDBServices::ReadVirtual( goto exit; } - read = process.ReadMemory(offset, buffer, bufferSize, error); + // Try the full read and return if successful + bytesRead = process.ReadMemory(offset, buffer, bufferSize, error); + if (error.Success()) + { + goto exit; + } + + // As it turns out the lldb ReadMemory API doesn't do partial reads and the SOS + // caching depends on that behavior. Round up to the next page boundry and attempt + // to read up to the page boundries. + nextPageStart = (offset + PAGE_SIZE - 1) & PAGE_MASK; - if (!error.Success()) + while (bufferSize > 0) + { + size_t size = nextPageStart - offset; + if (size > bufferSize) + { + size = bufferSize; + } + size_t read = process.ReadMemory(offset, buffer, size, error); + + bytesRead += read; + offset += read; + buffer = (BYTE*)buffer + read; + bufferSize -= read; + nextPageStart += PAGE_SIZE; + + if (!error.Success()) + { + break; + } + } + + // If the read isn't complete, try reading directly from native modules in the address range. + if (bufferSize > 0) { lldb::SBTarget target = process.GetTarget(); if (!target.IsValid()) @@ -787,8 +837,7 @@ LLDBServices::ReadVirtual( } int numModules = target.GetNumModules(); - bool found = false; - for (int i = 0; !found && i < numModules; i++) + for (int i = 0; i < numModules; i++) { lldb::SBModule module = target.GetModuleAtIndex(i); int numSections = module.GetNumSections(); @@ -803,9 +852,8 @@ LLDBServices::ReadVirtual( lldb::SBData sectionData = section.GetSectionData(offset - loadAddr, bufferSize); if (sectionData.IsValid()) { - read = sectionData.ReadRawData(error, 0, buffer, bufferSize); - found = true; - break; + bytesRead += sectionData.ReadRawData(error, 0, buffer, bufferSize); + goto exit; } } } @@ -813,11 +861,11 @@ LLDBServices::ReadVirtual( } exit: - if (bytesRead) + if (pbytesRead) { - *bytesRead = read; + *pbytesRead = bytesRead; } - return error.Success() || (read != 0) ? S_OK : E_FAIL; + return bytesRead > 0 ? S_OK : E_FAIL; } HRESULT @@ -2113,19 +2161,17 @@ class ExtensionCommand : public lldb::SBCommandPluginInterface result.SetStatus(lldb::eReturnStatusFailed); return false; } - std::string commandLine; - commandLine.append(m_commandName); - commandLine.append(" "); + std::string commandArguments; if (arguments != nullptr) { - for (const char* arg = *arguments; arg; arg = *(++arguments)) + for (const char* arg = *arguments; arg != nullptr; arg = *(++arguments)) { - commandLine.append(arg); - commandLine.append(" "); + commandArguments.append(arg); + commandArguments.append(" "); } } g_services->FlushCheck(); - HRESULT hr = hostservices->DispatchCommand(commandLine.c_str()); + HRESULT hr = hostservices->DispatchCommand(m_commandName, commandArguments.c_str()); if (hr != S_OK) { result.SetStatus(lldb::eReturnStatusFailed); @@ -2784,6 +2830,66 @@ LLDBServices::AddCommand( return command; } +void +LLDBServices::AddManagedCommand( + const char* name, + const char* help) +{ + HRESULT hr = AddCommand(name, help, nullptr, 0); + if (FAILED(hr)) + { + Output(DEBUG_OUTPUT_ERROR, "AddManagedCommand FAILED %08x\n", hr); + } +} + +bool +LLDBServices::ExecuteCommand( + const char* commandName, + char** arguments, + lldb::SBCommandReturnObject &result) +{ + // Build all the possible arguments into a string + std::string commandArguments; + for (const char* arg = *arguments; arg != nullptr; arg = *(++arguments)) + { + commandArguments.append(arg); + commandArguments.append(" "); + } + // Load and initialize the managed extensions and commands before we check the m_commands list. + IHostServices* hostservices = GetHostServices(); + + // If the command is a native SOS or managed extension command execute it through the lldb command added. + if (m_commands.find(commandName) != m_commands.end()) + { + std::string commandLine; + commandLine.append(commandName); + if (!commandArguments.empty()) + { + commandLine.append(" "); + commandLine.append(commandArguments); + } + lldb::ReturnStatus status = m_interpreter.HandleCommand(commandLine.c_str(), result); + result.SetStatus(status); + return true; + } + + // Fallback to dispatch it as a managed command for those commands that couldn't be added + // directly to the lldb interpreter because of existing commands or aliases. + if (hostservices != nullptr) + { + g_services->FlushCheck(); + HRESULT hr = hostservices->DispatchCommand(commandName, commandArguments.c_str()); + if (hr != E_NOTIMPL) + { + result.SetStatus(hr == S_OK ? lldb::eReturnStatusSuccessFinishResult : lldb::eReturnStatusFailed); + return true; + } + } + + // Command not found; attempt dispatch to native SOS module + return false; +} + HRESULT LLDBServices::InternalOutputVaList( ULONG mask, diff --git a/src/SOS/lldbplugin/services.h b/src/SOS/lldbplugin/services.h index 558f30d856..d741ed51eb 100644 --- a/src/SOS/lldbplugin/services.h +++ b/src/SOS/lldbplugin/services.h @@ -414,5 +414,9 @@ class LLDBServices : public ILLDBServices, public ILLDBServices2, public IDebugg lldb::SBCommand AddCommand(const char *name, lldb::SBCommandPluginInterface *impl, const char *help); + void AddManagedCommand(const char* name, const char* help); + + bool ExecuteCommand( const char* commandName, char** arguments, lldb::SBCommandReturnObject &result); + HRESULT InternalOutputVaList(ULONG mask, PCSTR format, va_list args); }; diff --git a/src/SOS/lldbplugin/soscommand.cpp b/src/SOS/lldbplugin/soscommand.cpp index 3517fca109..d2dca0394a 100644 --- a/src/SOS/lldbplugin/soscommand.cpp +++ b/src/SOS/lldbplugin/soscommand.cpp @@ -38,21 +38,27 @@ class sosCommand : public lldb::SBCommandPluginInterface { result.SetStatus(lldb::eReturnStatusSuccessFinishResult); - LoadSos(); - - if (g_sosHandle != nullptr) + const char* sosCommand = m_command; + if (sosCommand == nullptr) { - const char* sosCommand = m_command; - if (sosCommand == nullptr) + if (arguments == nullptr || *arguments == nullptr) { - if (arguments == nullptr || *arguments == nullptr) { - sosCommand = "Help"; - } - else + sosCommand = "Help"; + } + else + { + sosCommand = *arguments++; + if (g_services->ExecuteCommand(sosCommand, arguments, result)) { - sosCommand = *arguments++; + return result.Succeeded(); } } + } + + LoadSos(); + + if (g_sosHandle != nullptr) + { CommandFunc commandFunc = (CommandFunc)dlsym(g_sosHandle, sosCommand); if (commandFunc) { @@ -149,21 +155,21 @@ bool sosCommandInitialize(lldb::SBDebugger debugger) { g_services->AddCommand("sos", new sosCommand(nullptr), "Various .NET Core debugging commands. See 'soshelp' for more details. sos <command-name> <args>"); - g_services->AddCommand("ext", new sosCommand("ext"), "Execute extension command. See 'soshelp' for more details. ext <command-name> <args>"); + g_services->AddCommand("ext", new sosCommand(nullptr), "Various .NET Core debugging commands. See 'soshelp' for more details. ext <command-name> <args>"); g_services->AddCommand("bpmd", new sosCommand("bpmd"), "Creates a breakpoint at the specified managed method in the specified module."); - g_services->AddCommand("clrmodules", new sosCommand("clrmodules"), "Lists the managed modules in the process."); + g_services->AddManagedCommand("clrmodules", "Lists the managed modules in the process."); g_services->AddCommand("clrstack", new sosCommand("ClrStack"), "Provides a stack trace of managed code only."); g_services->AddCommand("clrthreads", new sosCommand("Threads"), "List the managed threads running."); g_services->AddCommand("clru", new sosCommand("u"), "Displays an annotated disassembly of a managed method."); g_services->AddCommand("dbgout", new sosCommand("dbgout"), "Enable/disable (-off) internal SOS logging."); - g_services->AddCommand("logging", new sosCommand("logging"), "Enable/disable internal SOS logging."); g_services->AddCommand("dumpalc", new sosCommand("DumpALC"), "Displays details about a collectible AssemblyLoadContext to which the specified object is loaded."); g_services->AddCommand("dumparray", new sosCommand("DumpArray"), "Displays details about a managed array."); - g_services->AddCommand("dumpasync", new sosCommand("DumpAsync"), "Displays information about async \"stacks\" on the garbage-collected heap."); + g_services->AddManagedCommand("dumpasync", "Displays information about async \"stacks\" on the garbage-collected heap."); g_services->AddCommand("dumpassembly", new sosCommand("DumpAssembly"), "Displays details about an assembly."); g_services->AddCommand("dumpclass", new sosCommand("DumpClass"), "Displays information about a EE class structure at the specified address."); g_services->AddCommand("dumpdelegate", new sosCommand("DumpDelegate"), "Displays information about a delegate."); g_services->AddCommand("dumpdomain", new sosCommand("DumpDomain"), "Displays information all the AppDomains and all assemblies within the domains."); + g_services->AddCommand("dumpgcdata", new sosCommand("DumpGCData"), "Displays information about the GC data."); g_services->AddCommand("dumpheap", new sosCommand("DumpHeap"), "Displays info about the garbage-collected heap and collection statistics about objects."); g_services->AddCommand("dumpil", new sosCommand("DumpIL"), "Displays the Microsoft intermediate language (MSIL) that is associated with a managed method."); g_services->AddCommand("dumplog", new sosCommand("DumpLog"), "Writes the contents of an in-memory stress log to the specified file."); @@ -171,34 +177,53 @@ sosCommandInitialize(lldb::SBDebugger debugger) g_services->AddCommand("dumpmodule", new sosCommand("DumpModule"), "Displays information about a EE module structure at the specified address."); g_services->AddCommand("dumpmt", new sosCommand("DumpMT"), "Displays information about a method table at the specified address."); g_services->AddCommand("dumpobj", new sosCommand("DumpObj"), "Displays info about an object at the specified address."); - g_services->AddCommand("dumpvc", new sosCommand("DumpVC"), "Displays info about the fields of a value class."); + g_services->AddCommand("dumpruntimetypes", new sosCommand("DumpRuntimeTypes"), "Finds all System.RuntimeType objects in the gc heap and prints the type name and MethodTable they refer too."); + g_services->AddCommand("dumpsig", new sosCommand("DumpSig"), "This command dumps the signature of a method or field given by <sigaddr> <moduleaddr>."); + g_services->AddCommand("dumpsigelem", new sosCommand("DumpSigElem"), "This command dumps a single element of a signature object."); g_services->AddCommand("dumpstack", new sosCommand("DumpStack"), "Displays a native and managed stack trace."); + g_services->AddCommand("dumpstackobjects", new sosCommand("DumpStackObjects"), "Displays all managed objects found within the bounds of the current stack."); g_services->AddCommand("dso", new sosCommand("DumpStackObjects"), "Displays all managed objects found within the bounds of the current stack."); + g_services->AddCommand("dumpvc", new sosCommand("DumpVC"), "Displays info about the fields of a value class."); g_services->AddCommand("eeheap", new sosCommand("EEHeap"), "Displays info about process memory consumed by internal runtime data structures."); g_services->AddCommand("eestack", new sosCommand("EEStack"), "Runs dumpstack on all threads in the process."); g_services->AddCommand("eeversion", new sosCommand("EEVersion"), "Displays information about the runtime version."); + g_services->AddCommand("ehinfo", new sosCommand("EHInfo"), "Displays the exception handling blocks in a jitted method."); g_services->AddCommand("finalizequeue", new sosCommand("FinalizeQueue"), "Displays all objects registered for finalization."); + g_services->AddCommand("findappdomain", new sosCommand("FindAppDomain"), "Attempts to resolve the AppDomain of a GC object."); + g_services->AddCommand("findroots", new sosCommand("FindRoots"), ""); + g_services->AddCommand("gchandles", new sosCommand("GCHandles"), "Displays statistics about garbage collector handles in the process."); + g_services->AddCommand("gcheapstat", new sosCommand("GCHeapStat"), "Displays statistics about garbage collector."); + g_services->AddCommand("gcinfo", new sosCommand("GCInfo"), "Displays info JIT GC encoding for a method."); g_services->AddCommand("gcroot", new sosCommand("GCRoot"), "Displays info about references (or roots) to an object at the specified address."); g_services->AddCommand("gcwhere", new sosCommand("GCWhere"), "Displays the location in the GC heap of the argument passed in."); - g_services->AddCommand("ip2md", new sosCommand("IP2MD"), "Displays the MethodDesc structure at the specified address in code that has been JIT-compiled."); - g_services->AddCommand("loadsymbols", new sosCommand("SetSymbolServer", "-loadsymbols"), "Load the .NET Core native module symbols."); - g_services->AddCommand("name2ee", new sosCommand("Name2EE"), "Displays the MethodTable structure and EEClass structure for the specified type or method in the specified module."); - g_services->AddCommand("pe", new sosCommand("PrintException"), "Displays and formats fields of any object derived from the Exception class at the specified address."); - g_services->AddCommand("syncblk", new sosCommand("SyncBlk"), "Displays the SyncBlock holder info."); g_services->AddCommand("histclear", new sosCommand("HistClear"), "Releases any resources used by the family of Hist commands."); g_services->AddCommand("histinit", new sosCommand("HistInit"), "Initializes the SOS structures from the stress log saved in the debuggee."); g_services->AddCommand("histobj", new sosCommand("HistObj"), "Examines all stress log relocation records and displays the chain of garbage collection relocations that may have led to the address passed in as an argument."); g_services->AddCommand("histobjfind", new sosCommand("HistObjFind"), "Displays all the log entries that reference an object at the specified address."); g_services->AddCommand("histroot", new sosCommand("HistRoot"), "Displays information related to both promotions and relocations of the specified root."); + g_services->AddCommand("histstats", new sosCommand("HistStats"), "Displays stress log stats."); + g_services->AddCommand("ip2md", new sosCommand("IP2MD"), "Displays the MethodDesc structure at the specified address in code that has been JIT-compiled."); + g_services->AddCommand("listnearobj", new sosCommand("ListNearObj"), "displays the object preceeding and succeeding the address passed."); + g_services->AddManagedCommand("loadsymbols", "Load the .NET Core native module symbols."); + g_services->AddManagedCommand("logging", "Enable/disable internal SOS logging."); + g_services->AddCommand("name2ee", new sosCommand("Name2EE"), "Displays the MethodTable structure and EEClass structure for the specified type or method in the specified module."); + g_services->AddCommand("objsize", new sosCommand("ObjSize"), "Displays the size of the specified object."); + g_services->AddCommand("pathto", new sosCommand("PathTo"), "Displays the GC path from <root> to <target>."); + g_services->AddCommand("pe", new sosCommand("PrintException"), "Displays and formats fields of any object derived from the Exception class at the specified address."); + g_services->AddCommand("printexception", new sosCommand("PrintException"), "Displays and formats fields of any object derived from the Exception class at the specified address."); + g_services->AddCommand("runtimes", new sosCommand("runtimes"), "List the runtimes in the target or change the default runtime."); + g_services->AddCommand("stoponcatch", new sosCommand("StopOnCatch"), "Debuggee will break the next time a managed exception is caught during execution"); g_services->AddCommand("setclrpath", new sosCommand("SetClrPath"), "Set the path to load the runtime DAC/DBI files."); - g_services->AddCommand("setsymbolserver", new sosCommand("SetSymbolServer"), "Enables the symbol server support "); - g_services->AddCommand("sympath", new sosCommand("SetSymbolServer", "-sympath"), "Add server, cache and directory paths in the Windows symbol path format."); + g_services->AddManagedCommand("setsymbolserver", "Enables the symbol server support "); g_services->AddCommand("soshelp", new sosCommand("Help"), "Displays all available commands when no parameter is specified, or displays detailed help information about the specified command. soshelp <command>"); g_services->AddCommand("sosstatus", new sosCommand("SOSStatus"), "Displays the global SOS status."); - g_services->AddCommand("runtimes", new sosCommand("runtimes"), "List the runtimes in the target or change the default runtime."); g_services->AddCommand("sosflush", new sosCommand("SOSFlush"), "Flushes the DAC caches."); + g_services->AddCommand("syncblk", new sosCommand("SyncBlk"), "Displays the SyncBlock holder info."); g_services->AddCommand("threadpool", new sosCommand("ThreadPool"), "Displays info about the runtime thread pool."); g_services->AddCommand("threadstate", new sosCommand("ThreadState"), "Pretty prints the meaning of a threads state."); + g_services->AddCommand("token2ee", new sosCommand("token2ee"), "Displays the MethodTable structure and MethodDesc structure for the specified token and module."); + g_services->AddCommand("traverseheap", new sosCommand("TraverseHeap"), "Writes out heap information to a file in a format understood by the CLR Profiler."); g_services->AddCommand("verifyheap", new sosCommand("VerifyHeap"), "Checks the GC heap for signs of corruption."); + g_services->AddCommand("verifyobj", new sosCommand("VerifyObj"), "Checks the object that is passed as an argument for signs of corruption."); return true; } diff --git a/src/Tools/dotnet-counters/CounterMonitor.cs b/src/Tools/dotnet-counters/CounterMonitor.cs index a6a1f87157..86a27c538e 100644 --- a/src/Tools/dotnet-counters/CounterMonitor.cs +++ b/src/Tools/dotnet-counters/CounterMonitor.cs @@ -169,6 +169,7 @@ private void HandleCounterRate(TraceEvent obj) CounterPayload payload = new RatePayload(meterName, instrumentName, null, unit, tags, rate, _interval, obj.TimeStamp); _renderer.CounterPayloadReceived(payload, _pauseCmdSet); } + } private void HandleGauge(TraceEvent obj) @@ -192,6 +193,12 @@ private void HandleGauge(TraceEvent obj) CounterPayload payload = new GaugePayload(meterName, instrumentName, null, unit, tags, lastValue, obj.TimeStamp); _renderer.CounterPayloadReceived(payload, _pauseCmdSet); } + else + { + // for observable instruments we assume the lack of data is meaningful and remove it from the UI + CounterPayload payload = new RatePayload(meterName, instrumentName, null, unit, tags, 0, _interval, obj.TimeStamp); + _renderer.CounterStopped(payload); + } } private void HandleHistogram(TraceEvent obj) diff --git a/src/Tools/dotnet-counters/Exporters/CSVExporter.cs b/src/Tools/dotnet-counters/Exporters/CSVExporter.cs index a7a56499fe..284c641b8d 100644 --- a/src/Tools/dotnet-counters/Exporters/CSVExporter.cs +++ b/src/Tools/dotnet-counters/Exporters/CSVExporter.cs @@ -83,6 +83,8 @@ public void CounterPayloadReceived(CounterPayload payload, bool _) } } + public void CounterStopped(CounterPayload payload) { } + public void Stop() { string outputString; diff --git a/src/Tools/dotnet-counters/Exporters/ConsoleWriter.cs b/src/Tools/dotnet-counters/Exporters/ConsoleWriter.cs index a22567c558..b6ff55040b 100644 --- a/src/Tools/dotnet-counters/Exporters/ConsoleWriter.cs +++ b/src/Tools/dotnet-counters/Exporters/ConsoleWriter.cs @@ -56,22 +56,26 @@ public ObservedTagSet(string tags) } private readonly object _lock = new object(); - private readonly Dictionary<string, ObservedProvider> providers = new Dictionary<string, ObservedProvider>(); // Tracks observed providers and counters. + private readonly Dictionary<string, ObservedProvider> _providers = new Dictionary<string, ObservedProvider>(); // Tracks observed providers and counters. private const int Indent = 4; // Counter name indent size. - private int maxNameLength = 40; // Allow room for 40 character counter names by default. + private const int CounterValueLength = 15; - private int STATUS_ROW; // Row # of where we print the status of dotnet-counters - private int Top_Row; - private bool paused = false; - private bool initialized = false; + private int _maxNameLength = 0; + private int _statusRow; // Row # of where we print the status of dotnet-counters + private int _topRow; + private bool _paused = false; + private bool _initialized = false; private string _errorText = null; - private int maxRow = -1; - private bool useAnsi = false; + private int _maxRow = -1; + private bool _useAnsi = false; + + private int _consoleHeight = -1; + private int _consoleWidth = -1; public ConsoleWriter(bool useAnsi) { - this.useAnsi = useAnsi; + this._useAnsi = useAnsi; } public void Initialize() @@ -92,9 +96,9 @@ public void SetErrorText(string errorText) private void SetCursorPosition(int col, int row) { - if (this.useAnsi) + if (this._useAnsi) { - Console.Write($"\u001b[{row + 1 - Top_Row};{col + 1}H"); + Console.Write($"\u001b[{row + 1 - _topRow};{col + 1}H"); } else { @@ -104,7 +108,7 @@ private void SetCursorPosition(int col, int row) private void Clear() { - if (this.useAnsi) + if (this._useAnsi) { Console.Write($"\u001b[H\u001b[J"); } @@ -115,21 +119,28 @@ private void Clear() } private void UpdateStatus() { - SetCursorPosition(0, STATUS_ROW); + SetCursorPosition(0, _statusRow); Console.Write($" Status: {GetStatus()}{new string(' ', 40)}"); // Write enough blanks to clear previous status. } - private string GetStatus() => !initialized ? "Waiting for initial payload..." : (paused ? "Paused" : "Running"); + private string GetStatus() => !_initialized ? "Waiting for initial payload..." : (_paused ? "Paused" : "Running"); /// <summary>Clears display and writes out category and counter name layout.</summary> public void AssignRowsAndInitializeDisplay() { Clear(); + _consoleWidth = Console.WindowWidth; + _consoleHeight = Console.WindowHeight; + _maxNameLength = Math.Max(Math.Min(80, _consoleWidth) - (CounterValueLength + Indent + 1), 0); // Truncate the name to prevent line wrapping as long as the console width is >= CounterValueLength + Indent + 1 characters + + int row = Console.CursorTop; - Top_Row = row; - Console.WriteLine("Press p to pause, r to resume, q to quit."); row++; - Console.WriteLine($" Status: {GetStatus()}"); STATUS_ROW = row++; + _topRow = row; + + string instructions = "Press p to pause, r to resume, q to quit."; + Console.WriteLine((instructions.Length < _consoleWidth) ? instructions : instructions.Substring(0, _consoleWidth)); row++; + Console.WriteLine($" Status: {GetStatus()}"); _statusRow = row++; if (_errorText != null) { Console.WriteLine(_errorText); @@ -137,15 +148,21 @@ public void AssignRowsAndInitializeDisplay() } Console.WriteLine(); row++; // Blank line. - foreach (ObservedProvider provider in providers.Values.OrderBy(p => p.KnownProvider == null).ThenBy(p => p.Name)) // Known providers first. + foreach (ObservedProvider provider in _providers.Values.OrderBy(p => p.KnownProvider == null).ThenBy(p => p.Name)) // Known providers first. { Console.WriteLine($"[{provider.Name}]"); row++; + foreach (ObservedCounter counter in provider.Counters.Values.OrderBy(c => c.DisplayName)) { - string name = MakeFixedWidth($"{new string(' ', Indent)}{counter.DisplayName}", Indent + maxNameLength); + + string name = MakeFixedWidth($"{new string(' ', Indent)}{counter.DisplayName}", Indent + _maxNameLength); counter.Row = row++; if (counter.RenderValueInline) { + if(row >= _consoleHeight) // prevents from displaying more counters than vertical space available + { + break; + } Console.WriteLine($"{name} {FormatValue(counter.LastValue)}"); } else @@ -153,7 +170,12 @@ public void AssignRowsAndInitializeDisplay() Console.WriteLine(name); foreach (ObservedTagSet tagSet in counter.TagSets.Values.OrderBy(t => t.Tags)) { - string tagName = MakeFixedWidth($"{new string(' ', 2 * Indent)}{tagSet.Tags}", Indent + maxNameLength); + if(row >= _consoleHeight) + { + break; + } + + string tagName = MakeFixedWidth($"{new string(' ', 2 * Indent)}{tagSet.Tags}", Indent + _maxNameLength); Console.WriteLine($"{tagName} {FormatValue(tagSet.LastValue)}"); tagSet.Row = row++; } @@ -161,17 +183,17 @@ public void AssignRowsAndInitializeDisplay() } } - maxRow = Math.Max(maxRow, row); + _maxRow = Math.Max(_maxRow, row); } public void ToggleStatus(bool pauseCmdSet) { - if (paused == pauseCmdSet) + if (_paused == pauseCmdSet) { return; } - paused = pauseCmdSet; + _paused = pauseCmdSet; UpdateStatus(); } @@ -179,9 +201,9 @@ public void CounterPayloadReceived(CounterPayload payload, bool pauseCmdSet) { lock (_lock) { - if (!initialized) + if (!_initialized) { - initialized = true; + _initialized = true; AssignRowsAndInitializeDisplay(); } @@ -195,9 +217,9 @@ public void CounterPayloadReceived(CounterPayload payload, bool pauseCmdSet) string tags = payload.Tags; bool redraw = false; - if (!providers.TryGetValue(providerName, out ObservedProvider provider)) + if (!_providers.TryGetValue(providerName, out ObservedProvider provider)) { - providers[providerName] = provider = new ObservedProvider(providerName); + _providers[providerName] = provider = new ObservedProvider(providerName); redraw = true; } @@ -205,7 +227,7 @@ public void CounterPayloadReceived(CounterPayload payload, bool pauseCmdSet) { string displayName = payload.DisplayName; provider.Counters[name] = counter = new ObservedCounter(displayName); - maxNameLength = Math.Max(maxNameLength, displayName.Length); + _maxNameLength = Math.Max(_maxNameLength, displayName.Length); if(tags != null) { counter.LastValue = payload.Value; @@ -217,22 +239,69 @@ public void CounterPayloadReceived(CounterPayload payload, bool pauseCmdSet) if (tags != null && !counter.TagSets.TryGetValue(tags, out tagSet)) { counter.TagSets[tags] = tagSet = new ObservedTagSet(tags); - maxNameLength = Math.Max(maxNameLength, tagSet.DisplayTags.Length); + _maxNameLength = Math.Max(_maxNameLength, tagSet.DisplayTags.Length); tagSet.LastValue = payload.Value; redraw = true; } + if(Console.WindowWidth != _consoleWidth || Console.WindowHeight != _consoleHeight) + { + redraw=true; + } + if (redraw) { AssignRowsAndInitializeDisplay(); } int row = counter.RenderValueInline ? counter.Row : tagSet.Row; - SetCursorPosition(Indent + maxNameLength + 1, row); + SetCursorPosition(Indent + _maxNameLength + 1, row); Console.Write(FormatValue(payload.Value)); } } + public void CounterStopped(CounterPayload payload) + { + lock (_lock) + { + string providerName = payload.ProviderName; + string counterName = payload.Name; + string tags = payload.Tags; + + if (!_providers.TryGetValue(providerName, out ObservedProvider provider)) + { + return; + } + + if (!provider.Counters.TryGetValue(counterName, out ObservedCounter counter)) + { + return; + } + + ObservedTagSet tagSet = null; + if (tags != null) + { + if (!counter.TagSets.TryGetValue(tags, out tagSet)) + { + return; + } + else + { + counter.TagSets.Remove(tags); + if(counter.TagSets.Count == 0) + { + provider.Counters.Remove(counterName); + } + } + } + else + { + provider.Counters.Remove(counterName); + } + AssignRowsAndInitializeDisplay(); + } + } + private static int GetLineWrappedLines(string text) { string[] lines = text.Split(Environment.NewLine); @@ -305,9 +374,9 @@ public void Stop() { lock (_lock) { - if (initialized) + if (_initialized) { - var row = maxRow; + var row = _maxRow; if (row > -1) { diff --git a/src/Tools/dotnet-counters/Exporters/ICounterRenderer.cs b/src/Tools/dotnet-counters/Exporters/ICounterRenderer.cs index e1bbec7f03..4b6ffabe94 100644 --- a/src/Tools/dotnet-counters/Exporters/ICounterRenderer.cs +++ b/src/Tools/dotnet-counters/Exporters/ICounterRenderer.cs @@ -10,6 +10,7 @@ public interface ICounterRenderer void EventPipeSourceConnected(); void ToggleStatus(bool paused); void CounterPayloadReceived(CounterPayload payload, bool paused); + void CounterStopped(CounterPayload payload); void SetErrorText(string errorText); void Stop(); } diff --git a/src/Tools/dotnet-counters/Exporters/JSONExporter.cs b/src/Tools/dotnet-counters/Exporters/JSONExporter.cs index 8293a16119..592973e131 100644 --- a/src/Tools/dotnet-counters/Exporters/JSONExporter.cs +++ b/src/Tools/dotnet-counters/Exporters/JSONExporter.cs @@ -81,6 +81,8 @@ public void CounterPayloadReceived(CounterPayload payload, bool _) } } + public void CounterStopped(CounterPayload payload) { } + public void Stop() { lock (_lock) diff --git a/src/Tools/dotnet-dsrouter/USBMuxTcpClientRouterFactory.cs b/src/Tools/dotnet-dsrouter/USBMuxTcpClientRouterFactory.cs index 870008b163..0d2f06c58b 100644 --- a/src/Tools/dotnet-dsrouter/USBMuxTcpClientRouterFactory.cs +++ b/src/Tools/dotnet-dsrouter/USBMuxTcpClientRouterFactory.cs @@ -118,12 +118,18 @@ public override Task FlushAsync(CancellationToken cancellationToken) public override int Read(byte[] buffer, int offset, int count) { - bool continueRead = true; - int bytesToRead = count; - int totalBytesRead = 0; - int currentBytesRead = 0; + int bytesRead = 0; - while (continueRead && bytesToRead - totalBytesRead > 0) + if (offset + count > buffer.Length) + throw new InvalidOperationException ("Potential write beyond end of buffer"); + + if (offset < 0) + throw new InvalidOperationException ("Write before beginning of buffer"); + + if (count < 0) + throw new InvalidOperationException ("Negative read count"); + + while (true) { if (!IsOpen) throw new EndOfStreamException(); @@ -132,21 +138,15 @@ public override int Read(byte[] buffer, int offset, int count) { fixed (byte* fixedBuffer = buffer) { - currentBytesRead = USBMuxInterop.recv(_handle, fixedBuffer + totalBytesRead, new IntPtr(bytesToRead - totalBytesRead), 0); + bytesRead = USBMuxInterop.recv(_handle, fixedBuffer + offset, new IntPtr (count), 0); } } - if (currentBytesRead == -1 && Marshal.GetLastWin32Error() == USBMuxInterop.EINTR) + if (bytesRead == -1 && Marshal.GetLastWin32Error() == USBMuxInterop.EINTR) continue; - continueRead = currentBytesRead > 0; - if (!continueRead) - break; - - totalBytesRead += currentBytesRead; + return bytesRead; } - - return totalBytesRead; } public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) diff --git a/src/Tools/dotnet-dsrouter/dotnet-dsrouter.csproj b/src/Tools/dotnet-dsrouter/dotnet-dsrouter.csproj index 73fd6f82e3..3afa713272 100644 --- a/src/Tools/dotnet-dsrouter/dotnet-dsrouter.csproj +++ b/src/Tools/dotnet-dsrouter/dotnet-dsrouter.csproj @@ -22,8 +22,8 @@ <ItemGroup> <PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="$(MicrosoftDiagnosticsTracingTraceEventVersion)" GeneratePathProperty="true" /> <PackageReference Include="System.CommandLine" Version="$(SystemCommandLineVersion)" /> - <PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingVersion)" /> - <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingVersion)" /> + <PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingPinnedVersion)" /> + <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingPinnedVersion)" /> </ItemGroup> </Project> diff --git a/src/Tools/dotnet-dump/Analyzer.cs b/src/Tools/dotnet-dump/Analyzer.cs index 7532b870df..6071b5ac28 100644 --- a/src/Tools/dotnet-dump/Analyzer.cs +++ b/src/Tools/dotnet-dump/Analyzer.cs @@ -23,7 +23,8 @@ namespace Microsoft.Diagnostics.Tools.Dump public class Analyzer : IHost { private readonly ServiceProvider _serviceProvider; - private readonly ConsoleService _consoleProvider; + private readonly ConsoleService _consoleService; + private readonly FileLoggingConsoleService _fileLoggingConsoleService; private readonly CommandService _commandService; private readonly SymbolService _symbolService; private readonly ContextService _contextService; @@ -32,23 +33,26 @@ public class Analyzer : IHost public Analyzer() { - LoggingCommand.Initialize(); + DiagnosticLoggingService.Initialize(); _serviceProvider = new ServiceProvider(); - _consoleProvider = new ConsoleService(); + _consoleService = new ConsoleService(); + _fileLoggingConsoleService = new FileLoggingConsoleService(_consoleService); _commandService = new CommandService(); _symbolService = new SymbolService(this); _contextService = new ContextService(this); + DiagnosticLoggingService.Instance.SetConsole(_fileLoggingConsoleService, _fileLoggingConsoleService); _serviceProvider.AddService<IHost>(this); - _serviceProvider.AddService<IConsoleService>(_consoleProvider); + _serviceProvider.AddService<IConsoleService>(_fileLoggingConsoleService); + _serviceProvider.AddService<IConsoleFileLoggingService>(_fileLoggingConsoleService); + _serviceProvider.AddService<IDiagnosticLoggingService>(DiagnosticLoggingService.Instance); _serviceProvider.AddService<ICommandService>(_commandService); _serviceProvider.AddService<ISymbolService>(_symbolService); _serviceProvider.AddService<IContextService>(_contextService); _serviceProvider.AddServiceFactory<SOSLibrary>(() => SOSLibrary.Create(this)); - _contextService.ServiceProvider.AddServiceFactory<ClrMDHelper>(() => - { + _contextService.ServiceProvider.AddServiceFactory<ClrMDHelper>(() => { ClrRuntime clrRuntime = _contextService.Services.GetService<ClrRuntime>(); return clrRuntime != null ? new ClrMDHelper(clrRuntime) : null; }); @@ -57,12 +61,13 @@ public Analyzer() _commandService.AddCommands(new Assembly[] { typeof(ClrMDHelper).Assembly }); _commandService.AddCommands(new Assembly[] { typeof(SOSHost).Assembly }); _commandService.AddCommands(typeof(HelpCommand), (services) => new HelpCommand(_commandService, services)); - _commandService.AddCommands(typeof(ExitCommand), (services) => new ExitCommand(_consoleProvider.Stop)); + _commandService.AddCommands(typeof(ExitCommand), (services) => new ExitCommand(_consoleService.Stop)); + _commandService.AddCommands(typeof(SOSCommand), (services) => new SOSCommand(_commandService, services)); } public Task<int> Analyze(FileInfo dump_path, string[] command) { - _consoleProvider.WriteLine($"Loading core dump: {dump_path} ..."); + _fileLoggingConsoleService.WriteLine($"Loading core dump: {dump_path} ..."); // Attempt to load the persisted command history string dotnetHome = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".dotnet"); @@ -70,7 +75,7 @@ public Task<int> Analyze(FileInfo dump_path, string[] command) try { string[] history = File.ReadAllLines(historyFileName); - _consoleProvider.AddCommandHistory(history); + _consoleService.AddCommandHistory(history); } catch (Exception ex) when (ex is IOException || @@ -108,20 +113,21 @@ ex is NotSupportedException || foreach (string cmd in command) { _commandService.Execute(cmd, _contextService.Services); - if (_consoleProvider.Shutdown) + if (_consoleService.Shutdown) { break; } } } - if (!_consoleProvider.Shutdown && (!Console.IsOutputRedirected || Console.IsInputRedirected)) + if (!_consoleService.Shutdown && (!Console.IsOutputRedirected || Console.IsInputRedirected)) { // Start interactive command line processing - _consoleProvider.WriteLine("Ready to process analysis commands. Type 'help' to list available commands or 'help [command]' to get detailed help on a command."); - _consoleProvider.WriteLine("Type 'quit' or 'exit' to exit the session."); + _fileLoggingConsoleService.WriteLine("Ready to process analysis commands. Type 'help' to list available commands or 'help [command]' to get detailed help on a command."); + _fileLoggingConsoleService.WriteLine("Type 'quit' or 'exit' to exit the session."); - _consoleProvider.Start((string commandLine, CancellationToken cancellation) => + _consoleService.Start((string prompt, string commandLine, CancellationToken cancellation) => { + _fileLoggingConsoleService.WriteLine("{0}{1}", prompt, commandLine); _commandService.Execute(commandLine, _contextService.Services); }); } @@ -136,7 +142,7 @@ ex is InvalidDataException || ex is InvalidOperationException || ex is NotSupportedException) { - _consoleProvider.WriteLine(OutputType.Error, $"{ex.Message}"); + _fileLoggingConsoleService.WriteError($"{ex.Message}"); return Task.FromResult(1); } finally @@ -148,7 +154,7 @@ ex is InvalidOperationException || // Persist the current command history try { - File.WriteAllLines(historyFileName, _consoleProvider.GetCommandHistory()); + File.WriteAllLines(historyFileName, _consoleService.GetCommandHistory()); } catch (Exception ex) when (ex is IOException || @@ -223,12 +229,12 @@ private void LoadExtension(string extensionPath) } catch (Exception ex) when (ex is IOException || ex is ArgumentException || ex is BadImageFormatException || ex is System.Security.SecurityException) { - _consoleProvider.WriteLineError($"Extension load {extensionPath} FAILED {ex.Message}"); + _fileLoggingConsoleService.WriteLineError($"Extension load {extensionPath} FAILED {ex.Message}"); } if (assembly is not null) { _commandService.AddCommands(assembly); - _consoleProvider.WriteLine($"Extension loaded {extensionPath}"); + _fileLoggingConsoleService.WriteLine($"Extension loaded {extensionPath}"); } } } diff --git a/src/Tools/dotnet-dump/Commands/ReadMemoryCommand.cs b/src/Tools/dotnet-dump/Commands/ReadMemoryCommand.cs index a6f7a25c90..6cf6ec614b 100644 --- a/src/Tools/dotnet-dump/Commands/ReadMemoryCommand.cs +++ b/src/Tools/dotnet-dump/Commands/ReadMemoryCommand.cs @@ -6,7 +6,7 @@ using System; using System.Text; -namespace Microsoft.Diagnostics.ExtensionCommands +namespace Microsoft.Diagnostics.Tools.Dump { [Command(Name = "readmemory", Aliases = new string[] { "d" }, Help = "Dump memory contents.")] [Command(Name = "db", DefaultOptions = "--ascii:true --unicode:false --ascii-string:false --unicode-string:false -c:128 -l:1 -w:16", Help = "Dump memory as bytes.")] diff --git a/src/Tools/dotnet-dump/Commands/SOSCommand.cs b/src/Tools/dotnet-dump/Commands/SOSCommand.cs new file mode 100644 index 0000000000..6094454f25 --- /dev/null +++ b/src/Tools/dotnet-dump/Commands/SOSCommand.cs @@ -0,0 +1,60 @@ +// 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 Microsoft.Diagnostics.DebugServices; +using Microsoft.Diagnostics.DebugServices.Implementation; +using SOS.Hosting; +using System; +using System.Linq; + +namespace Microsoft.Diagnostics.Tools.Dump +{ + [Command(Name = "sos", Aliases = new string[] { "ext" }, Help = "Run an SOS command.", Flags = CommandFlags.Global | CommandFlags.Manual)] + public class SOSCommand : CommandBase + { + private readonly CommandService _commandService; + private readonly IServiceProvider _services; + private SOSHost _sosHost; + + [Argument(Name = "arguments", Help = "SOS command and arguments.")] + public string[] Arguments { get; set; } + + public SOSCommand(CommandService commandService, IServiceProvider services) + { + _commandService = commandService; + _services = services; + } + + public override void Invoke() + { + string commandLine; + string commandName; + if (Arguments != null && Arguments.Length > 0) + { + commandLine = string.Concat(Arguments.Select((arg) => arg + " ")).Trim(); + commandName = Arguments[0]; + } + else + { + commandLine = commandName = "help"; + } + if (_commandService.IsCommand(commandName)) + { + _commandService.Execute(commandLine, _services); + } + else + { + if (_sosHost is null) + { + _sosHost = _services.GetService<SOSHost>(); + if (_sosHost is null) + { + throw new DiagnosticsException($"'{commandName}' command not found"); + } + } + _sosHost.ExecuteCommand(commandLine); + } + } + } +} diff --git a/src/Tools/dotnet-dump/Program.cs b/src/Tools/dotnet-dump/Program.cs index 45368c7d44..56965cd392 100644 --- a/src/Tools/dotnet-dump/Program.cs +++ b/src/Tools/dotnet-dump/Program.cs @@ -108,7 +108,7 @@ private static Argument DumpPath() => private static Option RunCommand() => new Option( aliases: new[] { "-c", "--command" }, - description: "Run the command on start.") + description: "Runs the command on start. Multiple instances of this parameter can be used in an invocation to chain commands. Commands will get run in the order that they are provided on the command line. If you want dotnet dump to exit after the commands, your last command should be 'exit'.") { Argument = new Argument<string[]>(name: "command", getDefaultValue: () => Array.Empty<string>()) { Arity = ArgumentArity.ZeroOrMore } }; diff --git a/src/Tools/dotnet-gcdump/DotNetHeapDump/Graph.cs b/src/Tools/dotnet-gcdump/DotNetHeapDump/Graph.cs index 23bed8b0e3..7280bbdb3f 100644 --- a/src/Tools/dotnet-gcdump/DotNetHeapDump/Graph.cs +++ b/src/Tools/dotnet-gcdump/DotNetHeapDump/Graph.cs @@ -125,7 +125,7 @@ public virtual NodeType AllocTypeNodeStorage() /// <summary> /// Same as NodeIndexLimit, just cast to an integer. /// </summary> - public int NodeCount { get { return m_nodes.Count; } } + public long NodeCount { get { return m_nodes.Count; } } /// <summary> /// It is expected that users will want additional information associated with TYPES of the nodes of the graph. They can /// do this by allocating an array of code:NodeTypeIndexLimit and then indexing this by code:NodeTypeIndex @@ -882,35 +882,38 @@ internal static int ReadCompressedInt(SegmentedMemoryStreamReader reader) internal static void WriteCompressedInt(SegmentedMemoryStreamWriter writer, int value) { - if (value << 25 >> 25 == value) + unchecked { - goto oneByte; - } + if (value << 25 >> 25 == value) + { + goto oneByte; + } - if (value << 18 >> 18 == value) - { - goto twoBytes; - } + if (value << 18 >> 18 == value) + { + goto twoBytes; + } - if (value << 11 >> 11 == value) - { - goto threeBytes; - } + if (value << 11 >> 11 == value) + { + goto threeBytes; + } - if (value << 4 >> 4 == value) - { - goto fourBytes; - } + if (value << 4 >> 4 == value) + { + goto fourBytes; + } - writer.Write((byte)((value >> 28) | 0x80)); + writer.Write((byte)((value >> 28) | 0x80)); fourBytes: - writer.Write((byte)((value >> 21) | 0x80)); + writer.Write((byte)((value >> 21) | 0x80)); threeBytes: - writer.Write((byte)((value >> 14) | 0x80)); + writer.Write((byte)((value >> 14) | 0x80)); twoBytes: - writer.Write((byte)((value >> 7) | 0x80)); + writer.Write((byte)((value >> 7) | 0x80)); oneByte: - writer.Write((byte)(value & 0x7F)); + writer.Write((byte)(value & 0x7F)); + } } internal NodeIndex m_index; diff --git a/src/Tools/dotnet-sos/Program.cs b/src/Tools/dotnet-sos/Program.cs index 1074d8433e..55fc1c68a6 100644 --- a/src/Tools/dotnet-sos/Program.cs +++ b/src/Tools/dotnet-sos/Program.cs @@ -40,7 +40,7 @@ private static Command InstallCommand() => private static Option ArchitectureOption() => new Option( - alias: "--architecture", + aliases: new[] { "-a", "--arch", "--architecture" }, description: "The processor architecture to install.") { Argument = new Argument<Architecture>(name: "architecture") diff --git a/src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs b/src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs index c980e6d183..d7e3025482 100644 --- a/src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs +++ b/src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs @@ -304,7 +304,7 @@ private static async Task<int> Collect(CancellationToken ct, IConsole console, i while (!shouldExit.WaitOne(100) && !(cancelOnEnter && Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Enter)) printStatus(); - // if the CopyToAsync ended early (target program exited, etc.), the we don't need to stop the session. + // if the CopyToAsync ended early (target program exited, etc.), then we don't need to stop the session. if (!copyTask.Wait(0)) { // Behavior concerning Enter moving text in the terminal buffer when at the bottom of the buffer diff --git a/src/dbgshim/dbgshim.cpp b/src/dbgshim/dbgshim.cpp index f50a14830e..ef8623dbc5 100644 --- a/src/dbgshim/dbgshim.cpp +++ b/src/dbgshim/dbgshim.cpp @@ -1173,9 +1173,12 @@ GetTargetCLRMetrics( pClrInfo->DacSizeOfImage = pDebugResource->dwDacSizeOfImage; return true; }); - if (!pedecoder.EnumerateWin32Resources(W("CLRDEBUGINFO"), MAKEINTRESOURCEW(10), callback, pClrInfoOut)) + if (!pedecoder.EnumerateWin32Resources(CLRDEBUGINFO_RESOURCE_NAME, MAKEINTRESOURCEW(10), callback, pClrInfoOut) || !pClrInfoOut->IsValid()) { - return E_FAIL; + if (!pedecoder.EnumerateWin32Resources(W("CLRDEBUGINFO"), MAKEINTRESOURCEW(10), callback, pClrInfoOut) || !pClrInfoOut->IsValid()) + { + return E_FAIL; + } } } else diff --git a/src/dbgshim/dbgshim.vcxproj b/src/dbgshim/dbgshim.vcxproj index 6cc64432f6..8e464496df 100644 --- a/src/dbgshim/dbgshim.vcxproj +++ b/src/dbgshim/dbgshim.vcxproj @@ -111,7 +111,7 @@ <RuntimeTypeInfo>false</RuntimeTypeInfo> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4007;4013;4102;4551;4700;4640;4806</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4007;4013;4102;4551;4700;4640;4806</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UseFullPaths>true</UseFullPaths> @@ -180,7 +180,7 @@ <RuntimeTypeInfo>false</RuntimeTypeInfo> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4007;4013;4102;4551;4700;4640;4806</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4007;4013;4102;4551;4700;4640;4806</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UseFullPaths>true</UseFullPaths> @@ -248,7 +248,7 @@ <RuntimeTypeInfo>false</RuntimeTypeInfo> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4007;4013;4102;4551;4700;4640;4806</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4007;4013;4102;4551;4700;4640;4806</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UseFullPaths>true</UseFullPaths> @@ -318,7 +318,7 @@ <RuntimeTypeInfo>false</RuntimeTypeInfo> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4007;4013;4102;4551;4700;4640;4806</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4007;4013;4102;4551;4700;4640;4806</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UseFullPaths>true</UseFullPaths> diff --git a/src/dbgshim/debugshim.cpp b/src/dbgshim/debugshim.cpp index 0f6a0741b9..efddfaed60 100644 --- a/src/dbgshim/debugshim.cpp +++ b/src/dbgshim/debugshim.cpp @@ -604,43 +604,8 @@ HRESULT CLRDebuggingImpl::GetCLRInfo(ICorDebugDataTarget * pDataTarget, BOOL useCrossPlatformNaming = FALSE; if (SUCCEEDED(hr)) { - // the initial state is that we haven't found a proper resource - HRESULT hrGetResource = E_FAIL; - // First check for the resource which has type = RC_DATA = 10, name = "CLRDEBUGINFO<host_os><host_arch>", language = 0 - #if defined (HOST_WINDOWS) && defined(HOST_X86) - const WCHAR * resourceName = W("CLRDEBUGINFOWINDOWSX86"); - #endif - - #if !defined (HOST_WINDOWS) && defined(HOST_X86) - const WCHAR * resourceName = W("CLRDEBUGINFOCORESYSX86"); - #endif - - #if defined (HOST_WINDOWS) && defined(HOST_AMD64) - const WCHAR * resourceName = W("CLRDEBUGINFOWINDOWSAMD64"); - #endif - - #if !defined (HOST_WINDOWS) && defined(HOST_AMD64) - const WCHAR * resourceName = W("CLRDEBUGINFOCORESYSAMD64"); - #endif - - #if defined (HOST_WINDOWS) && defined(HOST_ARM64) - const WCHAR * resourceName = W("CLRDEBUGINFOWINDOWSARM64"); - #endif - - #if !defined (HOST_WINDOWS) && defined(HOST_ARM64) - const WCHAR * resourceName = W("CLRDEBUGINFOCORESYSARM64"); - #endif - - #if defined (HOST_WINDOWS) && defined(HOST_ARM) - const WCHAR * resourceName = W("CLRDEBUGINFOWINDOWSARM"); - #endif - - #if !defined (HOST_WINDOWS) && defined(HOST_ARM) - const WCHAR * resourceName = W("CLRDEBUGINFOCORESYSARM"); - #endif - - hrGetResource = GetResourceRvaFromResourceSectionRvaByName(pDataTarget, moduleBaseAddress, resourceSectionRVA, 10, resourceName, 0, &debugResourceRVA, &debugResourceSize); + HRESULT hrGetResource = GetResourceRvaFromResourceSectionRvaByName(pDataTarget, moduleBaseAddress, resourceSectionRVA, 10, CLRDEBUGINFO_RESOURCE_NAME, 0, &debugResourceRVA, &debugResourceSize); useCrossPlatformNaming = SUCCEEDED(hrGetResource); #if defined(HOST_WINDOWS) && (defined(HOST_X86) || defined(HOST_AMD64) || defined(HOST_ARM) || defined(HOST_ARM64)) diff --git a/src/dbgshim/debugshim.h b/src/dbgshim/debugshim.h index 2d5d556b02..8346258d5c 100644 --- a/src/dbgshim/debugshim.h +++ b/src/dbgshim/debugshim.h @@ -17,6 +17,31 @@ #include <metahost.h> #include "runtimeinfo.h" +#if defined (HOST_WINDOWS) && defined(HOST_X86) +#define CLRDEBUGINFO_RESOURCE_NAME W("CLRDEBUGINFOWINDOWSX86") +#endif +#if !defined (HOST_WINDOWS) && defined(HOST_X86) +#define CLRDEBUGINFO_RESOURCE_NAME W("CLRDEBUGINFOCORESYSX86") +#endif +#if defined (HOST_WINDOWS) && defined(HOST_AMD64) +#define CLRDEBUGINFO_RESOURCE_NAME W("CLRDEBUGINFOWINDOWSAMD64") +#endif +#if !defined (HOST_WINDOWS) && defined(HOST_AMD64) +#define CLRDEBUGINFO_RESOURCE_NAME W("CLRDEBUGINFOCORESYSAMD64") +#endif +#if defined (HOST_WINDOWS) && defined(HOST_ARM64) +#define CLRDEBUGINFO_RESOURCE_NAME W("CLRDEBUGINFOWINDOWSARM64") +#endif +#if !defined (HOST_WINDOWS) && defined(HOST_ARM64) +#define CLRDEBUGINFO_RESOURCE_NAME W("CLRDEBUGINFOCORESYSARM64") +#endif +#if defined (HOST_WINDOWS) && defined(HOST_ARM) +#define CLRDEBUGINFO_RESOURCE_NAME W("CLRDEBUGINFOWINDOWSARM") +#endif +#if !defined (HOST_WINDOWS) && defined(HOST_ARM) +#define CLRDEBUGINFO_RESOURCE_NAME W("CLRDEBUGINFOCORESYSARM") +#endif + #define CORECLR_DAC_MODULE_NAME_W W("mscordaccore") #define CLR_DAC_MODULE_NAME_W W("mscordacwks") #define MAIN_DBI_MODULE_NAME_W W("mscordbi") diff --git a/src/dbgshim/pkg/Directory.Build.props b/src/dbgshim/pkg/Directory.Build.props index f013850303..4b12ff819e 100644 --- a/src/dbgshim/pkg/Directory.Build.props +++ b/src/dbgshim/pkg/Directory.Build.props @@ -1,43 +1,18 @@ <Project> <Import Project="$(MSBuildThisFileDirectory)..\..\Directory.Build.props"/> + <PropertyGroup> <IsShipping>true</IsShipping> <NoPackageAnalysis>true</NoPackageAnalysis> <PackageDescription>Internal implementation package not meant for direct consumption. Please do not reference directly.</PackageDescription> + <ExeSuffix Condition="$(PackageRID.StartsWith('win'))">.exe</ExeSuffix> + <OsFolderName Condition="$(PackageRID.StartsWith('win'))">Windows_NT</OsFolderName> + <OsFolderName Condition="$(PackageRID.StartsWith('linux-musl'))">Linux-musl</OsFolderName> + <OsFolderName Condition="$(PackageRID.StartsWith('linux')) and '$(OsFolderName)' == ''">Linux</OsFolderName> + <OsFolderName Condition="$(PackageRID.StartsWith('osx'))">OSX</OsFolderName> </PropertyGroup> - <Choose> - <When Condition="$(OutputRid.StartsWith('win'))"> - <PropertyGroup> - <OsFolderName>Windows_NT</OsFolderName> - <ExeSuffix>.exe</ExeSuffix> - <LibSuffix>.dll</LibSuffix> - <StaticLibSuffix>.lib</StaticLibSuffix> - <SymbolsSuffix>.pdb</SymbolsSuffix> - </PropertyGroup> - </When> - <When Condition="$(OutputRid.StartsWith('osx'))"> - <PropertyGroup> - <OsFolderName>OSX</OsFolderName> - <LibPrefix>lib</LibPrefix> - <LibSuffix>.dylib</LibSuffix> - <StaticLibSuffix>.a</StaticLibSuffix> - <SymbolsSuffix>.dwarf</SymbolsSuffix> - </PropertyGroup> - </When> - <Otherwise> - <PropertyGroup> - <OsFolderName>Linux</OsFolderName> - <OsFolderName Condition="$(OutputRid.StartsWith('linux-musl'))">Linux-musl</OsFolderName> - <LibPrefix>lib</LibPrefix> - <LibSuffix>.so</LibSuffix> - <StaticLibSuffix>.a</StaticLibSuffix> - <SymbolsSuffix>.dbg</SymbolsSuffix> - </PropertyGroup> - </Otherwise> - </Choose> - <PropertyGroup> - <NativeBinDir>$(ArtifactsBinDir)\$(OsFolderName).$(PackageArch).$(Configuration)\</NativeBinDir> + <NativeBinDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', '$(OsFolderName).$(PackageArch).$(Configuration)'))</NativeBinDir> </PropertyGroup> </Project> diff --git a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-arm.proj b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-arm.proj index 039146be0d..fb228f6235 100644 --- a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-arm.proj +++ b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-arm.proj @@ -1,6 +1,6 @@ <Project> <PropertyGroup> - <OutputRid>linux-arm</OutputRid> + <PackageRID>linux-arm</PackageRID> <PackageArch>arm</PackageArch> </PropertyGroup> <Import Project="Microsoft.Diagnostics.DbgShim.props" /> diff --git a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-arm64.proj b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-arm64.proj index bc7268cfd1..d9f61eef3f 100644 --- a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-arm64.proj +++ b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-arm64.proj @@ -1,6 +1,6 @@ <Project> <PropertyGroup> - <OutputRid>linux-arm64</OutputRid> + <PackageRID>linux-arm64</PackageRID> <PackageArch>arm64</PackageArch> </PropertyGroup> <Import Project="Microsoft.Diagnostics.DbgShim.props" /> diff --git a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-musl-arm64.proj b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-musl-arm64.proj index f0ed0b096b..17aa3f3358 100644 --- a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-musl-arm64.proj +++ b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-musl-arm64.proj @@ -1,7 +1,7 @@ <Project> <PropertyGroup> - <OutputRid>linux-musl-x64</OutputRid> - <PackageArch>x64</PackageArch> + <PackageRID>linux-musl-arm64</PackageRID> + <PackageArch>arm64</PackageArch> </PropertyGroup> <Import Project="Microsoft.Diagnostics.DbgShim.props" /> </Project> diff --git a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-musl-x64.proj b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-musl-x64.proj index f0ed0b096b..6bae66704c 100644 --- a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-musl-x64.proj +++ b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-musl-x64.proj @@ -1,6 +1,6 @@ <Project> <PropertyGroup> - <OutputRid>linux-musl-x64</OutputRid> + <PackageRID>linux-musl-x64</PackageRID> <PackageArch>x64</PackageArch> </PropertyGroup> <Import Project="Microsoft.Diagnostics.DbgShim.props" /> diff --git a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-x64.proj b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-x64.proj index b68d4f6e35..26e2c04e0c 100644 --- a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-x64.proj +++ b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.linux-x64.proj @@ -1,6 +1,6 @@ <Project> <PropertyGroup> - <OutputRid>linux-x64</OutputRid> + <PackageRID>linux-x64</PackageRID> <PackageArch>x64</PackageArch> </PropertyGroup> <Import Project="Microsoft.Diagnostics.DbgShim.props" /> diff --git a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.osx-arm64.proj b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.osx-arm64.proj index 1db7896ba8..0aed728885 100644 --- a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.osx-arm64.proj +++ b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.osx-arm64.proj @@ -1,6 +1,6 @@ <Project> <PropertyGroup> - <OutputRid>osx-arm64</OutputRid> + <PackageRID>osx-arm64</PackageRID> <PackageArch>arm64</PackageArch> </PropertyGroup> <Import Project="Microsoft.Diagnostics.DbgShim.props" /> diff --git a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.osx-x64.proj b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.osx-x64.proj index 8e7c9ec48b..127cc45a18 100644 --- a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.osx-x64.proj +++ b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.osx-x64.proj @@ -1,6 +1,6 @@ <Project> <PropertyGroup> - <OutputRid>osx-x64</OutputRid> + <PackageRID>osx-x64</PackageRID> <PackageArch>x64</PackageArch> </PropertyGroup> <Import Project="Microsoft.Diagnostics.DbgShim.props" /> diff --git a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.props b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.props index cf15af8c84..9c22d95636 100644 --- a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.props +++ b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.props @@ -3,7 +3,7 @@ <TargetFramework>netstandard2.0</TargetFramework> <SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking> <!-- IncludeBuildOutput needs to be set to true to make NuGet include the passed in debug symbol files. --> - <IncludeBuildOutput>false</IncludeBuildOutput> + <IncludeBuildOutput>true</IncludeBuildOutput> <IncludeSymbols>true</IncludeSymbols> <IsPackable>true</IsPackable> <AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder>$(SymbolsSuffix)</AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder> @@ -16,20 +16,22 @@ <ItemGroup> <None Include="$(NativeBinDir)$(LibPrefix)dbgshim$(LibSuffix)" - PackagePath="runtimes/$(OutputRid)/native" + PackagePath="runtimes/$(PackageRID)/native" Pack="true" /> </ItemGroup> <Target Name="AddRuntimeSpecificNativeSymbolToPackage"> - <ItemGroup> - <TfmSpecificDebugSymbolsFile Condition="$(OutputRid.StartsWith('win'))" - Include="$(NativeBinDir)PDB\$(LibPrefix)dbgshim$(SymbolsSuffix)" - TargetPath="/runtimes/$(OutputRid)/native" - TargetFramework="$(TargetFramework)" /> + <PropertyGroup> + <_SymbolFilePath>$([MSBuild]::NormalizePath('$(NativeBinDir)', '$(LibPrefix)dbgshim$(LibSuffix)$(SymbolsSuffix)'))</_SymbolFilePath> + <_SymbolFilePath Condition="$(PackageRID.StartsWith('win'))">$([MSBuild]::NormalizePath('$(NativeBinDir)', 'PDB', '$(LibPrefix)dbgshim$(SymbolsSuffix)'))</_SymbolFilePath> + </PropertyGroup> - <TfmSpecificDebugSymbolsFile Condition="!$(OutputRid.StartsWith('win'))" - Include="$(NativeBinDir)$(LibPrefix)dbgshim$(LibSuffix)$(SymbolsSuffix)" - TargetPath="/runtimes/$(OutputRid)/native" + <Error Condition="!Exists('$(_SymbolFilePath)')" + Text="Symbol file to package not found at: $(_SymbolFilePath)"/> + + <ItemGroup> + <TfmSpecificDebugSymbolsFile Include="$(_SymbolFilePath)" + TargetPath="/runtimes/$(PackageRID)/native" TargetFramework="$(TargetFramework)" /> </ItemGroup> </Target> diff --git a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.win-arm.proj b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.win-arm.proj index a017c118c4..d64f6f71d1 100644 --- a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.win-arm.proj +++ b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.win-arm.proj @@ -1,6 +1,6 @@ <Project> <PropertyGroup> - <OutputRid>win-arm</OutputRid> + <PackageRID>win-arm</PackageRID> <PackageArch>arm</PackageArch> </PropertyGroup> <Import Project="Microsoft.Diagnostics.DbgShim.props" /> diff --git a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.win-arm64.proj b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.win-arm64.proj index 07c9fc387a..ea85c3329b 100644 --- a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.win-arm64.proj +++ b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.win-arm64.proj @@ -1,6 +1,6 @@ <Project> <PropertyGroup> - <OutputRid>win-arm64</OutputRid> + <PackageRID>win-arm64</PackageRID> <PackageArch>arm64</PackageArch> </PropertyGroup> <Import Project="Microsoft.Diagnostics.DbgShim.props" /> diff --git a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.win-x64.proj b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.win-x64.proj index 87f3cef758..a3a610fe05 100644 --- a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.win-x64.proj +++ b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.win-x64.proj @@ -1,6 +1,6 @@ <Project> <PropertyGroup> - <OutputRid>win-x64</OutputRid> + <PackageRID>win-x64</PackageRID> <PackageArch>x64</PackageArch> </PropertyGroup> <Import Project="Microsoft.Diagnostics.DbgShim.props" /> diff --git a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.win-x86.proj b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.win-x86.proj index a3699b17e9..07cfcee8da 100644 --- a/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.win-x86.proj +++ b/src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.win-x86.proj @@ -1,6 +1,6 @@ <Project> <PropertyGroup> - <OutputRid>win-x86</OutputRid> + <PackageRID>win-x86</PackageRID> <PackageArch>x86</PackageArch> </PropertyGroup> <Import Project="Microsoft.Diagnostics.DbgShim.props" /> diff --git a/src/dbgshim/pkg/microsoft.diagnostics.dbgshim.linux-musl-arm.proj b/src/dbgshim/pkg/microsoft.diagnostics.dbgshim.linux-musl-arm.proj new file mode 100644 index 0000000000..89a1074b9b --- /dev/null +++ b/src/dbgshim/pkg/microsoft.diagnostics.dbgshim.linux-musl-arm.proj @@ -0,0 +1,7 @@ +<Project> + <PropertyGroup> + <PackageRID>linux-musl-arm</PackageRID> + <PackageArch>arm</PackageArch> + </PropertyGroup> + <Import Project="Microsoft.Diagnostics.DbgShim.props" /> +</Project> diff --git a/src/shared/dbgutil/dbgutil.vcxproj b/src/shared/dbgutil/dbgutil.vcxproj index d2eb25746b..d783d06dc2 100644 --- a/src/shared/dbgutil/dbgutil.vcxproj +++ b/src/shared/dbgutil/dbgutil.vcxproj @@ -112,7 +112,7 @@ <StringPooling>true</StringPooling> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4640</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4640</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UndefinePreprocessorDefinitions>_MT</UndefinePreprocessorDefinitions> @@ -172,7 +172,7 @@ <StringPooling>true</StringPooling> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4640</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4640</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UndefinePreprocessorDefinitions>_MT</UndefinePreprocessorDefinitions> @@ -228,7 +228,7 @@ <StringPooling>true</StringPooling> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4640</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4640</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UndefinePreprocessorDefinitions>_MT</UndefinePreprocessorDefinitions> @@ -286,7 +286,7 @@ <StringPooling>true</StringPooling> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4640</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4640</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UndefinePreprocessorDefinitions>_MT</UndefinePreprocessorDefinitions> diff --git a/src/shared/dbgutil/elfreader.cpp b/src/shared/dbgutil/elfreader.cpp index 0848b3f3fd..f01d8a5611 100644 --- a/src/shared/dbgutil/elfreader.cpp +++ b/src/shared/dbgutil/elfreader.cpp @@ -103,7 +103,7 @@ class ElfReaderFromFile : public ElfReader { return false; } - if (PAL_fseek(m_file, (LONG)address, SEEK_SET) != 0) + if (PAL_fseek(m_file, (LONG_PTR)address, SEEK_SET) != 0) { return false; } diff --git a/src/shared/gcdump/gcdump.vcxproj b/src/shared/gcdump/gcdump.vcxproj index 23d2a3ab99..298ca74072 100644 --- a/src/shared/gcdump/gcdump.vcxproj +++ b/src/shared/gcdump/gcdump.vcxproj @@ -107,7 +107,7 @@ <StringPooling>true</StringPooling> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4640</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4640</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UndefinePreprocessorDefinitions>_MT</UndefinePreprocessorDefinitions> @@ -167,7 +167,7 @@ <StringPooling>true</StringPooling> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4640</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4640</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UndefinePreprocessorDefinitions>_MT</UndefinePreprocessorDefinitions> @@ -223,7 +223,7 @@ <StringPooling>true</StringPooling> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4640</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4640</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UndefinePreprocessorDefinitions>_MT</UndefinePreprocessorDefinitions> @@ -281,7 +281,7 @@ <StringPooling>true</StringPooling> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4640</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4640</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UndefinePreprocessorDefinitions>_MT</UndefinePreprocessorDefinitions> diff --git a/src/shared/inc/clrdata.idl b/src/shared/inc/clrdata.idl index 0ce58c6fa7..2663a7b057 100644 --- a/src/shared/inc/clrdata.idl +++ b/src/shared/inc/clrdata.idl @@ -25,6 +25,7 @@ import "unknwn.idl"; interface ICLRDataEnumMemoryRegions; interface ICLRDataEnumMemoryRegionsCallback; interface ICLRDataEnumMemoryRegionsCallback2; +interface ICLRDataEnumMemoryRegionsCallback3; interface ICLRDataTarget; interface ICLRDataTarget2; interface ICLRMetadataLocator; @@ -287,6 +288,20 @@ interface ICLRDataEnumMemoryRegionsCallback2 : ICLRDataEnumMemoryRegionsCallback [in, size_is(bufferSize)] BYTE* buffer); } +/* + * Optional callback interface for logging EnumMemoryRegions operations and errors. + */ +[ + object, + local, + uuid(F315248D-8B79-49DB-B184-37426559F703) +] +interface ICLRDataLoggingCallback : IUnknown +{ + HRESULT LogMessage( + [in] LPCSTR message); +} + /* * Flags for controlling which memory regions are enumerated. */ diff --git a/src/shared/inc/dumpcommon.h b/src/shared/inc/dumpcommon.h new file mode 100644 index 0000000000..83a0f447c4 --- /dev/null +++ b/src/shared/inc/dumpcommon.h @@ -0,0 +1,136 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#ifndef DEBUGGER_DUMPCOMMON_H +#define DEBUGGER_DUMPCOMMON_H + +#ifdef HOST_UNIX +typedef enum _MINIDUMP_TYPE { + MiniDumpNormal = 0x00000000, + MiniDumpWithDataSegs = 0x00000001, + MiniDumpWithFullMemory = 0x00000002, + MiniDumpWithHandleData = 0x00000004, + MiniDumpFilterMemory = 0x00000008, + MiniDumpScanMemory = 0x00000010, + MiniDumpWithUnloadedModules = 0x00000020, + MiniDumpWithIndirectlyReferencedMemory = 0x00000040, + MiniDumpFilterModulePaths = 0x00000080, + MiniDumpWithProcessThreadData = 0x00000100, + MiniDumpWithPrivateReadWriteMemory = 0x00000200, + MiniDumpWithoutOptionalData = 0x00000400, + MiniDumpWithFullMemoryInfo = 0x00000800, + MiniDumpWithThreadInfo = 0x00001000, + MiniDumpWithCodeSegs = 0x00002000, + MiniDumpWithoutAuxiliaryState = 0x00004000, + MiniDumpWithFullAuxiliaryState = 0x00008000, + MiniDumpWithPrivateWriteCopyMemory = 0x00010000, + MiniDumpIgnoreInaccessibleMemory = 0x00020000, + MiniDumpWithTokenInformation = 0x00040000, + MiniDumpWithModuleHeaders = 0x00080000, + MiniDumpFilterTriage = 0x00100000, + MiniDumpWithAvxXStateContext = 0x00200000, + MiniDumpValidTypeFlags = 0x003fffff, +} MINIDUMP_TYPE; +#endif // HOST_UNIX + +#if defined(DACCESS_COMPILE) || defined(RIGHT_SIDE_COMPILE) + +// When debugging against minidumps, we frequently need to ignore errors +// due to the dump not having memory content. +// You should be VERY careful using these macros. Because our code does not +// distinguish target types, when you allow memory to be missing because a dump +// target may not have that memory content by-design you are also implicitly +// allowing that same data to be missing from a live debugging target. +// Also, be aware that these macros exist in code under vm\. You must be careful to +// only allow them to change execution for DAC and DBI. +// Be careful state is such that execution can continue if the target is missing +// memory. +// In general, there are two solutions to this problem: +// a) add the memory to all minidumps +// b) stop forcing the memory to always be present +// All decisions between a & b focus on cost. For a, cost is adding the memory & a complete +// path to locate it to the dump, both in terms of dump generation time and most +// especially in terms of dump size (we cannot make MiniDumpNormal many MB for trivial +// apps). +// For b, cost is that we lose some of our validation when we have to turn off asserts +// and other checks for targets that should always have the missing memory present +// because we have no concept of allowing it to be missing only from a dump. + +// This seemingly awkward try block starting tag is so that when the macro is used over +// multiple source lines we don't create a useless try/catch block. This is important +// when using the macros in vm\ code. +#define EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY EX_TRY +#define EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY \ + EX_CATCH \ + { \ + if ((GET_EXCEPTION()->GetHR() != HRESULT_FROM_WIN32(ERROR_PARTIAL_COPY)) && \ + (GET_EXCEPTION()->GetHR() != CORDBG_E_READVIRTUAL_FAILURE) ) \ + { \ + EX_RETHROW; \ + } \ + } \ + EX_END_CATCH(SwallowAllExceptions) + +#define EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY_WITH_HANDLER EX_TRY +#define EX_CATCH_ALLOW_DATATARGET_MISSING_MEMORY_WITH_HANDLER \ + EX_CATCH \ + { \ + if ((GET_EXCEPTION()->GetHR() != HRESULT_FROM_WIN32(ERROR_PARTIAL_COPY)) && \ + (GET_EXCEPTION()->GetHR() != CORDBG_E_READVIRTUAL_FAILURE) ) \ + { \ + EX_RETHROW; \ + } \ + else \ + +#define EX_TRY_ALLOW_DATATARGET_MISSING_OR_INCONSISTENT_MEMORY EX_TRY +#define EX_END_CATCH_ALLOW_DATATARGET_MISSING_OR_INCONSISTENT_MEMORY \ + EX_CATCH \ + { \ + if ((GET_EXCEPTION()->GetHR() != HRESULT_FROM_WIN32(ERROR_PARTIAL_COPY)) && \ + (GET_EXCEPTION()->GetHR() != CORDBG_E_READVIRTUAL_FAILURE) && \ + (GET_EXCEPTION()->GetHR() != CORDBG_E_TARGET_INCONSISTENT)) \ + { \ + EX_RETHROW; \ + } \ + } \ + EX_END_CATCH(SwallowAllExceptions) + + +#define EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY_WITH_HANDLER \ + } \ + EX_END_CATCH(SwallowAllExceptions) + +// Only use this version for wrapping single source lines, or you'll make debugging +// painful. +#define ALLOW_DATATARGET_MISSING_MEMORY(sourceCode) \ + EX_TRY \ + { \ + sourceCode \ + } \ + EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY + +#define ALLOW_DATATARGET_MISSING_OR_INCONSISTENT_MEMORY(sourceCode) \ + EX_TRY \ + { \ + sourceCode \ + } \ + EX_END_CATCH_ALLOW_DATATARGET_MISSING_OR_INCONSISTENT_MEMORY + +#else +#define EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY +#define EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY +#define EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY_WITH_HANDLER \ + #error This macro is only intended for use in DAC code! +#define EX_CATCH_ALLOW_DATATARGET_MISSING_MEMORY_WITH_HANDLER \ + #error This macro is only intended for use in DAC code! +#define EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY_WITH_HANDLER \ + #error This macro is only intended for use in DAC code! + + +#define ALLOW_DATATARGET_MISSING_MEMORY(sourceCode) \ + sourceCode + +#endif // defined(DACCESS_COMPILE) || defined(RIGHT_SIDE_COMPILE) + + +#endif //DEBUGGER_DUMPCOMMON_H diff --git a/src/shared/inc/gcdesc.h b/src/shared/inc/gcdesc.h index 9b461a701a..2a9ca3529d 100644 --- a/src/shared/inc/gcdesc.h +++ b/src/shared/inc/gcdesc.h @@ -161,8 +161,6 @@ class CGCDesc // If it doesn't contain pointers, there isn't a GCDesc PTR_MethodTable mt(pMT); - _ASSERTE(mt->ContainsPointers()); - return PTR_CGCDesc(mt); } diff --git a/src/shared/pal/prebuilt/idl/clrdata_i.cpp b/src/shared/pal/prebuilt/idl/clrdata_i.cpp index 7d6b61a14f..26d36c133b 100644 --- a/src/shared/pal/prebuilt/idl/clrdata_i.cpp +++ b/src/shared/pal/prebuilt/idl/clrdata_i.cpp @@ -6,11 +6,9 @@ /* link this file in with the server and any clients */ - /* File created by MIDL compiler version 8.01.0622 */ -/* at Mon Jan 18 19:14:07 2038 - */ -/* Compiler settings for C:/ssd/runtime/src/coreclr/inc/clrdata.idl: - Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.01.0622 + /* File created by MIDL compiler version 8.01.0626 */ +/* Compiler settings for clrdata.idl: + Oicf, W1, Zp8, env=Win64 (32b run), target_arch=AMD64 8.01.0626 protocol : dce , ms_ext, c_ext, robust error checks: allocation ref bounds_check enum stub_data VC __declspec() decoration level: @@ -89,6 +87,9 @@ MIDL_DEFINE_GUID(IID, IID_ICLRDataEnumMemoryRegionsCallback,0xBCDD6908,0xBA2D,0x MIDL_DEFINE_GUID(IID, IID_ICLRDataEnumMemoryRegionsCallback2,0x3721A26F,0x8B91,0x4D98,0xA3,0x88,0xDB,0x17,0xB3,0x56,0xFA,0xDB); +MIDL_DEFINE_GUID(IID, IID_ICLRDataLoggingCallback,0xF315248D,0x8B79,0x49DB,0xB1,0x84,0x37,0x42,0x65,0x59,0xF7,0x03); + + MIDL_DEFINE_GUID(IID, IID_ICLRDataEnumMemoryRegions,0x471c35b4,0x7c2f,0x4ef0,0xa9,0x45,0x00,0xf8,0xc3,0x80,0x56,0xf1); #undef MIDL_DEFINE_GUID diff --git a/src/shared/pal/prebuilt/inc/clrdata.h b/src/shared/pal/prebuilt/inc/clrdata.h index 29f72974c5..802c34a87b 100644 --- a/src/shared/pal/prebuilt/inc/clrdata.h +++ b/src/shared/pal/prebuilt/inc/clrdata.h @@ -4,11 +4,9 @@ /* this ALWAYS GENERATED file contains the definitions for the interfaces */ - /* File created by MIDL compiler version 8.01.0622 */ -/* at Mon Jan 18 19:14:07 2038 - */ -/* Compiler settings for C:/ssd/runtime/src/coreclr/inc/clrdata.idl: - Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.01.0622 + /* File created by MIDL compiler version 8.01.0626 */ +/* Compiler settings for clrdata.idl: + Oicf, W1, Zp8, env=Win64 (32b run), target_arch=AMD64 8.01.0626 protocol : dce , ms_ext, c_ext, robust error checks: allocation ref bounds_check enum stub_data VC __declspec() decoration level: @@ -44,6 +42,14 @@ #pragma once #endif +#ifndef DECLSPEC_XFGVIRT +#if _CONTROL_FLOW_GUARD_XFG +#define DECLSPEC_XFGVIRT(base, func) __declspec(xfg_virtual(base, func)) +#else +#define DECLSPEC_XFGVIRT(base, func) +#endif +#endif + /* Forward Declarations */ #ifndef __ICLRDataTarget_FWD_DEFINED__ @@ -95,6 +101,13 @@ typedef interface ICLRDataEnumMemoryRegionsCallback2 ICLRDataEnumMemoryRegionsCa #endif /* __ICLRDataEnumMemoryRegionsCallback2_FWD_DEFINED__ */ +#ifndef __ICLRDataLoggingCallback_FWD_DEFINED__ +#define __ICLRDataLoggingCallback_FWD_DEFINED__ +typedef interface ICLRDataLoggingCallback ICLRDataLoggingCallback; + +#endif /* __ICLRDataLoggingCallback_FWD_DEFINED__ */ + + #ifndef __ICLRDataEnumMemoryRegions_FWD_DEFINED__ #define __ICLRDataEnumMemoryRegions_FWD_DEFINED__ typedef interface ICLRDataEnumMemoryRegions ICLRDataEnumMemoryRegions; @@ -119,6 +132,7 @@ extern "C"{ + typedef ULONG64 CLRDATA_ADDRESS; STDAPI CLRDataCreateInstance(REFIID iid, ICLRDataTarget* target, void** iface); @@ -205,31 +219,38 @@ EXTERN_C const IID IID_ICLRDataTarget; { BEGIN_INTERFACE + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) HRESULT ( STDMETHODCALLTYPE *QueryInterface )( ICLRDataTarget * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); + DECLSPEC_XFGVIRT(IUnknown, AddRef) ULONG ( STDMETHODCALLTYPE *AddRef )( ICLRDataTarget * This); + DECLSPEC_XFGVIRT(IUnknown, Release) ULONG ( STDMETHODCALLTYPE *Release )( ICLRDataTarget * This); + DECLSPEC_XFGVIRT(ICLRDataTarget, GetMachineType) HRESULT ( STDMETHODCALLTYPE *GetMachineType )( ICLRDataTarget * This, /* [out] */ ULONG32 *machineType); + DECLSPEC_XFGVIRT(ICLRDataTarget, GetPointerSize) HRESULT ( STDMETHODCALLTYPE *GetPointerSize )( ICLRDataTarget * This, /* [out] */ ULONG32 *pointerSize); + DECLSPEC_XFGVIRT(ICLRDataTarget, GetImageBase) HRESULT ( STDMETHODCALLTYPE *GetImageBase )( ICLRDataTarget * This, /* [string][in] */ LPCWSTR imagePath, /* [out] */ CLRDATA_ADDRESS *baseAddress); + DECLSPEC_XFGVIRT(ICLRDataTarget, ReadVirtual) HRESULT ( STDMETHODCALLTYPE *ReadVirtual )( ICLRDataTarget * This, /* [in] */ CLRDATA_ADDRESS address, @@ -237,6 +258,7 @@ EXTERN_C const IID IID_ICLRDataTarget; /* [in] */ ULONG32 bytesRequested, /* [out] */ ULONG32 *bytesRead); + DECLSPEC_XFGVIRT(ICLRDataTarget, WriteVirtual) HRESULT ( STDMETHODCALLTYPE *WriteVirtual )( ICLRDataTarget * This, /* [in] */ CLRDATA_ADDRESS address, @@ -244,22 +266,26 @@ EXTERN_C const IID IID_ICLRDataTarget; /* [in] */ ULONG32 bytesRequested, /* [out] */ ULONG32 *bytesWritten); + DECLSPEC_XFGVIRT(ICLRDataTarget, GetTLSValue) HRESULT ( STDMETHODCALLTYPE *GetTLSValue )( ICLRDataTarget * This, /* [in] */ ULONG32 threadID, /* [in] */ ULONG32 index, /* [out] */ CLRDATA_ADDRESS *value); + DECLSPEC_XFGVIRT(ICLRDataTarget, SetTLSValue) HRESULT ( STDMETHODCALLTYPE *SetTLSValue )( ICLRDataTarget * This, /* [in] */ ULONG32 threadID, /* [in] */ ULONG32 index, /* [in] */ CLRDATA_ADDRESS value); + DECLSPEC_XFGVIRT(ICLRDataTarget, GetCurrentThreadID) HRESULT ( STDMETHODCALLTYPE *GetCurrentThreadID )( ICLRDataTarget * This, /* [out] */ ULONG32 *threadID); + DECLSPEC_XFGVIRT(ICLRDataTarget, GetThreadContext) HRESULT ( STDMETHODCALLTYPE *GetThreadContext )( ICLRDataTarget * This, /* [in] */ ULONG32 threadID, @@ -267,12 +293,14 @@ EXTERN_C const IID IID_ICLRDataTarget; /* [in] */ ULONG32 contextSize, /* [size_is][out] */ BYTE *context); + DECLSPEC_XFGVIRT(ICLRDataTarget, SetThreadContext) HRESULT ( STDMETHODCALLTYPE *SetThreadContext )( ICLRDataTarget * This, /* [in] */ ULONG32 threadID, /* [in] */ ULONG32 contextSize, /* [size_is][in] */ BYTE *context); + DECLSPEC_XFGVIRT(ICLRDataTarget, Request) HRESULT ( STDMETHODCALLTYPE *Request )( ICLRDataTarget * This, /* [in] */ ULONG32 reqCode, @@ -384,31 +412,38 @@ EXTERN_C const IID IID_ICLRDataTarget2; { BEGIN_INTERFACE + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) HRESULT ( STDMETHODCALLTYPE *QueryInterface )( ICLRDataTarget2 * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); + DECLSPEC_XFGVIRT(IUnknown, AddRef) ULONG ( STDMETHODCALLTYPE *AddRef )( ICLRDataTarget2 * This); + DECLSPEC_XFGVIRT(IUnknown, Release) ULONG ( STDMETHODCALLTYPE *Release )( ICLRDataTarget2 * This); + DECLSPEC_XFGVIRT(ICLRDataTarget, GetMachineType) HRESULT ( STDMETHODCALLTYPE *GetMachineType )( ICLRDataTarget2 * This, /* [out] */ ULONG32 *machineType); + DECLSPEC_XFGVIRT(ICLRDataTarget, GetPointerSize) HRESULT ( STDMETHODCALLTYPE *GetPointerSize )( ICLRDataTarget2 * This, /* [out] */ ULONG32 *pointerSize); + DECLSPEC_XFGVIRT(ICLRDataTarget, GetImageBase) HRESULT ( STDMETHODCALLTYPE *GetImageBase )( ICLRDataTarget2 * This, /* [string][in] */ LPCWSTR imagePath, /* [out] */ CLRDATA_ADDRESS *baseAddress); + DECLSPEC_XFGVIRT(ICLRDataTarget, ReadVirtual) HRESULT ( STDMETHODCALLTYPE *ReadVirtual )( ICLRDataTarget2 * This, /* [in] */ CLRDATA_ADDRESS address, @@ -416,6 +451,7 @@ EXTERN_C const IID IID_ICLRDataTarget2; /* [in] */ ULONG32 bytesRequested, /* [out] */ ULONG32 *bytesRead); + DECLSPEC_XFGVIRT(ICLRDataTarget, WriteVirtual) HRESULT ( STDMETHODCALLTYPE *WriteVirtual )( ICLRDataTarget2 * This, /* [in] */ CLRDATA_ADDRESS address, @@ -423,22 +459,26 @@ EXTERN_C const IID IID_ICLRDataTarget2; /* [in] */ ULONG32 bytesRequested, /* [out] */ ULONG32 *bytesWritten); + DECLSPEC_XFGVIRT(ICLRDataTarget, GetTLSValue) HRESULT ( STDMETHODCALLTYPE *GetTLSValue )( ICLRDataTarget2 * This, /* [in] */ ULONG32 threadID, /* [in] */ ULONG32 index, /* [out] */ CLRDATA_ADDRESS *value); + DECLSPEC_XFGVIRT(ICLRDataTarget, SetTLSValue) HRESULT ( STDMETHODCALLTYPE *SetTLSValue )( ICLRDataTarget2 * This, /* [in] */ ULONG32 threadID, /* [in] */ ULONG32 index, /* [in] */ CLRDATA_ADDRESS value); + DECLSPEC_XFGVIRT(ICLRDataTarget, GetCurrentThreadID) HRESULT ( STDMETHODCALLTYPE *GetCurrentThreadID )( ICLRDataTarget2 * This, /* [out] */ ULONG32 *threadID); + DECLSPEC_XFGVIRT(ICLRDataTarget, GetThreadContext) HRESULT ( STDMETHODCALLTYPE *GetThreadContext )( ICLRDataTarget2 * This, /* [in] */ ULONG32 threadID, @@ -446,12 +486,14 @@ EXTERN_C const IID IID_ICLRDataTarget2; /* [in] */ ULONG32 contextSize, /* [size_is][out] */ BYTE *context); + DECLSPEC_XFGVIRT(ICLRDataTarget, SetThreadContext) HRESULT ( STDMETHODCALLTYPE *SetThreadContext )( ICLRDataTarget2 * This, /* [in] */ ULONG32 threadID, /* [in] */ ULONG32 contextSize, /* [size_is][in] */ BYTE *context); + DECLSPEC_XFGVIRT(ICLRDataTarget, Request) HRESULT ( STDMETHODCALLTYPE *Request )( ICLRDataTarget2 * This, /* [in] */ ULONG32 reqCode, @@ -460,6 +502,7 @@ EXTERN_C const IID IID_ICLRDataTarget2; /* [in] */ ULONG32 outBufferSize, /* [size_is][out] */ BYTE *outBuffer); + DECLSPEC_XFGVIRT(ICLRDataTarget2, AllocVirtual) HRESULT ( STDMETHODCALLTYPE *AllocVirtual )( ICLRDataTarget2 * This, /* [in] */ CLRDATA_ADDRESS addr, @@ -468,6 +511,7 @@ EXTERN_C const IID IID_ICLRDataTarget2; /* [in] */ ULONG32 protectFlags, /* [out] */ CLRDATA_ADDRESS *virt); + DECLSPEC_XFGVIRT(ICLRDataTarget2, FreeVirtual) HRESULT ( STDMETHODCALLTYPE *FreeVirtual )( ICLRDataTarget2 * This, /* [in] */ CLRDATA_ADDRESS addr, @@ -585,31 +629,38 @@ EXTERN_C const IID IID_ICLRDataTarget3; { BEGIN_INTERFACE + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) HRESULT ( STDMETHODCALLTYPE *QueryInterface )( ICLRDataTarget3 * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); + DECLSPEC_XFGVIRT(IUnknown, AddRef) ULONG ( STDMETHODCALLTYPE *AddRef )( ICLRDataTarget3 * This); + DECLSPEC_XFGVIRT(IUnknown, Release) ULONG ( STDMETHODCALLTYPE *Release )( ICLRDataTarget3 * This); + DECLSPEC_XFGVIRT(ICLRDataTarget, GetMachineType) HRESULT ( STDMETHODCALLTYPE *GetMachineType )( ICLRDataTarget3 * This, /* [out] */ ULONG32 *machineType); + DECLSPEC_XFGVIRT(ICLRDataTarget, GetPointerSize) HRESULT ( STDMETHODCALLTYPE *GetPointerSize )( ICLRDataTarget3 * This, /* [out] */ ULONG32 *pointerSize); + DECLSPEC_XFGVIRT(ICLRDataTarget, GetImageBase) HRESULT ( STDMETHODCALLTYPE *GetImageBase )( ICLRDataTarget3 * This, /* [string][in] */ LPCWSTR imagePath, /* [out] */ CLRDATA_ADDRESS *baseAddress); + DECLSPEC_XFGVIRT(ICLRDataTarget, ReadVirtual) HRESULT ( STDMETHODCALLTYPE *ReadVirtual )( ICLRDataTarget3 * This, /* [in] */ CLRDATA_ADDRESS address, @@ -617,6 +668,7 @@ EXTERN_C const IID IID_ICLRDataTarget3; /* [in] */ ULONG32 bytesRequested, /* [out] */ ULONG32 *bytesRead); + DECLSPEC_XFGVIRT(ICLRDataTarget, WriteVirtual) HRESULT ( STDMETHODCALLTYPE *WriteVirtual )( ICLRDataTarget3 * This, /* [in] */ CLRDATA_ADDRESS address, @@ -624,22 +676,26 @@ EXTERN_C const IID IID_ICLRDataTarget3; /* [in] */ ULONG32 bytesRequested, /* [out] */ ULONG32 *bytesWritten); + DECLSPEC_XFGVIRT(ICLRDataTarget, GetTLSValue) HRESULT ( STDMETHODCALLTYPE *GetTLSValue )( ICLRDataTarget3 * This, /* [in] */ ULONG32 threadID, /* [in] */ ULONG32 index, /* [out] */ CLRDATA_ADDRESS *value); + DECLSPEC_XFGVIRT(ICLRDataTarget, SetTLSValue) HRESULT ( STDMETHODCALLTYPE *SetTLSValue )( ICLRDataTarget3 * This, /* [in] */ ULONG32 threadID, /* [in] */ ULONG32 index, /* [in] */ CLRDATA_ADDRESS value); + DECLSPEC_XFGVIRT(ICLRDataTarget, GetCurrentThreadID) HRESULT ( STDMETHODCALLTYPE *GetCurrentThreadID )( ICLRDataTarget3 * This, /* [out] */ ULONG32 *threadID); + DECLSPEC_XFGVIRT(ICLRDataTarget, GetThreadContext) HRESULT ( STDMETHODCALLTYPE *GetThreadContext )( ICLRDataTarget3 * This, /* [in] */ ULONG32 threadID, @@ -647,12 +703,14 @@ EXTERN_C const IID IID_ICLRDataTarget3; /* [in] */ ULONG32 contextSize, /* [size_is][out] */ BYTE *context); + DECLSPEC_XFGVIRT(ICLRDataTarget, SetThreadContext) HRESULT ( STDMETHODCALLTYPE *SetThreadContext )( ICLRDataTarget3 * This, /* [in] */ ULONG32 threadID, /* [in] */ ULONG32 contextSize, /* [size_is][in] */ BYTE *context); + DECLSPEC_XFGVIRT(ICLRDataTarget, Request) HRESULT ( STDMETHODCALLTYPE *Request )( ICLRDataTarget3 * This, /* [in] */ ULONG32 reqCode, @@ -661,6 +719,7 @@ EXTERN_C const IID IID_ICLRDataTarget3; /* [in] */ ULONG32 outBufferSize, /* [size_is][out] */ BYTE *outBuffer); + DECLSPEC_XFGVIRT(ICLRDataTarget2, AllocVirtual) HRESULT ( STDMETHODCALLTYPE *AllocVirtual )( ICLRDataTarget3 * This, /* [in] */ CLRDATA_ADDRESS addr, @@ -669,24 +728,28 @@ EXTERN_C const IID IID_ICLRDataTarget3; /* [in] */ ULONG32 protectFlags, /* [out] */ CLRDATA_ADDRESS *virt); + DECLSPEC_XFGVIRT(ICLRDataTarget2, FreeVirtual) HRESULT ( STDMETHODCALLTYPE *FreeVirtual )( ICLRDataTarget3 * This, /* [in] */ CLRDATA_ADDRESS addr, /* [in] */ ULONG32 size, /* [in] */ ULONG32 typeFlags); + DECLSPEC_XFGVIRT(ICLRDataTarget3, GetExceptionRecord) HRESULT ( STDMETHODCALLTYPE *GetExceptionRecord )( ICLRDataTarget3 * This, /* [in] */ ULONG32 bufferSize, /* [out] */ ULONG32 *bufferUsed, /* [size_is][out] */ BYTE *buffer); + DECLSPEC_XFGVIRT(ICLRDataTarget3, GetExceptionContextRecord) HRESULT ( STDMETHODCALLTYPE *GetExceptionContextRecord )( ICLRDataTarget3 * This, /* [in] */ ULONG32 bufferSize, /* [out] */ ULONG32 *bufferUsed, /* [size_is][out] */ BYTE *buffer); + DECLSPEC_XFGVIRT(ICLRDataTarget3, GetExceptionThreadID) HRESULT ( STDMETHODCALLTYPE *GetExceptionThreadID )( ICLRDataTarget3 * This, /* [out] */ ULONG32 *threadID); @@ -802,18 +865,22 @@ EXTERN_C const IID IID_ICLRRuntimeLocator; { BEGIN_INTERFACE + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) HRESULT ( STDMETHODCALLTYPE *QueryInterface )( ICLRRuntimeLocator * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); + DECLSPEC_XFGVIRT(IUnknown, AddRef) ULONG ( STDMETHODCALLTYPE *AddRef )( ICLRRuntimeLocator * This); + DECLSPEC_XFGVIRT(IUnknown, Release) ULONG ( STDMETHODCALLTYPE *Release )( ICLRRuntimeLocator * This); + DECLSPEC_XFGVIRT(ICLRRuntimeLocator, GetRuntimeBase) HRESULT ( STDMETHODCALLTYPE *GetRuntimeBase )( ICLRRuntimeLocator * This, /* [out] */ CLRDATA_ADDRESS *baseAddress); @@ -890,18 +957,22 @@ EXTERN_C const IID IID_ICLRMetadataLocator; { BEGIN_INTERFACE + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) HRESULT ( STDMETHODCALLTYPE *QueryInterface )( ICLRMetadataLocator * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); + DECLSPEC_XFGVIRT(IUnknown, AddRef) ULONG ( STDMETHODCALLTYPE *AddRef )( ICLRMetadataLocator * This); + DECLSPEC_XFGVIRT(IUnknown, Release) ULONG ( STDMETHODCALLTYPE *Release )( ICLRMetadataLocator * This); + DECLSPEC_XFGVIRT(ICLRMetadataLocator, GetMetadata) HRESULT ( STDMETHODCALLTYPE *GetMetadata )( ICLRMetadataLocator * This, /* [in] */ LPCWSTR imagePath, @@ -979,18 +1050,22 @@ EXTERN_C const IID IID_ICLRDataEnumMemoryRegionsCallback; { BEGIN_INTERFACE + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) HRESULT ( STDMETHODCALLTYPE *QueryInterface )( ICLRDataEnumMemoryRegionsCallback * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); + DECLSPEC_XFGVIRT(IUnknown, AddRef) ULONG ( STDMETHODCALLTYPE *AddRef )( ICLRDataEnumMemoryRegionsCallback * This); + DECLSPEC_XFGVIRT(IUnknown, Release) ULONG ( STDMETHODCALLTYPE *Release )( ICLRDataEnumMemoryRegionsCallback * This); + DECLSPEC_XFGVIRT(ICLRDataEnumMemoryRegionsCallback, EnumMemoryRegion) HRESULT ( STDMETHODCALLTYPE *EnumMemoryRegion )( ICLRDataEnumMemoryRegionsCallback * This, /* [in] */ CLRDATA_ADDRESS address, @@ -1062,23 +1137,28 @@ EXTERN_C const IID IID_ICLRDataEnumMemoryRegionsCallback2; { BEGIN_INTERFACE + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) HRESULT ( STDMETHODCALLTYPE *QueryInterface )( ICLRDataEnumMemoryRegionsCallback2 * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); + DECLSPEC_XFGVIRT(IUnknown, AddRef) ULONG ( STDMETHODCALLTYPE *AddRef )( ICLRDataEnumMemoryRegionsCallback2 * This); + DECLSPEC_XFGVIRT(IUnknown, Release) ULONG ( STDMETHODCALLTYPE *Release )( ICLRDataEnumMemoryRegionsCallback2 * This); + DECLSPEC_XFGVIRT(ICLRDataEnumMemoryRegionsCallback, EnumMemoryRegion) HRESULT ( STDMETHODCALLTYPE *EnumMemoryRegion )( ICLRDataEnumMemoryRegionsCallback2 * This, /* [in] */ CLRDATA_ADDRESS address, /* [in] */ ULONG32 size); + DECLSPEC_XFGVIRT(ICLRDataEnumMemoryRegionsCallback2, UpdateMemoryRegion) HRESULT ( STDMETHODCALLTYPE *UpdateMemoryRegion )( ICLRDataEnumMemoryRegionsCallback2 * This, /* [in] */ CLRDATA_ADDRESS address, @@ -1126,7 +1206,91 @@ EXTERN_C const IID IID_ICLRDataEnumMemoryRegionsCallback2; #endif /* __ICLRDataEnumMemoryRegionsCallback2_INTERFACE_DEFINED__ */ -/* interface __MIDL_itf_clrdata_0000_0007 */ +#ifndef __ICLRDataLoggingCallback_INTERFACE_DEFINED__ +#define __ICLRDataLoggingCallback_INTERFACE_DEFINED__ + +/* interface ICLRDataLoggingCallback */ +/* [uuid][local][object] */ + + +EXTERN_C const IID IID_ICLRDataLoggingCallback; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("F315248D-8B79-49DB-B184-37426559F703") + ICLRDataLoggingCallback : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE LogMessage( + /* [in] */ LPCSTR message) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ICLRDataLoggingCallbackVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ICLRDataLoggingCallback * This, + /* [in] */ REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ICLRDataLoggingCallback * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ICLRDataLoggingCallback * This); + + DECLSPEC_XFGVIRT(ICLRDataLoggingCallback, LogMessage) + HRESULT ( STDMETHODCALLTYPE *LogMessage )( + ICLRDataLoggingCallback * This, + /* [in] */ LPCSTR message); + + END_INTERFACE + } ICLRDataLoggingCallbackVtbl; + + interface ICLRDataLoggingCallback + { + CONST_VTBL struct ICLRDataLoggingCallbackVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ICLRDataLoggingCallback_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ICLRDataLoggingCallback_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ICLRDataLoggingCallback_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ICLRDataLoggingCallback_LogMessage(This,message) \ + ( (This)->lpVtbl -> LogMessage(This,message) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ICLRDataLoggingCallback_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_clrdata_0000_0008 */ /* [local] */ typedef @@ -1135,13 +1299,14 @@ enum CLRDataEnumMemoryFlags CLRDATA_ENUM_MEM_DEFAULT = 0, CLRDATA_ENUM_MEM_MINI = CLRDATA_ENUM_MEM_DEFAULT, CLRDATA_ENUM_MEM_HEAP = 0x1, - CLRDATA_ENUM_MEM_TRIAGE = 0x2 + CLRDATA_ENUM_MEM_TRIAGE = 0x2, + CLRDATA_ENUM_MEM_HEAP2 = 0x3 } CLRDataEnumMemoryFlags; -extern RPC_IF_HANDLE __MIDL_itf_clrdata_0000_0007_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_clrdata_0000_0007_v0_0_s_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_clrdata_0000_0008_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_clrdata_0000_0008_v0_0_s_ifspec; #ifndef __ICLRDataEnumMemoryRegions_INTERFACE_DEFINED__ #define __ICLRDataEnumMemoryRegions_INTERFACE_DEFINED__ @@ -1172,18 +1337,22 @@ EXTERN_C const IID IID_ICLRDataEnumMemoryRegions; { BEGIN_INTERFACE + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) HRESULT ( STDMETHODCALLTYPE *QueryInterface )( ICLRDataEnumMemoryRegions * This, /* [in] */ REFIID riid, /* [annotation][iid_is][out] */ _COM_Outptr_ void **ppvObject); + DECLSPEC_XFGVIRT(IUnknown, AddRef) ULONG ( STDMETHODCALLTYPE *AddRef )( ICLRDataEnumMemoryRegions * This); + DECLSPEC_XFGVIRT(IUnknown, Release) ULONG ( STDMETHODCALLTYPE *Release )( ICLRDataEnumMemoryRegions * This); + DECLSPEC_XFGVIRT(ICLRDataEnumMemoryRegions, EnumMemoryRegions) HRESULT ( STDMETHODCALLTYPE *EnumMemoryRegions )( ICLRDataEnumMemoryRegions * This, /* [in] */ ICLRDataEnumMemoryRegionsCallback *callback, diff --git a/src/shared/palrt/bstr.cpp b/src/shared/palrt/bstr.cpp index 2f5ccd9cd4..93c1da7743 100644 --- a/src/shared/palrt/bstr.cpp +++ b/src/shared/palrt/bstr.cpp @@ -47,7 +47,7 @@ inline HRESULT CbSysStringSize(ULONG cchSize, BOOL isByteLen, ULONG *result) else { ULONG temp = 0; // should not use in-place addition in ULongAdd - if (SUCCEEDED(ULongMult(cchSize, sizeof(WCHAR), &temp)) & + if (SUCCEEDED(ULongMult(cchSize, sizeof(WCHAR), &temp)) && SUCCEEDED(ULongAdd(temp, constant, result))) { *result = *result & ~WIN32_ALLOC_ALIGN; diff --git a/src/shared/utilcode/utilcode.vcxproj b/src/shared/utilcode/utilcode.vcxproj index 0d53d34f27..c06ce671b3 100644 --- a/src/shared/utilcode/utilcode.vcxproj +++ b/src/shared/utilcode/utilcode.vcxproj @@ -102,7 +102,7 @@ <RuntimeTypeInfo>false</RuntimeTypeInfo> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4007;4013;4102;4551;4700;4640;4806</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4007;4013;4102;4551;4700;4640;4806</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UseFullPaths>true</UseFullPaths> @@ -158,7 +158,7 @@ <RuntimeTypeInfo>false</RuntimeTypeInfo> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4007;4013;4102;4551;4700;4640;4806</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4007;4013;4102;4551;4700;4640;4806</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UseFullPaths>true</UseFullPaths> @@ -211,7 +211,7 @@ <RuntimeTypeInfo>false</RuntimeTypeInfo> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4007;4013;4102;4551;4700;4640;4806</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4007;4013;4102;4551;4700;4640;4806</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UseFullPaths>true</UseFullPaths> @@ -266,7 +266,7 @@ <RuntimeTypeInfo>false</RuntimeTypeInfo> <StructMemberAlignment>8Bytes</StructMemberAlignment> <SuppressStartupBanner>true</SuppressStartupBanner> - <TreatSpecificWarningsAsErrors>4007;4013;4102;4551;4700;4640;4806</TreatSpecificWarningsAsErrors> + <TreatSpecificWarningsAsErrors>$(TreatSpecificWarningsAsErrors);4007;4013;4102;4551;4700;4640;4806</TreatSpecificWarningsAsErrors> <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <TreatWarningAsError>true</TreatWarningAsError> <UseFullPaths>true</UseFullPaths> diff --git a/src/sos-packaging.props b/src/sos-packaging.props index 9ad7d04685..7ca956b59d 100644 --- a/src/sos-packaging.props +++ b/src/sos-packaging.props @@ -40,6 +40,10 @@ <SosRequiredBinaries Include="$(ArtifactsBinDir)\Linux-musl.arm64.$(Configuration)\libsos.so" TargetRid="linux-musl-arm64" /> <SosRequiredBinaries Include="$(ArtifactsBinDir)\Linux-musl.arm64.$(Configuration)\sosdocsunix.txt" TargetRid="linux-musl-arm64" /> + <SosRequiredBinaries Include="$(ArtifactsBinDir)\Linux-musl.arm.$(Configuration)\libsosplugin.so" TargetRid="linux-musl-arm" /> + <SosRequiredBinaries Include="$(ArtifactsBinDir)\Linux-musl.arm.$(Configuration)\libsos.so" TargetRid="linux-musl-arm" /> + <SosRequiredBinaries Include="$(ArtifactsBinDir)\Linux-musl.arm.$(Configuration)\sosdocsunix.txt" TargetRid="linux-musl-arm" /> + <SosRequiredBinaries Include="$(ArtifactsBinDir)\OSX.x64.$(Configuration)\libsosplugin.dylib" TargetRid="osx-x64" /> <SosRequiredBinaries Include="$(ArtifactsBinDir)\OSX.x64.$(Configuration)\libsos.dylib" TargetRid="osx-x64" /> <SosRequiredBinaries Include="$(ArtifactsBinDir)\OSX.x64.$(Configuration)\sosdocsunix.txt" TargetRid="osx-x64" /> diff --git a/src/tests/CommonTestRunner/CommonTestRunner.csproj b/src/tests/CommonTestRunner/CommonTestRunner.csproj new file mode 100644 index 0000000000..1f5b049fdf --- /dev/null +++ b/src/tests/CommonTestRunner/CommonTestRunner.csproj @@ -0,0 +1,51 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <TargetFramework>netcoreapp3.1</TargetFramework> + <CommonTestRunnerConfigFileName>$(OutputPath)$(TargetFramework)\Debugger.Tests.Common.txt</CommonTestRunnerConfigFileName> + </PropertyGroup> + + <ItemGroup> + <ProjectReference Include="$(MSBuildThisFileDirectory)..\..\Microsoft.Diagnostics.TestHelpers\Microsoft.Diagnostics.TestHelpers.csproj" /> + </ItemGroup> + + <ItemGroup> + <Content Include="$(MSBuildThisFileDirectory)ConfigFiles\Windows\Debugger.Tests.Config.txt" Condition="'$(OS)' == 'Windows_NT'"> + <Link>Debugger.Tests.Config.txt</Link> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="$(MSBuildThisFileDirectory)ConfigFiles\Unix\Debugger.Tests.Config.txt" Condition="$(OS) == 'Unix'"> + <Link>Debugger.Tests.Config.txt</Link> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="$(CommonTestRunnerConfigFileName)"> + <Link>Debugger.Tests.Common.txt</Link> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + </ItemGroup> + + <ItemGroup> + <ConfigFileEntries Include="Entries"> + <ConfigFileEntry> +<![CDATA[ +<Configuration> + <TargetConfiguration>$(Configuration)</TargetConfiguration> + <RepoRootDir>$(RepoRoot)</RepoRootDir> +</Configuration> +]]> + </ConfigFileEntry> + </ConfigFileEntries> + </ItemGroup> + + <Target Name="CommonTestRunnerWriteTestConfigFile" Outputs="$(CommonTestRunnerConfigFileName)" AfterTargets="Build"> + <PropertyGroup> + <TestConfigFileLines>@(ConfigFileEntries->Metadata("ConfigFileEntry"))</TestConfigFileLines> + </PropertyGroup> + <WriteLinesToFile File="$(CommonTestRunnerConfigFileName)" Lines="$(TestConfigFileLines)" Overwrite="true" WriteOnlyWhenDifferent="true" /> + <Message Importance="High" Text="Created config file $(CommonTestRunnerConfigFileName)" /> + <ItemGroup> + <FileWrites Include="$(CommonTestRunnerConfigFileName)" /> + </ItemGroup> + </Target> + +</Project> diff --git a/src/tests/CommonTestRunner/ConfigFiles/Unix/Debugger.Tests.Config.txt b/src/tests/CommonTestRunner/ConfigFiles/Unix/Debugger.Tests.Config.txt new file mode 100644 index 0000000000..1518328255 --- /dev/null +++ b/src/tests/CommonTestRunner/ConfigFiles/Unix/Debugger.Tests.Config.txt @@ -0,0 +1,54 @@ +<Configuration> + <Import ConfigFile="Debugger.Tests.Common.txt" /> + <DotNetRoot>$(RepoRootDir)/.dotnet-test</DotNetRoot> + <Import ConfigFile="$(DotNetRoot)/Debugger.Tests.Versions.txt" /> + + <RootBinDir>$(RepoRootDir)/artifacts</RootBinDir> + <InstallDir>$(RootBinDir)/bin/$(OS).$(TargetArchitecture).$(TargetConfiguration)</InstallDir> + <LogDir>$(RootBinDir)/TestResults/$(TargetConfiguration)/common.unittests_$(Timestamp)</LogDir> + + <!-- Build the debuggee for this framework version but run it on latest --> + <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '7')">net7.0</BuildProjectFrameworkLatest> + <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '6')">net6.0</BuildProjectFrameworkLatest> + <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '5')">net5.0</BuildProjectFrameworkLatest> + <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '3.1')">netcoreapp3.1</BuildProjectFrameworkLatest> + + <TestProduct>ProjectK</TestProduct> + <DebuggeeSourceRoot>$(RepoRootDir)/src/tests</DebuggeeSourceRoot> + <DebuggeeBuildProcess>cli</DebuggeeBuildProcess> + <DebuggeeBuildProcess>sdk.prebuilt</DebuggeeBuildProcess> + <DebuggeeBuildRoot>$(RootBinDir)</DebuggeeBuildRoot> + + <CliPath>$(DotNetRoot)/dotnet</CliPath> + + <NuGetPackageFeeds> + dotnet6=https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet6/nuget/v3/index.json; + dotnet-core=https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json; + dotnet-public=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json + </NuGetPackageFeeds> + + <Options> + <!-- + Default (prebuilt) + --> + <Option Condition="'$(RuntimeVersionLatest)' != ''"> + <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework> + <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion> + </Option> + <Option Condition="'$(RuntimeVersion60)' != ''"> + <BuildProjectFramework>net6.0</BuildProjectFramework> + <RuntimeFrameworkVersion>$(RuntimeVersion60)</RuntimeFrameworkVersion> + </Option> + <Option Condition="'$(RuntimeVersion31)' != ''"> + <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework> + <RuntimeFrameworkVersion>$(RuntimeVersion31)</RuntimeFrameworkVersion> + </Option> + </Options> + + <!-- Single-file debuggees don't need the host --> + <HostExe Condition="'$(PublishSingleFile)' != 'true'">$(DotNetRoot)/dotnet</HostExe> + <HostArgs Condition="'$(PublishSingleFile)' != 'true'">--fx-version $(RuntimeFrameworkVersion)</HostArgs> + + <DotNetTraceHost>$(DotNetRoot)/dotnet</DotNetTraceHost> + <DotNetTracePath>$(RootBinDir)/bin/dotnet-trace/$(TargetConfiguration)/netcoreapp3.1/dotnet-trace.dll</DotNetTracePath> +</Configuration> diff --git a/src/tests/CommonTestRunner/ConfigFiles/Windows/Debugger.Tests.Config.txt b/src/tests/CommonTestRunner/ConfigFiles/Windows/Debugger.Tests.Config.txt new file mode 100644 index 0000000000..fc0ad14297 --- /dev/null +++ b/src/tests/CommonTestRunner/ConfigFiles/Windows/Debugger.Tests.Config.txt @@ -0,0 +1,53 @@ +<Configuration> + <Import ConfigFile="Debugger.Tests.Common.txt" /> + <DotNetRoot Condition="'$(TargetArchitecture)' != 'x86'">$(RepoRootDir)\.dotnet-test</DotNetRoot> + <DotNetRoot Condition="'$(TargetArchitecture)' == 'x86'">$(RepoRootDir)\.dotnet-test\x86</DotNetRoot> + <Import ConfigFile="$(DotNetRoot)\Debugger.Tests.Versions.txt" /> + + <RootBinDir>$(RepoRootDir)\artifacts</RootBinDir> + <InstallDir>$(RootBinDir)\bin\Windows_NT.$(TargetArchitecture).$(TargetConfiguration)</InstallDir> + <LogDir>$(RootBinDir)\TestResults\$(TargetConfiguration)\common.unittests_$(Timestamp)</LogDir> + + <!-- Build the debuggee for this framework version but run it on latest --> + <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '7')">net7.0</BuildProjectFrameworkLatest> + <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '6')">net6.0</BuildProjectFrameworkLatest> + <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '5')">net5.0</BuildProjectFrameworkLatest> + <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '3.1')">netcoreapp3.1</BuildProjectFrameworkLatest> + + <TestProduct>ProjectK</TestProduct> + <DebuggeeSourceRoot>$(RepoRootDir)\src\tests</DebuggeeSourceRoot> + <DebuggeeBuildProcess>sdk.prebuilt</DebuggeeBuildProcess> + <DebuggeeBuildRoot>$(RootBinDir)</DebuggeeBuildRoot> + <CliPath>$(DotNetRoot)\dotnet.exe</CliPath> + + <NuGetPackageFeeds> + dotnet6=https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet6/nuget/v3/index.json; + dotnet-core=https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json; + dotnet-public=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json + </NuGetPackageFeeds> + + <Options> + <!-- + Default (prebuilt) + --> + <Option Condition="'$(RuntimeVersionLatest)' != ''"> + <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework> + <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion> + </Option> + <Option Condition="'$(RuntimeVersion60)' != ''"> + <BuildProjectFramework>net6.0</BuildProjectFramework> + <RuntimeFrameworkVersion>$(RuntimeVersion60)</RuntimeFrameworkVersion> + </Option> + <Option Condition="'$(RuntimeVersion31)' != ''"> + <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework> + <RuntimeFrameworkVersion>$(RuntimeVersion31)</RuntimeFrameworkVersion> + </Option> + </Options> + + <!-- Single-file debuggees don't need the host --> + <HostExe Condition="'$(PublishSingleFile)' != 'true'">$(DotNetRoot)\dotnet.exe</HostExe> + <HostArgs Condition="'$(PublishSingleFile)' != 'true'">--fx-version $(RuntimeFrameworkVersion)</HostArgs> + + <DotNetTraceHost>$(DotNetRoot)\dotnet.exe</DotNetTraceHost> + <DotNetTracePath>$(RootBinDir)\bin\dotnet-trace\$(TargetConfiguration)\netcoreapp3.1\dotnet-trace.dll</DotNetTracePath> +</Configuration> diff --git a/src/tests/Microsoft.Diagnostics.NETCore.Client/DiagnosticPortsHelper.cs b/src/tests/CommonTestRunner/DiagnosticPortsHelper.cs similarity index 92% rename from src/tests/Microsoft.Diagnostics.NETCore.Client/DiagnosticPortsHelper.cs rename to src/tests/CommonTestRunner/DiagnosticPortsHelper.cs index c5b3122790..3abb327a32 100644 --- a/src/tests/Microsoft.Diagnostics.NETCore.Client/DiagnosticPortsHelper.cs +++ b/src/tests/CommonTestRunner/DiagnosticPortsHelper.cs @@ -4,11 +4,10 @@ using System.IO; using System.Runtime.InteropServices; -using Xunit.Abstractions; -namespace Microsoft.Diagnostics.NETCore.Client +namespace Microsoft.Diagnostics.CommonTestRunner { - internal static class DiagnosticPortsHelper + public static class DiagnosticPortsHelper { private const string DiagnosticPortsEnvName = "DOTNET_DiagnosticPorts"; private const string DefaultDiagnosticPortSuspendEnvName = "DOTNET_DefaultDiagnosticPortSuspend"; diff --git a/src/tests/CommonTestRunner/TestRunner.cs b/src/tests/CommonTestRunner/TestRunner.cs new file mode 100644 index 0000000000..0837a05e86 --- /dev/null +++ b/src/tests/CommonTestRunner/TestRunner.cs @@ -0,0 +1,342 @@ +// 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 Microsoft.Diagnostics.TestHelpers; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.IO; +using System.IO.Pipes; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Xunit.Abstractions; + +namespace Microsoft.Diagnostics.CommonTestRunner +{ + public class TestRunner : IAsyncDisposable + { + private static readonly string _timeFormat = "mm\\:ss\\.fff"; + private readonly ITestOutputHelper _outputHelper; + private readonly ProcessRunner _runner; + private readonly DateTime _startTime; + private readonly NamedPipeServerStream _pipeServer; + + static TestRunner() + { + TestConfiguration.BaseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + } + + public static IEnumerable<object[]> Configurations => GetConfigurations("TestName", null); + + public static IEnumerable<object[]> GetConfigurations(string key, string value) + { + return TestRunConfiguration.Instance.Configurations.Where((c) => key == null || c.AllSettings.GetValueOrDefault(key) == value).Select(c => new[] { c }); + } + + public static async Task<TestRunner> Create(TestConfiguration config, ITestOutputHelper outputHelper, string testExeName, string testArguments = null, bool usePipe = true) + { + Debug.Assert(config != null); + Debug.Assert(outputHelper != null); + Debug.Assert(testExeName != null); + + // Restore and build the debuggee. + DebuggeeConfiguration debuggeeConfig = await DebuggeeCompiler.Execute(config, testExeName, outputHelper); + + // Get the full debuggee launch command line (includes the host if required) + string exePath = debuggeeConfig.BinaryExePath; + string pipeName = null; + + var arguments = new StringBuilder(); + var managedArguments = new StringBuilder(); + if (!string.IsNullOrWhiteSpace(config.HostExe)) + { + exePath = config.HostExe; + if (!string.IsNullOrWhiteSpace(config.HostArgs)) + { + arguments.Append(config.HostArgs); + } + managedArguments.Append(debuggeeConfig.BinaryExePath); + } + if (usePipe) + { + pipeName = Guid.NewGuid().ToString(); + managedArguments.AppendSpace(); + managedArguments.Append(pipeName); + } + if (testArguments != null) + { + managedArguments.AppendSpace(); + managedArguments.Append(testArguments); + } + arguments.AppendSpace(); + arguments.Append(managedArguments); + + // Create the native debugger process running + ProcessRunner processRunner = new ProcessRunner(exePath, arguments.ToString()). + WithEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0"). + WithEnvironmentVariable("DOTNET_ROOT", config.DotNetRoot). + WithLog(outputHelper); + + return new TestRunner(config, outputHelper, processRunner, pipeName, managedArguments.ToString()); + } + + private TestRunner(TestConfiguration config, ITestOutputHelper outputHelper, ProcessRunner runner, string pipeName, string managedArguments) + { + Configuration = config; + _outputHelper = new IndentedTestOutputHelper(outputHelper); + _runner = runner; + _startTime = DateTime.Now; + _pipeServer = pipeName is not null ? new NamedPipeServerStream(pipeName) : null; + ManagedArguments = managedArguments; + outputHelper.WriteLine($"[{_startTime}] Test runner created"); + } + + /// <summary> + /// Test configuration + /// </summary> + public TestConfiguration Configuration { get; } + + /// <summary> + /// Tracee process id + /// </summary> + public int Pid => _runner.ProcessId; + + /// <summary> + /// The host exe path + /// </summary> + public string ExePath => _runner.ExePath; + + /// <summary> + /// All the arguments including the managed program dll + /// </summary> + public string Arguments => _runner.Arguments; + + /// <summary> + /// The managed app path and the app arguments (doesn't include the host exe and host args). + /// </summary> + public string ManagedArguments { get; } + + /// <summary> + /// Add environment variable. Needs to be called before Start(). + /// </summary> + /// <param name="key">variable name</param> + /// <param name="value">value</param> + public void AddEnvVar(string key, string value) => _runner.WithEnvironmentVariable(key, value); + + /// <summary> + /// Start the tracee. + /// </summary> + /// <param name="testProcessTimeout">Cancel process/fail test after this time. Default 30 secs</param> + /// <param name="waitForTracee">Wait for tracee if true. Default true. Set to false when the process is suspended.</param> + public async Task Start(int testProcessTimeout = 30_000, bool waitForTracee = true) + { + // Set the target process time out + _runner.WithTimeout(TimeSpan.FromMilliseconds(testProcessTimeout)); + + try + { + _runner.Start(); + } + catch (Exception ex) + { + _outputHelper.WriteLine($"[{_startTime}] Could not start process: {_runner.ExePath} {ex}"); + throw; + } + WriteLine("Successfully started process"); + + if (waitForTracee) + { + await WaitForTracee(); + } + else + { + // Retry getting the module count because we can catch the process during startup and it fails temporarily. + for (int retry = 0; retry < 5; retry++) + { + try + { + WriteLine($"Have total {_runner.ModuleCount} modules loaded"); + break; + } + catch (Win32Exception) + { + } + } + + // Block until we see the IPC channel created, or until timeout specified. + try + { + var source = new CancellationTokenSource(TimeSpan.FromSeconds(15)); + await Task.Run(cancellationToken: source.Token, action: () => + { + while (true) + { + string[] matchingFiles; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + // On Windows, we wait until the named pipe is created. + matchingFiles = Directory.GetFiles(@"\\.\pipe\", $"dotnet-diagnostic-{_runner.ProcessId}*"); + } + else + { + // On Linux, we wait until the socket is created. + matchingFiles = Directory.GetFiles(Path.GetTempPath(), $"dotnet-diagnostic-{_runner.ProcessId}-*-socket"); // Try best match. + } + if (matchingFiles.Length > 0) + { + break; + } + Task.Delay(100); + } + }); + } + catch (TaskCanceledException) + { + } + } + } + + public void Stop() + { + WriteLine("Stopping"); + try + { + // Make a good will attempt to end the tracee process and its process tree + _runner.Kill(KillReason.Stopped); + } + catch (Exception ex) + { + Trace.TraceError($"Stopping {Pid} failed {ex}"); + } + } + + public void PrintStatus() + { + if (_runner.WaitForExit().IsCompleted) + { + WriteLine($"Process status: Exited 0x{_runner.ExitCode:X}"); + } + else + { + WriteLine($"Process status: Running"); + } + } + + public async Task WaitForExit(TimeSpan timeout) + { + WriteLine("WaitForExitAsync"); + Task timeoutTask = Task.Delay(timeout); + Task result = await Task.WhenAny(_runner.WaitForExit(), timeoutTask); + if (result == timeoutTask) + { + throw new TaskCanceledException($"WaitForExitAsync timed out {Pid}"); + } + WriteLine("WaitForExitAsync DONE"); + } + + public async Task WaitForTracee() + { + if (_pipeServer is not null) + { + WriteLine("WaitForTracee"); + try + { + var source = new CancellationTokenSource(TimeSpan.FromMinutes(2)); + await _pipeServer.WaitForConnectionAsync(source.Token); + WriteLine("WaitForTracee: DONE"); + } + catch (Exception ex) when (ex is TaskCanceledException || ex is OperationCanceledException) + { + WriteLine($"WaitForTracee: canceled {ex}"); + } + } + } + + public void WakeupTracee() + { + if (_pipeServer is not null) + { + WriteLine("WakeupTracee"); + try + { + _pipeServer.WriteByte(42); + } + catch (Exception ex) when (ex is IOException || ex is InvalidOperationException) + { + Trace.TraceError($"WakeupTracee {Pid} failed {ex}"); + } + WriteLine("WakeupTracee DONE"); + } + } + + public void WaitForSignal() + { + if (_pipeServer is not null) + { + WriteLine("WaitForSignal"); + try + { + int signal = _pipeServer.ReadByte(); + WriteLine($"WaitForSignal DONE {signal}"); + } + catch (Exception ex) when (ex is IOException || ex is InvalidOperationException) + { + WriteLine($"WaitForSignal failed {ex}"); + } + } + } + + public async ValueTask DisposeAsync() + { + WriteLine("Disposing"); + WakeupTracee(); + try + { + await WaitForExit(TimeSpan.FromSeconds(10)); + } + catch (TaskCanceledException) + { + WriteLine("Disposing: Did not exit within timeout period. Forcefully stopping process."); + Stop(); + } + _pipeServer?.Dispose(); + _runner.Dispose(); + } + + public void WriteLine(string message) + { + TimeSpan offset = _startTime - DateTime.Now; + _outputHelper.WriteLine($"[{offset.ToString(_timeFormat)}] {Pid} {message}"); + } + } + + public static class TestConfigExtensions + { + public static string DotNetTraceHost(this TestConfiguration config) + { + string dotnetTraceHost = config.GetValue("DotNetTraceHost"); + return TestConfiguration.MakeCanonicalPath(dotnetTraceHost); + } + + public static string DotNetTracePath(this TestConfiguration config) + { + string dotnetTracePath = config.GetValue("DotNetTracePath"); + return TestConfiguration.MakeCanonicalPath(dotnetTracePath); + } + + public static void AppendSpace(this StringBuilder sb) + { + if (sb.Length > 0) + { + sb.Append(' '); + } + } + } +} diff --git a/src/tests/DbgShim.UnitTests/ConfigFiles/Unix/Debugger.Tests.Config.txt b/src/tests/DbgShim.UnitTests/ConfigFiles/Unix/Debugger.Tests.Config.txt index e03b297ca9..8638e73682 100644 --- a/src/tests/DbgShim.UnitTests/ConfigFiles/Unix/Debugger.Tests.Config.txt +++ b/src/tests/DbgShim.UnitTests/ConfigFiles/Unix/Debugger.Tests.Config.txt @@ -7,7 +7,7 @@ <InstallDir>$(RootBinDir)/bin/$(OS).$(TargetArchitecture).$(TargetConfiguration)</InstallDir> <LogDir>$(RootBinDir)/TestResults/$(TargetConfiguration)/dbgshim.unittests_$(Timestamp)</LogDir> - <!-- Build the debuggee for this framework version but run it on latest --> + <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '7')">net7.0</BuildProjectFrameworkLatest> <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '6')">net6.0</BuildProjectFrameworkLatest> <TestProduct>ProjectK</TestProduct> @@ -22,6 +22,7 @@ <CliPath>$(DotNetRoot)/dotnet</CliPath> <NuGetPackageFeeds> + dotnet7=https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet7/nuget/v3/index.json; dotnet6=https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet6/nuget/v3/index.json; dotnet-core=https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json; dotnet-public=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json @@ -70,7 +71,7 @@ <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework> <PublishSingleFile>true</PublishSingleFile> <BuildProjectRuntime>$(TargetRid)</BuildProjectRuntime> - <RuntimeFrameworkVersion>$(SingleFileRuntimeVersion)</RuntimeFrameworkVersion> + <RuntimeFrameworkVersion>$(SingleFileRuntimeLatestVersion)</RuntimeFrameworkVersion> </Option> <!-- Default @@ -80,6 +81,11 @@ <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework> <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion> </Option> + <Option Condition="'$(RuntimeVersion60)' != ''"> + <DebuggeeBuildRoot>$(RootBinDir)\Debuggees</DebuggeeBuildRoot> + <BuildProjectFramework>net6.0</BuildProjectFramework> + <RuntimeFrameworkVersion>$(RuntimeVersion60)</RuntimeFrameworkVersion> + </Option> </Options> </Option> </Options> @@ -92,18 +98,12 @@ <Options> <Option Condition="'$(OS)' == 'Linux'"> - <!-- - <DbgShimPath>$(DotNetRoot)/shared/Microsoft.NETCore.App/$(RuntimeFrameworkVersion)/libdbgshim.so</DbgShimPath> - --> <DbgShimPath>$(InstallDir)/libdbgshim.so</DbgShimPath> <RuntimeModulePath Condition="'$(RuntimeModuleDir)' != ''">$(RuntimeModuleDir)/libcoreclr.so</RuntimeModulePath> <DbiModulePath Condition="'$(RuntimeModuleDir)' != ''">$(RuntimeModuleDir)/libmscordbi.so</DbiModulePath> <DacModulePath Condition="'$(RuntimeModuleDir)' != ''">$(RuntimeModuleDir)/libmscordaccore.so</DacModulePath> </Option> <Option Condition="'$(OS)' == 'OSX'"> - <!-- - <DbgShimPath>$(DotNetRoot)/shared/Microsoft.NETCore.App/$(RuntimeFrameworkVersion)/libdbgshim.dylib</DbgShimPath> - --> <DbgShimPath>$(InstallDir)/libdbgshim.dylib</DbgShimPath> <RuntimeModulePath Condition="'$(RuntimeModuleDir)' != ''">$(RuntimeModuleDir)/libcoreclr.dylib</RuntimeModulePath> <DbiModulePath Condition="'$(RuntimeModuleDir)' != ''">$(RuntimeModuleDir)/libmscordbi.dylib</DbiModulePath> diff --git a/src/tests/DbgShim.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt b/src/tests/DbgShim.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt index 6f23a07a95..fd6e1343ec 100644 --- a/src/tests/DbgShim.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt +++ b/src/tests/DbgShim.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt @@ -8,7 +8,7 @@ <InstallDir>$(RootBinDir)\bin\Windows_NT.$(TargetArchitecture).$(TargetConfiguration)</InstallDir> <LogDir>$(RootBinDir)\TestResults\$(TargetConfiguration)\dbgshim.unittests_$(Timestamp)</LogDir> - <!-- Build the debuggee for this framework version but run it on latest --> + <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '7')">net7.0</BuildProjectFrameworkLatest> <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '6')">net6.0</BuildProjectFrameworkLatest> <TestProduct>ProjectK</TestProduct> @@ -19,6 +19,7 @@ <CliPath>$(DotNetRoot)\dotnet.exe</CliPath> <NuGetPackageFeeds> + dotnet7=https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet7/nuget/v3/index.json; dotnet6=https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet6/nuget/v3/index.json; dotnet-core=https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json; dotnet-public=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json @@ -68,7 +69,7 @@ <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework> <PublishSingleFile>true</PublishSingleFile> <BuildProjectRuntime>$(TargetRid)</BuildProjectRuntime> - <RuntimeFrameworkVersion>$(SingleFileRuntimeVersion)</RuntimeFrameworkVersion> + <RuntimeFrameworkVersion>$(SingleFileRuntimeLatestVersion)</RuntimeFrameworkVersion> </Option> <!-- Default @@ -78,6 +79,11 @@ <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework> <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion> </Option> + <Option Condition="'$(RuntimeVersion60)' != ''"> + <DebuggeeBuildRoot>$(RootBinDir)\Debuggees</DebuggeeBuildRoot> + <BuildProjectFramework>net6.0</BuildProjectFramework> + <RuntimeFrameworkVersion>$(RuntimeVersion60)</RuntimeFrameworkVersion> + </Option> </Options> </Option> </Options> @@ -88,9 +94,6 @@ <RuntimeModuleDir>$(DotNetRoot)\shared\Microsoft.NETCore.App\$(RuntimeFrameworkVersion)</RuntimeModuleDir> - <!-- - <DbgShimPath>$(DotNetRoot)\shared\Microsoft.NETCore.App\$(RuntimeFrameworkVersion)\dbgshim.dll</DbgShimPath> - --> <DbgShimPath>$(InstallDir)\dbgshim.dll</DbgShimPath> <RuntimeModulePath Condition="'$(RuntimeModuleDir)' != ''">$(RuntimeModuleDir)\coreclr.dll</RuntimeModulePath> <DbiModulePath Condition="'$(RuntimeModuleDir)' != ''">$(RuntimeModuleDir)\mscordbi.dll</DbiModulePath> diff --git a/src/tests/DbgShim.UnitTests/DbgShimAPI.cs b/src/tests/DbgShim.UnitTests/DbgShimAPI.cs index 30a1881176..1f648441e7 100644 --- a/src/tests/DbgShim.UnitTests/DbgShimAPI.cs +++ b/src/tests/DbgShim.UnitTests/DbgShimAPI.cs @@ -113,11 +113,11 @@ public static HResult RegisterForRuntimeStartup3(int pid, string applicationGrou return hr; } - private delegate void NativeRuntimeStartupCallbackDelegate(IntPtr cordbg, IntPtr parameter, HResult hresult); + private delegate void NativeRuntimeStartupCallbackDelegate(IntPtr cordbg, IntPtr parameter, int hresult); private static IntPtr RuntimeStartupCallback(object parameter, RuntimeStartupCallbackDelegate callback, out GCHandle nativeCallbackHandle, out IntPtr nativeParameter) { - NativeRuntimeStartupCallbackDelegate native = (IntPtr cordbg, IntPtr param, HResult hresult) => { + NativeRuntimeStartupCallbackDelegate native = (IntPtr cordbg, IntPtr param, int hresult) => { GCHandle gch = GCHandle.FromIntPtr(param); callback(ICorDebug.Create(cordbg), gch.Target, hresult); gch.Free(); @@ -260,7 +260,7 @@ private static T GetDelegateFunction<T>(string functionName, bool optional = fal #region DbgShim pinvoke delegates [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError = true)] - private delegate HResult CreateProcessForLaunchDelegate( + private delegate int CreateProcessForLaunchDelegate( [MarshalAs(UnmanagedType.LPWStr)] string lpCommandLine, [MarshalAs(UnmanagedType.Bool)] bool bSuspendProcess, IntPtr lpEnvironment, @@ -269,22 +269,22 @@ private delegate HResult CreateProcessForLaunchDelegate( out IntPtr suspendHandle); [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError = true)] - private delegate HResult ResumeProcessDelegate( + private delegate int ResumeProcessDelegate( IntPtr handle); [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError = true)] - private delegate HResult CloseResumeHandleDelegate( + private delegate int CloseResumeHandleDelegate( IntPtr handle); [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate HResult RegisterForRuntimeStartupDelegate( + private delegate int RegisterForRuntimeStartupDelegate( uint processId, IntPtr callback, IntPtr parameter, out IntPtr unregisterToken); [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate HResult RegisterForRuntimeStartupExDelegate( + private delegate int RegisterForRuntimeStartupExDelegate( uint processId, [MarshalAs(UnmanagedType.LPWStr)] string applicationGroupId, IntPtr callback, @@ -292,7 +292,7 @@ private delegate HResult RegisterForRuntimeStartupExDelegate( out IntPtr unregisterToken); [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate HResult RegisterForRuntimeStartup3Delegate( + private delegate int RegisterForRuntimeStartup3Delegate( uint processId, [MarshalAs(UnmanagedType.LPWStr)] string applicationGroupId, IntPtr libraryProvider, @@ -301,24 +301,24 @@ private delegate HResult RegisterForRuntimeStartup3Delegate( out IntPtr unregisterToken); [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate HResult UnregisterForRuntimeStartupDelegate( + private delegate int UnregisterForRuntimeStartupDelegate( IntPtr unregisterToken); [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private unsafe delegate HResult EnumerateCLRsDelegate( + private unsafe delegate int EnumerateCLRsDelegate( int processId, out IntPtr* handleArray, out char** stringArray, out int arrayLength); [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private unsafe delegate HResult CloseCLREnumerationDelegate( + private unsafe delegate int CloseCLREnumerationDelegate( IntPtr* handleArray, char** stringArray, int arrayLength); [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private unsafe delegate HResult CreateVersionStringFromModuleDelegate( + private unsafe delegate int CreateVersionStringFromModuleDelegate( int processId, [MarshalAs(UnmanagedType.LPWStr)] string moduleName, char* versionString, @@ -326,25 +326,25 @@ private unsafe delegate HResult CreateVersionStringFromModuleDelegate( out int actualVersionStringLength); [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private unsafe delegate HResult CreateDebuggingInterfaceFromVersionDelegate( + private unsafe delegate int CreateDebuggingInterfaceFromVersionDelegate( [MarshalAs(UnmanagedType.LPWStr)] string versionString, out IntPtr cordbg); [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private unsafe delegate HResult CreateDebuggingInterfaceFromVersionExDelegate( + private unsafe delegate int CreateDebuggingInterfaceFromVersionExDelegate( int debuggerVersion, [MarshalAs(UnmanagedType.LPWStr)] string versionString, out IntPtr cordbg); [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private unsafe delegate HResult CreateDebuggingInterfaceFromVersion2Delegate( + private unsafe delegate int CreateDebuggingInterfaceFromVersion2Delegate( int debuggerVersion, [MarshalAs(UnmanagedType.LPWStr)] string versionString, [MarshalAs(UnmanagedType.LPWStr)] string applicationGroupId, out IntPtr cordbg); [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private unsafe delegate HResult CreateDebuggingInterfaceFromVersion3Delegate( + private unsafe delegate int CreateDebuggingInterfaceFromVersion3Delegate( int debuggerVersion, [MarshalAs(UnmanagedType.LPWStr)] string versionString, [MarshalAs(UnmanagedType.LPWStr)] string applicationGroupId, @@ -352,7 +352,7 @@ private unsafe delegate HResult CreateDebuggingInterfaceFromVersion3Delegate( out IntPtr cordbg); [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private unsafe delegate HResult CLRCreateInstanceDelegate( + private unsafe delegate int CLRCreateInstanceDelegate( in Guid clrsid, in Guid riid, out IntPtr pInterface); diff --git a/src/tests/DbgShim.UnitTests/DebuggeeInfo.cs b/src/tests/DbgShim.UnitTests/DebuggeeInfo.cs index 3ac8d3d4cd..5bcd43986b 100644 --- a/src/tests/DbgShim.UnitTests/DebuggeeInfo.cs +++ b/src/tests/DbgShim.UnitTests/DebuggeeInfo.cs @@ -77,7 +77,7 @@ public async Task<bool> WaitForDebuggee() await _pipeServer.WaitForConnectionAsync(source.Token); Trace.TraceInformation($"DebuggeeInfo.WaitForDebuggee: after wait {ProcessId}"); } - catch (OperationCanceledException ex) + catch (Exception ex) when (ex is TaskCanceledException || ex is OperationCanceledException) { Trace.TraceError($"DebuggeeInfo.WaitForDebuggee: canceled {ex}"); return false; diff --git a/src/tests/DbgShim.UnitTests/Debuggees/SimpleDebuggee/SimpleDebuggee.cs b/src/tests/DbgShim.UnitTests/Debuggees/SimpleDebuggee/SimpleDebuggee.cs index 0e870ae3e1..8be1fbab04 100644 --- a/src/tests/DbgShim.UnitTests/Debuggees/SimpleDebuggee/SimpleDebuggee.cs +++ b/src/tests/DbgShim.UnitTests/Debuggees/SimpleDebuggee/SimpleDebuggee.cs @@ -16,12 +16,11 @@ public static int Main(string[] args) { try { - int timeout = TimeSpan.FromMinutes(5).Milliseconds; using var pipeStream = new NamedPipeClientStream(pipeServerName); Console.WriteLine("{0} SimpleDebuggee: connecting to pipe", pid); Console.Out.Flush(); - pipeStream.Connect(timeout); + pipeStream.Connect((int)TimeSpan.FromMinutes(5).TotalMilliseconds); Console.WriteLine("{0} SimpleDebuggee: connected to pipe", pid); Console.Out.Flush(); diff --git a/src/tests/DbgShim.UnitTests/ICLRDebugging.cs b/src/tests/DbgShim.UnitTests/ICLRDebugging.cs index cd2ca5e87e..9d3b2b6d9a 100644 --- a/src/tests/DbgShim.UnitTests/ICLRDebugging.cs +++ b/src/tests/DbgShim.UnitTests/ICLRDebugging.cs @@ -51,7 +51,7 @@ public HResult OpenVirtualProcess( [StructLayout(LayoutKind.Sequential)] private readonly unsafe struct ICLRDebuggingVTable { - public readonly delegate* unmanaged[Stdcall]<IntPtr, ulong, IntPtr, IntPtr, in ClrDebuggingVersion, in Guid, out IntPtr, out ClrDebuggingVersion, out ClrDebuggingProcessFlags, HResult> OpenVirtualProcess; + public readonly delegate* unmanaged[Stdcall]<IntPtr, ulong, IntPtr, IntPtr, in ClrDebuggingVersion, in Guid, out IntPtr, out ClrDebuggingVersion, out ClrDebuggingProcessFlags, int> OpenVirtualProcess; } } } diff --git a/src/tests/DbgShim.UnitTests/ICorDebug.cs b/src/tests/DbgShim.UnitTests/ICorDebug.cs index 18a0fcfb41..5ba2627d95 100644 --- a/src/tests/DbgShim.UnitTests/ICorDebug.cs +++ b/src/tests/DbgShim.UnitTests/ICorDebug.cs @@ -35,12 +35,12 @@ private ICorDebug(IntPtr punk) [StructLayout(LayoutKind.Sequential)] private readonly unsafe struct ICorDebugVTable { - public readonly delegate* unmanaged[Stdcall]<IntPtr, HResult> Initialize; - public readonly delegate* unmanaged[Stdcall]<IntPtr, HResult> Terminate; - public readonly delegate* unmanaged[Stdcall]<IntPtr, IntPtr, HResult> SetManangedHandler; - public readonly delegate* unmanaged[Stdcall]<IntPtr, IntPtr, HResult> SetUnmanangedHandler; - public readonly delegate* unmanaged[Stdcall]<IntPtr, HResult> CreateProcess; - public readonly delegate* unmanaged[Stdcall]<IntPtr, int, int, out IntPtr, HResult> DebugActiveProcess; + public readonly delegate* unmanaged[Stdcall]<IntPtr, int> Initialize; + public readonly delegate* unmanaged[Stdcall]<IntPtr, int> Terminate; + public readonly delegate* unmanaged[Stdcall]<IntPtr, IntPtr, int> SetManangedHandler; + public readonly delegate* unmanaged[Stdcall]<IntPtr, IntPtr, int> SetUnmanangedHandler; + public readonly delegate* unmanaged[Stdcall]<IntPtr, int> CreateProcess; + public readonly delegate* unmanaged[Stdcall]<IntPtr, int, int, out IntPtr, int> DebugActiveProcess; } } } diff --git a/src/tests/DbgShim.UnitTests/ICorDebugController.cs b/src/tests/DbgShim.UnitTests/ICorDebugController.cs index 042b013bcf..aad6d994fe 100644 --- a/src/tests/DbgShim.UnitTests/ICorDebugController.cs +++ b/src/tests/DbgShim.UnitTests/ICorDebugController.cs @@ -35,14 +35,14 @@ private ICorDebugController(IntPtr punk) [StructLayout(LayoutKind.Sequential)] private readonly unsafe struct ICorDebugControllerVTable { - public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, HResult> Stop; - public readonly delegate* unmanaged[Stdcall]<IntPtr, int, HResult> Continue; - public readonly delegate* unmanaged[Stdcall]<IntPtr, HResult> IsRunning_dummy; - public readonly delegate* unmanaged[Stdcall]<IntPtr, HResult> HasQueuedCallbacks_dummy; - public readonly delegate* unmanaged[Stdcall]<IntPtr, HResult> EnumerateThreads_dummy; - public readonly delegate* unmanaged[Stdcall]<IntPtr, HResult> SetAllThreadsDebugState_dummy; - public readonly delegate* unmanaged[Stdcall]<IntPtr, HResult> Detach; - public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, HResult> Terminate; + public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, int> Stop; + public readonly delegate* unmanaged[Stdcall]<IntPtr, int, int> Continue; + public readonly delegate* unmanaged[Stdcall]<IntPtr, int> IsRunning_dummy; + public readonly delegate* unmanaged[Stdcall]<IntPtr, int> HasQueuedCallbacks_dummy; + public readonly delegate* unmanaged[Stdcall]<IntPtr, int> EnumerateThreads_dummy; + public readonly delegate* unmanaged[Stdcall]<IntPtr, int> SetAllThreadsDebugState_dummy; + public readonly delegate* unmanaged[Stdcall]<IntPtr, int> Detach; + public readonly delegate* unmanaged[Stdcall]<IntPtr, uint, int> Terminate; } } } diff --git a/src/tests/DbgShim.UnitTests/LibraryProviderWrapper.cs b/src/tests/DbgShim.UnitTests/LibraryProviderWrapper.cs index 63929610cd..4d92f048b5 100644 --- a/src/tests/DbgShim.UnitTests/LibraryProviderWrapper.cs +++ b/src/tests/DbgShim.UnitTests/LibraryProviderWrapper.cs @@ -83,7 +83,7 @@ protected override void Destroy() Trace.TraceInformation("LibraryProviderWrapper.Destroy"); } - private HResult ProvideLibrary( + private int ProvideLibrary( IntPtr self, string fileName, uint timeStamp, @@ -134,7 +134,7 @@ private HResult ProvideLibrary( return HResult.E_INVALIDARG; } - private HResult ProvideLibrary2( + private int ProvideLibrary2( IntPtr self, string fileName, uint timeStamp, @@ -187,7 +187,7 @@ private HResult ProvideLibrary2( return HResult.E_INVALIDARG; } - private HResult ProvideWindowsLibrary( + private int ProvideWindowsLibrary( IntPtr self, string fileName, string runtimeModulePath, @@ -243,7 +243,7 @@ private HResult ProvideWindowsLibrary( return HResult.E_INVALIDARG; } - private HResult ProvideUnixLibrary( + private int ProvideUnixLibrary( IntPtr self, string fileName, string runtimeModulePath, @@ -469,7 +469,7 @@ private ISymbolService SymbolService #region ICLRDebuggingLibraryProvider* delegates [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult ProvideLibraryDelegate( + private delegate int ProvideLibraryDelegate( [In] IntPtr self, [In, MarshalAs(UnmanagedType.LPWStr)] string fileName, [In] uint timeStamp, @@ -477,7 +477,7 @@ private delegate HResult ProvideLibraryDelegate( out IntPtr moduleHandle); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult ProvideLibrary2Delegate( + private delegate int ProvideLibrary2Delegate( [In] IntPtr self, [In, MarshalAs(UnmanagedType.LPWStr)] string fileName, [In] uint timeStamp, @@ -485,7 +485,7 @@ private delegate HResult ProvideLibrary2Delegate( out IntPtr modulePath); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult ProvideWindowsLibraryDelegate( + private delegate int ProvideWindowsLibraryDelegate( [In] IntPtr self, [In, MarshalAs(UnmanagedType.LPWStr)] string fileName, [In, MarshalAs(UnmanagedType.LPWStr)] string runtimeModulePath, @@ -495,7 +495,7 @@ private delegate HResult ProvideWindowsLibraryDelegate( out IntPtr modulePath); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult ProvideUnixLibraryDelegate( + private delegate int ProvideUnixLibraryDelegate( [In] IntPtr self, [In, MarshalAs(UnmanagedType.LPWStr)] string fileName, [In, MarshalAs(UnmanagedType.LPWStr)] string runtimeModulePath, diff --git a/src/tests/DbgShim.UnitTests/ManagedCallbackWrapper.cs b/src/tests/DbgShim.UnitTests/ManagedCallbackWrapper.cs index 75e9094ac9..36c31dd309 100644 --- a/src/tests/DbgShim.UnitTests/ManagedCallbackWrapper.cs +++ b/src/tests/DbgShim.UnitTests/ManagedCallbackWrapper.cs @@ -83,110 +83,110 @@ private HResult WriteLine(string message) #region ICorDebugManagedCallback delegates [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult BreakpointDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pBreakpoint); + private delegate int BreakpointDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pBreakpoint); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult StepCompleteDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pStepper, [In] int reason); + private delegate int StepCompleteDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pStepper, [In] int reason); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult BreakDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread); + private delegate int BreakDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult ExceptionDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] int unhandled); + private delegate int ExceptionDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] int unhandled); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult EvalCompleteDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pEval); + private delegate int EvalCompleteDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pEval); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult EvalExceptionDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pEval); + private delegate int EvalExceptionDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pEval); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult CreateProcessDelegate([In] IntPtr self, [In] IntPtr pProcess); + private delegate int CreateProcessDelegate([In] IntPtr self, [In] IntPtr pProcess); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult ExitProcessDelegate([In] IntPtr self, [In] IntPtr pProcess); + private delegate int ExitProcessDelegate([In] IntPtr self, [In] IntPtr pProcess); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult CreateThreadDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr thread); + private delegate int CreateThreadDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr thread); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult ExitThreadDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr thread); + private delegate int ExitThreadDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr thread); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult LoadModuleDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pModule); + private delegate int LoadModuleDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pModule); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult UnloadModuleDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pModule); + private delegate int UnloadModuleDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pModule); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult LoadClassDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr c); + private delegate int LoadClassDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr c); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult UnloadClassDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr c); + private delegate int UnloadClassDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr c); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult DebuggerErrorDelegate([In] IntPtr self, [In] IntPtr pProcess, [In] HResult errorHR, [In] uint errorCode); + private delegate int DebuggerErrorDelegate([In] IntPtr self, [In] IntPtr pProcess, [In] int errorHR, [In] uint errorCode); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult LogMessageDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] int lLevel, [In, MarshalAs(UnmanagedType.LPWStr)] string pLogSwitchName, [In, MarshalAs(UnmanagedType.LPWStr)] string pMessage); + private delegate int LogMessageDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] int lLevel, [In, MarshalAs(UnmanagedType.LPWStr)] string pLogSwitchName, [In, MarshalAs(UnmanagedType.LPWStr)] string pMessage); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult LogSwitchDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] int lLevel, [In] uint ulReason, [In, MarshalAs(UnmanagedType.LPWStr)] string pLogSwitchName, [In, MarshalAs(UnmanagedType.LPWStr)] string pParentName); + private delegate int LogSwitchDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] int lLevel, [In] uint ulReason, [In, MarshalAs(UnmanagedType.LPWStr)] string pLogSwitchName, [In, MarshalAs(UnmanagedType.LPWStr)] string pParentName); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult CreateAppDomainDelegate([In] IntPtr self, [In] IntPtr pProcess, [In] IntPtr pAppDomain); + private delegate int CreateAppDomainDelegate([In] IntPtr self, [In] IntPtr pProcess, [In] IntPtr pAppDomain); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult ExitAppDomainDelegate([In] IntPtr self, [In] IntPtr pProcess, [In] IntPtr pAppDomain); + private delegate int ExitAppDomainDelegate([In] IntPtr self, [In] IntPtr pProcess, [In] IntPtr pAppDomain); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult LoadAssemblyDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pAssembly); + private delegate int LoadAssemblyDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pAssembly); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult UnloadAssemblyDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pAssembly); + private delegate int UnloadAssemblyDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pAssembly); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult ControlCTrapDelegate([In] IntPtr self, [In] IntPtr pProcess); + private delegate int ControlCTrapDelegate([In] IntPtr self, [In] IntPtr pProcess); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult NameChangeDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread); + private delegate int NameChangeDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult UpdateModuleSymbolsDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pModule, [In] IntPtr pSymbolStream); + private delegate int UpdateModuleSymbolsDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pModule, [In] IntPtr pSymbolStream); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult EditAndContinueRemapDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pFunction, [In] int fAccurate); + private delegate int EditAndContinueRemapDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pFunction, [In] int fAccurate); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult BreakpointSetErrorDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pBreakpoint, [In] uint dwError); + private delegate int BreakpointSetErrorDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pBreakpoint, [In] uint dwError); #endregion #region ICorDebugManagedCallback2 delegates [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult FunctionRemapOpportunityDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pOldFunction, [In] IntPtr pNewFunction, [In] uint oldILOffset); + private delegate int FunctionRemapOpportunityDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pOldFunction, [In] IntPtr pNewFunction, [In] uint oldILOffset); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult CreateConnectionDelegate([In] IntPtr self, [In] IntPtr pProcess, [In] uint dwConnectionId, [In] ref ushort pConnName); + private delegate int CreateConnectionDelegate([In] IntPtr self, [In] IntPtr pProcess, [In] uint dwConnectionId, [In] ref ushort pConnName); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult ChangeConnectionDelegate([In] IntPtr self, [In] IntPtr pProcess, [In] uint dwConnectionId); + private delegate int ChangeConnectionDelegate([In] IntPtr self, [In] IntPtr pProcess, [In] uint dwConnectionId); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult DestroyConnectionDelegate([In] IntPtr self, [In] IntPtr pProcess, [In] uint dwConnectionId); + private delegate int DestroyConnectionDelegate([In] IntPtr self, [In] IntPtr pProcess, [In] uint dwConnectionId); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult ExceptionDelegate2([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pFrame, [In] uint nOffset, [In] int dwEventType, [In] uint dwFlags); + private delegate int ExceptionDelegate2([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pFrame, [In] uint nOffset, [In] int dwEventType, [In] uint dwFlags); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult ExceptionUnwindDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] int dwEventType, [In] uint dwFlags); + private delegate int ExceptionUnwindDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] int dwEventType, [In] uint dwFlags); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult FunctionRemapCompleteDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pFunction); + private delegate int FunctionRemapCompleteDelegate([In] IntPtr self, [In] IntPtr pAppDomain, [In] IntPtr pThread, [In] IntPtr pFunction); [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult MDANotificationDelegate([In] IntPtr self, [In] IntPtr pController, [In] IntPtr pThread, [In] IntPtr pMDA); + private delegate int MDANotificationDelegate([In] IntPtr self, [In] IntPtr pController, [In] IntPtr pThread, [In] IntPtr pMDA); #endregion } diff --git a/src/tests/Directory.Build.props b/src/tests/Directory.Build.props new file mode 100644 index 0000000000..eaf4b4e2f5 --- /dev/null +++ b/src/tests/Directory.Build.props @@ -0,0 +1,16 @@ +<Project> + <Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props"/> + + <PropertyGroup> + <BuildArch Condition="'$(BuildArch)' == ''">$(Platform)</BuildArch> + <BuildArch Condition="'$(BuildArch)' == 'AnyCpu'">$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant)</BuildArch> + + <!-- Don't run any unit tests on .NET Core 3.1 on arm64. MacOS M1 doesn't have a 3.1 SDK --> + <Enable31Testing>true</Enable31Testing> + <Enable31Testing Condition="'$(BuildArch)' == 'arm64'">false</Enable31Testing> + + <UnitTestTargetFrameworks Condition="$(Enable31Testing)">netcoreapp3.1;net6.0;net7.0</UnitTestTargetFrameworks> + <UnitTestTargetFrameworks Condition="!$(Enable31Testing)">net6.0;net7.0</UnitTestTargetFrameworks> + </PropertyGroup> + +</Project> diff --git a/src/tests/EventPipeTracee/EventPipeTracee.csproj b/src/tests/EventPipeTracee/EventPipeTracee.csproj index 1b898c05dc..0d7605719e 100644 --- a/src/tests/EventPipeTracee/EventPipeTracee.csproj +++ b/src/tests/EventPipeTracee/EventPipeTracee.csproj @@ -2,7 +2,7 @@ <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework> - <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp3.1;net5.0</TargetFrameworks> + <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp3.1;net6.0;net7.0</TargetFrameworks> </PropertyGroup> <ItemGroup> diff --git a/src/tests/EventPipeTracee/Program.cs b/src/tests/EventPipeTracee/Program.cs index 0daa16664f..752c803ea7 100644 --- a/src/tests/EventPipeTracee/Program.cs +++ b/src/tests/EventPipeTracee/Program.cs @@ -6,6 +6,8 @@ using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; +using System.Diagnostics; +using System.IO.Pipes; using System.Linq; namespace EventPipeTracee @@ -14,16 +16,29 @@ class Program { private const string AppLoggerCategoryName = "AppLoggerCategory"; - static void Main(string[] args) + public static int Main(string[] args) { - bool spinWait10 = args.Length > 1 && "SpinWait10".Equals(args[1], StringComparison.Ordinal); - TestBody(args[0], spinWait10); - } + int pid = Process.GetCurrentProcess().Id; + string pipeServerName = args.Length > 0 ? args[0] : null; + if (pipeServerName == null) + { + Console.Error.WriteLine($"{pid} EventPipeTracee: no pipe name"); + Console.Error.Flush(); + return -1; + } + using var pipeStream = new NamedPipeClientStream(pipeServerName); + bool spinWait10 = args.Length > 2 && "SpinWait10".Equals(args[2], StringComparison.Ordinal); + string loggerCategory = args[1]; - private static void TestBody(string loggerCategory, bool spinWait10) - { - Console.Error.WriteLine("Starting remote test process"); - Console.Error.Flush(); + Console.WriteLine($"{pid} EventPipeTracee: start process"); + Console.Out.Flush(); + + // Signal that the tracee has started + Console.WriteLine($"{pid} EventPipeTracee: connecting to pipe"); + Console.Out.Flush(); + pipeStream.Connect(5 * 60 * 1000); + Console.WriteLine($"{pid} EventPipeTracee: connected to pipe"); + Console.Out.Flush(); ServiceCollection serviceCollection = new ServiceCollection(); serviceCollection.AddLogging(builder => @@ -38,19 +53,20 @@ private static void TestBody(string loggerCategory, bool spinWait10) var customCategoryLogger = loggerFactory.CreateLogger(loggerCategory); var appCategoryLogger = loggerFactory.CreateLogger(AppLoggerCategoryName); - Console.Error.WriteLine($"{DateTime.UtcNow} Awaiting start"); - Console.Error.Flush(); - if (Console.Read() == -1) - { - throw new InvalidOperationException("Unable to receive start signal"); - } + Console.WriteLine($"{pid} EventPipeTracee: {DateTime.UtcNow} Awaiting start"); + Console.Out.Flush(); + + // Wait for server to send something + int input = pipeStream.ReadByte(); + + Console.WriteLine($"{pid} {DateTime.UtcNow} Starting test body '{input}'"); + Console.Out.Flush(); - Console.Error.WriteLine($"{DateTime.UtcNow} Starting test body"); - Console.Error.Flush(); TestBodyCore(customCategoryLogger, appCategoryLogger); - //Signal end of test data - Console.WriteLine("1"); + Console.WriteLine($"{pid} EventPipeTracee: signal end of test data"); + Console.Out.Flush(); + pipeStream.WriteByte(31); if (spinWait10) { @@ -62,22 +78,22 @@ private static void TestBody(string loggerCategory, bool spinWait10) acc++; if (acc % 1_000_000 == 0) { - Console.Error.WriteLine("Spin waiting..."); + Console.WriteLine($"{pid} Spin waiting..."); } } } - Console.Error.WriteLine($"{DateTime.UtcNow} Awaiting end"); - Console.Error.Flush(); - if (Console.Read() == -1) - { - throw new InvalidOperationException("Unable to receive end signal"); - } + Console.WriteLine($"{pid} {DateTime.UtcNow} Awaiting end"); + Console.Out.Flush(); + + // Wait for server to send something + input = pipeStream.ReadByte(); - Console.Error.WriteLine($"{DateTime.UtcNow} Ending remote test process"); + Console.WriteLine($"{pid} EventPipeTracee {DateTime.UtcNow} Ending remote test process '{input}'"); + return 0; } - //TODO At some point we may want parameters to choose different test bodies. + // TODO At some point we may want parameters to choose different test bodies. private static void TestBodyCore(ILogger customCategoryLogger, ILogger appCategoryLogger) { //Json data is always converted to strings for ActivityStart events. diff --git a/src/tests/ExitCodeTracee/ExitCodeTracee.csproj b/src/tests/ExitCodeTracee/ExitCodeTracee.csproj index cd0510ad22..6b634ef181 100644 --- a/src/tests/ExitCodeTracee/ExitCodeTracee.csproj +++ b/src/tests/ExitCodeTracee/ExitCodeTracee.csproj @@ -2,6 +2,6 @@ <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework> - <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp3.1;net5.0</TargetFrameworks> + <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp3.1;net6.0;net7.0</TargetFrameworks> </PropertyGroup> </Project> diff --git a/src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt b/src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt index c987fb16d8..f25d61ffed 100644 --- a/src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt +++ b/src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt @@ -19,11 +19,13 @@ </Option> <!-- Can currently only have one TestDbgEng test --> + <!-- Disable TestDbgEng testing see https://github.com/dotnet/diagnostics/issues/3111 <Option> <TestDbgEng>true</TestDbgEng> <DumpFile>$(Package_TestAssets_Windows_x64_5_0)\DualRuntimes\SOS.DualRuntimes.Heap.dmp</DumpFile> <TestDataFile>$(Package_TestAssets_Windows_x64_5_0)\DualRuntimes\SOS.DualRuntimes.Heap.dmp.xml</TestDataFile> </Option> + --> <Option> <DumpFile>$(Package_TestAssets_Windows_x64_5_0)\DualRuntimes\SOS.DualRuntimes.Heap.dmp</DumpFile> @@ -114,11 +116,13 @@ </Option> <!-- Can currently only have one TestDbgEng test --> + <!-- Disable TestDbgEng testing see https://github.com/dotnet/diagnostics/issues/3111 <Option> <TestDbgEng>true</TestDbgEng> <DumpFile>$(Package_TestAssets_Windows_x86_5_0)\DualRuntimes\SOS.DualRuntimes.Heap.dmp</DumpFile> <TestDataFile>$(Package_TestAssets_Windows_x86_5_0)\DualRuntimes\SOS.DualRuntimes.Heap.dmp.xml</TestDataFile> </Option> + --> <Option> <DumpFile>$(Package_TestAssets_Windows_x86_5_0)\DualRuntimes\SOS.DualRuntimes.Heap.dmp</DumpFile> diff --git a/src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/DebugServicesTests.cs b/src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/DebugServicesTests.cs index fedc6f7f77..b612ffbf69 100644 --- a/src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/DebugServicesTests.cs +++ b/src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/DebugServicesTests.cs @@ -6,6 +6,7 @@ using System.Diagnostics; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using Xunit; using Xunit.Abstractions; using Xunit.Extensions; @@ -62,7 +63,7 @@ public void TargetTests(TestHost host) Assert.NotNull(contextService.GetCurrentTarget()); // Check that the ITarget properties match the test data - host.TestData.Target.CompareMembers(target); + host.TestData.CompareMembers(host.TestData.Target, target); // Test temp directory AssertX.DirectoryExists("Target temporary directory", target.GetTempDirectory(), Output); @@ -96,7 +97,13 @@ public void ModuleTests(TestHost host) Trace.TraceInformation($"GetModuleFromBaseAddress({imageBase:X16}) {moduleFileName} FAILED"); // Skip modules not found when running under lldb - if (host.Target.Host.HostType == HostType.Lldb) { + if (host.Target.Host.HostType == HostType.Lldb) + { + continue; + } + // Older xml versions on Linux have modules that are not reported anymore by the new CLRMD. + if (host.TestData.Version <= TestDataReader.Version100 && host.Target.OperatingSystem == OSPlatform.Linux) + { continue; } } @@ -105,7 +112,7 @@ public void ModuleTests(TestHost host) if (host.Target.Host.HostType != HostType.Lldb) { // Check that the resulting module matches the test data - moduleData.CompareMembers(module); + host.TestData.CompareMembers(moduleData, module); } IModule module1 = moduleService.GetModuleFromIndex(module.ModuleIndex); @@ -113,21 +120,23 @@ public void ModuleTests(TestHost host) Assert.Equal(module, module1); // Test GetModuleFromAddress on various address in module - IModule module2 = moduleService.GetModuleFromAddress(imageBase); - Assert.NotNull(module2); - Assert.True(module.ModuleIndex == module2.ModuleIndex); - Assert.Equal(module, module2); - - module2 = moduleService.GetModuleFromAddress(imageBase + 0x100); - Assert.NotNull(module2); - Assert.True(module.ModuleIndex == module2.ModuleIndex); - Assert.Equal(module, module2); - - module2 = moduleService.GetModuleFromAddress(imageBase + module.ImageSize - 1); - Assert.NotNull(module2); - Assert.True(module.ModuleIndex == module2.ModuleIndex); - Assert.Equal(module, module2); - + if (module.ImageSize > 0) + { + IModule module2 = moduleService.GetModuleFromAddress(imageBase); + Assert.NotNull(module2); + Assert.True(module.ModuleIndex == module2.ModuleIndex); + Assert.Equal(module, module2); + + module2 = moduleService.GetModuleFromAddress(imageBase + 0x100); + Assert.NotNull(module2); + Assert.True(module.ModuleIndex == module2.ModuleIndex); + Assert.Equal(module, module2); + + module2 = moduleService.GetModuleFromAddress(imageBase + module.ImageSize - 1); + Assert.NotNull(module2); + Assert.True(module.ModuleIndex == module2.ModuleIndex); + Assert.Equal(module, module2); + } // Find this module in the list of all modules Assert.NotNull(moduleService.EnumerateModules().SingleOrDefault((mod) => mod.ImageBase == imageBase)); @@ -145,7 +154,7 @@ public void ModuleTests(TestHost host) if (mod.ImageBase == imageBase) { // Check that the resulting module matches the test data - moduleData.CompareMembers(mod); + host.TestData.CompareMembers(moduleData, mod); } } } @@ -211,7 +220,7 @@ public void ThreadTests(TestHost host) Assert.NotNull(thread); // Check that the resulting thread matches the test data - threadData.CompareMembers(thread); + host.TestData.CompareMembers(threadData, thread); IThread thread2 = threadService.GetThreadFromIndex(thread.ThreadIndex); Assert.NotNull(thread2); @@ -226,7 +235,7 @@ public void ThreadTests(TestHost host) Assert.True(register.TryGetValue("RegisterIndex", out int registerIndex)); Assert.True(threadService.TryGetRegisterInfo(registerIndex, out RegisterInfo registerInfo)); - register.CompareMembers(registerInfo); + host.TestData.CompareMembers(register, registerInfo); Assert.True(thread.TryGetRegisterValue(registerIndex, out ulong value)); Assert.Equal(value, register["Value"].GetValue<ulong>()); @@ -262,7 +271,7 @@ public void RuntimeTests(TestHost host) IRuntime runtime = runtimeService.EnumerateRuntimes().FirstOrDefault((r) => r.Id == id); Assert.NotNull(runtime); - runtimeData.CompareMembers(runtime); + host.TestData.CompareMembers(runtimeData, runtime); ClrInfo clrInfo = runtime.Services.GetService<ClrInfo>(); Assert.NotNull(clrInfo); diff --git a/src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/Microsoft.Diagnostics.DebugServices.UnitTests.csproj b/src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/Microsoft.Diagnostics.DebugServices.UnitTests.csproj index d947ebb42e..ed9a4290f1 100644 --- a/src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/Microsoft.Diagnostics.DebugServices.UnitTests.csproj +++ b/src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/Microsoft.Diagnostics.DebugServices.UnitTests.csproj @@ -1,8 +1,7 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <!-- Needs to be netcoreapp3.1 and not higher so this test assembly can be loaded by dotnet-dump via the DOTNET_DIAGNOSTIC_EXTENSIONS env var --> - <TargetFramework>netcoreapp3.1</TargetFramework> + <TargetFramework>net6.0</TargetFramework> <DebugServicesConfigFileName>$(OutputPath)$(TargetFramework)\Debugger.Tests.Common.txt</DebugServicesConfigFileName> <TestAssetsVersion>1.0.257801</TestAssetsVersion> <!-- Controls the test asset package restore and the tests that use them --> @@ -11,7 +10,6 @@ <ItemGroup> <PackageReference Include="Microsoft.Diagnostics.Runtime" Version="$(MicrosoftDiagnosticsRuntimeVersion)" /> - <PackageReference Include="Microsoft.Diagnostics.Runtime.Utilities" Version="$(MicrosoftDiagnosticsRuntimeUtilitiesVersion)" /> </ItemGroup> <ItemGroup> diff --git a/src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/TestDbgEng.cs b/src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/TestDbgEng.cs index e4df5ede61..ae04090f2f 100644 --- a/src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/TestDbgEng.cs +++ b/src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/TestDbgEng.cs @@ -1,9 +1,9 @@ using Microsoft.Diagnostics.Runtime; -using Microsoft.Diagnostics.Runtime.Interop; using Microsoft.Diagnostics.Runtime.Utilities; using Microsoft.Diagnostics.TestHelpers; using SOS.Extensions; using SOS.Hosting; +using SOS.Hosting.DbgEng.Interop; using System; using System.Diagnostics; using System.IO; @@ -40,7 +40,7 @@ protected override ITarget GetTarget() class DbgEngController : IDebugOutputCallbacks { [UnmanagedFunctionPointer(CallingConvention.Winapi)] - private delegate HResult DebugCreateDelegate( + private delegate int DebugCreateDelegate( ref Guid interfaceId, [MarshalAs(UnmanagedType.IUnknown)] out object iinterface); diff --git a/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/EventCounterPipelineUnitTests.cs b/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/EventCounterPipelineUnitTests.cs index cf7cc8e976..bfb15c6b6b 100644 --- a/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/EventCounterPipelineUnitTests.cs +++ b/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/EventCounterPipelineUnitTests.cs @@ -3,14 +3,15 @@ // See the LICENSE file in the project root for more information. using Microsoft.Diagnostics.NETCore.Client; -using Microsoft.Diagnostics.NETCore.Client.UnitTests; -using System; +using Microsoft.Diagnostics.TestHelpers; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; +using Xunit.Extensions; +using TestRunner = Microsoft.Diagnostics.CommonTestRunner.TestRunner; namespace Microsoft.Diagnostics.Monitoring.EventPipe.UnitTests { @@ -18,6 +19,8 @@ public class EventCounterPipelineUnitTests { private readonly ITestOutputHelper _output; + public static IEnumerable<object[]> Configurations => TestRunner.Configurations; + public EventCounterPipelineUnitTests(ITestOutputHelper output) { _output = output; @@ -83,8 +86,8 @@ private static string CreateKey(string providerName, string counterName) } } - [Fact] - public async Task TestCounterEventPipeline() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task TestCounterEventPipeline(TestConfiguration config) { var expectedCounters = new[] { "cpu-usage", "working-set" }; string expectedProvider = "System.Runtime"; @@ -96,11 +99,9 @@ public async Task TestCounterEventPipeline() var logger = new TestMetricsLogger(expectedMap, foundExpectedCountersSource); - await using (var testExecution = StartTraceeProcess("CounterRemoteTest")) + await using (var testRunner = await PipelineTestUtilities.StartProcess(config, "CounterRemoteTest", _output)) { - //TestRunner should account for start delay to make sure that the diagnostic pipe is available. - - var client = new DiagnosticsClient(testExecution.TestRunner.Pid); + var client = new DiagnosticsClient(testRunner.Pid); await using EventCounterPipeline pipeline = new EventCounterPipeline(client, new EventPipeCounterPipelineSettings { @@ -116,10 +117,9 @@ public async Task TestCounterEventPipeline() CounterIntervalSeconds = 1 }, new[] { logger }); - await PipelineTestUtilities.ExecutePipelineWithDebugee( - _output, + await PipelineTestUtilities.ExecutePipelineWithTracee( pipeline, - testExecution, + testRunner, foundExpectedCountersSource); } @@ -130,10 +130,5 @@ await PipelineTestUtilities.ExecutePipelineWithDebugee( Assert.Equal(expectedCounters, actualMetrics); Assert.True(logger.Metrics.All(m => string.Equals(m.Provider, expectedProvider))); } - - private RemoteTestExecution StartTraceeProcess(string loggerCategory) - { - return RemoteTestExecution.StartProcess(CommonHelper.GetTraceePathWithArgs("EventPipeTracee") + " " + loggerCategory, _output); - } } } diff --git a/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/EventCounterTriggerTests.cs b/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/EventCounterTriggerTests.cs index 257b6b078c..ca1317cba6 100644 --- a/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/EventCounterTriggerTests.cs +++ b/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/EventCounterTriggerTests.cs @@ -5,8 +5,9 @@ using Microsoft.Diagnostics.Monitoring.EventPipe.Triggers.EventCounter; using Microsoft.Diagnostics.Monitoring.EventPipe.Triggers.Pipelines; using Microsoft.Diagnostics.NETCore.Client; -using Microsoft.Diagnostics.NETCore.Client.UnitTests; +using Microsoft.Diagnostics.TestHelpers; using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Globalization; using System.Runtime.InteropServices; @@ -15,6 +16,7 @@ using Xunit; using Xunit.Abstractions; using Xunit.Extensions; +using TestRunner = Microsoft.Diagnostics.CommonTestRunner.TestRunner; namespace Microsoft.Diagnostics.Monitoring.EventPipe.UnitTests { @@ -22,6 +24,8 @@ public class EventCounterTriggerTests { private readonly ITestOutputHelper _output; + public static IEnumerable<object[]> Configurations => TestRunner.Configurations; + public EventCounterTriggerTests(ITestOutputHelper output) { _output = output; @@ -315,12 +319,12 @@ public void EventCounterTriggerDropTest() /// Tests that the trigger condition can be detected on a live application /// using the EventPipeTriggerPipeline. /// </summary> - [SkippableFact] - public async Task EventCounterTriggerWithEventPipePipelineTest() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task EventCounterTriggerWithEventPipePipelineTest(TestConfiguration config) { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (config.RuntimeFrameworkVersionMajor < 6) { - throw new SkipTestException("https://github.com/dotnet/diagnostics/issues/2568"); + throw new SkipTestException("Unreliable on .NET 3.1"); } EventCounterTriggerSettings settings = new() { @@ -331,11 +335,9 @@ public async Task EventCounterTriggerWithEventPipePipelineTest() CounterIntervalSeconds = 1 }; - await using (var testExecution = StartTraceeProcess("TriggerRemoteTest")) + await using (var testRunner = await PipelineTestUtilities.StartProcess(config, "TriggerRemoteTest SpinWait10", _output, testProcessTimeout: 2 * 60 * 1000)) { - //TestRunner should account for start delay to make sure that the diagnostic pipe is available. - - DiagnosticsClient client = new(testExecution.TestRunner.Pid); + DiagnosticsClient client = new(testRunner.Pid); TaskCompletionSource<object> waitSource = new(TaskCreationOptions.RunContinuationsAsynchronously); @@ -353,10 +355,9 @@ public async Task EventCounterTriggerWithEventPipePipelineTest() waitSource.TrySetResult(null); }); - await PipelineTestUtilities.ExecutePipelineWithDebugee( - _output, + await PipelineTestUtilities.ExecutePipelineWithTracee( pipeline, - testExecution, + testRunner, waitSource); Assert.True(waitSource.Task.IsCompletedSuccessfully); @@ -404,11 +405,6 @@ private void SimulateDataVerifyTrigger(EventCounterTriggerSettings settings, Cpu } } - private RemoteTestExecution StartTraceeProcess(string loggerCategory) - { - return RemoteTestExecution.StartProcess(CommonHelper.GetTraceePathWithArgs("EventPipeTracee") + " " + loggerCategory + " SpinWait10", _output); - } - private sealed class CpuData { public CpuData(double value, bool? result, bool drop = false) diff --git a/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/EventLogsPipelineUnitTests.cs b/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/EventLogsPipelineUnitTests.cs index 86e441c4b1..4d91d2c29d 100644 --- a/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/EventLogsPipelineUnitTests.cs +++ b/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/EventLogsPipelineUnitTests.cs @@ -2,8 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.Diagnostics.CommonTestRunner; using Microsoft.Diagnostics.NETCore.Client; -using Microsoft.Diagnostics.NETCore.Client.UnitTests; +using Microsoft.Diagnostics.TestHelpers; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; @@ -15,6 +16,7 @@ using Xunit; using Xunit.Abstractions; using Xunit.Extensions; +using TestRunner = Microsoft.Diagnostics.CommonTestRunner.TestRunner; namespace Microsoft.Diagnostics.Monitoring.EventPipe.UnitTests { @@ -26,6 +28,8 @@ public class EventLogsPipelineUnitTests private readonly ITestOutputHelper _output; + public static IEnumerable<object[]> Configurations => TestRunner.Configurations; + public EventLogsPipelineUnitTests(ITestOutputHelper output) { _output = output; @@ -34,15 +38,15 @@ public EventLogsPipelineUnitTests(ITestOutputHelper output) /// <summary> /// Test that all log events are collected if no filters are specified. /// </summary> - [SkippableFact] - public async Task TestLogsAllCategoriesAllLevels() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task TestLogsAllCategoriesAllLevels(TestConfiguration config) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { throw new SkipTestException("https://github.com/dotnet/diagnostics/issues/2541"); } - using Stream outputStream = await GetLogsAsync(settings => + using Stream outputStream = await GetLogsAsync(config, settings => { settings.UseAppFilters = false; }); @@ -63,14 +67,15 @@ public async Task TestLogsAllCategoriesAllLevels() /// <summary> /// Test that log events at or above the default level are collected. /// </summary> - [SkippableFact] - public async Task TestLogsAllCategoriesDefaultLevel() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task TestLogsAllCategoriesDefaultLevel(TestConfiguration config) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { throw new SkipTestException("https://github.com/dotnet/diagnostics/issues/2541"); } - using Stream outputStream = await GetLogsAsync(settings => + + using Stream outputStream = await GetLogsAsync(config, settings => { settings.UseAppFilters = false; settings.LogLevel = LogLevel.Warning; @@ -90,15 +95,15 @@ public async Task TestLogsAllCategoriesDefaultLevel() /// <summary> /// Test that log events at the default level are collected for categories without a specified level. /// </summary> - [SkippableFact] - public async Task TestLogsAllCategoriesDefaultLevelFallback() + [SkippableTheory(Skip = "Unreliable test https://github.com/dotnet/diagnostics/issues/3143"), MemberData(nameof(Configurations))] + public async Task TestLogsAllCategoriesDefaultLevelFallback(TestConfiguration config) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { throw new SkipTestException("https://github.com/dotnet/diagnostics/issues/2541"); } - using Stream outputStream = await GetLogsAsync(settings => + using Stream outputStream = await GetLogsAsync(config, settings => { settings.UseAppFilters = false; settings.LogLevel = LogLevel.Error; @@ -123,12 +128,13 @@ public async Task TestLogsAllCategoriesDefaultLevelFallback() /// <summary> /// Test that LogLevel.None is not supported as the default log level. /// </summary> - [Fact] - public async Task TestLogsAllCategoriesDefaultLevelNoneNotSupported() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task TestLogsAllCategoriesDefaultLevelNoneNotSupported(TestConfiguration config) { // Pipeline should throw PipelineException with inner exception of NotSupportedException. PipelineException exception = await Assert.ThrowsAsync<PipelineException>( () => GetLogsAsync( + config, settings => { settings.UseAppFilters = false; @@ -141,10 +147,15 @@ public async Task TestLogsAllCategoriesDefaultLevelNoneNotSupported() /// <summary> /// Test that log events are collected for the categories and levels specified by the application. /// </summary> - [Fact] - public async Task TestLogsUseAppFilters() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task TestLogsUseAppFilters(TestConfiguration config) { - using Stream outputStream = await GetLogsAsync(); + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + throw new SkipTestException("https://github.com/dotnet/diagnostics/issues/2541"); + } + + using Stream outputStream = await GetLogsAsync(config); Assert.True(outputStream.Length > 0, "No data written by logging process."); @@ -160,15 +171,15 @@ public async Task TestLogsUseAppFilters() /// Test that log events are collected for the categories and levels specified by the application /// and for the categories and levels specified in the filter specs. /// </summary> - [SkippableFact] - public async Task TestLogsUseAppFiltersAndFilterSpecs() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task TestLogsUseAppFiltersAndFilterSpecs(TestConfiguration config) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { throw new SkipTestException("https://github.com/dotnet/diagnostics/issues/2541"); } - using Stream outputStream = await GetLogsAsync(settings => + using Stream outputStream = await GetLogsAsync(config, settings => { settings.FilterSpecs = new Dictionary<string, LogLevel?>() { @@ -190,14 +201,15 @@ public async Task TestLogsUseAppFiltersAndFilterSpecs() /// <summary> /// Test that log events are collected for wildcard categories. /// </summary> - [SkippableFact] - public async Task TestLogsWildcardCategory() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task TestLogsWildcardCategory(TestConfiguration config) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - throw new SkipTestException("https://github.com/dotnet/diagnostics/issues/2568"); + throw new SkipTestException("https://github.com/dotnet/diagnostics/issues/2541"); } - using Stream outputStream = await GetLogsAsync(settings => + + using Stream outputStream = await GetLogsAsync(config, settings => { settings.UseAppFilters = false; settings.LogLevel = LogLevel.Critical; @@ -218,16 +230,14 @@ public async Task TestLogsWildcardCategory() Assert.True(reader.EndOfStream, "Expected to have read all entries from stream."); } - private async Task<Stream> GetLogsAsync(Action<EventLogsPipelineSettings> settingsCallback = null) + private async Task<Stream> GetLogsAsync(TestConfiguration config, Action<EventLogsPipelineSettings> settingsCallback = null) { var outputStream = new MemoryStream(); - await using (var testExecution = StartTraceeProcess(LoggerRemoteTestName)) + await using (var testRunner = await PipelineTestUtilities.StartProcess(config, LoggerRemoteTestName, _output)) { - //TestRunner should account for start delay to make sure that the diagnostic pipe is available. - using var loggerFactory = new LoggerFactory(new[] { new TestStreamingLoggerProvider(outputStream) }); - var client = new DiagnosticsClient(testExecution.TestRunner.Pid); + var client = new DiagnosticsClient(testRunner.Pid); var logSettings = new EventLogsPipelineSettings { Duration = Timeout.InfiniteTimeSpan }; if (null != settingsCallback) @@ -236,7 +246,7 @@ private async Task<Stream> GetLogsAsync(Action<EventLogsPipelineSettings> settin } await using var pipeline = new EventLogsPipeline(client, logSettings, loggerFactory); - await PipelineTestUtilities.ExecutePipelineWithDebugee(_output, pipeline, testExecution); + await PipelineTestUtilities.ExecutePipelineWithTracee(pipeline, testRunner); } outputStream.Position = 0L; @@ -334,11 +344,6 @@ private static void Validate(IDictionary<string, JsonElement> values, params (st } } - private RemoteTestExecution StartTraceeProcess(string loggerCategory) - { - return RemoteTestExecution.StartProcess(CommonHelper.GetTraceePathWithArgs("EventPipeTracee") + " " + loggerCategory, _output); - } - private sealed class LoggerTestResult { public string Category { get; set; } diff --git a/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/EventTracePipelineUnitTests.cs b/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/EventTracePipelineUnitTests.cs index 13dd2bbb80..8c88286e28 100644 --- a/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/EventTracePipelineUnitTests.cs +++ b/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/EventTracePipelineUnitTests.cs @@ -2,22 +2,20 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.Diagnostics.CommonTestRunner; +using Microsoft.Diagnostics.NETCore.Client; +using Microsoft.Diagnostics.TestHelpers; +using Microsoft.Diagnostics.Tracing; using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; -using System.Linq; using System.Runtime.InteropServices; -using System.Text.Json; using System.Threading; using System.Threading.Tasks; -using Microsoft.Diagnostics.NETCore.Client; -using Microsoft.Diagnostics.NETCore.Client.UnitTests; -using Microsoft.Diagnostics.Tracing; -using Microsoft.Extensions.Logging; using Xunit; using Xunit.Abstractions; using Xunit.Extensions; +using TestRunner = Microsoft.Diagnostics.CommonTestRunner.TestRunner; namespace Microsoft.Diagnostics.Monitoring.EventPipe.UnitTests { @@ -25,20 +23,20 @@ public class EventTracePipelineUnitTests { private readonly ITestOutputHelper _output; + public static IEnumerable<object[]> Configurations => TestRunner.Configurations; + public EventTracePipelineUnitTests(ITestOutputHelper output) { _output = output; } - [Fact] - public async Task TestTraceStopAsync() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task TestTraceStopAsync(TestConfiguration config) { Stream eventStream = null; - await using (var testExecution = StartTraceeProcess("TraceStopTest")) + await using (var testRunner = await PipelineTestUtilities.StartProcess(config, "TraceStopTest", _output)) { - //TestRunner should account for start delay to make sure that the diagnostic pipe is available. - - var client = new DiagnosticsClient(testExecution.TestRunner.Pid); + var client = new DiagnosticsClient(testRunner.Pid); var settings = new EventTracePipelineSettings() { Duration = Timeout.InfiniteTimeSpan, @@ -67,10 +65,9 @@ public async Task TestTraceStopAsync() await Task.Run(() => Assert.True(eventSource.Process()), token); }); - await PipelineTestUtilities.ExecutePipelineWithDebugee( - _output, + await PipelineTestUtilities.ExecutePipelineWithTracee( pipeline, - testExecution, + testRunner, foundProviderSource); } @@ -78,21 +75,19 @@ await PipelineTestUtilities.ExecutePipelineWithDebugee( Assert.Throws<ObjectDisposedException>(() => eventStream.Read(new byte[4], 0, 4)); } - [SkippableFact] - public async Task TestEventStreamCleanup() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task TestEventStreamCleanup(TestConfiguration config) { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - throw new SkipTestException("Test debugee sigfaults for OSX/Linux"); + throw new SkipTestException("Test tracee sigfaults for OSX/Linux"); } Stream eventStream = null; using var cancellationTokenSource = new CancellationTokenSource(); - await using (var testExecution = StartTraceeProcess("TestEventStreamCleanup")) + await using (var testRunner = await PipelineTestUtilities.StartProcess(config, "TestEventStreamCleanup", _output)) { - //TestRunner should account for start delay to make sure that the diagnostic pipe is available. - - var client = new DiagnosticsClient(testExecution.TestRunner.Pid); + var client = new DiagnosticsClient(testRunner.Pid); var settings = new EventTracePipelineSettings() { Duration = Timeout.InfiniteTimeSpan, @@ -108,20 +103,14 @@ public async Task TestEventStreamCleanup() }); await Assert.ThrowsAsync<OperationCanceledException>( - async () => await PipelineTestUtilities.ExecutePipelineWithDebugee( - _output, + async () => await PipelineTestUtilities.ExecutePipelineWithTracee( pipeline, - testExecution, + testRunner, cancellationTokenSource.Token)); } //Validate that the stream is only valid for the lifetime of the callback in the trace pipeline. Assert.Throws<ObjectDisposedException>(() => eventStream.Read(new byte[4], 0, 4)); } - - private RemoteTestExecution StartTraceeProcess(string loggerCategory) - { - return RemoteTestExecution.StartProcess(CommonHelper.GetTraceePathWithArgs("EventPipeTracee") + " " + loggerCategory, _output); - } } } diff --git a/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/Microsoft.Diagnostics.Monitoring.EventPipe.UnitTests.csproj b/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/Microsoft.Diagnostics.Monitoring.EventPipe.UnitTests.csproj index 8410ef25cd..2b066212c5 100644 --- a/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/Microsoft.Diagnostics.Monitoring.EventPipe.UnitTests.csproj +++ b/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/Microsoft.Diagnostics.Monitoring.EventPipe.UnitTests.csproj @@ -1,16 +1,13 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks> + <TargetFrameworks>$(UnitTestTargetFrameworks)</TargetFrameworks> </PropertyGroup> <ItemGroup> <ProjectReference Include="$(MSBuildThisFileDirectory)..\..\Microsoft.Diagnostics.Monitoring.EventPipe\Microsoft.Diagnostics.Monitoring.EventPipe.csproj" /> <ProjectReference Include="$(MSBuildThisFileDirectory)..\..\Microsoft.Diagnostics.NETCore.Client\Microsoft.Diagnostics.NETCore.Client.csproj" /> - <ProjectReference Include="$(MSBuildThisFileDirectory)..\Microsoft.Diagnostics.NETCore.Client\Microsoft.Diagnostics.NETCore.Client.UnitTests.csproj" /> - <ProjectReference Include="..\EventPipeTracee\EventPipeTracee.csproj" PrivateAssets="all"> - <ReferenceOutputAssembly>false</ReferenceOutputAssembly> - </ProjectReference> + <ProjectReference Include="$(MSBuildThisFileDirectory)..\CommonTestRunner\CommonTestRunner.csproj" /> </ItemGroup> <ItemGroup> diff --git a/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/PipelineTestUtilities.cs b/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/PipelineTestUtilities.cs index bc7992542a..4941ff9ecd 100644 --- a/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/PipelineTestUtilities.cs +++ b/src/tests/Microsoft.Diagnostics.Monitoring.EventPipe/PipelineTestUtilities.cs @@ -2,84 +2,85 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Diagnostics.NETCore.Client.UnitTests; +using Microsoft.Diagnostics.TestHelpers; using System; using System.Threading; using System.Threading.Tasks; using Xunit.Abstractions; +using TestRunner = Microsoft.Diagnostics.CommonTestRunner.TestRunner; namespace Microsoft.Diagnostics.Monitoring.EventPipe.UnitTests { internal static class PipelineTestUtilities { - private static readonly TimeSpan DefaultPipelineRunTimeout = TimeSpan.FromMinutes(1); + private static readonly TimeSpan DefaultPipelineRunTimeout = TimeSpan.FromMinutes(2); - public static async Task ExecutePipelineWithDebugee( - ITestOutputHelper outputHelper, + public static async Task<TestRunner> StartProcess(TestConfiguration config, string testArguments, ITestOutputHelper outputHelper, int testProcessTimeout = 60_000) + { + TestRunner runner = await TestRunner.Create(config, outputHelper, "EventPipeTracee", testArguments); + await runner.Start(testProcessTimeout); + return runner; + } + + public static async Task ExecutePipelineWithTracee( Pipeline pipeline, - RemoteTestExecution testExecution, + TestRunner testRunner, TaskCompletionSource<object> waitTaskSource = null) { using var cancellation = new CancellationTokenSource(DefaultPipelineRunTimeout); - await ExecutePipelineWithDebugee( - outputHelper, + await ExecutePipelineWithTracee( pipeline, - testExecution, + testRunner, cancellation.Token, waitTaskSource); } - public static async Task ExecutePipelineWithDebugee<T>( - ITestOutputHelper outputHelper, + public static async Task ExecutePipelineWithTracee<T>( EventSourcePipeline<T> pipeline, - RemoteTestExecution testExecution, + TestRunner testRunner, TaskCompletionSource<object> waitTaskSource = null) where T : EventSourcePipelineSettings { using var cancellation = new CancellationTokenSource(DefaultPipelineRunTimeout); - await ExecutePipelineWithDebugee( - outputHelper, + await ExecutePipelineWithTracee( pipeline, (p, t) => p.StartAsync(t), - testExecution, + testRunner, cancellation.Token, waitTaskSource); } - public static Task ExecutePipelineWithDebugee( - ITestOutputHelper outputHelper, + public static Task ExecutePipelineWithTracee( Pipeline pipeline, - RemoteTestExecution testExecution, + TestRunner testRunner, CancellationToken token, TaskCompletionSource<object> waitTaskSource = null) { - return ExecutePipelineWithDebugee( - outputHelper, + return ExecutePipelineWithTracee( pipeline, (p, t) => Task.FromResult(p.RunAsync(t)), - testExecution, + testRunner, token, waitTaskSource); } - private static async Task ExecutePipelineWithDebugee<TPipeline>( - ITestOutputHelper outputHelper, + private static async Task ExecutePipelineWithTracee<TPipeline>( TPipeline pipeline, Func<TPipeline, CancellationToken, Task<Task>> startPipelineAsync, - RemoteTestExecution testExecution, + TestRunner testRunner, CancellationToken token, TaskCompletionSource<object> waitTaskSource = null) where TPipeline : Pipeline { Task runTask = await startPipelineAsync(pipeline, token); - //Begin event production - testExecution.SendSignal(); + // Begin event production + testRunner.WakeupTracee(); - //Wait for event production to be done - testExecution.WaitForSignal(); + // Wait for event production to be done + testRunner.WaitForSignal(); try { @@ -88,7 +89,7 @@ private static async Task ExecutePipelineWithDebugee<TPipeline>( { using var _ = token.Register(() => { - outputHelper.WriteLine("Did not receive completion signal before cancellation."); + testRunner.WriteLine("Did not receive completion signal before cancellation."); waitTaskSource.TrySetCanceled(token); }); @@ -103,8 +104,8 @@ private static async Task ExecutePipelineWithDebugee<TPipeline>( } finally { - //Signal for debugee that's ok to end/move on. - testExecution.SendSignal(); + // Signal for debugee that's ok to end/move on. + testRunner.WakeupTracee(); } } } diff --git a/src/tests/Microsoft.Diagnostics.Monitoring/Microsoft.Diagnostics.Monitoring.UnitTests.csproj b/src/tests/Microsoft.Diagnostics.Monitoring/Microsoft.Diagnostics.Monitoring.UnitTests.csproj index a7ee91a2ff..7b2263b52e 100644 --- a/src/tests/Microsoft.Diagnostics.Monitoring/Microsoft.Diagnostics.Monitoring.UnitTests.csproj +++ b/src/tests/Microsoft.Diagnostics.Monitoring/Microsoft.Diagnostics.Monitoring.UnitTests.csproj @@ -1,17 +1,13 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks> + <TargetFrameworks>$(UnitTestTargetFrameworks)</TargetFrameworks> </PropertyGroup> <ItemGroup> <ProjectReference Include="$(MSBuildThisFileDirectory)..\..\Microsoft.Diagnostics.Monitoring\Microsoft.Diagnostics.Monitoring.csproj" /> <ProjectReference Include="$(MSBuildThisFileDirectory)..\..\Microsoft.Diagnostics.Monitoring.EventPipe\Microsoft.Diagnostics.Monitoring.EventPipe.csproj" /> <ProjectReference Include="$(MSBuildThisFileDirectory)..\..\Microsoft.Diagnostics.NETCore.Client\Microsoft.Diagnostics.NETCore.Client.csproj" /> - <ProjectReference Include="$(MSBuildThisFileDirectory)..\Microsoft.Diagnostics.NETCore.Client\Microsoft.Diagnostics.NETCore.Client.UnitTests.csproj" /> - <ProjectReference Include="..\EventPipeTracee\EventPipeTracee.csproj" PrivateAssets="all"> - <ReferenceOutputAssembly>false</ReferenceOutputAssembly> - </ProjectReference> </ItemGroup> <ItemGroup> diff --git a/src/tests/Microsoft.Diagnostics.Monitoring/PipelineTests.cs b/src/tests/Microsoft.Diagnostics.Monitoring/PipelineTests.cs index 227e4a2927..eab58c889f 100644 --- a/src/tests/Microsoft.Diagnostics.Monitoring/PipelineTests.cs +++ b/src/tests/Microsoft.Diagnostics.Monitoring/PipelineTests.cs @@ -2,11 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Diagnostics.Monitoring; -using Microsoft.Diagnostics.Tracing.Parsers.Kernel; using System; -using System.Collections.Generic; -using System.Text; using System.Threading; using System.Threading.Tasks; using Xunit; diff --git a/src/tests/Microsoft.Diagnostics.NETCore.Client/CommonHelper.cs b/src/tests/Microsoft.Diagnostics.NETCore.Client/CommonHelper.cs deleted file mode 100644 index cbfbc886af..0000000000 --- a/src/tests/Microsoft.Diagnostics.NETCore.Client/CommonHelper.cs +++ /dev/null @@ -1,42 +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. - -using System; -using System.IO; -using System.Runtime.InteropServices; - -namespace Microsoft.Diagnostics.NETCore.Client -{ - public partial class CommonHelper - { - public static string HostExe = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? - (RuntimeInformation.ProcessArchitecture == Architecture.X86 ? - "..\\..\\..\\..\\..\\.dotnet\\x86\\dotnet.exe" : - "..\\..\\..\\..\\..\\.dotnet\\dotnet.exe") : - "../../../../../.dotnet/dotnet"; - - /// <summary> - /// gets the tracee path, with args for the dotnet host for finding the correct version of the runtime.!-- - /// example: "--fx-version 5.0.0-rc.1.12345.12 /path/to/tracee" - /// </summary> - public static string GetTraceePathWithArgs(string traceeName = "Tracee", string targetFramework = "netcoreapp3.1") - { - var curPath = Directory.GetCurrentDirectory(); - - var traceePath = curPath - .Replace(System.Reflection.Assembly.GetCallingAssembly().GetName().Name, traceeName) - .Replace("netcoreapp3.1", targetFramework); - - traceePath = Path.Combine(traceePath, Path.ChangeExtension(traceeName, ".dll")); - - - // CurrentDARCVersion is generated at build time by Microsoft.Diagnostics.NETCore.Client.UnitTests.csproj - // This value will be set to whatever the value for the newest runtime in eng/Versions.Props is - if (targetFramework.Equals("net5.0", StringComparison.InvariantCultureIgnoreCase)) - traceePath = $"--fx-version {CurrentDARCVersion} {traceePath}"; - - return traceePath; - } - } -} diff --git a/src/tests/Microsoft.Diagnostics.NETCore.Client/EventPipeSessionTests.cs b/src/tests/Microsoft.Diagnostics.NETCore.Client/EventPipeSessionTests.cs index 8a761289ca..1a3c39212e 100644 --- a/src/tests/Microsoft.Diagnostics.NETCore.Client/EventPipeSessionTests.cs +++ b/src/tests/Microsoft.Diagnostics.NETCore.Client/EventPipeSessionTests.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.Diagnostics.CommonTestRunner; +using Microsoft.Diagnostics.TestHelpers; using Microsoft.Diagnostics.Tracing; using System; using System.Collections.Generic; @@ -9,71 +11,72 @@ using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; +using Xunit.Extensions; +using TestRunner = Microsoft.Diagnostics.CommonTestRunner.TestRunner; namespace Microsoft.Diagnostics.NETCore.Client { public class EventPipeSessionTests { - private readonly ITestOutputHelper output; + private readonly ITestOutputHelper _output; + + public static IEnumerable<object[]> Configurations => TestRunner.Configurations; public EventPipeSessionTests(ITestOutputHelper outputHelper) { - output = outputHelper; + _output = outputHelper; } - [Fact] - public Task BasicEventPipeSessionTest() + [SkippableTheory, MemberData(nameof(Configurations))] + public Task BasicEventPipeSessionTest(TestConfiguration config) { - return BasicEventPipeSessionTestCore(useAsync: false); + return BasicEventPipeSessionTestCore(config, useAsync: false); } - [Fact] - public Task BasicEventPipeSessionTestAsync() + [SkippableTheory, MemberData(nameof(Configurations))] + public Task BasicEventPipeSessionTestAsync(TestConfiguration config) { - return BasicEventPipeSessionTestCore(useAsync: true); + return BasicEventPipeSessionTestCore(config, useAsync: true); } /// <summary> /// A simple test that checks if we can create an EventPipeSession on a child process /// </summary> - private async Task BasicEventPipeSessionTestCore(bool useAsync) - + private async Task BasicEventPipeSessionTestCore(TestConfiguration config, bool useAsync) { - using TestRunner runner = new TestRunner(CommonHelper.GetTraceePathWithArgs(), output); - runner.Start(timeoutInMSPipeCreation: 15_000, testProcessTimeout: 60_000); + await using TestRunner runner = await TestRunner.Create(config, _output, "Tracee"); + await runner.Start(testProcessTimeout: 60_000); DiagnosticsClientApiShim clientShim = new DiagnosticsClientApiShim(new DiagnosticsClient(runner.Pid), useAsync); - using (var session = await clientShim.StartEventPipeSession(new List<EventPipeProvider>() + // Don't dispose of the session here because it unnecessarily hangs the test for 30 secs + EventPipeSession session = await clientShim.StartEventPipeSession(new List<EventPipeProvider>() { new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Informational) - })) - { - Assert.True(session.EventStream != null); - } + }); + Assert.True(session.EventStream != null); runner.Stop(); } - [Fact] - public Task EventPipeSessionStreamTest() + [SkippableTheory, MemberData(nameof(Configurations))] + public Task EventPipeSessionStreamTest(TestConfiguration config) { - return EventPipeSessionStreamTestCore(useAsync: false); + return EventPipeSessionStreamTestCore(config, useAsync: false); } - [Fact] - public Task EventPipeSessionStreamTestAsync() + [SkippableTheory, MemberData(nameof(Configurations))] + public Task EventPipeSessionStreamTestAsync(TestConfiguration config) { - return EventPipeSessionStreamTestCore(useAsync: true); + return EventPipeSessionStreamTestCore(config, useAsync: true); } /// <summary> /// Checks if we can create an EventPipeSession and can get some expected events out of it. /// </summary> - private async Task EventPipeSessionStreamTestCore(bool useAsync) + private async Task EventPipeSessionStreamTestCore(TestConfiguration config, bool useAsync) { - TestRunner runner = new TestRunner(CommonHelper.GetTraceePathWithArgs(), output); - runner.Start(timeoutInMSPipeCreation: 15_000, testProcessTimeout: 60_000); + await using TestRunner runner = await TestRunner.Create(config, _output, "Tracee"); + await runner.Start(testProcessTimeout: 60_000); DiagnosticsClientApiShim clientShim = new DiagnosticsClientApiShim(new DiagnosticsClient(runner.Pid), useAsync); - runner.PrintStatus(); - output.WriteLine($"[{DateTime.Now.ToString()}] Trying to start an EventPipe session on process {runner.Pid}"); + runner.WriteLine($"Trying to start an EventPipe session"); using (var session = await clientShim.StartEventPipeSession(new List<EventPipeProvider>() { new EventPipeProvider("System.Runtime", EventLevel.Informational, 0, new Dictionary<string, string>() { @@ -86,47 +89,46 @@ private async Task EventPipeSessionStreamTestCore(bool useAsync) Task streamTask = Task.Run(() => { var source = new EventPipeEventSource(session.EventStream); source.Dynamic.All += (TraceEvent obj) => { - output.WriteLine("Got an event"); + runner.WriteLine("Got an event"); evntCnt += 1; }; try { source.Process(); } - catch (Exception e) + catch (Exception ex) { // This exception can happen if the target process exits while EventPipeEventSource is in the middle of reading from the pipe. - output.WriteLine("Error encountered while processing events"); - output.WriteLine(e.ToString()); + runner.WriteLine($"Error encountered while processing events {ex}"); } finally { - runner.Stop(); + runner.WakeupTracee(); } }); - output.WriteLine("Waiting for stream Task"); + runner.WriteLine("Waiting for stream Task"); streamTask.Wait(10000); - output.WriteLine("Done waiting for stream Task"); + runner.WriteLine("Done waiting for stream Task"); Assert.True(evntCnt > 0); } } - [Fact] - public Task EventPipeSessionUnavailableTest() + [SkippableTheory, MemberData(nameof(Configurations))] + public Task EventPipeSessionUnavailableTest(TestConfiguration config) { - return EventPipeSessionUnavailableTestCore(useAsync: false); + return EventPipeSessionUnavailableTestCore(config, useAsync: false); } - [Fact] - public Task EventPipeSessionUnavailableTestAsync() + [SkippableTheory, MemberData(nameof(Configurations))] + public Task EventPipeSessionUnavailableTestAsync(TestConfiguration config) { - return EventPipeSessionUnavailableTestCore(useAsync: true); + return EventPipeSessionUnavailableTestCore(config, useAsync: true); } /// <summary> /// Tries to start an EventPipe session on a non-existent process /// </summary> - private async Task EventPipeSessionUnavailableTestCore(bool useAsync) + private async Task EventPipeSessionUnavailableTestCore(TestConfiguration config, bool useAsync) { List<int> pids = new List<int>(DiagnosticsClient.GetPublishedProcesses()); int arbitraryPid = 1; @@ -139,30 +141,29 @@ await Assert.ThrowsAsync<ServerNotAvailableException>(() => clientShim.StartEven })); } - [Fact] - public Task StartEventPipeSessionWithSingleProviderTest() + [SkippableTheory, MemberData(nameof(Configurations))] + public Task StartEventPipeSessionWithSingleProviderTest(TestConfiguration config) { - return StartEventPipeSessionWithSingleProviderTestCore(useAsync: false); + return StartEventPipeSessionWithSingleProviderTestCore(config, useAsync: false); } - [Fact] - public Task StartEventPipeSessionWithSingleProviderTestAsync() + [SkippableTheory, MemberData(nameof(Configurations))] + public Task StartEventPipeSessionWithSingleProviderTestAsync(TestConfiguration config) { - return StartEventPipeSessionWithSingleProviderTestCore(useAsync: true); + return StartEventPipeSessionWithSingleProviderTestCore(config, useAsync: true); } /// <summary> /// Test for the method overload: public EventPipeSession StartEventPipeSession(EventPipeProvider provider, bool requestRundown=true, int circularBufferMB=256) /// </summary> - private async Task StartEventPipeSessionWithSingleProviderTestCore(bool useAsync) + private async Task StartEventPipeSessionWithSingleProviderTestCore(TestConfiguration config, bool useAsync) { - using TestRunner runner = new TestRunner(CommonHelper.GetTraceePathWithArgs(), output); - runner.Start(timeoutInMSPipeCreation: 15_000, testProcessTimeout: 60_000); + await using TestRunner runner = await TestRunner.Create(config, _output, "Tracee"); + await runner.Start(testProcessTimeout: 60_000); DiagnosticsClientApiShim clientShim = new DiagnosticsClientApiShim(new DiagnosticsClient(runner.Pid), useAsync); - using (var session = await clientShim.StartEventPipeSession(new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Informational))) - { - Assert.True(session.EventStream != null); - } + // Don't dispose of the session here because it unnecessarily hangs the test for 30 secs + EventPipeSession session = await clientShim.StartEventPipeSession(new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Informational)); + Assert.True(session.EventStream != null); runner.Stop(); } } diff --git a/src/tests/Microsoft.Diagnostics.NETCore.Client/GetProcessEnvironmentTests.cs b/src/tests/Microsoft.Diagnostics.NETCore.Client/GetProcessEnvironmentTests.cs index 5a27f825fc..d191b42e20 100644 --- a/src/tests/Microsoft.Diagnostics.NETCore.Client/GetProcessEnvironmentTests.cs +++ b/src/tests/Microsoft.Diagnostics.NETCore.Client/GetProcessEnvironmentTests.cs @@ -2,53 +2,61 @@ // 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 Microsoft.Diagnostics.TestHelpers; using System.Collections.Generic; using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; +using Xunit.Extensions; +using TestRunner = Microsoft.Diagnostics.CommonTestRunner.TestRunner; namespace Microsoft.Diagnostics.NETCore.Client { public class ProcessEnvironmentTests { - private readonly ITestOutputHelper output; + private readonly ITestOutputHelper _output; + + public static IEnumerable<object[]> Configurations => TestRunner.Configurations; public ProcessEnvironmentTests(ITestOutputHelper outputHelper) { - output = outputHelper; + _output = outputHelper; } - [Fact] - public Task BasicEnvTest() + [SkippableTheory, MemberData(nameof(Configurations))] + public Task BasicEnvTest(TestConfiguration config) { - return BasicEnvTestCore(useAsync: false); + return BasicEnvTestCore(config, useAsync: false); } - [Fact] - public Task BasicEnvTestAsync() + [SkippableTheory, MemberData(nameof(Configurations))] + public Task BasicEnvTestAsync(TestConfiguration config) { - return BasicEnvTestCore(useAsync: true); + return BasicEnvTestCore(config, useAsync: true); } /// <summary> /// A simple test that collects process environment. /// </summary> - private async Task BasicEnvTestCore(bool useAsync) + private async Task BasicEnvTestCore(TestConfiguration config, bool useAsync) { + if (config.RuntimeFrameworkVersionMajor < 5) + { + throw new SkipTestException("Not supported on < .NET 5.0"); + } // as the attribute says, this test requires 5.0-rc1 or newer. This has been tested locally on // an rc1 build and passes. It is equivalent to the dotnet/runtime version of this test. - using TestRunner runner = new TestRunner(CommonHelper.GetTraceePathWithArgs(targetFramework: "net5.0"), output); + await using TestRunner runner = await TestRunner.Create(config, _output, "Tracee"); string testKey = "FOO"; string testVal = "BAR"; runner.AddEnvVar(testKey, testVal); - runner.Start(timeoutInMSPipeCreation: 3000); + await runner.Start(); var clientShim = new DiagnosticsClientApiShim(new DiagnosticsClient(runner.Pid), useAsync); Dictionary<string,string> env = await clientShim.GetProcessEnvironment(); Assert.True(env.ContainsKey(testKey) && env[testKey].Equals(testVal)); - runner.Stop(); + runner.WakeupTracee(); } } } diff --git a/src/tests/Microsoft.Diagnostics.NETCore.Client/GetProcessInfoTests.cs b/src/tests/Microsoft.Diagnostics.NETCore.Client/GetProcessInfoTests.cs index 53b514b1e4..2b986fabf8 100644 --- a/src/tests/Microsoft.Diagnostics.NETCore.Client/GetProcessInfoTests.cs +++ b/src/tests/Microsoft.Diagnostics.NETCore.Client/GetProcessInfoTests.cs @@ -2,10 +2,16 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.Diagnostics.CommonTestRunner; +using Microsoft.Diagnostics.TestHelpers; using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; +using Xunit.Extensions; +using TestRunner = Microsoft.Diagnostics.CommonTestRunner.TestRunner; namespace Microsoft.Diagnostics.NETCore.Client { @@ -13,43 +19,49 @@ public class GetProcessInfoTests { private readonly ITestOutputHelper _output; + public static IEnumerable<object[]> Configurations => TestRunner.Configurations; + public GetProcessInfoTests(ITestOutputHelper outputHelper) { _output = outputHelper; } - [Fact] - public Task BasicProcessInfoNoSuspendTest() + [SkippableTheory, MemberData(nameof(Configurations))] + public Task BasicProcessInfoNoSuspendTest(TestConfiguration config) { - return BasicProcessInfoTestCore(useAsync: false, suspend: false); + return BasicProcessInfoTestCore(config, useAsync: false, suspend: false); } - [Fact] - public Task BasicProcessInfoNoSuspendTestAsync() + [SkippableTheory, MemberData(nameof(Configurations))] + public Task BasicProcessInfoNoSuspendTestAsync(TestConfiguration config) { - return BasicProcessInfoTestCore(useAsync: true, suspend: false); + return BasicProcessInfoTestCore(config, useAsync: true, suspend: false); } - [Fact] - public Task BasicProcessInfoSuspendTest() + [SkippableTheory, MemberData(nameof(Configurations))] + public Task BasicProcessInfoSuspendTest(TestConfiguration config) { - return BasicProcessInfoTestCore(useAsync: false, suspend: true); + return BasicProcessInfoTestCore(config, useAsync: false, suspend: true); } - [Fact] - public Task BasicProcessInfoSuspendTestAsync() + [SkippableTheory, MemberData(nameof(Configurations))] + public Task BasicProcessInfoSuspendTestAsync(TestConfiguration config) { - return BasicProcessInfoTestCore(useAsync: true, suspend: true); + return BasicProcessInfoTestCore(config, useAsync: true, suspend: true); } - private async Task BasicProcessInfoTestCore(bool useAsync, bool suspend) + private async Task BasicProcessInfoTestCore(TestConfiguration config, bool useAsync, bool suspend) { - using TestRunner runner = new TestRunner(CommonHelper.GetTraceePathWithArgs(targetFramework: "net5.0"), _output); + if (config.RuntimeFrameworkVersionMajor < 5) + { + throw new SkipTestException("Not supported on < .NET 5.0"); + } + await using TestRunner runner = await TestRunner.Create(config, _output, "Tracee"); if (suspend) { runner.SuspendDefaultDiagnosticPort(); } - runner.Start(); + await runner.Start(testProcessTimeout: 60_000, waitForTracee: !suspend); try { @@ -64,23 +76,36 @@ private async Task BasicProcessInfoTestCore(bool useAsync, bool suspend) Assert.True(string.IsNullOrEmpty(processInfoBeforeResume.ManagedEntrypointAssemblyName)); await clientShim.ResumeRuntime(); + + await runner.WaitForTracee(); } // The entrypoint information is available some short time after the runtime // begins to execute. Retry getting process information until entrypoint is available. ProcessInfo processInfo = await GetProcessInfoWithEntrypointAsync(clientShim); ValidateProcessInfo(runner.Pid, processInfo); + + // This is only true if targetFramework for the tracee app is greater than Assert.Equal("Tracee", processInfo.ManagedEntrypointAssemblyName); - // Validate values before resume (except for entrypoint) are the same after resume. if (suspend) { Assert.Equal(processInfoBeforeResume.ProcessId, processInfo.ProcessId); Assert.Equal(processInfoBeforeResume.RuntimeInstanceCookie, processInfo.RuntimeInstanceCookie); - Assert.Equal(processInfoBeforeResume.CommandLine, processInfo.CommandLine); Assert.Equal(processInfoBeforeResume.OperatingSystem, processInfo.OperatingSystem); Assert.Equal(processInfoBeforeResume.ProcessArchitecture, processInfo.ProcessArchitecture); Assert.Equal(processInfoBeforeResume.ClrProductVersionString, processInfo.ClrProductVersionString); + // Given we are in a .NET 6.0+ app, we should have ProcessInfo2 available. Pre and post pause should differ. + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + Assert.Equal($"\"{runner.ExePath}\" {runner.Arguments}", processInfoBeforeResume.CommandLine); + Assert.Equal($"\"{runner.ExePath}\" {runner.Arguments}", processInfo.CommandLine); + } + else + { + Assert.Equal($"{runner.ExePath}", processInfoBeforeResume.CommandLine); + Assert.Equal($"{runner.ExePath} {runner.ManagedArguments}", processInfo.CommandLine); + } } } finally diff --git a/src/tests/Microsoft.Diagnostics.NETCore.Client/GetPublishedProcessesTests.cs b/src/tests/Microsoft.Diagnostics.NETCore.Client/GetPublishedProcessesTests.cs index 9f571b465e..ff77348124 100644 --- a/src/tests/Microsoft.Diagnostics.NETCore.Client/GetPublishedProcessesTests.cs +++ b/src/tests/Microsoft.Diagnostics.NETCore.Client/GetPublishedProcessesTests.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.Diagnostics.TestHelpers; using System; using System.Collections.Generic; using System.Runtime.InteropServices; @@ -9,6 +10,8 @@ using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; +using Xunit.Extensions; +using TestRunner = Microsoft.Diagnostics.CommonTestRunner.TestRunner; namespace Microsoft.Diagnostics.NETCore.Client { @@ -18,76 +21,75 @@ namespace Microsoft.Diagnostics.NETCore.Client /// </summary> public class GetPublishedProcessesTest { - private readonly ITestOutputHelper output; + private readonly ITestOutputHelper _output; + + public static IEnumerable<object[]> Configurations => TestRunner.Configurations; public GetPublishedProcessesTest(ITestOutputHelper outputHelper) { - output = outputHelper; + _output = outputHelper; } - [Fact] - public void PublishedProcessTest1() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task PublishedProcessTest1(TestConfiguration config) { - using TestRunner runner = new TestRunner(CommonHelper.GetTraceePathWithArgs(), output); - runner.Start(timeoutInMSPipeCreation: 3000); - // On Windows, runner.Start will not wait for named pipe creation since for other tests, NamedPipeClientStream will - // just wait until the named pipe is created. - // For these tests, we need to sleep an arbitrary time before pipe is created. - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - Thread.Sleep(5000); - } + await using TestRunner runner = await TestRunner.Create(config, _output, "Tracee"); + await runner.Start(); + List<int> publishedProcesses = new List<int>(DiagnosticsClient.GetPublishedProcesses()); foreach (int p in publishedProcesses) { - output.WriteLine($"[{DateTime.Now.ToString()}] Saw published process {p}"); + runner.WriteLine($"Saw published process {p}"); } Assert.Contains(publishedProcesses, p => p == runner.Pid); - runner.Stop(); + runner.WakeupTracee(); } - [Fact] - public void MultiplePublishedProcessTest() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task MultiplePublishedProcessTest(TestConfiguration config) { TestRunner[] runner = new TestRunner[3]; int[] pids = new int[3]; - for (var i = 0; i < 3; i++) - { - runner[i] = new TestRunner(CommonHelper.GetTraceePathWithArgs(), output); - runner[i].Start(); - pids[i] = runner[i].Pid; - } - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - Thread.Sleep(5000); - } - List<int> publishedProcesses = new List<int>(DiagnosticsClient.GetPublishedProcesses()); - foreach (int p in publishedProcesses) + try { - output.WriteLine($"[{DateTime.Now.ToString()}] Saw published process {p}"); - } + for (var i = 0; i < 3; i++) + { + runner[i] = await TestRunner.Create(config, _output, "Tracee"); + await runner[i].Start(); + pids[i] = runner[i].Pid; + } - for (var i = 0; i < 3; i++) - { - Assert.Contains(publishedProcesses, p => p == pids[i]); - } + List<int> publishedProcesses = new List<int>(DiagnosticsClient.GetPublishedProcesses()); + foreach (int p in publishedProcesses) + { + _output.WriteLine($"[{DateTime.Now}] Saw published process {p}"); + } + + for (var i = 0; i < 3; i++) + { + Assert.Contains(publishedProcesses, p => p == pids[i]); + } - for (var i = 0 ; i < 3; i++) + for (var i = 0; i < 3; i++) + { + runner[i].WakeupTracee(); + } + } + finally { - runner[i].Stop(); + for (var i = 0; i < 3; i++) + { + await runner[i].DisposeAsync(); + } } } - [Fact] - public async Task WaitForConnectionTest() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task WaitForConnectionTest(TestConfiguration config) { - using TestRunner runner = new TestRunner(CommonHelper.GetTraceePathWithArgs(), output); - runner.Start(timeoutInMSPipeCreation: 3000); - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - Thread.Sleep(5000); - } + await using TestRunner runner = await TestRunner.Create(config, _output, "Tracee"); + await runner.Start(); var client = new DiagnosticsClient(runner.Pid); using var timeoutSource = new CancellationTokenSource(TimeSpan.FromMilliseconds(250)); @@ -97,7 +99,7 @@ public async Task WaitForConnectionTest() } finally { - runner.Stop(); + runner.WakeupTracee(); } } } diff --git a/src/tests/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.UnitTests.csproj b/src/tests/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.UnitTests.csproj index b1c14ebee1..8db5cfa78f 100644 --- a/src/tests/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.UnitTests.csproj +++ b/src/tests/Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.UnitTests.csproj @@ -1,66 +1,17 @@ <Project Sdk="Microsoft.NET.Sdk"> - <!-- - DARCVersionFileName, GenerateDARCVersion, and InjectDARCVersion are used for injecting the value of MicrosoftNETCoreAppRuntimewinx64Version - int csharp code so that it can be used by testing harnesses for running tests under a specific runtime version. This specifically - allows tests to run on a version of the runtime besides whatever was included with Arcade's SDK. - --> - - <PropertyGroup> - <DARCVersionFileName>$(IntermediateOutputPath)/DARCVersion.g.cs</DARCVersionFileName> - </PropertyGroup> - - <Target Name="GenerateDARCVersionCs" - Inputs="$(VersionsPropsPath)" - Outputs="$(DARCVersionFileName)"> - <PropertyGroup> - <DARCVersionFile> -<![CDATA[ -// 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. - - -// THIS FILE IS AUTO-GENERATED DURING BUILD. MODIFICATIONS _WILL_ BE OVERWRITTEN! - -namespace Microsoft.Diagnostics.NETCore.Client -{ - public partial class CommonHelper - { - public static readonly string CurrentDARCVersion = "$(MicrosoftNETCoreAppRuntimewinx64Version)"; - } -} -]]> - </DARCVersionFile> - </PropertyGroup> - - <WriteLinesToFile File="$(DARCVersionFileName)" - Overwrite="true" - Lines="$(DARCVersionFile.Replace(';', '%3B'))" - WriteOnlyWhenDifferent="true" /> - </Target> - - <Target Name="InjectDARCVersion" BeforeTargets="BeforeCompile" DependsOnTargets="GenerateDARCVersionCs"> - <ItemGroup> - <FileWrites Include="$(DARCVersionFileName)" /> - <Compile Include="$(DARCVersionFileName)" /> - </ItemGroup> - </Target> - <PropertyGroup> - <TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks> + <TargetFrameworks>$(UnitTestTargetFrameworks)</TargetFrameworks> </PropertyGroup> <ItemGroup> - <ProjectReference Include="../../Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj" /> - <ProjectReference Include="../../Microsoft.Diagnostics.TestHelpers/Microsoft.Diagnostics.TestHelpers.csproj" /> - <ProjectReference Include="../Tracee/Tracee.csproj" PrivateAssets="all" /> + <ProjectReference Include="$(MSBuildThisFileDirectory)../../Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.csproj" /> + <ProjectReference Include="$(MSBuildThisFileDirectory)../../Microsoft.Diagnostics.TestHelpers/Microsoft.Diagnostics.TestHelpers.csproj" /> + <ProjectReference Include="$(MSBuildThisFileDirectory)../CommonTestRunner/CommonTestRunner.csproj" /> </ItemGroup> + <ItemGroup> <PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="$(MicrosoftDiagnosticsTracingTraceEventVersion)" /> </ItemGroup> - <ItemGroup> - <InternalsVisibleTo Include="DotnetStack.UnitTests" /> - <InternalsVisibleTo Include="Microsoft.Diagnostics.Monitoring.UnitTests" /> - </ItemGroup> + </Project> diff --git a/src/tests/Microsoft.Diagnostics.NETCore.Client/RemoteTestExecution.cs b/src/tests/Microsoft.Diagnostics.NETCore.Client/RemoteTestExecution.cs deleted file mode 100644 index a3b592339d..0000000000 --- a/src/tests/Microsoft.Diagnostics.NETCore.Client/RemoteTestExecution.cs +++ /dev/null @@ -1,110 +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. - -using System; -using System.IO; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Diagnostics.NETCore.Client; -using Xunit.Abstractions; - -namespace Microsoft.Diagnostics.NETCore.Client.UnitTests -{ - /// <summary> - /// Utility class to control remote test execution. - /// </summary> - public sealed class RemoteTestExecution : IAsyncDisposable - { - private Task IoReadingTask { get; } - - private ITestOutputHelper OutputHelper { get; } - - public TestRunner TestRunner { get; } - - private RemoteTestExecution(TestRunner runner, Task ioReadingTask, ITestOutputHelper outputHelper) - { - TestRunner = runner; - IoReadingTask = ioReadingTask; - OutputHelper = outputHelper; - } - - //Very simple signals that synchronize execution between the test process and the debuggee process. - - public void SendSignal() - { - //We cannot use named synchronization primitives since they do not work across processes - //on Linux. Use redirected standard input instead. - TestRunner.StandardInput.Write('0'); - TestRunner.StandardInput.Flush(); - } - - public void WaitForSignal() - { - var result = TestRunner.StandardOutput.ReadLine(); - if (string.Equals(result, "1")) - { - return; - } - } - - public static RemoteTestExecution StartProcess(string commandLine, ITestOutputHelper outputHelper, string reversedServerTransportName = null) - { - TestRunner runner = new TestRunner(commandLine, outputHelper, redirectError: true, redirectInput: true); - if (!string.IsNullOrEmpty(reversedServerTransportName)) - { - runner.SetDiagnosticPort(reversedServerTransportName, suspend: false); - } - runner.Start(testProcessTimeout: 60_000); - - Task readingTask = ReadAllOutput(runner.StandardOutput, runner.StandardError, outputHelper); - - return new RemoteTestExecution(runner, readingTask, outputHelper); - } - - private static Task ReadAllOutput(StreamReader output, StreamReader error, ITestOutputHelper outputHelper) - { - return Task.Run(async () => - { - try - { - Task<string> stdErrorTask = error.ReadToEndAsync(); - - try - { - string result = await stdErrorTask; - outputHelper.WriteLine("Stderr:"); - if (result != null) - { - outputHelper.WriteLine(result); - } - } - catch (Exception e) - { - outputHelper.WriteLine("Error reading standard error from child process: " + e.ToString()); - } - } - catch (ObjectDisposedException) - { - outputHelper.WriteLine("Failed to collect remote process's output"); - } - }); - } - - public async ValueTask DisposeAsync() - { - using var timeoutSource = new CancellationTokenSource(TimeSpan.FromSeconds(1)); - try - { - await TestRunner.WaitForExitAsync(timeoutSource.Token); - } - catch (OperationCanceledException) - { - OutputHelper.WriteLine("Remote process did not exit within timeout period. Forcefully stopping process."); - TestRunner.Stop(); - } - - await IoReadingTask; - } - } -} diff --git a/src/tests/Microsoft.Diagnostics.NETCore.Client/ReversedServerTests.cs b/src/tests/Microsoft.Diagnostics.NETCore.Client/ReversedServerTests.cs index 07f6a17170..4576994396 100644 --- a/src/tests/Microsoft.Diagnostics.NETCore.Client/ReversedServerTests.cs +++ b/src/tests/Microsoft.Diagnostics.NETCore.Client/ReversedServerTests.cs @@ -2,16 +2,22 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.Diagnostics.CommonTestRunner; +using Microsoft.Diagnostics.TestHelpers; +using Microsoft.Diagnostics.Tracing; using System; using System.Collections.Generic; using System.Diagnostics.Tracing; using System.IO; using System.Net; +using System.Net.Sockets; +using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; -using Microsoft.Diagnostics.Tracing; using Xunit; using Xunit.Abstractions; +using Xunit.Extensions; +using TestRunner = Microsoft.Diagnostics.CommonTestRunner.TestRunner; namespace Microsoft.Diagnostics.NETCore.Client { @@ -23,6 +29,8 @@ public class ReversedServerTests private readonly ITestOutputHelper _outputHelper; + public static IEnumerable<object[]> Configurations => TestRunner.Configurations; + public ReversedServerTests(ITestOutputHelper outputHelper) { _outputHelper = outputHelper; @@ -92,6 +100,40 @@ await Assert.ThrowsAsync<ObjectDisposedException>( () => server.RemoveConnection(Guid.Empty)); } + [SkippableFact] + public async Task ReversedServerAddressInUseTest() + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + throw new SkipTestException("Not applicable on Windows due to named pipe usage."); + } + + await using var server = CreateReversedServer(out string transportName); + + Assert.False(File.Exists(transportName), "Unix Domain Socket should not exist yet."); + + try + { + // Create file to simulate that the socket is already created. + File.Create(transportName).Dispose(); + + SocketException ex = Assert.Throws<SocketException>(() => server.Start()); + + int expectedErrorCode = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? 48 : 98; // Address already in use + Assert.Equal(expectedErrorCode, ex.ErrorCode); + } + finally + { + try + { + File.Delete(transportName); + } + catch (Exception) + { + } + } + } + /// <summary> /// Tests that <see cref="ReversedDiagnosticsServer.AcceptAsync(CancellationToken)"/> does not complete /// when no connections are available and that cancellation will move the returned task to the cancelled state. @@ -111,22 +153,22 @@ public async Task ReversedServerAcceptAsyncYieldsTest() Assert.True(acceptTask.IsCanceled); } - [Fact] - public async Task ReversedServerNonExistingRuntimeIdentifierTest() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task ReversedServerNonExistingRuntimeIdentifierTest(TestConfiguration config) { - await ReversedServerNonExistingRuntimeIdentifierTestCore(useAsync: false); + await ReversedServerNonExistingRuntimeIdentifierTestCore(config, useAsync: false); } - [Fact] - public async Task ReversedServerNonExistingRuntimeIdentifierTestAsync() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task ReversedServerNonExistingRuntimeIdentifierTestAsync(TestConfiguration config) { - await ReversedServerNonExistingRuntimeIdentifierTestCore(useAsync: true); + await ReversedServerNonExistingRuntimeIdentifierTestCore(config, useAsync: true); } /// <summary> /// Tests that invoking server methods with non-existing runtime identifier appropriately fail. /// </summary> - private async Task ReversedServerNonExistingRuntimeIdentifierTestCore(bool useAsync) + private async Task ReversedServerNonExistingRuntimeIdentifierTestCore(TestConfiguration config, bool useAsync) { await using var server = CreateReversedServer(out string transportName); @@ -149,16 +191,16 @@ private async Task ReversedServerNonExistingRuntimeIdentifierTestCore(bool useAs Assert.False(server.RemoveConnection(Guid.NewGuid()), "Removal of nonexisting connection should fail."); } - [Fact] - public async Task ReversedServerSingleTargetMultipleUseClientTest() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task ReversedServerSingleTargetMultipleUseClientTest(TestConfiguration config) { - await ReversedServerSingleTargetMultipleUseClientTestCore(useAsync: false); + await ReversedServerSingleTargetMultipleUseClientTestCore(config, useAsync: false); } - [Fact] - public async Task ReversedServerSingleTargetMultipleUseClientTestAsync() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task ReversedServerSingleTargetMultipleUseClientTestAsync(TestConfiguration config) { - await ReversedServerSingleTargetMultipleUseClientTestCore(useAsync: true); + await ReversedServerSingleTargetMultipleUseClientTestCore(config, useAsync: true); } /// <summary> @@ -170,18 +212,19 @@ public async Task ReversedServerSingleTargetMultipleUseClientTestAsync() /// because of how the endpoint is updated with new stream information each /// time the target process reconnects to the server. /// </remarks> - private async Task ReversedServerSingleTargetMultipleUseClientTestCore(bool useAsync) + private async Task ReversedServerSingleTargetMultipleUseClientTestCore(TestConfiguration config, bool useAsync) { + if (config.RuntimeFrameworkVersionMajor < 5) + { + throw new SkipTestException("Not supported on < .NET 5.0"); + } await using var server = CreateReversedServer(out string transportName); server.Start(); - - TestRunner runner = null; IpcEndpointInfo info; - try - { - // Start client pointing to diagnostics server - runner = StartTracee(transportName); + // Start client pointing to diagnostics server + await using (TestRunner runner = await StartTracee(config, transportName)) + { info = await AcceptEndpointInfo(server, useAsync); await VerifyEndpointInfo(runner, info, useAsync); @@ -191,13 +234,10 @@ private async Task ReversedServerSingleTargetMultipleUseClientTestCore(bool useA await ResumeRuntime(info, useAsync); + await runner.WaitForTracee(); + await VerifySingleSession(info, useAsync); } - finally - { - _outputHelper.WriteLine("Stopping tracee."); - runner?.Stop(); - } // Wait some time for the process to exit await Task.Delay(TimeSpan.FromSeconds(1)); @@ -211,33 +251,34 @@ private async Task ReversedServerSingleTargetMultipleUseClientTestCore(bool useA await VerifyNoNewEndpointInfos(server, useAsync); } - [Fact] - public async Task ReversedServerSingleTargetExitsClientInviableTest() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task ReversedServerSingleTargetExitsClientInviableTest(TestConfiguration config) { - await ReversedServerSingleTargetExitsClientInviableTestCore(useAsync: false); + await ReversedServerSingleTargetExitsClientInviableTestCore(config, useAsync: false); } - [Fact] - public async Task ReversedServerSingleTargetExitsClientInviableTestAsync() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task ReversedServerSingleTargetExitsClientInviableTestAsync(TestConfiguration config) { - await ReversedServerSingleTargetExitsClientInviableTestCore(useAsync: true); + await ReversedServerSingleTargetExitsClientInviableTestCore(config, useAsync: true); } /// <summary> /// Tests that a DiagnosticsClient is not viable after target exists. /// </summary> - private async Task ReversedServerSingleTargetExitsClientInviableTestCore(bool useAsync) + private async Task ReversedServerSingleTargetExitsClientInviableTestCore(TestConfiguration config, bool useAsync) { + if (config.RuntimeFrameworkVersionMajor < 5) + { + throw new SkipTestException("Not supported on < .NET 5.0"); + } await using var server = CreateReversedServer(out string transportName); server.Start(); - TestRunner runner = null; + // Start client pointing to diagnostics server IpcEndpointInfo info; - try + await using (TestRunner runner = await StartTracee(config, transportName)) { - // Start client pointing to diagnostics server - runner = StartTracee(transportName); - // Get client connection info = await AcceptEndpointInfo(server, useAsync); @@ -248,13 +289,10 @@ private async Task ReversedServerSingleTargetExitsClientInviableTestCore(bool us await ResumeRuntime(info, useAsync); + await runner.WaitForTracee(); + await VerifyWaitForConnection(info, useAsync); } - finally - { - _outputHelper.WriteLine("Stopping tracee."); - runner?.Stop(); - } // Wait some time for the process to exit await Task.Delay(TimeSpan.FromSeconds(1)); @@ -272,22 +310,22 @@ private async Task ReversedServerSingleTargetExitsClientInviableTestCore(bool us /// Validates that the <see cref="ReversedDiagnosticsServer"/> does not create a new server /// transport during disposal. /// </summary> - [Fact] - public async Task ReversedServerNoCreateTransportAfterDispose() + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task ReversedServerNoCreateTransportAfterDispose(TestConfiguration config) { + if (config.RuntimeFrameworkVersionMajor < 5) + { + throw new SkipTestException("Not supported on < .NET 5.0"); + } var transportCallback = new IpcServerTransportCallback(); - int transportVersion = 0; - TestRunner runner = null; - try - { - await using var server = CreateReversedServer(out string transportName); - server.TransportCallback = transportCallback; - server.Start(); - // Start client pointing to diagnostics server - runner = StartTracee(transportName); + await using var server = CreateReversedServer(out string transportName); + server.TransportCallback = transportCallback; + server.Start(); + await using (TestRunner runner = await StartTracee(config, transportName)) + { // Get client connection IpcEndpointInfo info = await AcceptEndpointInfo(server, useAsync: true); @@ -298,17 +336,14 @@ public async Task ReversedServerNoCreateTransportAfterDispose() await ResumeRuntime(info, useAsync: true); + await runner.WaitForTracee(); + await VerifyWaitForConnection(info, useAsync: true); transportVersion = await transportCallback.GetStableTransportVersion(); // Server will be disposed } - finally - { - _outputHelper.WriteLine("Stopping tracee."); - runner?.Stop(); - } // Check that the reversed server did not create a new server transport upon disposal. Assert.Equal(transportVersion, await transportCallback.GetStableTransportVersion()); @@ -328,12 +363,11 @@ private async Task<IpcEndpointInfo> AcceptEndpointInfo(ReversedDiagnosticsServer return await shim.Accept(DefaultPositiveVerificationTimeout); } - private TestRunner StartTracee(string transportName) + private async Task<TestRunner> StartTracee(TestConfiguration config, string transportName) { - _outputHelper.WriteLine("Starting tracee."); - var runner = new TestRunner(CommonHelper.GetTraceePathWithArgs(targetFramework: "net5.0"), _outputHelper); + TestRunner runner = await TestRunner.Create(config, _outputHelper, "Tracee"); runner.SetDiagnosticPort(transportName, suspend: true); - runner.Start(); + await runner.Start(waitForTracee: false); return runner; } @@ -364,7 +398,7 @@ private async Task VerifyNoNewEndpointInfos(ReversedDiagnosticsServer server, bo /// </summary> private async Task VerifyEndpointInfo(TestRunner runner, IpcEndpointInfo info, bool useAsync, bool expectTimeout = false) { - _outputHelper.WriteLine($"Verifying connection information for process ID {runner.Pid}."); + runner.WriteLine("Verifying connection information for process"); Assert.NotNull(runner); Assert.Equal(runner.Pid, info.ProcessId); Assert.NotEqual(Guid.Empty, info.RuntimeInstanceCookie); @@ -372,7 +406,7 @@ private async Task VerifyEndpointInfo(TestRunner runner, IpcEndpointInfo info, b await VerifyWaitForConnection(info, useAsync, expectTimeout); - _outputHelper.WriteLine($"Connection: {info.DebuggerDisplay}"); + runner.WriteLine($"Connection: {info.DebuggerDisplay}"); } private async Task ResumeRuntime(IpcEndpointInfo info, bool useAsync) diff --git a/src/tests/Microsoft.Diagnostics.NETCore.Client/TestRunner.cs b/src/tests/Microsoft.Diagnostics.NETCore.Client/TestRunner.cs deleted file mode 100644 index 88fa0014ee..0000000000 --- a/src/tests/Microsoft.Diagnostics.NETCore.Client/TestRunner.cs +++ /dev/null @@ -1,178 +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. - - -using System; -using System.Linq; -using System.ComponentModel; -using System.Diagnostics; -using System.IO; -using System.Runtime.InteropServices; -using System.Threading; -using System.Threading.Tasks; -using Xunit.Abstractions; -using System.Collections.Generic; - -namespace Microsoft.Diagnostics.NETCore.Client -{ - public class TestRunner : IDisposable - { - private Process testProcess; - private ProcessStartInfo startInfo; - private ITestOutputHelper outputHelper; - private CancellationTokenSource cts; - - public TestRunner(string testExePath, ITestOutputHelper _outputHelper = null, - bool redirectError = false, bool redirectInput = false, Dictionary<string, string> envVars = null) - { - startInfo = new ProcessStartInfo(CommonHelper.HostExe, testExePath); - startInfo.UseShellExecute = false; - startInfo.RedirectStandardOutput = true; - startInfo.RedirectStandardError = redirectError; - startInfo.RedirectStandardInput = redirectInput; - envVars?.ToList().ForEach(item => startInfo.Environment.Add(item.Key, item.Value)); - outputHelper = _outputHelper; - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - try - { - // Make a good will attempt to end the tracee process - // and its process tree - testProcess?.Kill(entireProcessTree: true); - } - catch {} - - if(disposing) - { - testProcess?.Dispose(); - } - - cts.Dispose(); - } - - public void AddEnvVar(string key, string value) - { - startInfo.EnvironmentVariables[key] = value; - } - - public StreamWriter StandardInput => testProcess.StandardInput; - public StreamReader StandardOutput => testProcess.StandardOutput; - public StreamReader StandardError => testProcess.StandardError; - - public void Start(int timeoutInMSPipeCreation=15_000, int testProcessTimeout=30_000) - { - if (outputHelper != null) - outputHelper.WriteLine($"[{DateTime.Now.ToString()}] Launching test: " + startInfo.FileName + " " + startInfo.Arguments); - - testProcess = new Process(); - testProcess.StartInfo = startInfo; - testProcess.EnableRaisingEvents = true; - - if (!testProcess.Start()) - { - outputHelper.WriteLine($"Could not start process: " + startInfo.FileName); - } - - if (testProcess.HasExited) - { - outputHelper.WriteLine($"Process " + startInfo.FileName + " came back as exited"); - } - - cts = new CancellationTokenSource(testProcessTimeout); - cts.Token.Register(() => testProcess.Kill()); - - if (outputHelper != null) - { - outputHelper.WriteLine($"[{DateTime.Now.ToString()}] Successfully started process {testProcess.Id}"); - // Retry getting the module count because we can catch the process during startup and it fails temporarily. - for (int retry = 0; retry < 5; retry++) - { - try - { - outputHelper.WriteLine($"Have total {testProcess.Modules.Count} modules loaded"); - break; - } - catch (Win32Exception) - { - } - } - } - - // Block until we see the IPC channel created, or until timeout specified. - Task monitorSocketTask = Task.Run(() => - { - while (true) - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // On Windows, named pipe connection will block until the named pipe is ready to connect so no need to block here - break; - } - else - { - // On Linux, we wait until the socket is created. - var matchingFiles = Directory.GetFiles(Path.GetTempPath(), $"dotnet-diagnostic-{testProcess.Id}-*-socket"); // Try best match. - if (matchingFiles.Length > 0) - { - break; - } - } - Task.Delay(100); - } - }); - - monitorSocketTask.Wait(TimeSpan.FromMilliseconds(timeoutInMSPipeCreation)); - } - - public void Stop() - { - this.Dispose(); - } - - public int Pid { - get { return testProcess.Id; } - } - - public void PrintStatus() - { - if (testProcess.HasExited) - { - outputHelper.WriteLine($"Process {testProcess.Id} status: Exited 0x{testProcess.ExitCode:X}"); - } - else - { - outputHelper.WriteLine($"Process {testProcess.Id} status: Running"); - } - } - - public async Task WaitForExitAsync(CancellationToken token) - { - TaskCompletionSource<object> exitedSource = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously); - EventHandler exitedHandler = (s, e) => exitedSource.TrySetResult(null); - - testProcess.Exited += exitedHandler; - try - { - if (!testProcess.HasExited) - { - using var _ = token.Register(() => exitedSource.TrySetCanceled(token)); - - await exitedSource.Task; - } - } - finally - { - testProcess.Exited -= exitedHandler; - } - } - } -} diff --git a/src/tests/StackTracee/Program.cs b/src/tests/StackTracee/Program.cs index 12dc739197..efbd514851 100644 --- a/src/tests/StackTracee/Program.cs +++ b/src/tests/StackTracee/Program.cs @@ -10,7 +10,7 @@ class Program { static void Main(string[] args) { - Console.ReadKey(); + Console.Read(); } } } diff --git a/src/tests/StackTracee/StackTracee.csproj b/src/tests/StackTracee/StackTracee.csproj index cd0510ad22..6b634ef181 100644 --- a/src/tests/StackTracee/StackTracee.csproj +++ b/src/tests/StackTracee/StackTracee.csproj @@ -2,6 +2,6 @@ <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework> - <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp3.1;net5.0</TargetFrameworks> + <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp3.1;net6.0;net7.0</TargetFrameworks> </PropertyGroup> </Project> diff --git a/src/tests/Tracee/Program.cs b/src/tests/Tracee/Program.cs index 8250ea7c8e..2107a7f9fa 100644 --- a/src/tests/Tracee/Program.cs +++ b/src/tests/Tracee/Program.cs @@ -3,27 +3,50 @@ // See the LICENSE file in the project root for more information. using System; -using System.Threading; +using System.Diagnostics; +using System.IO.Pipes; namespace Tracee { class Program { - private const int LoopCount = 30; - - static void Main(string[] args) + public static int Main(string[] args) { - Console.WriteLine("Sleep in loop for {0} seconds.", LoopCount); - - // Runs for max of 30 sec - for (var i = 0; i < LoopCount; i++) + int pid = Process.GetCurrentProcess().Id; + string pipeServerName = args.Length > 0 ? args[0] : null; + if (pipeServerName == null) { - Console.WriteLine("Iteration #{0}", i); - Thread.Sleep(1000); + Console.Error.WriteLine($"{pid} Tracee: no pipe name"); + Console.Error.Flush(); + return -1; } + Console.WriteLine($"{pid} Tracee: pipe server: {pipeServerName}"); + Console.Out.Flush(); + try + { + using var pipeStream = new NamedPipeClientStream(pipeServerName); + + Console.WriteLine("{0} Tracee: connecting to pipe", pid); + Console.Out.Flush(); + pipeStream.Connect(5 * 60 * 1000); + Console.WriteLine("{0} Tracee: connected to pipe", pid); + Console.Out.Flush(); - Console.WriteLine("Press any key to exit."); - Console.ReadKey(); + // Wait for server to send something + int input = pipeStream.ReadByte(); + + Console.WriteLine("{0} Tracee: waking up {1}", pid, input); + Console.Out.Flush(); + } + catch (Exception ex) + { + Console.Error.WriteLine(ex.ToString()); + Console.Error.Flush(); + return -1; + } + Console.WriteLine("{0} Tracee: exiting normally", pid); + Console.Out.Flush(); + return 0; } } } diff --git a/src/tests/Tracee/Tracee.csproj b/src/tests/Tracee/Tracee.csproj index cd0510ad22..6b634ef181 100644 --- a/src/tests/Tracee/Tracee.csproj +++ b/src/tests/Tracee/Tracee.csproj @@ -2,6 +2,6 @@ <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework Condition="'$(BuildProjectFramework)' != ''">$(BuildProjectFramework)</TargetFramework> - <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp3.1;net5.0</TargetFrameworks> + <TargetFrameworks Condition="'$(BuildProjectFramework)' == ''">netcoreapp3.1;net6.0;net7.0</TargetFrameworks> </PropertyGroup> </Project> diff --git a/src/tests/dotnet-counters/DotnetCounters.UnitTests.csproj b/src/tests/dotnet-counters/DotnetCounters.UnitTests.csproj index 3e891e2a45..06c1878141 100644 --- a/src/tests/dotnet-counters/DotnetCounters.UnitTests.csproj +++ b/src/tests/dotnet-counters/DotnetCounters.UnitTests.csproj @@ -1,7 +1,7 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFramework>net5.0</TargetFramework> + <TargetFramework>net6.0</TargetFramework> </PropertyGroup> <ItemGroup> diff --git a/src/tests/dotnet-stack/DotnetStack.UnitTests.csproj b/src/tests/dotnet-stack/DotnetStack.UnitTests.csproj index 94b587a2ec..7cdad15afc 100644 --- a/src/tests/dotnet-stack/DotnetStack.UnitTests.csproj +++ b/src/tests/dotnet-stack/DotnetStack.UnitTests.csproj @@ -1,12 +1,12 @@ <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFramework>net5.0</TargetFramework> + <TargetFrameworks>net6.0</TargetFrameworks> </PropertyGroup> <ItemGroup> - <ProjectReference Include="../../Tools/dotnet-stack/dotnet-stack.csproj" /> - <ProjectReference Include="../Microsoft.Diagnostics.NETCore.Client/Microsoft.Diagnostics.NETCore.Client.UnitTests.csproj" /> + <ProjectReference Include="$(MSBuildThisFileDirectory)..\..\Tools\dotnet-stack\dotnet-stack.csproj" /> + <ProjectReference Include="$(MSBuildThisFileDirectory)..\CommonTestRunner\CommonTestRunner.csproj" /> </ItemGroup> </Project> diff --git a/src/tests/dotnet-stack/StackTests.cs b/src/tests/dotnet-stack/StackTests.cs index e98820c08e..c106d1e366 100644 --- a/src/tests/dotnet-stack/StackTests.cs +++ b/src/tests/dotnet-stack/StackTests.cs @@ -2,45 +2,71 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Diagnostics.NETCore.Client; +using Microsoft.Diagnostics.TestHelpers; using System; +using System.Collections.Generic; using System.CommandLine; using System.CommandLine.IO; using System.CommandLine.Parsing; using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; +using Xunit.Extensions; +using TestRunner = Microsoft.Diagnostics.CommonTestRunner.TestRunner; namespace Microsoft.Diagnostics.Tools.Stack { public class StackTests { - private readonly ITestOutputHelper output; + private readonly ITestOutputHelper _output; + + private const string _correctStack70 = @" [Native Frames] + System.Console.il!Interop+Kernel32.ReadFile(int,unsigned int8*,int32,int32&,int) + System.Console.il!System.ConsolePal+WindowsConsoleStream.ReadFileNative(int,value class System.Span`1<unsigned int8>,bool,int32&,bool) + System.Console.il!System.ConsolePal+WindowsConsoleStream.Read(value class System.Span`1<unsigned int8>) + System.Console.il!System.IO.ConsoleStream.Read(unsigned int8[],int32,int32) + System.Private.CoreLib.il!System.IO.StreamReader.ReadBuffer() + System.Private.CoreLib.il!System.IO.StreamReader.Read() + System.Console.il!System.IO.SyncTextReader.Read() + System.Console.il!System.Console.Read() + ?!?"; + + private const string _correctStack60 = @" [Native Frames] + System.Console.il!System.ConsolePal+WindowsConsoleStream.ReadFileNative(int,value class System.Span`1<unsigned int8>,bool,int32&,bool) + System.Console.il!System.ConsolePal+WindowsConsoleStream.Read(value class System.Span`1<unsigned int8>) + System.Console.il!System.IO.ConsoleStream.Read(unsigned int8[],int32,int32) + System.Private.CoreLib.il!System.IO.StreamReader.ReadBuffer() + System.Private.CoreLib.il!System.IO.StreamReader.Read() + System.Console.il!System.IO.SyncTextReader.Read() + System.Console.il!System.Console.Read() + StackTracee!Tracee.Program.Main(class System.String[])"; - private readonly string correctStack = @" [Native Frames] - System.Console!System.IO.StdInReader.ReadKey(bool&) - System.Console!System.IO.SyncTextReader.ReadKey(bool&) - System.Console!System.ConsolePal.ReadKey(bool) - System.Console!System.Console.ReadKey() + private const string _correctStack31 = @" [Native Frames] + System.Console.il!System.ConsolePal+WindowsConsoleStream.ReadFileNative(int,unsigned int8[],int32,int32,bool,int32&,bool) + System.Console.il!System.ConsolePal+WindowsConsoleStream.Read(unsigned int8[],int32,int32) + System.Private.CoreLib.il!System.IO.StreamReader.ReadBuffer() + System.Private.CoreLib.il!System.IO.StreamReader.Read() + System.Console.il!System.IO.SyncTextReader.Read() + System.Console.il!System.Console.Read() StackTracee!Tracee.Program.Main(class System.String[])"; + public static IEnumerable<object[]> Configurations => TestRunner.Configurations; + public StackTests(ITestOutputHelper outputHelper) { - output = outputHelper; + _output = outputHelper; } - [Theory] - [InlineData("netcoreapp3.1")] - [InlineData("net5.0")] - public async Task ReportsStacksCorrectly(string traceeFramework) + [SkippableTheory, MemberData(nameof(Configurations))] + public async Task ReportsStacksCorrectly(TestConfiguration config) { Command reportCommand = ReportCommandHandler.ReportCommand(); var console = new TestConsole(); var parser = new Parser(reportCommand); - using TestRunner runner = new TestRunner(CommonHelper.GetTraceePathWithArgs(traceeName: "StackTracee", targetFramework: traceeFramework), output); - runner.Start(); + await using TestRunner runner = await TestRunner.Create(config, _output, "StackTracee", usePipe: false); + await runner.Start(); // Wait for tracee to get to readkey call await Task.Delay(TimeSpan.FromSeconds(1)); @@ -49,10 +75,16 @@ public async Task ReportsStacksCorrectly(string traceeFramework) string report = console.Out.ToString(); - output.WriteLine($"REPORT_START\n{report}REPORT_END"); + runner.WriteLine($"REPORT_START\n{report}REPORT_END"); Assert.True(!string.IsNullOrEmpty(report)); - + string correctStack = config.RuntimeFrameworkVersionMajor switch + { + 7 => _correctStack70, + 6 => _correctStack60, + 3 => _correctStack31, + _ => throw new NotSupportedException($"Runtime version {config.RuntimeFrameworkVersionMajor} not supported") + }; string[] correctStackParts = correctStack.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries); string[] stackParts = report.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries); @@ -68,4 +100,4 @@ public async Task ReportsStacksCorrectly(string traceeFramework) } } } -} \ No newline at end of file +} diff --git a/src/tests/dotnet-trace/ChildProcessTests.cs b/src/tests/dotnet-trace/ChildProcessTests.cs index 14101e28c9..35a003046f 100644 --- a/src/tests/dotnet-trace/ChildProcessTests.cs +++ b/src/tests/dotnet-trace/ChildProcessTests.cs @@ -2,19 +2,23 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Diagnostics.NETCore.Client; -using System; -using Xunit; -using Xunit.Abstractions; +using Microsoft.Diagnostics.CommonTestRunner; +using Microsoft.Diagnostics.TestHelpers; using System.Collections.Generic; -using System.Linq; using System.Diagnostics; +using System.Text; +using Xunit; +using Xunit.Abstractions; +using Xunit.Extensions; +using TestRunner = Microsoft.Diagnostics.CommonTestRunner.TestRunner; namespace Microsoft.Diagnostics.Tools.Trace { public class ChildProcessTests { + public static IEnumerable<object[]> Configurations => TestRunner.Configurations; + // Pass ITestOutputHelper into the test class, which xunit provides per-test public ChildProcessTests(ITestOutputHelper outputHelper) { @@ -23,10 +27,35 @@ public ChildProcessTests(ITestOutputHelper outputHelper) private ITestOutputHelper OutputHelper { get; } - private void LaunchDotNetTrace(string command, out int exitCode, out string stdOut, out string stdErr) + private void LaunchDotNetTrace(TestConfiguration config, string dotnetTraceCommand, string traceeArguments, out int exitCode, out string stdOut, out string stdErr) { - string dotnetTracePathWithArgs = CommonHelper.GetTraceePathWithArgs(traceeName: "dotnet-trace").Replace("net5.0", "netcoreapp3.1"); - ProcessStartInfo startInfo = new ProcessStartInfo(CommonHelper.HostExe, $"{dotnetTracePathWithArgs} {command}"); + if (config.RuntimeFrameworkVersionMajor < 5) + { + throw new SkipTestException("Not supported on < .NET 5.0"); + } + DebuggeeConfiguration debuggeeConfig = DebuggeeCompiler.Execute(config, "ExitCodeTracee", OutputHelper).GetAwaiter().GetResult(); + + var dotnetTraceArguments = new StringBuilder(); + dotnetTraceArguments.Append(config.DotNetTracePath()); + dotnetTraceArguments.Append(' '); + dotnetTraceArguments.Append(dotnetTraceCommand); + dotnetTraceArguments.Append(" -- "); + + if (!string.IsNullOrWhiteSpace(config.HostExe)) + { + dotnetTraceArguments.Append(config.HostExe); + dotnetTraceArguments.Append(' '); + if (!string.IsNullOrWhiteSpace(config.HostArgs)) + { + dotnetTraceArguments.Append(config.HostArgs); + dotnetTraceArguments.Append(' '); + } + } + dotnetTraceArguments.Append(debuggeeConfig.BinaryExePath); + dotnetTraceArguments.Append(' '); + dotnetTraceArguments.Append(traceeArguments); + + ProcessStartInfo startInfo = new ProcessStartInfo(config.DotNetTraceHost(), dotnetTraceArguments.ToString()); OutputHelper.WriteLine($"Launching: {startInfo.FileName} {startInfo.Arguments}"); startInfo.RedirectStandardInput = true; @@ -53,45 +82,47 @@ private void LaunchDotNetTrace(string command, out int exitCode, out string stdO Assert.True(processExitedCleanly, "Launched process failed to exit"); exitCode = process.ExitCode; } + + if (!string.IsNullOrWhiteSpace(stdErr)) + { + OutputHelper.WriteLine(stdErr); + } } - [Theory] - [InlineData("232", 232)] - [InlineData("0", 0)] - public void VerifyExitCode(string commandLineArg, int exitCode) + [SkippableTheory, MemberData(nameof(Configurations))] + public void VerifyExitCode(TestConfiguration config) { - string exitCodeTraceePath = CommonHelper.GetTraceePathWithArgs(traceeName: "ExitCodeTracee", targetFramework: "net5.0"); + VerifyExitCodeX(config, "232", 232); + VerifyExitCodeX(config, "0", 0); + } - LaunchDotNetTrace($"collect -o verifyexitcode.nettrace -- {CommonHelper.HostExe} {exitCodeTraceePath} {commandLineArg}", out int dotnetTraceExitCode, out string stdOut, out string stdErr); + private void VerifyExitCodeX(TestConfiguration config, string commandLineArg, int exitCode) + { + LaunchDotNetTrace(config, "collect -o verifyexitcode.nettrace", commandLineArg, out int dotnetTraceExitCode, out string stdOut, out string stdErr); Assert.Equal(exitCode, dotnetTraceExitCode); - Assert.Contains($"Process exited with code '{exitCode}'.", stdOut); } - [Theory] - [InlineData("0 this is a message", new string[] { "\nthis\n", "\nis\n", "\na\n" })] - public void VerifyHideIO(string commandLineArg, string[] stringsInOutput) + [SkippableTheory, MemberData(nameof(Configurations))] + public void VerifyHideIO(TestConfiguration config) { - string exitCodeTraceePath = CommonHelper.GetTraceePathWithArgs(traceeName: "ExitCodeTracee", targetFramework: "net5.0"); - - LaunchDotNetTrace($"collect -o VerifyHideIO.nettrace -- {CommonHelper.HostExe} {exitCodeTraceePath} {commandLineArg}", out int dotnetTraceExitCode, out string stdOut, out string stdErr); + LaunchDotNetTrace(config, "collect -o VerifyHideIO.nettrace", "0 this is a message", out int dotnetTraceExitCode, out string stdOut, out string stdErr); Assert.Equal(0, dotnetTraceExitCode); stdOut = stdOut.Replace("\r", ""); + string[] stringsInOutput = new string[] { "\nthis\n", "\nis\n", "\na\n" }; foreach (string s in stringsInOutput) Assert.DoesNotContain(s, stdOut); } - [Theory] - [InlineData("0 this is a message", new string[] { "\nthis\n", "\nis\n", "\na\n" })] - public void VerifyShowIO(string commandLineArg, string[] stringsInOutput) + [SkippableTheory, MemberData(nameof(Configurations))] + public void VerifyShowIO(TestConfiguration config) { - string exitCodeTraceePath = CommonHelper.GetTraceePathWithArgs(traceeName: "ExitCodeTracee", targetFramework: "net5.0"); - - LaunchDotNetTrace($"collect -o VerifyShowIO.nettrace --show-child-io -- {CommonHelper.HostExe} {exitCodeTraceePath} {commandLineArg}", out int dotnetTraceExitCode, out string stdOut, out string stdErr); + LaunchDotNetTrace(config, "collect -o VerifyShowIO.nettrace --show-child-io", "0 this is a message", out int dotnetTraceExitCode, out string stdOut, out string stdErr); Assert.Equal(0, dotnetTraceExitCode); stdOut = stdOut.Replace("\r", ""); + string[] stringsInOutput = new string[] { "\nthis\n", "\nis\n", "\na\n" }; foreach (string s in stringsInOutput) Assert.Contains(s, stdOut); } diff --git a/src/tests/dotnet-trace/DotnetTrace.UnitTests.csproj b/src/tests/dotnet-trace/DotnetTrace.UnitTests.csproj index 5c99730da2..fb372850fe 100644 --- a/src/tests/dotnet-trace/DotnetTrace.UnitTests.csproj +++ b/src/tests/dotnet-trace/DotnetTrace.UnitTests.csproj @@ -1,13 +1,12 @@ -<Project Sdk="Microsoft.NET.Sdk"> +<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFramework>net5.0</TargetFramework> + <TargetFramework>net6.0</TargetFramework> </PropertyGroup> <ItemGroup> - <ProjectReference Include="../../Tools/dotnet-trace/dotnet-trace.csproj" /> - <ProjectReference Include="..\ExitCodeTracee\ExitCodeTracee.csproj" /> - <ProjectReference Include="..\Microsoft.Diagnostics.NETCore.Client\Microsoft.Diagnostics.NETCore.Client.UnitTests.csproj" /> + <ProjectReference Include="..\..\Tools\dotnet-trace\dotnet-trace.csproj" /> + <ProjectReference Include="..\CommonTestRunner\CommonTestRunner.csproj" /> </ItemGroup> </Project> diff --git a/src/tests/eventpipe/EventPipe.UnitTests.csproj b/src/tests/eventpipe/EventPipe.UnitTests.csproj index f6c26727c4..efa46f1b5c 100644 --- a/src/tests/eventpipe/EventPipe.UnitTests.csproj +++ b/src/tests/eventpipe/EventPipe.UnitTests.csproj @@ -1,7 +1,7 @@ -<Project Sdk="Microsoft.NET.Sdk"> +<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFrameworks>netcoreapp3.1</TargetFrameworks> + <TargetFrameworks>$(UnitTestTargetFrameworks)</TargetFrameworks> </PropertyGroup> <ItemGroup> diff --git a/src/tests/eventpipe/GCEvents.cs b/src/tests/eventpipe/GCEvents.cs index ad36377fa2..02f4fd5093 100644 --- a/src/tests/eventpipe/GCEvents.cs +++ b/src/tests/eventpipe/GCEvents.cs @@ -10,6 +10,8 @@ using EventPipe.UnitTests.Common; using Microsoft.Diagnostics.NETCore.Client; using Microsoft.Diagnostics.Tracing; +using System.Reflection; +using System.Runtime.InteropServices; namespace EventPipe.UnitTests.GCEventsValidation { @@ -188,8 +190,16 @@ await RemoteTestExecutorHelper.RunTestCaseAsync(() => Action _eventGeneratingAction = () => { List<string> testList = new List<string>(); - for(int i = 0; i < 100000000; i ++) + for (int i = 0; i < 100_000_000; i ++) { + // This test was failing (no GCFreeSegment callbacks) on x86 until this GC Collects happened. + if (RuntimeInformation.ProcessArchitecture == Architecture.X86) + { + if (i % 1_000_000 == 0) + { + GC.Collect(); + } + } string t = "Test string!"; testList.Add(t); } @@ -216,7 +226,9 @@ await RemoteTestExecutorHelper.RunTestCaseAsync(() => Logger.logger.Log("GCCreateSegmentEvents: " + GCCreateSegmentEvents); Logger.logger.Log("GCFreeSegmentEvents: " + GCFreeSegmentEvents); - bool GCSegmentResult = GCCreateSegmentEvents > 0 && GCFreeSegmentEvents > 0; + + // Disable checking GCFreeSegmentEvents on .NET 7.0 issue: https://github.com/dotnet/diagnostics/issues/3143 + bool GCSegmentResult = GCCreateSegmentEvents > 0 && (GCFreeSegmentEvents > 0 || Environment.Version.Major >= 7); Logger.logger.Log("GCSegmentResult: " + GCSegmentResult); Logger.logger.Log("GCAllocationTickEvents: " + GCAllocationTickEvents); diff --git a/src/tests/eventpipe/LoaderEvents.cs b/src/tests/eventpipe/LoaderEvents.cs index 6f68063aa7..50c21c4ebb 100644 --- a/src/tests/eventpipe/LoaderEvents.cs +++ b/src/tests/eventpipe/LoaderEvents.cs @@ -54,7 +54,7 @@ await RemoteTestExecutorHelper.RunTestCaseAsync(() => GetAssemblyPath(); try { - for(int i=0; i<100; i++) + for (int i = 0; i < 100; i++) { if (i % 10 == 0) Logger.logger.Log($"Load/Unload Assembly {i} times..."); @@ -62,6 +62,7 @@ await RemoteTestExecutorHelper.RunTestCaseAsync(() => assemblyLoad.LoadFromAssemblyPath(assemblyPath+"\\Microsoft.Diagnostics.Runtime.dll"); assemblyLoad.Unload(); } + GC.Collect(); } catch(Exception ex) {