Jump to content

Attaching XCOM2 to debugger / ModBuddy?


hairlessorphan

Recommended Posts

Has anyone successfully attached XCOM2 to a debugger? What steps did you take?

 

I saw this in the tech documentation, and none of it makes sense, because Firaxis.

Script Debugging

The stock command line options for development specify “-autodebug”, which 
tells UE3 to attempt to attach to a script debugger if one is available. 
This level of debug support is only necessary for deep or complex mods, or
 if you would like to learn more about how the game works by watching it in
 motion within a debugging environment. XCOM 2 Modbuddy performs many of 
the steps required to get script debugging working, but to review the 
basic requirements / steps they are:


1. The game must run in an “uncooked” mode. This is enabled by you when you
 set the SDK and Game directories in Modbuddy, because modbuddy will then 
create symlinks / junctions to the game directories giving it access to the
 uncooked resources of the SDK.


2. Game scripts must be compiled in debug mode. Adding a “Debug” 
configuration to your mod project and building using it will set this up. 
Performing this action will also add a new command line option to the 
“StartDebugging” batch script: “-noseekfreeloading” which will instruct the
 game to use the uncooked resources and debug scripts.


3. You will need to install a script debugger that will respond to 
“-autodebug”. An example of such a debugger can be found here: 
https://code.google.com/archive/p/unreal-debugger/downloads. The basic
 setup for a debugger will include a DLL for the game to attach to and a 
debug environment that is launched by that DLL or connects to it.

So I believe step one happens automatically. Step two works, no problem. Step three is what? Where does it want these .dll's from the .zip? In the folder with the Visual Studio (Mod"Buddy") install? In the folder with the UDK (XComGame.exe) install? In the folder with the base game install? What happens after that?

 

I've also tried console command toggledebugger, but all that does is crash.

 

Any ideas?

Edited by hairlessorphan
Link to comment
Share on other sites

Nevermind, got it. Damn it, this always happens. I slam my face against a wall for two hours, I ask for help, I solve it five minutes later.

 

For those wondering, here's the ticket:

 

1) Copy the .dll's from the .zip into the folder with XCom2.exe:

[steam Install Location]\SteamApps\common\XCOM 2\Binaries\Win64 (or Win32 if you're luddite)

 

2) Go to the launcher folder:

[steam Install Location]\SteamApps\common\XCOM 2\Binaries\Win64\Launcher

 

3) Edit StartDebugging.bat to:

ModLauncherWPF.exe -allowconsole -log -autodebug -noseekfreeloading

 

(flags:

-allowconsole allows console

-log will open a new shell window that will display all `LOG calls from the scripts in realtime

-autodebug will make it look for the debugger .dll's

-noseekfreeloading will make it load the game from uncooked scripts)

 

4) Execute StartDebugging.bat

 

5) Enjoy breakpoints

 

Ok, new problem. I've been trying to catch the engine in the act of loading up item templates by placing breakpoints on the various X2ItemTemplate_DefaultThingy.CreateTemplates() functions, but I can't. Not sure why; my best guess is they happen before the debugger loads up and hits the game window breakpoint. Any ideas what the very first event might be and/or which class actually invokes the template creators?

Link to comment
Share on other sites

AFAIK the callchain for Template creation is thus:

[some Native C++ Function inside the game] -> X2DataSet.uc -> [Loop through classes that extend X2DataSet] -> Call CreateTemplates() on each

Which would explain why CreateTemplates() called on an override of one of the base game's CreateTemplates() function doesn't replace the call in the overriden class, it calls the override class serially afterwards instead.
Unsure if that's intentional behaviour but it makes updating existing templates after creation easier.
See here: http://forums.nexusmods.com/index.php?/topic/3771570-overriding-vanilla-content/?p=34411265

Link to comment
Share on other sites

Is there a way to know why project failes to build by XCOM2 mod buddy? I thought debug log in documentation does that but judging by your instruction it's for the game (after project is built). I know there is a mistake in scripts but I can't know which one without prefixing lines one by one with "//".

Link to comment
Share on other sites

Has anyone actually managed to get breakpoints to work? The breakpoints never trigger for me. I've made changes that are definitely being implemented into the game when I build my mod but when I place breakpoints in the debugger the program never breaks.

 

Edit: ignore me, my own fault fixed it now. I was just getting confused

Edited by SheepDarklord
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...