Installing and Debugging the Source Code: Difference between revisions
Jump to navigation
Jump to search
Note:You will be told that symbols could not be found for <whatever>.exe - this is normal, as you don't have that source code. Ignore the warning.
Line 48: | Line 48: | ||
* To break into the debugger, press {{key|Ctrl+C}}; to continue afterwards perform <code>cont</code>. | * To break into the debugger, press {{key|Ctrl+C}}; to continue afterwards perform <code>cont</code>. | ||
* To set a breakpoint, do <code>break <function></code>. See <code>help breakpoint</code> for more details. | * To set a breakpoint, do <code>break <function></code>. See <code>help breakpoint</code> for more details. | ||
* To print an expression, do <code>print <expr></code>. | * To print an expression, do <code>print <expr></code>[http://www.blognesian.com/ .] | ||
[[Category:Programming]] | [[Category:Programming]] | ||
[[Category:Modding]] | [[Category:Modding]] |
Revision as of 00:42, 25 August 2011
Installing
- Run the Source SDK and choose Create a Mod. See Create a Mod for details about the process.
- Choose a compiler
- Go! Get started with Your First Entity.
To compile your code on Linux, see Compiling under Linux.
Debugging
Debugging is the process of a human examining closely the inner workings of a program. It can reveal the causes of crashes and other bugs.
Windows
- Make sure you are working in the Debug configuration, not Release.
- In the Solution Explorer (Microsoft Visual C++), right-click on the active project (the one in bold) and choose Properties. It doesn't matter whether you're working with the server or client.
- In the window that appears, choose Debugging from the left-hand list.
- Change Command to the path to the .exe file you want to launch (the same on that runs when you play the game/mod in question, e.g.
C:\Steam\SteamApps\username\source sdk base 2007\hl2.exe
). - Change Command Arguments to read something like
-allowdebug -dev -sw -game "C:\Steam\SteamApps\SourceMods\MyMod"
- Change Working Directory to the folder containing the .exe you chose for Command e.g.
C:\Steam\SteamApps\username\source sdk base 2007
.
You can now press F5 at any time to start debugging. (If you really do want to debug in Release mode, repeat the above for that configuration. But don't expect the results to be very useful).

Run-time attachment
If you want to debug a process that is already running, choose Debug > Attach to Process... and select it from the list.
Linux
- Disable OPTFLAGS in the root makefile
- Uncomment DEBUG in your project's makefile.
Confirm:Change it to read
-O0 -g -ggdb3
. - Make and Install
- Open a terminal window and cd to the location of the executable you are running
- Perform
gdb srcds_linux
(or whatever the name is) - Perform
run <parameters>
to start the program
- On a crash ("segfault"), do
bt
("backtrace") to see the callstack. - To break into the debugger, press Ctrl+C; to continue afterwards perform
cont
. - To set a breakpoint, do
break <function>
. Seehelp breakpoint
for more details. - To print an expression, do
print <expr>
.