Debugging and profiling tools

Started by
2 comments, last by DvDmanDT 10 years, 4 months ago

Hi everyone,

I was wondering about how to better debug and profile my games. I use Visual Studio with its debugger and profiler, but there are cases where they are difficult or impractical to use which is why I'm adding various tools to my "engine". A typical example is the debug console which can display explicit Log(message) calls, and their callstacks when messages are clicked. My console also allows arbitrary C# and IronPython statements which is great for debugging and testing. Included in this I also support a command which displays the result of an arbitrary expression on screen. Great for debugging mouse movements, picking etc.

My "engine" also has basic support for profiling subsystems by using something like BeginProfile/EndProfile which creates a treeview-like view when nested. It displays something like the minimum, maximum and average timings over N frames. It can be pretty helpful, but requires alot of manual instrumentation which I'm not entirely happy with. How can I improve this to make it more useful while less intrusive to the code?

What other debug and/or performance tools have you found to improve your development experiences?

Advertisement

That sounds better than 99% of debugging logs I have had to deal with. What don't you like about it, write it down and then you'll probably see what you want to achieve?

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

My "engine" also has basic support for profiling subsystems by using something like BeginProfile/EndProfile which creates a treeview-like view when nested. It displays something like the minimum, maximum and average timings over N frames. It can be pretty helpful, but requires alot of manual instrumentation which I'm not entirely happy with. How can I improve this to make it more useful while less intrusive to the code?


It is surprisingly easy to write your own in-game sampling profiler. It's really just another thread that periodically pauses and snoops the instruction pointer of the other threads. You can walk the call stack to generate the complete stack. You can also record other data in your own stack-like structures if you want to show additional context besides the raw call stack.

Sean Middleditch – Game Systems Engineer – Join my team!

I'm interested in trying to create my own sampler, but I'm not sure how well that works with .NET and it's JIT compilation..? Also, the best thing would be if I could add a command similar to "prof MyClass.MyMethod" to hook that method and wrap it in BeginProfile/EndProfile calls.

I found a CodeProject article/sample which is supposed to allow modifying code while running. It's samples work, but I'm unable to get it working for my own code.

http://www.codeproject.com/Articles/463508/NET-CLR-Injection-Modify-IL-Code-during-Run-time

I keep getting invalid program exceptions when trying to run a modified method, even though I tried to take the contents from an identical method. I gotta wonder if there's a way to do this that actually works. I also gotta wonder why it works in those samples but not in my code... Hmm. Anyway, anyone successfully managed to hook a method in C#?

This topic is closed to new replies.

Advertisement