mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 09:19:58 -04:00
Write the frame-time summary and the stutter map at a fatal error too, the map only when its lock is free.
dispatch.c fatal_end wrote only the profiler's samples, so a run that ended in a FATAL had no "frametime" or stutter-map lines for its last period: the numbers that would show what the game was doing before it failed. perf.c perf_summary_flush_try (weak in dispatch.c for builds without perf.c) runs after fs_save_crash_wait: ft_stop, then the running period's "frametime: at a fatal error" lines and the stutter map. The failing thread may hold any lock, so stutter_map.c gains stutter_report_as(tag, try_only), which only tries sm_lock and writes nothing when it is taken (stutter_report keeps the blocking take); the back end's exit lines (gfx_exit_log) and the trace's segments (seg_close) are left out, as they read state the failure may have left half made. The crash report keeps no summary: its state may be damaged. Not reproduced before the change (a missing diagnostic). tests/fatal_exit_check.py now wants the summary at rt_fatal and checks statically that perf_summary_flush_try only tries the map's lock and leaves the back end out; tests/stutter_hitch_check.c gets the trylock stand-in it needs. fatal_exit_check, stutter_hitch_check, stutter_map_check and the compile checks of every runtime file pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -60,6 +60,9 @@ void prof_sampler_write(void) {}
|
||||
void rtss_limit_restore(void) {}
|
||||
void kern_checkpoint(void) {}
|
||||
|
||||
// perf.c's summary at a fatal error, which dispatch.c calls through a weak symbol
|
||||
void perf_summary_flush_try(void) { say("frametime: at a fatal error\n"); }
|
||||
|
||||
// input.c's stop, which dispatch.c calls through a weak symbol: says it ran, or hangs as when SDL's lock is held
|
||||
static int rumble_hangs;
|
||||
void input_rumble_hd_stop(void) {
|
||||
|
||||
@@ -78,6 +78,13 @@ def static_checks():
|
||||
print(f'static: main.c crash_handler starts with the shared guard: {"ok" if ok else "FAIL (" + first + ")"}',
|
||||
flush=True)
|
||||
bad += not ok
|
||||
# the fatal error's summary leaves out what the failure may have left half made, and only tries the map's lock
|
||||
flush = re.sub(r'//[^\n]*', '', function((RT / 'perf.c').read_text(encoding='utf-8'), 'void perf_summary_flush_try(void)'))
|
||||
ok = ('stutter_report_as(' in flush and 'stutter_report(' not in flush and 'gfx_exit_log' not in flush
|
||||
and 'seg_close' not in flush)
|
||||
print(f'static: perf.c perf_summary_flush_try tries the stutter map\'s lock and leaves the back end out: '
|
||||
f'{"ok" if ok else "FAIL"}', flush=True)
|
||||
bad += not ok
|
||||
# both failed ends stop HD rumble through the bounded stop, after RivaTuner's restore
|
||||
fatal = re.sub(r'//[^\n]*', '', function((RT / 'dispatch.c').read_text(encoding='utf-8'),
|
||||
'static void fatal_end(int code, const char *fmt, va_list ap) {'))
|
||||
@@ -92,7 +99,7 @@ def static_checks():
|
||||
|
||||
CASES = [
|
||||
# mode, exit code, lines that must be there, lines that must not
|
||||
('fatal', 70, ['FATAL: the test\'s fatal error 1', 'rumble: stopped'], ['detach:']),
|
||||
('fatal', 70, ['FATAL: the test\'s fatal error 1', 'frametime: at a fatal error', 'rumble: stopped'], ['detach:']),
|
||||
# the rumble stop hangs (SDL's lock held by a thread that crashed): the end goes on after 300 ms
|
||||
('fatal_rumble', 70, ['FATAL: the test\'s fatal error 1'], ['rumble: stopped', 'detach:']),
|
||||
# two faults at once: the first report whole, the second thread waits (dispatch.c rt_ending_enter)
|
||||
|
||||
@@ -11,6 +11,7 @@ int cfg_bool(const char *name) { return !strcmp(name, "NX2NAVI_STUTTER_MAP"); }
|
||||
uint64_t kern_now_ns(void) { return clock_ns; }
|
||||
void plat_mutex_lock(PlatMutex *m) { (void)m; }
|
||||
void plat_mutex_unlock(PlatMutex *m) { (void)m; }
|
||||
int plat_mutex_trylock(PlatMutex *m) { (void)m; return 1; }
|
||||
static int logged;
|
||||
static char head[1400]; // the last report's first line
|
||||
void rt_log(const char *fmt, ...) {
|
||||
|
||||
Reference in New Issue
Block a user