add '--debug:fuzzer' command line option

Provide a way to bypass a debugger when initiating fuzzing.
 nethack -D --debug:fuzzer        # run fuzzer in wizard mode
 nethack --debug:fuzzer           # run it in normal mode
 nethack [-D] -@ --debug:fuzzer   # skip role/race/&c selection
This commit is contained in:
PatR
2025-04-16 12:46:28 -07:00
parent 15fa0758f2
commit a7412dc835
2 changed files with 17 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 flag.h $NHDT-Date: 1715979826 2024/05/17 21:03:46 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.246 $ */
/* NetHack 3.7 flag.h $NHDT-Date: 1744860497 2025/04/16 19:28:17 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.251 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2006. */
/* NetHack may be freely redistributed. See license for details. */
@@ -237,9 +237,11 @@ enum debug_fuzzer_states {
* and probably warrant a structure of their own elsewhere some day.
*/
struct instance_flags {
boolean query_menu; /* use a menu for yes/no queries */
boolean showdamage;
boolean defer_plname; /* X11 hack: askname() might not set svp.plname */
boolean fuzzerpending; /* fuzzing requested on command line but not active
* yet (to allow interactive initialization prior
* to input becoming taken over);
* True => enable fuzzer when entering moveloop */
boolean herecmd_menu; /* use menu when mouseclick on yourself */
boolean invis_goldsym; /* gold symbol is ' '? */
boolean in_lua; /* executing a lua script */
@@ -247,8 +249,10 @@ struct instance_flags {
boolean nofollowers; /* level change ignores pets (for tutorial) */
boolean partly_eaten_hack; /* extra flag for xname() used when it's called
* indirectly so we can't use xname_flags() */
boolean query_menu; /* use a menu for yes/no queries */
boolean remember_getpos; /* save getpos() positioning in do-again queue */
boolean sad_feeling; /* unseen pet is dying */
boolean showdamage; /* extra message reporting damage hero has taken */
xint8 debug_fuzzer; /* fuzz testing */
int at_midnight; /* only valid during end of game disclosure */
int at_night; /* also only valid during end of game disclosure */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 allmain.c $NHDT-Date: 1742207239 2025/03/17 02:27:19 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.275 $ */
/* NetHack 3.7 allmain.c $NHDT-Date: 1744860497 2025/04/16 19:28:17 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.276 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -99,6 +99,12 @@ moveloop_preamble(boolean resuming)
u.uz0.dlevel = u.uz.dlevel;
svc.context.move = 0;
/* finish processing "--debug:fuzzer" from the command line */
if (iflags.fuzzerpending) {
iflags.debug_fuzzer = fuzzer_impossible_panic;
iflags.fuzzerpending = FALSE;
}
program_state.in_moveloop = 1;
/* for perm_invent preset at startup, display persistent inventory after
invent is fully populated and the in_moveloop flag has been set */
@@ -1078,6 +1084,7 @@ argcheck(int argc, char *argv[], enum earlyarg e_arg)
* immediateflips - WIN32: turn off display performance
* optimization so that display output
* can be debugged without buffering.
* fuzzer - enable fuzzer without debugger intervention.
*/
staticfn void
debug_fields(const char *opts)
@@ -1122,6 +1129,8 @@ debug_fields(const char *opts)
if (match_optname(opts, "immediateflips", 14, FALSE))
iflags.debug.immediateflips = negated ? FALSE : TRUE;
#endif
if (match_optname(opts, "fuzzer", 4, FALSE))
iflags.fuzzerpending = TRUE;
return;
}