Register for your free account! | Forgot your password?

You last visited: Today at 18:50

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Guide] How to Debug Your Server

Discussion on [Guide] How to Debug Your Server within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.

Reply
 
Old   #1
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,205
Received Thanks: 4,107
[Guide] How to Debug Your Server

Who is this guide for?
This guide is for beginning programmers who care about how their source is made and would like to learn how to debug their source properly. This guide is not for naive members who think they can run a server without any programming knowledge what-so-ever.

Introduction:
So, what is debugging? The formal definition is "Debugging is a methodical process of finding and reducing the number of bugs, or defects, in a computer program or a piece of electronic hardware, thus making it behave as expected." The story behind it is that Grace Hopper (a computer scientist in the 1940s when punch cards were used as input, output, and programming) found a moth stuck in one of the holes of a punch card. Upon removing the bug, the program worked (thus why we call removing problems "debugging").

Debugging by Comparison:
One method of debugging is by comparing expected output with actual output. It's a very simple thing to do, output the actual values in variables as your program executes using print line / write line statements, then compare those values with your expected values.

Debugging in Visual Studio:
A lot of IDEs (Integrated Development Environments), such as Visual Studio, offer a variety of debugging tools. In this guide (since most of the community uses C#), I'll be showing you some of the tools in Visual Studio. First, let's prepare the project for debugging. Run your project in debugging mode. While the project is running, open the Debug menu. Under "Debug > Windows", open the "Locals", "Auto", and "Watch 1" windows. Drag each window to where you'd like them to be in the solution (I drag mine to the right side with my solution explorer).

Now that your project is set up, stop the project and find a line where you would like to start debugging from in your code (you can do this while the project is running as well). I've created a test project to debug, and will be starting in my main function after initializing an array with random values. On the line you wish to start from, right click and select "Breakpoint > Insert Breakpoint". You may also do this by clicking in the gray margin to the left of the line.



Next, start your project (or have the project run the code where the breakpoint will be hit). When the project attempts to run the code where the breakpoint is, it will pause execution on that line and allow you to see what's stored in variables. Open your locals window or hover your mouse over variables to see what's inside!



Keep the locals window open (it will change because we're now going to let it run to the next line). At the very top of the window in your toolbar, you'll see the debug toolbar (shown below).



Hover your mouse over the buttons to see what they do. There are some very useful buttons there. To execute to the next line (called a step), or to step into a function (if the line you're on calls a function), use the "step into" button. To step over a function (if the line you're on calls a function), use "step over". Finally, if you want to step out of a function, use "step out" and the project will run the rest of the function and bring you back to the outside of the function.

Step through each line, one at a time, and notice how your locals change.



Notice the yellow arrow to the left of the line you're on. I'm going to change the code above it, then drag the yellow arrow to the line I want it to jump back to (so I can run the same code again).



Now, sometimes you'll have a lot of local variables to sort through. This can be problematic if you're trying to focus on a group of variables. That's where the autos window and watch window come in. The autos window will focus on values not only in variables, but in assignments. See the example below:



The watch window will only show variables that you want to watch. To add a variable to the watch list, right click on a variable and select "Add Watch". Also, when you hover your mouse over a variable to show the value inside it, you can pin it to the page using the pin icon.



You can also edit values in variables by double clicking on the value in the tooltip (popup value box when you hover over a variable) or in the autos / locals / watch window.

Conclusion:
There's more to debugging, but I don't want to make this too long. Hopefully this has been helpful to some. Sorry for how bad this guide probably is (I haven't proofread it). Good luck.

Edit: Unit testing information...
Spirited is offline  
Thanks
4 Users
Old 09/18/2013, 23:01   #2
 
Super Aids's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 946
If you don't know how to debug, you simply shouldn't be running a server in the first place.
Super Aids is offline  
Old 09/18/2013, 23:44   #3
 
Smallxmac's Avatar
 
elite*gold: 0
Join Date: Dec 2010
Posts: 105
Received Thanks: 13
I know right! Debugging is very easy and is important to see if the information you want is really going though the program. Many people think debugging is just hitting the debug button on the source and see of an Exception gets thrown. Then they have no idea how to tell what the problem is because they did not do custom Exception...
Smallxmac is offline  
Old 09/18/2013, 23:56   #4
 
Super Aids's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 946
and because they use tries with empty catches everywhere.
Super Aids is offline  
Old 09/19/2013, 00:39   #5
 
CriticallyDev's Avatar
 
elite*gold: 0
Join Date: May 2012
Posts: 87
Received Thanks: 4
I don't understand..why wasn't this information shared years ago? When people actually gave a shat?

This guide is completely useless now for two obvious reasons:
1. "People" pay others to program-setup-run their projects.
2. Common sense.
CriticallyDev is offline  
Old 09/19/2013, 00:57   #6
 
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 327
well unlike everyone else, i think that without this kind of tutorials this forum will fails even more, yes people who can't debug in visual studio should not own server, but the fact is that they do and the fact is that this will help them and save alot of useless threads
go for it is offline  
Old 09/19/2013, 01:47   #7
 
Super Aids's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 946
They will still make useless threads.
Super Aids is offline  
Old 09/19/2013, 01:57   #8
 
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 327
Quote:
Originally Posted by Super Aids View Post
They will still make useless threads.
you can't live life expecting that everything won't work out the way it was planned to be, that way no one will ever do something useful
go for it is offline  
Old 09/19/2013, 02:56   #9
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,205
Received Thanks: 4,107
There are very educated people in my life and in this community who were very interested in a guide like this. They learn quickly but they're scared to ask questions because of these types of responses from other members in the community. I was very scared to ask questions when I was teaching myself programming, and I've been doing my best to reverse that. This community should be open to all levels of programmers. Now, please keep on topic and please stop discouraging members (be more aware of what you're saying).
Spirited is offline  
Thanks
10 Users
Reply


Similar Threads Similar Threads
guide: debug pwi, find function addresses and offsets, write a bot(c++ code included)
09/04/2022 - PW Hacks, Bots, Cheats, Exploits - 123 Replies
hi, let's start right away. what you can learn: - trace and call ingame-functions like attack, cast spell, pick up, moveto, ... - traverse object lists like items, mobs, players - read ingame structures (class objects) and how they play together - write your own fully client-side bot that doesnt need to simulate mouse/keyboard input and doesnt need to read pixels
World Server Debug
08/02/2013 - Flyff Private Server - 1 Replies
Hi , wie kann ich den World Server im Debug Modus starten? Habe bereits gegooglet und finde eigentlich nur Englische Foren und 1 Deutsches aber dort wurde nicht zu dem Thema kommentiert. Ich weiß bereits das man es über die Source machen muss , aber wie? :s
[Guide] Debug .dll Files on x64 Systems
03/16/2012 - Mabinogi Hacks, Bots, Cheats & Exploits - 25 Replies
Nope, not going for the obvious fix of using a different disassembler. Bet your thinking: *HOPES HE SAYS WE USE OLLYDBG, ELSE ITS SHIT* Also I'm not going to say "Install x32". This is because most advanced programmers and reverse code engineers will be using x64 systems because we just do? : D <3
Complete Server-Commands ( debug )
07/23/2011 - Rappelz - 11 Replies
I see the actually server command list and i think i release my list because my list have all commands included... Btw. the ingame commands srsly included in my list .. Have fun. Memory Commands : memory.summon_heap_size memory.item_heap_size
Guide: Debug console
01/13/2011 - Perfect World - 26 Replies
In this guide I wil tell you how to get the debug console to work in 2 ways. Updated for pw international 1.4.0 First and easy way: Launch the game with console:1 you can make a batchscript for that 1 create an empty .txt file in the folder where your elementclient.exe is located 2 copy pase the following code in it:



All times are GMT +1. The time now is 18:50.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.