From 7b7cb45f7c1ed307b585ab3506dc57854ec076a6 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Wed, 30 Apr 2025 22:55:05 +0100 Subject: Add some useful info printouts to debug builds Specifically when building in debug mode, we now: * Display all features on load, including skipped and internal ones, sorted by internal name instead of display name. * Print the names of all matched gametype tags after the feature list. * Add an sst_dbg_getcmdcb command to get the address of a command callback for quick breakpoint insertion or Ghidra lookup. * Add an sst_dbg_sendtables command to dump out the full ServerClass tree to help get names for entprops.txt. Note: this output is very long so you'll likely need to log console output to a file to be able to read it all. There's a bunch of developer experience and debug help stuff I want to get done eventually. This is just a very small piece, but it's a start. --- src/build/mkgamedata.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/build/mkgamedata.c') diff --git a/src/build/mkgamedata.c b/src/build/mkgamedata.c index 325cda2..f187028 100644 --- a/src/build/mkgamedata.c +++ b/src/build/mkgamedata.c @@ -265,6 +265,32 @@ _i("}") _( "}") } +static inline void dbgdump(FILE *out) { +_( "static void dumpgamedata() {") + int cursrc = -1; + for (int i = 0; i < nents; ++i) { + if (indents[i] != 0) continue; + if_cold (srcfiles[i] != cursrc) { + cursrc = srcfiles[i]; +F( " con_msg(\"-- %" fS " --\\n\");", srcnames[cursrc]) + } + const char *s = sbase + tags[i]; + int line = srclines[i]; + if (exprs[i]) { +F( " con_msg(\" [x] %s = %%d (line %d)\\n\", %s);", s, line, s) + } + else { +F( " if (has_%s) {", sbase + tags[i]) +F( " con_msg(\" [x] %s = %%d (line %d)\\n\", %s);", s, line, s) +_( " }") +_( " else {") +F( " con_msg(\" [ ] %s (line %d)\\n\");", s, line); +_( " }") + } + } +_( "}") +} + int OS_MAIN(int argc, os_char *argv[]) { srcnames = (const os_char *const *)argv; int sbase_len = 0, sbase_max = 65536; @@ -304,6 +330,13 @@ int OS_MAIN(int argc, os_char *argv[]) { defs(out); _("") init(out); + + // technically we don't need this header in release builds, but whatever. + out = fopen(".build/include/gamedatadbg.gen.h", "wb"); + if_cold (!out) die(100, "couldn't open gamedatadbg.gen.h"); + H(); + dbgdump(out); + return 0; } -- cgit v1.2.3-54-g00ecf