PSX Research
This commit is contained in:
parent
bbd29b1f10
commit
94c49ac5bd
16 changed files with 2052 additions and 16 deletions
|
|
@ -3,9 +3,11 @@ from __future__ import annotations
|
|||
import unittest
|
||||
|
||||
from tools.poc_crusader_usecode_parser import (
|
||||
classify_post_ret_metadata,
|
||||
format_target_event_reference,
|
||||
get_intrinsic_hints,
|
||||
intrinsic_display_name,
|
||||
render_pseudocode,
|
||||
render_partially_structured_blocks,
|
||||
render_structured_pseudocode,
|
||||
try_decode_loop_selector,
|
||||
|
|
@ -14,6 +16,44 @@ from tools.poc_crusader_usecode_parser import (
|
|||
|
||||
|
||||
class UsecodeStructuringTests(unittest.TestCase):
|
||||
def test_post_ret_debug_symbols_are_classified_as_metadata(self) -> None:
|
||||
body = bytes([0x50, 0x01, 0x01, 0x69, 0x00, 0x00]) + b"referent\x00" + bytes([0x7A])
|
||||
ops = [{"mnemonic": "ret", "offset": 0, "raw_bytes": "50", "operands": {}}]
|
||||
|
||||
metadata = classify_post_ret_metadata(body, ops)
|
||||
|
||||
self.assertIsNotNone(metadata)
|
||||
self.assertEqual(metadata["end_reason"], "debug_symbols_then_end")
|
||||
self.assertEqual(metadata["debug_symbol_offset"], 1)
|
||||
self.assertEqual(len(metadata["debug_symbols"]), 1)
|
||||
self.assertEqual(metadata["debug_symbols"][0]["name"], "referent")
|
||||
|
||||
def test_render_pseudocode_includes_post_ret_metadata_comment(self) -> None:
|
||||
ir = {
|
||||
"class": {"class_name": "JELYHACK", "entry_index": 277, "class_id": 0x04D3},
|
||||
"event": {"event_name_hint": "use", "slot": 0x01},
|
||||
"body": {"end_reason": "debug_symbols_then_end", "decoded_op_count": 1},
|
||||
"ops": [{"mnemonic": "ret", "offset": 0, "absolute_body_offset": 0, "raw_bytes": "50", "operands": {}}],
|
||||
"debug_symbols": [
|
||||
{
|
||||
"index": 0,
|
||||
"unknown1": 0x01,
|
||||
"type_id": 0x69,
|
||||
"type_char": "i",
|
||||
"bp_offset": 0x00,
|
||||
"bp_repr": "[BP+00h]",
|
||||
"unknown3": 0x00,
|
||||
"name": "referent",
|
||||
}
|
||||
],
|
||||
"field_tags": [],
|
||||
}
|
||||
|
||||
rendered = render_pseudocode(ir)
|
||||
|
||||
self.assertIn("post-return metadata (not executable)", rendered)
|
||||
self.assertIn("debug_symbol referent [BP+00h] type=0x69", rendered)
|
||||
|
||||
def test_alarmbox_style_forward_flow_renders_without_block_labels(self) -> None:
|
||||
blocks = [
|
||||
("entry", ["set_info(0x0211, *(arg_06));", "process_exclude();", "if var goto block_0330;"]),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue