S&box Wiki

Debugging

Debugging using Visual Studio

This page explains the process of debugging using Visual Studio, for other IDEs use their corresponding debugging capabilities.

Starting in debug mode

S&box supports debugging, it's as simple as opening up the generated Addons.sln and hitting Debug > Start Debugging ( f5 ). This will launch a new instance of s&box and attach a debugger to it.

Attaching a debugger

You can also attach a debugger to an already running instance of the game by going to Debug > Attach to Process ( ctrl + alt + p ) and selecting sbox.exe in the list of processes.

After this you can reattach the debugger to the same process using Debug > Reattach to Process ( ⇧ shift + alt + p ).

Using breakpoints

Breakpoint

Breakpoints allow you to pause execution when it reaches specified points in your code (breakpoints). To add or remove a breakpoint click on the left from the line of code you want to pause or put the caret on this line and press f9. A red circle should appear and the line should turn red.

When this line will be reached execution will pause allowing you to inspect variables values, continue execution step-by-step and more. After you are done press f5 to continue execution.

Breakpoints can be added and removed freely in runtime, unlike code changes they don't require recompiling.

Disabling Edit and Continue

You may notice that you get green underlines while debugging and editing code, this is due to Edit and Continue being enabled in the Visual Studio settings, normally this is a good thing but due to s&box hotloading it needs to be disabled. You can disable this by going to Tools > Options > (or Debug > Options) > Debugging > General then scrolling about half way down and unchecking Edit and Continue.

Page Links


Special Pages


Wikis

?

Render Time: 93ms

DB GetPage 40
Generate Html 0
SaveChanges (1) 51
Render Body 0
Render Sidebar 0