Debugging C++ in Visual Studio

How do I use Visual Studio’s debugging capabilities on a client server game? I’m running both the client and the server on the same machine during development. When I run “Local Windows Debugger” in Visual Studio and set a breakpoint in my code, how do I know if execution hits the breakpoint in the server executable or the client executable?

Hello, Ian

Please note that for client-server game debugging, you can use Network Profiler tool that comes with the Engine.
It can show you a lot of network-related information, such as the amount of replicated properties and Actors, how much bandwidth is being used and more.

You can find the tool at /Engine/Binaries/DotNET/ directory.

To view the data, please capture a profile while your game is running. To do this you can enter ‘netprofile’ command in the console to start/stop recording. Then, after the recording stops, the appropriate *.nprof file will appear in Saved/Profiling directory of your project. To get the information, please open the file with the Network Profiler.

Hope this helped!

Have a great day!

But if I want to just single step through my code on just the server side or just the client side how do I do that?

I don’t know if it will help, but you have several configurations. “Debug Game Editor”, “Development Editor”, …

If you use “Development Editor”, what I’ve seen, is that some variables are optimized. The editor is launched separately and you have to attach the debugger to an exe. Every time you made code modifications, the hot reload takes care of the changes.

If you use “Debug Game Editor”, it will launch the editor when you start debugging. It is slower, but easier to debug. You don’t launch the editor, VS2013 will do it for you.

I hope it will help.
Have a nice day.
D.

Thanks, but that still doesn’t help. I have a bug where I change the material of an actor. When running on a listen server the material change happens but not on a client. So I want to step through my code when it’s running as a server and again when it’s running as a client to see where the differences lie. Should be pretty straightforward but (as with everything that should be easy on ue4) I can’t figure it out.

This doesn’t work. I’m in game editor and click play. I type netprofile from console (which doesn’t autocomplete by the way so I don’t know if it even worked–but didn’t get an error msg so who knows). After I quit the game I can’t find the *.nprof file. There is no Saved/Profiling directory of my project. There Saved directory but it doesn’t contain a Profiling directory.

Ok.
Then you have two instance of VS2013. One for launching the listen server and one for the client ?
And you start the listen server instance and the client without launching the editor with the -game parameter on the debug command line ?

D.

I’m doing things differently. When I click on “Local Windows Debugger” in VS2013 it launches a debugging version of Unreal Editor. I click Play (with 2 players) and two windows launch, one for the client and one for the server. Then I switch between the two windows to test being on the client or on the server. Is there a better way for me to set up for debugging?

When I did debug on the client, I don’t launch the game through the EU4 Editor.
I debug the code launching the game without the editor. You have to change the debug command line and add the parameters you need to :

  • connect to your game server
  • to launch the exe as a game and not through the editor -game

May be the way you did it is right. I’m not 100% sure, but I prefer to debug the game without launching the editor.

D.

My way:

  1. build a windows dedicated server(DS);
  2. debug the DS, find what happened when launch the DS;
  3. package a DS, and start with the command:
    ShooterGameServer.exe /Game/Maps/Sanctuary?game=TDM -server -log -port=7777 -NOSTEAM
  4. build and package a game client;
  5. start the game client with the command:
    ShooterGame.exe 127.0.0.1
    then attach the client process to visual studio, and debug the client, find what happend when launch the client;
  6. debug the DS, make a break point at Net Driver or somewhere you like, then launch client to connect DS, find what happend when a client connect to DS;
  7. now, open your imagination to do something else like find what happened when a player fired to other player

better way to debug a game, please tell me, thanks!

Lol your response wasn’t helpful at all