What are you Missing by Debugging in VS Code?

what-are-you-missing-by-debugging-in-vs-code?

In the first chapter of my debugging book, I discuss IDE debugging. In that chapter, I mostly talk about IntelliJ/IDEA. People often ask me why I didnโ€™t write as much about VS Codeโ€ฆ The reason is that there isnโ€™t much to write about. Its debugger is simpler for better and for worse. It isnโ€™t as powerful as other IDEs. I created the following video that covers the content of this post:

This isnโ€™t a slam against VS Code or against Microsoft. Visual Studio has one of the most powerful debuggers around. But Visual Studio Code doesnโ€™t have a lot of the features from Visual Studio or other IDEs. I believe this is intentional. I think this is a user experience-driven decision in which they removed features to simplify usability. One thing VS Code did well was exposing the logpoint (tracepoint) feature, so it is more discoverable to the casual developer. Thatโ€™s pretty great and wouldnโ€™t have been practical if the IDE had all the salient features.

But thereโ€™s a price that comes with simplicity. As you can see in the following table there are many missing features that are available in IntelliJ. These are all features I covered in blog posts or videos. Notice that the video links in the following table are direct links to the specific time within the video.

Feature

VS Code

Comments

Links

Breakpoint

โœ…

Video, Post

Conditional Breakpoint

โœ…

Video, Post

Logpoint/Tracepoint

โœ…

Video, Post

Step Over

โœ…

Video, Post

Step Into

โœ…

Video, Post

Step Out

โœ…

Video, Post

Continue

โœ…

Video, Post

Run to Cursor

โœ…

Video, Post

Return Immediately

โŒ

Restart Frame is available

Video, Post

Jump to Line

โŒ

Video, Post

Return Value Display

โœ…

(on by default)

Video, Post

Evaluate

โœ…

Video, Post

Watch

โœ…

Video, Post

Inline Watch

โŒ

Video, Post

Set Value

โœ…

Video, Post

Object Marking

โŒ

Video, Post

Method Breakpoints

โŒ

Video, Post

Field watchpoints

โŒ

Video, Post

Exception Breakpoints

โœ…

They suck without filters

Video, Post

Grouping/Naming Breakpoints

โŒ

Video, Post

Disable Breakpoints

โœ…

Video, Post

Instance Filters

โŒ

Video, Post

Class Filters

โŒ

Video, Post

Caller Filters

โŒ

Video, Post

Filtering

โŒ

Array and Collection filtering

Video, Post

Stream Debugger

โŒ

Video, Post

Basic rendering

โœ…

Very simplistic

Video, Post

Entry Rendering

โŒ

Video, Post

Rendering Annotations

โŒ

Video, Post

Thread View

โŒ

Video, Post

Async Stack Traces

โŒ

No custom support

Video, Post

Searchable memory View

โŒ

Video, Post

Track new Instances

โŒ

Video, Post

The Missing Features

Following is a high-level overview of the missing features.

Flow Control

Return immediately lets us return right away from a method and potentially return an arbitrary value. This is fantastic when you want to test edge cases.

There are also drop frame and throw exception features.

To be fair, VS Code has โ€œrestart frameโ€ which is similar to โ€œdrop frameโ€ and also nice.

Jump to line requires a plugin for IntelliJ. It lets us drag the execution pointer to an arbitrary location. If you have a bug, just drag the execution back and try again.

Need to skip a line of code because your app is in a problematic state but you still want to debug?

Drag forward. This is a fantastic killer feature when you need it.

Watch Area

Both IDEs contain a watch but only IntelliJ can show the values of the watch variables directly in the editor itself. This is very convenient when watching multiple values. It lets us see the stack at a glance as we scroll through the code.

Object marking is one of my favorite obscure features. It lets us dynamically declare a global variable that helps us track a value. We can use this global variable in a conditional breakpoint to verify things. One such example is saving the current thread as a marked object and then only breaking if we hit the method with a different thread.

Breakpoints

Method breakpoints are pretty problematic but they have some edge uses. One of the big values is the ability to break when returning from a long method. This is helpful in tracing threading issues.

Field watchpoints are very useful when tracking field mutation and new values.

We can manage breakpoints, name, group and disable them as a hierarchy group. When dealing with multiple tasks and switching branches in the middle of a debugging session, we can keep that session on hold by grouping all the breakpoints together.

When we return to the task, we can instantly jump right back!

VS Code has exception breakpoints. But without filters they absolutely suck!

We can filter breakpoint hits based on multiple criteria such as instance, class or a specific method in the stack. I spent so much time pressing continue over and over again. We can reduce this pain using these tools.

Arrays, Collections and Streams

Thereโ€™s another spectacular type of filtering. We can filter the content of an array or collection right in the watch or evaluate area. I spent a great deal of time digging through arrays of image data with thousands of elements. This was a nightmare. With this, we can find the entries that we need in a collection or array, instantly!

This is about the Java 8 and newer stream API which is a functional programming construct. Itโ€™s a fantastic tool, but it makes debugging awkward. The stream debugger borrows concepts from time travel debuggers to make stream debugging easier than regular debugging sometimes.

Entry Rendering

This is one of the most fantastic features you can think of. We can completely customize the way entries look in the watch. In the demo here, I show how I can expose the content of an Object Relational Mapping object as I step over in the debugger.

But this is hard to configure every time for every case. Annotations let us configure this globally so we can see this every time for specific library objects when running in the debugger.

Thread and Asynchronous Debugging

VS Code shows threads, but it has very limited display functionality and configurability. IntelliJ can open a dedicated thread view, hierarchies and much more.

It also supports gluing asynchronous stack traces together to make it easier to debug asynchronous code. This works seamlessly with well known APIs and the really cool thing is that we can use annotations to add this to our custom APIs.

Memory

We can search through memory to find any object instance. We can find VM internal instances and investigate issues by reviewing the objects in the system.

Better yet. We can track every new instance of a particular class. Get full stack traces to every new instance created between one breakpoint and another. This can track what happened under the hood with surgical precision.

Finally

Thereโ€™s a lot I didnโ€™t cover because thereโ€™s just so much. I donโ€™t think VS Code is inherently bad. It just went for simplicity. Personally, I think of myself as a power user. If youโ€™re like me I hope this post gave you a sense of what youโ€™re missing.

Please check out my book, my course, and follow me for videos like the one embedded above.

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
how-digital-transformation-changes-the-logistics-and-scm-industry

How Digital Transformation Changes The Logistics and SCM Industry

Next Post
how-mailshake-moved-upmarket-from-smb-to-enterprise

How Mailshake Moved Upmarket from SMB to Enterprise

Related Posts