Chapter 8. Debugging

 

This chapter covers

  • Debuggers in the Visual Studio line of products
  • WinDBG/CDB—an advanced debugger that works from the command line
  • LLDB for debugging on Linux and macOS
  • SOS—the extension that makes CDB and LLDB work with .NET Core

Debuggers are valuable tools when developing any kind of software. Most of them are fairly intuitive to use, which may make you wonder why I would dedicate a chapter to this subject.

Many developers, especially if they’re used to Visual Studio and the .NET Framework, don’t realize what options are available for debugging in other editors or on other operating systems. Also, command-line debuggers still have a place in the modern developer’s toolbox because they can do powerful things that GUI debuggers can’t. By the end of this chapter, you’ll be armed with the information you need to debug .NET Core applications almost anywhere.

8.1. Debugging applications with Visual Studio Code

I introduced Visual Studio Code (VS Code) in chapter 2. It’s Microsoft’s lightweight, cross-platform, extensible text editor (similar to the Atom text editor). If you installed the C# extension from Microsoft, then you’ve likely seen the debug capabilities show up on both the menu and the left-side bar. VS Code may have also nagged you to add “required assets to build and debug.” If not, try creating a new project and opening VS Code with the following commands:

mkdir Test1
cd Test1
dotnet new console
code .

8.2. Debugging with Visual Studio 2017

8.3. Debugging with Visual Studio for Mac

8.4. SOS

Additional resources

Summary

sitemap