mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 09:08:38 +00:00
bug report info: keep Windows status and error codes (0xC0000409, 0x887A0005)
They say what went wrong (the crash or device-removed code players are asked for) and hold nothing of the game or the user. Addresses (longer, or not starting with C0 or 8) are still removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -48,8 +48,8 @@ class ScrubTests(unittest.TestCase):
|
||||
|
||||
def test_hex_values(self):
|
||||
out = info.scrub_line("status 0xC0000409 and 0x1f")
|
||||
self.assertNotIn("0x", out)
|
||||
self.assertNotIn("C0000409", out)
|
||||
self.assertIn("0xC0000409", out) # a Windows status code is kept
|
||||
self.assertNotIn("0x1f", out)
|
||||
|
||||
def test_stage_names(self):
|
||||
for text in ("ps_1a2b3c", "vs 8F3A9C", "cs=beef", "GS:cafe", "ms-abcd12_main", "ds_deadbeef", "hs_0123", "as_f00d"):
|
||||
@ -88,7 +88,7 @@ class LogTests(unittest.TestCase):
|
||||
text = "\n".join(["INFO fine", "ERROR a", "WARN device lost", "INFO device removed here", "panicked at x",
|
||||
"an exception", "exit 0xC0000005", "INFO 0 errors", "INFO ok"])
|
||||
self.assertEqual(info.error_lines(text), ["ERROR a", "WARN device lost", "INFO device removed here",
|
||||
"panicked at x", "an exception", "<hex>"[:0] or "exit <hex>"])
|
||||
"panicked at x", "an exception", "exit 0xC0000005"])
|
||||
|
||||
def test_ten_line_cap_keeps_the_newest(self):
|
||||
text = "\n".join(f"ERROR number {i}" for i in range(30))
|
||||
@ -153,7 +153,7 @@ class ReportTests(unittest.TestCase):
|
||||
"Frame generation: DLSS 3x", "Options: -Dlss quality -FrameGen 3",
|
||||
"Variables: LEONIDA_FG_LIMIT_FPS=60"):
|
||||
self.assertIn(expected, lines)
|
||||
self.assertEqual(lines[-3:], ["Last errors of the newest play log:", "ERROR device removed <hex>",
|
||||
self.assertEqual(lines[-3:], ["Last errors of the newest play log:", "ERROR device removed 0x887A0006",
|
||||
"ERROR second"])
|
||||
self.assertTrue(text.endswith("\n") and "\r" not in text)
|
||||
|
||||
@ -229,5 +229,16 @@ class LauncherTests(unittest.TestCase):
|
||||
self.assertIn("GPU: not in the log", text)
|
||||
|
||||
|
||||
|
||||
class StatusCodes(unittest.TestCase):
|
||||
def test_windows_status_codes_are_kept_and_addresses_are_not(self):
|
||||
out = info.scrub_line("exception 0xC0000409 at 0x7FF6A1B2C3D4, hr 0x887A0005, then 0x80070057; ptr 0x1234ABCD")
|
||||
self.assertIn("0xC0000409", out)
|
||||
self.assertIn("0x887A0005", out)
|
||||
self.assertIn("0x80070057", out)
|
||||
self.assertNotIn("7FF6A1B2C3D4", out)
|
||||
self.assertNotIn("1234ABCD", out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@ -41,6 +41,9 @@ NAMED_VALUE = re.compile(
|
||||
r"(?P<key>\b\w*(?:program|shader|pipeline|pso|hash)\w*)(?P<eq>\s*=\s*)"
|
||||
r"(?:\"[^\"]*\"|'[^']*'|[^\s,;)\]}]+)", re.IGNORECASE)
|
||||
HEX_VALUE = re.compile(r"0x[0-9A-Fa-f]+", re.IGNORECASE)
|
||||
# Windows status and error codes (NTSTATUS 0xC0000409, HRESULT 0x887A0005, 0x80070057) say what went wrong and
|
||||
# hold nothing of the game or the user: kept. An address is longer, or does not start with C0 or 8.
|
||||
STATUS_CODE = re.compile(r"0x(?:C0|8[0-9A-F])[0-9A-F]{6}", re.IGNORECASE)
|
||||
STAGE_NAME = re.compile(r"\b(?:cs|ps|vs|gs|hs|ds|ms|as)(?P<sep>[_:=\-\s]+)(?P<name>\w+)", re.IGNORECASE)
|
||||
HEX_RUN = re.compile(r"[0-9A-Fa-f]{8,}")
|
||||
LEADING_HEX = re.compile(r"[0-9A-Fa-f]{4,}")
|
||||
@ -62,7 +65,7 @@ def scrub_line(line: str) -> str:
|
||||
|
||||
1. a home folder (`C:\\Users\\<name>`, `/home/<name>`) becomes %USERPROFILE%;
|
||||
2. the value of a `program=`, `shader=`, `pipeline=`, `pso=` or `hash=` (also `shader_hash=`) is removed;
|
||||
3. a `0x...` value is removed;
|
||||
3. a `0x...` value is removed, unless it is a Windows status or error code (0xC0000409, 0x887A0005);
|
||||
4. the name after a stage word (cs, ps, vs, gs, hs, ds, ms, as) that is hex-like is removed;
|
||||
5. a run of 8 or more hex digits is removed.
|
||||
|
||||
@ -70,11 +73,12 @@ def scrub_line(line: str) -> str:
|
||||
line = CONTROL.sub("", ANSI.sub("", line.rstrip("\r\n")))
|
||||
line = HOME_FOLDER.sub(HOME, line)
|
||||
line = NAMED_VALUE.sub(lambda m: m.group("key") + m.group("eq") + "<removed>", line)
|
||||
line = HEX_VALUE.sub("<hex>", line)
|
||||
line = HEX_VALUE.sub(lambda m: m.group(0) if STATUS_CODE.fullmatch(m.group(0)) else "<hex>", line)
|
||||
line = STAGE_NAME.sub(_stage_name, line)
|
||||
# A run of digits after a dot is a timestamp's fraction (".123456789Z"): kept.
|
||||
line = HEX_RUN.sub(lambda m: m.group(0) if m.group(0).isdigit() and line[m.start() - 1:m.start()] == "."
|
||||
else "<hex>", line)
|
||||
# A kept status code's digits are not a run to remove.
|
||||
line = HEX_RUN.sub(lambda m: m.group(0) if (m.group(0).isdigit() and line[m.start() - 1:m.start()] == ".")
|
||||
or line[max(0, m.start() - 2):m.start()].lower() == "0x" else "<hex>", line)
|
||||
return line[:MAX_LINE]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user