public HResult ResumeDebuggee() { HResult result = HResult.S_OK; if (ResumeHandle != IntPtr.Zero) { Trace.TraceInformation($"DebuggeeInfo.ResumeDebuggee {ProcessId} handle {ResumeHandle:X8}"); result = DbgShimAPI.ResumeProcess(ResumeHandle); DbgShimAPI.CloseResumeHandle(ResumeHandle); ResumeHandle = IntPtr.Zero; } return(result); }
public async Task OpenVirtualProcess(TestConfiguration config) { // The current Linux test assets are not alpine/musl if (OS.IsAlpine) { throw new SkipTestException("Not supported on Alpine Linux (musl)"); } if (!config.AllSettings.ContainsKey("DumpFile")) { throw new SkipTestException("OpenVirtualProcessTest: No dump file"); } await RemoteInvoke(config, nameof(OpenVirtualProcess), static (string configXml) => { AfterInvoke(configXml, out TestConfiguration cfg, out ITestOutputHelper output); DbgShimAPI.Initialize(cfg.DbgShimPath()); AssertResult(DbgShimAPI.CLRCreateInstance(out ICLRDebugging clrDebugging)); Assert.NotNull(clrDebugging); TestDump testDump = new(cfg); ITarget target = testDump.Target; IRuntimeService runtimeService = target.Services.GetService <IRuntimeService>(); IRuntime runtime = runtimeService.EnumerateRuntimes().Single(); CorDebugDataTargetWrapper dataTarget = new(target.Services); LibraryProviderWrapper libraryProvider = new(target.OperatingSystem, runtime.RuntimeModule.BuildId, runtime.GetDbiFilePath(), runtime.GetDacFilePath()); ClrDebuggingVersion maxDebuggerSupportedVersion = new() { StructVersion = 0, Major = 4, Minor = 0, Build = 0, Revision = 0, }; HResult hr = clrDebugging.OpenVirtualProcess( runtime.RuntimeModule.ImageBase, dataTarget.ICorDebugDataTarget, libraryProvider.ILibraryProvider, maxDebuggerSupportedVersion, in RuntimeWrapper.IID_ICorDebugProcess, out IntPtr corDebugProcess, out ClrDebuggingVersion version, out ClrDebuggingProcessFlags flags); AssertResult(hr); Assert.NotEqual(IntPtr.Zero, corDebugProcess); Assert.Equal(1, COMHelper.Release(corDebugProcess)); Assert.Equal(0, COMHelper.Release(corDebugProcess)); Assert.Equal(0, clrDebugging.Release()); return(Task.FromResult(0)); });
public async Task CreateDebuggingInterfaceFromVersion3(TestConfiguration config) { if (OS.Kind == OSKind.OSX && config.PublishSingleFile) { throw new SkipTestException("CreateDebuggingInterfaceFromVersion3 single-file on MacOS"); } DbgShimAPI.Initialize(config.DbgShimPath()); if (!DbgShimAPI.IsCreateDebuggingInterfaceFromVersion3Supported) { throw new SkipTestException("CreateDebuggingInterfaceFromVersion3 not supported"); } await RemoteInvoke(config, nameof(CreateDebuggingInterfaceFromVersion3), static async (string configXml) => { using DebuggeeInfo debuggeeInfo = await StartDebuggee(configXml, launch: false); TestCreateDebuggingInterface(debuggeeInfo, 3); return(0); }); }
public async Task Attach3(TestConfiguration config) { if (OS.Kind == OSKind.OSX && config.PublishSingleFile) { throw new SkipTestException("Attach3 single-file on MacOS"); } DbgShimAPI.Initialize(config.DbgShimPath()); if (!DbgShimAPI.IsRegisterForRuntimeStartup3Supported) { throw new SkipTestException("IsRegisterForRuntimeStartup3 not supported"); } await RemoteInvoke(config, nameof(Attach3), static async (string configXml) => { using DebuggeeInfo debuggeeInfo = await StartDebuggee(configXml, launch: false); TestRegisterForRuntimeStartup(debuggeeInfo, 3); return(0); }); }
public async Task Launch3(TestConfiguration config) { if (OS.Kind == OSKind.OSX && config.PublishSingleFile) { throw new SkipTestException("Launch3 single-file on MacOS"); } DbgShimAPI.Initialize(config.DbgShimPath()); if (!DbgShimAPI.IsRegisterForRuntimeStartup3Supported) { throw new SkipTestException("IsRegisterForRuntimeStartup3 not supported"); } await RemoteInvoke(config, nameof(Launch3), static async (string configXml) => { using DebuggeeInfo debuggeeInfo = await StartDebuggee(configXml, launch: true); TestRegisterForRuntimeStartup(debuggeeInfo, 3); // Once the debuggee is resumed now wait until it starts Assert.True(await debuggeeInfo.WaitForDebuggee()); return(0); }); }
public async Task EnumerateCLRs(TestConfiguration config) { await RemoteInvoke(config, nameof(EnumerateCLRs), static async (string configXml) => { using DebuggeeInfo debuggeeInfo = await StartDebuggee(configXml, launch: false); Trace.TraceInformation("EnumerateCLRs pid {0} START", debuggeeInfo.ProcessId); HResult hr = DbgShimAPI.EnumerateCLRs(debuggeeInfo.ProcessId, (IntPtr[] continueEventHandles, string[] moduleNames) => { Assert.Single(continueEventHandles); Assert.Single(moduleNames); for (int i = 0; i < continueEventHandles.Length; i++) { Trace.TraceInformation("EnumerateCLRs pid {0} {1:X16} {2}", debuggeeInfo.ProcessId, continueEventHandles[i].ToInt64(), moduleNames[i]); AssertX.FileExists("ModuleFilePath", moduleNames[i], debuggeeInfo.Output); } }); AssertResult(hr); Trace.TraceInformation("EnumerateCLRs pid {0} DONE", debuggeeInfo.ProcessId); return(0); }); }