Visual Studio (Windows)
VS behaves oddly with debug paths, so you need to configure the project properties correctly.Setting Up Debug Configuration
- Open the xenia-app project properties
-
Set the following values:
- Command:
$(SolutionDir)$(TargetPath) - Working Directory:
$(SolutionDir)..\.."
- Command:
-
In the Command Arguments field, specify:
- Command-line flags
- The file to run
- Or use
--flagfile=flags.txtto load flags from a file
Example Command Arguments
Command-Line Arguments
Xenia supports numerous command-line arguments for debugging and configuration. Here are the most important ones for debugging:Log Files
By default, logs are written to a file with the name of the executable. Override the log file location:JIT Code Analysis
When debugging JIT-compiled code in Visual Studio, the disassembly around address0xA0000000 can be difficult to read.
Enable source annotations:
mov instructions in the disassembly, making it easier to understand the generated code.
The
--emit_source_annotations flag is specifically useful when examining JIT-compiled code in a debugger. It adds markers that help you correlate the assembly with the original PowerPC instructions.Common Debug Flags
Here are additional flags commonly used during debugging:Linux Debugging
Building for Debug
Normal building viaxb build uses CMake + Ninja. To build with debug symbols:
Using GDB
Debug with GDB:Using Valgrind
Check for memory issues with Valgrind:Make sure you have
valgrind installed: sudo apt-get install valgrindSetting Up Your Development Environment
To make debugging easier, set program startup arguments in your IDE.Visual Studio
- Right-click xenia-app project
- Select Properties
- Go to Debugging
- Set Command Arguments:
CLion / Other IDEs
For CMake-based IDEs like CLion:- Open Run/Debug Configurations
- Set Program arguments:
- Set Working directory to the project root
Debugging Tips
Analyzing JIT Code
When debugging the JIT compiler:- Enable source annotations: Use
--emit_source_annotations - Set breakpoints in the JIT code generator functions
- Examine memory around
0xA0000000where JIT code is placed - Use disassembly view to see generated x86/x64 code
Debugging Graphics Issues
- Enable GPU logging: Check for GPU-related flags in the code
- Use graphics debuggers: Tools like RenderDoc can capture frames
- Check shader compilation: Look for shader errors in logs
- Verify state changes: Watch for unexpected GPU state transitions
Debugging Audio Issues
- Check XMA decoder: Audio uses the XMA hardware decoder
- Monitor audio buffers: Look for underruns or overruns
- Verify timing: Audio issues often relate to timing problems
Debugging CPU Emulation
- Enable instruction tracing: Some builds support detailed CPU traces
- Check register state: Examine PowerPC register values
- Verify memory access: Watch for invalid memory operations
- Compare with hardware: Use known good values from real Xbox 360
Common Issues
Issue: Logs Not Appearing
Solution: Make sure you’re using--log_file=stdout or check the default log file location (usually next to the executable).
Issue: Can’t Set Breakpoints
Solution: Ensure you’re building in Debug configuration (xb build --config=debug or Debug configuration in Visual Studio).
Issue: Game Crashes Immediately
Solution:- Check logs for error messages
- Verify the game file is not corrupted
- Try with
--log_level=2for verbose output - Check if the game is known to work (see compatibility list)
Issue: JIT Disassembly Is Unreadable
Solution: Use the--emit_source_annotations flag to add markers in the generated code.
Advanced Debugging
Creating Flag Files
Create adebug_flags.txt file with commonly used flags:
Debugging Build Issues
If you encounter build errors:- Update dependencies: Run
xb setupagain - Clean build: Use
xb build --clean - Check LLVM version: Ensure you have the correct version for your platform
- Update submodules: Run
git submodule update --init --recursive
Profiling Performance
For performance debugging:- Use built-in profilers: Some builds include profiling support
- External tools: Use tools like VTune (Windows) or perf (Linux)
- Check frame times: Monitor frame rendering performance
- Profile hotspots: Identify slow functions and optimize
Getting Help
If you’re stuck debugging an issue:- Check the logs: Most issues leave traces in the log files
- Search existing issues: Someone may have encountered the same problem
- Ask on Discord: Join the
#devchannel on the Xenia Discord - Provide details: When asking for help, include:
- Log output
- Steps to reproduce
- System configuration
- Game title ID (not the game name)
