dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.88k stars 676 forks source link

Step into library code when debugging single tests #4880

Closed thundersen closed 3 years ago

thundersen commented 3 years ago

Issue Description

I'm trying to debug a single NUnit test by clicking on the Debug Test command on the test method definition. When I try to step into a call to a referenced library the debugger just steps over it. Do I need to manually add pdb's or any additional setting for decompiling the library code on the fly?

Steps to Reproduce

Expected Behavior

The debugger should let me step into the method.

Actual Behavior

It steps over it.

Debug Console Output

The exceptions in the end happen after the method call is stepped over. I want to investigate their cause.

Console Output Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Private.CoreLib.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/testhost.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Runtime.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.TestPlatform.CoreUtilities.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/netstandard.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Diagnostics.Tracing.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.TestPlatform.PlatformAbstractions.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Runtime.Extensions.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Diagnostics.Debug.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Runtime.InteropServices.RuntimeInformation.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Collections.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.TestPlatform.CrossPlatEngine.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.TestPlatform.CommunicationUtilities.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.VisualStudio.TestPlatform.ObjectModel.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.VisualStudio.TestPlatform.Common.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Newtonsoft.Json.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Runtime.Serialization.Formatters.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Collections.Concurrent.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Threading.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Diagnostics.TraceSource.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Diagnostics.Process.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.ComponentModel.Primitives.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Threading.ThreadPool.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Net.Primitives.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Net.Sockets.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/Microsoft.Win32.Primitives.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Threading.Thread.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Private.Uri.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Memory.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Linq.Expressions.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Runtime.Numerics.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Linq.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.ComponentModel.TypeConverter.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.ObjectModel.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Collections.Specialized.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Runtime.Serialization.Primitives.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Data.Common.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Xml.ReaderWriter.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Private.Xml.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.ComponentModel.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Reflection.Emit.ILGeneration.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Reflection.Primitives.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Reflection.Emit.Lightweight.dll'. Cannot find or open the PDB file. Loaded 'Anonymously Hosted DynamicMethods Assembly'. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.IO.FileSystem.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Runtime.InteropServices.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Runtime.Loader.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/NUnit3.TestAdapter.dll'. Symbols loaded. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Resources.ResourceManager.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/nunit.engine.api.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Security.Cryptography.Algorithms.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/NuGet.Frameworks.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/nunit.engine.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/nunit.engine.core.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/testcentric.engine.metadata.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Collector.Test.dll'. Symbols loaded. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/nunit.framework.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Console.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Text.Encoding.Extensions.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Net.Requests.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Text.RegularExpressions.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Xml.XDocument.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Private.Xml.Linq.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Reflection.Metadata.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.IO.MemoryMappedFiles.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Collections.Immutable.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/DotNet.Testcontainers.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.Extensions.Hosting.Abstractions.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.Extensions.Hosting.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.Extensions.Configuration.Abstractions.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.Extensions.DependencyInjection.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.Extensions.Configuration.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.Extensions.Primitives.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Threading.Tasks.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.Extensions.FileProviders.Abstractions.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.Extensions.FileProviders.Physical.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.Extensions.Configuration.FileExtensions.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.Extensions.Configuration.Json.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.IO.FileSystem.Watcher.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Threading.Timer.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.Extensions.FileSystemGlobbing.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.Extensions.Options.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.Extensions.Logging.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.Extensions.Logging.Abstractions.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Serilog.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Serilog.Settings.Configuration.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Microsoft.Extensions.DependencyModel.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Reflection.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.AppContext.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.IO.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Serilog.Extensions.Logging.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/Docker.DotNet.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Net.Http.dll'. Cannot find or open the PDB file. Exception thrown: 'System.ArgumentNullException' in System.Private.CoreLib.dll Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Net.Security.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Security.Cryptography.X509Certificates.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Collections.NonGeneric.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Buffers.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Security.Cryptography.Primitives.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Runtime.CompilerServices.Unsafe.dll'. Module was built without symbols. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Net.WebHeaderCollection.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Net.ServicePoint.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Diagnostics.DiagnosticSource.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Net.NameResolution.dll'. Cannot find or open the PDB file. Loaded '/home/USER/code/personal/timberborn/vevantzedata/collector_test/bin/Debug/net5.0/ICSharpCode.SharpZipLib.dll'. Cannot find or open the PDB file. Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Linq.Parallel.dll'. Cannot find or open the PDB file. Exception thrown: 'Docker.DotNet.DockerApiException' in Docker.DotNet.dll Exception thrown: 'Docker.DotNet.DockerApiException' in System.Private.CoreLib.dll Exception thrown: 'Docker.DotNet.DockerApiException' in System.Private.CoreLib.dll Exception thrown: 'Docker.DotNet.DockerApiException' in System.Private.CoreLib.dll Exception thrown: 'Docker.DotNet.DockerApiException' in System.Private.CoreLib.dll Exception thrown: 'Docker.DotNet.DockerApiException' in System.Private.CoreLib.dll Exception thrown: 'Docker.DotNet.DockerApiException' in System.Private.CoreLib.dll Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/5.0.11/System.Diagnostics.StackTrace.dll'. Cannot find or open the PDB file. The program '[2963451] dotnet' has exited with code 0 (0x0).

Environment information

VSCode version: 1.61.2 C# Extension: 1.23.16

Mono Information OmniSharp using global mono :6.8.0
Dotnet Information .NET SDK (reflecting any global.json): Version: 5.0.402 Commit: e9d3381880 Runtime Environment: OS Name: ubuntu OS Version: 20.04 OS Platform: Linux RID: ubuntu.20.04-x64 Base Path: /usr/share/dotnet/sdk/5.0.402/ Host (useful for support): Version: 5.0.11 Commit: f431858f8b .NET SDKs installed: 3.1.414 [/usr/share/dotnet/sdk] 5.0.402 [/usr/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 3.1.20 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.11 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.20 [/usr/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.11 [/usr/share/dotnet/shared/Microsoft.NETCore.App] To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |csharp|ms-dotnettools|1.23.16| |dotenv|mikestead|1.0.1| |flux|influxdata|0.6.9| |gitlens|eamodio|11.6.1| |ilspy-vscode|icsharpcode|0.12.1| |intellij-idea-keybindings|k--kato|1.5.0| |markdown-all-in-one|yzhang|3.4.0| |test-adapter-converter|ms-vscode|0.1.4| |vscode-dotnet-runtime|ms-dotnettools|1.3.0| |vscode-nuget-gallery|patcx|0.0.24| |vscode-nxunit-test-adapter|wghats|0.1.3| |vscode-test-explorer|hbenl|2.21.1|;
gregg-miskelly commented 3 years ago

There are two reasons why stepping into a library wouldn't work even with Just-My-Code off:

  1. No symbols - if the debugger couldn't find symbols for the module you stepped into, it wouldn't stop
  2. Optimization - if the method you are stepping into is optimized, stepping may or may not work. You can get around this in a few ways:
    • Disable optimizations. See here and here for some general advice on this. In the case of unit tests in particular this may be a bit more challenging than normal as I am not sure if there is a way to set environment variables, and the module you want to debug might already be loaded by the time you attach a debugger. In which case suppressJITOptimizations will have no effect.
    • Set breakpoints (or configuring exception settings) instead of stepping. You can either download the source files and start setting breakpoints trying to find some line that the .NET runtime keeps a mapping for, or you could try a function breakpoint. You could also configure the debugger to stop on the exception.
thundersen commented 3 years ago

Thanks a lot for the quick reply @gregg-miskelly!

My first guess would be missing symbols then. You can see a ton of complaints about missing pdb files in the Debug output. Is there no way to decompile third party code on the fly when debugging from vscode?

gregg-miskelly commented 3 years ago

Correct.

thundersen commented 3 years ago

Too bad. Thanks for confirming that!