diff --git a/kmir/src/kmir/kompile.py b/kmir/src/kmir/kompile.py index 67878e05e..c48fef906 100644 --- a/kmir/src/kmir/kompile.py +++ b/kmir/src/kmir/kompile.py @@ -521,13 +521,25 @@ def _functions(kmir: KMIR, smir_info: SMIRInfo) -> dict[int, KInner]: for ty in smir_info.function_symbols_reverse[item_name]: functions[ty] = parsed_item_kinner.args[1] - # Add intrinsic functions + # Add intrinsic functions and linked normal symbols that have no local body in `items`. + # Normal symbols must still map to `monoItemFn(..., noBody)` instead of falling back to UNKNOWN FUNCTION. for ty, sym in smir_info.function_symbols.items(): - if 'IntrinsicSym' in sym and ty not in functions: + if ty in functions: + continue + if 'IntrinsicSym' in sym: functions[ty] = KApply( 'IntrinsicFunction', [KApply('symbol(_)_LIB_Symbol_String', [stringToken(sym['IntrinsicSym'])])], ) + elif isinstance(sym.get('NormalSym'), str): + functions[ty] = KApply( + 'MonoItemKind::MonoItemFn', + ( + KApply('symbol(_)_LIB_Symbol_String', (stringToken(sym['NormalSym']),)), + KApply('defId(_)_BODY_DefId_Int', (intToken(ty),)), + KApply('noBody_BODY_MaybeBody', ()), + ), + ) return functions diff --git a/kmir/src/kmir/testing/fixtures.py b/kmir/src/kmir/testing/fixtures.py index 4ade1e06d..d42bf606d 100644 --- a/kmir/src/kmir/testing/fixtures.py +++ b/kmir/src/kmir/testing/fixtures.py @@ -1,5 +1,7 @@ from __future__ import annotations +import re +import sys from difflib import unified_diff from typing import TYPE_CHECKING @@ -13,24 +15,36 @@ from pytest import FixtureRequest, Parser -import sys - def pytest_configure(config) -> None: sys.setrecursionlimit(1000000) +def _normalize_symbol_hashes(text: str) -> str: + """Normalize rustc symbol hash suffixes that drift across builds/environments.""" + # Normalize mangled symbol hashes, including generic names with `$` and `.`. + # Keep trailing `E` when present; truncated variants may omit it. + text = re.sub(r'(_ZN[0-9A-Za-z_$.]+17h)[0-9a-fA-F]+E', r'\1E', text) + text = re.sub(r'(_ZN[0-9A-Za-z_$.]+17h)[0-9a-fA-F]+', r'\1', text) + # Normalize demangled hash suffixes (`...::h`). + text = re.sub(r'(::h)[0-9a-fA-F]{8,}', r'\1', text) + return text + + def assert_or_update_show_output( actual_text: str, expected_file: Path, *, update: bool, path_replacements: dict[str, str] | None = None ) -> None: if path_replacements: for old, new in path_replacements.items(): actual_text = actual_text.replace(old, new) + # Normalize rustc symbol hash suffixes that can drift across builds/environments. + actual_text = _normalize_symbol_hashes(actual_text) if update: expected_file.write_text(actual_text) else: assert expected_file.is_file() expected_text = expected_file.read_text() + expected_text = _normalize_symbol_hashes(expected_text) if actual_text != expected_text: diff = '\n'.join( unified_diff( diff --git a/kmir/src/kmir/utils.py b/kmir/src/kmir/utils.py index 935d37656..8feb00ca5 100644 --- a/kmir/src/kmir/utils.py +++ b/kmir/src/kmir/utils.py @@ -288,8 +288,8 @@ def _extract_alloc_id(operands: KInner) -> int | None: return None -def _annotate_unknown_function(k_cell: KInner, smir_info: SMIRInfo) -> list[str]: - """If the k cell is `#setUpCalleeData` for `** UNKNOWN FUNCTION **`, return annotation lines with decoded info.""" +def _annotate_nobody_function(k_cell: KInner, smir_info: SMIRInfo) -> list[str]: + """If the k cell is `#setUpCalleeData` for a `noBody` callee, return annotation lines with decoded info.""" from .alloc import Allocation, AllocId, AllocInfo, Memory from .linker import _demangle @@ -307,16 +307,14 @@ def _annotate_unknown_function(k_cell: KInner, smir_info: SMIRInfo) -> list[str] KApply( label=KLabel(name='MonoItemKind::MonoItemFn'), args=[ - KApply(args=[KToken(token=symbol_name)]), + KApply(args=[KToken()]), KApply(label=KLabel(name='defId(_)_BODY_DefId_Int'), args=[KToken(token=def_id_str)]), _, ], ), operands, KApply(label=KLabel(name='span'), args=[KToken(token=span_str)]), - ] if ( - symbol_name == '\"** UNKNOWN FUNCTION **\"' - ): + ]: def_id = int(def_id_str) span = int(span_str) case _: @@ -379,7 +377,7 @@ def render_leaf_k_cells(proof: APRProof, cterm_show: CTermShow, smir_info: SMIRI lines.extend(f' {k_line}' for k_line in k_lines) if smir_info is not None and k_cell is not None: - annotations = _annotate_unknown_function(k_cell, smir_info) + annotations = _annotate_nobody_function(k_cell, smir_info) lines.extend(annotations) if idx != len(leaves) - 1: diff --git a/kmir/src/tests/integration/data/crate-tests/single-lib/small_test_lib::testing::test_add_in_range.expected b/kmir/src/tests/integration/data/crate-tests/single-lib/small_test_lib::testing::test_add_in_range.expected index 36e7fa6a7..3cb67eec2 100644 --- a/kmir/src/tests/integration/data/crate-tests/single-lib/small_test_lib::testing::test_add_in_range.expected +++ b/kmir/src/tests/integration/data/crate-tests/single-lib/small_test_lib::testing::test_add_in_range.expected @@ -16,7 +16,7 @@ ┃ │ ┃ │ (6 steps) ┃ └─ 6 (stuck, leaf) -┃ #setUpCalleeData ( monoItemFn ( ... name: symbol ( "** UNKNOWN FUNCTION **" ) , +┃ #setUpCalleeData ( monoItemFn ( ... name: symbol ( "_ZN3std7process4exit17h ┃ ┗━━┓ subst: .Subst ┃ constraint: diff --git a/kmir/src/tests/integration/data/exec-smir/intrinsic/blackbox_function_symbols.expected.json b/kmir/src/tests/integration/data/exec-smir/intrinsic/blackbox_function_symbols.expected.json index 88db28bbd..3058a6679 100644 --- a/kmir/src/tests/integration/data/exec-smir/intrinsic/blackbox_function_symbols.expected.json +++ b/kmir/src/tests/integration/data/exec-smir/intrinsic/blackbox_function_symbols.expected.json @@ -1,69 +1,69 @@ { "-6": { - "NormalSym": "_ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17hb524060ed0e83bbbE" + "NormalSym": "_ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17hE" }, "-5": { - "NormalSym": "_ZN4core3ptr28drop_in_place$LT$$RF$u32$GT$17hb92e31f0aaa3d322E" + "NormalSym": "_ZN4core3ptr28drop_in_place$LT$$RF$u32$GT$17hE" }, "-4": { - "NormalSym": "_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h526a5c5d4d9d3202E" + "NormalSym": "_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17hE" }, "-3": { - "NormalSym": "_ZN42_$LT$$RF$T$u20$as$u20$core..fmt..Debug$GT$3fmt17h3a8781eea2f9ddb7E" + "NormalSym": "_ZN42_$LT$$RF$T$u20$as$u20$core..fmt..Debug$GT$3fmt17hE" }, "-2": { - "NormalSym": "_ZN3std2rt10lang_start17h17250425291430deE" + "NormalSym": "_ZN3std2rt10lang_start17hE" }, "-1": { - "NormalSym": "_ZN8blackbox4main17h56268fefa1135d9eE" + "NormalSym": "_ZN8blackbox4main17hE" }, "0": { - "NormalSym": "_ZN3std2rt19lang_start_internal17h018b8394ba015d86E" + "NormalSym": "_ZN3std2rt19lang_start_internal17hE" }, "13": { - "NormalSym": "_ZN3std3sys9backtrace28__rust_begin_short_backtrace17h3ac302c9481e885fE" + "NormalSym": "_ZN3std3sys9backtrace28__rust_begin_short_backtrace17hE" }, "14": { - "NormalSym": "_ZN54_$LT$$LP$$RP$$u20$as$u20$std..process..Termination$GT$6report17h8eaae5c69aab66e9E" + "NormalSym": "_ZN54_$LT$$LP$$RP$$u20$as$u20$std..process..Termination$GT$6report17hE" }, "19": { - "NormalSym": "_ZN4core3ops8function6FnOnce9call_once17haae505bd39892fd2E" + "NormalSym": "_ZN4core3ops8function6FnOnce9call_once17hE" }, "20": { "IntrinsicSym": "black_box" }, "21": { - "NormalSym": "_ZN4core3fmt3num50_$LT$impl$u20$core..fmt..Debug$u20$for$u20$u32$GT$3fmt17h99c61f0bde9a2afdE" + "NormalSym": "_ZN4core3fmt3num50_$LT$impl$u20$core..fmt..Debug$u20$for$u20$u32$GT$3fmt17hE" }, "27": { - "NormalSym": "_ZN4core3fmt3num53_$LT$impl$u20$core..fmt..LowerHex$u20$for$u20$u32$GT$3fmt17hb987357f13dc6cc8E" + "NormalSym": "_ZN4core3fmt3num53_$LT$impl$u20$core..fmt..LowerHex$u20$for$u20$u32$GT$3fmt17hE" }, "28": { - "NormalSym": "_ZN4core3fmt3num53_$LT$impl$u20$core..fmt..UpperHex$u20$for$u20$u32$GT$3fmt17h7baa47f3e5cbe44cE" + "NormalSym": "_ZN4core3fmt3num53_$LT$impl$u20$core..fmt..UpperHex$u20$for$u20$u32$GT$3fmt17hE" }, "29": { - "NormalSym": "_ZN4core3fmt3num3imp52_$LT$impl$u20$core..fmt..Display$u20$for$u20$u32$GT$3fmt17hec74c53b91325b16E" + "NormalSym": "_ZN4core3fmt3num3imp52_$LT$impl$u20$core..fmt..Display$u20$for$u20$u32$GT$3fmt17hE" }, "30": { - "NormalSym": "_ZN4core3ops8function6FnOnce9call_once17h2d8e0aae13049ae8E" + "NormalSym": "_ZN4core3ops8function6FnOnce9call_once17hE" }, "32": { - "NormalSym": "_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17h5c121846c1652782E" + "NormalSym": "_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hE" }, "35": { "IntrinsicSym": "black_box" }, "36": { - "NormalSym": "_ZN4core9panicking19assert_failed_inner17h1d286061ca0adfe7E" + "NormalSym": "_ZN4core9panicking19assert_failed_inner17hE" }, "43": { - "NormalSym": "_ZN8blackbox7add_one17h19d5f3b41fdf13daE" + "NormalSym": "_ZN8blackbox7add_one17hE" }, "44": { - "NormalSym": "_ZN4core4hint9black_box17h0bfc654765aa2ddfE" + "NormalSym": "_ZN4core4hint9black_box17hE" }, "45": { - "NormalSym": "_ZN4core9panicking13assert_failed17h9acd0d94a91ca0eaE" + "NormalSym": "_ZN4core9panicking13assert_failed17hE" }, "48": { "NoOpSym": "" diff --git a/kmir/src/tests/integration/data/exec-smir/intrinsic/blackbox_function_symbols_reverse.expected.json b/kmir/src/tests/integration/data/exec-smir/intrinsic/blackbox_function_symbols_reverse.expected.json index 4fcfd0647..05755f54f 100644 --- a/kmir/src/tests/integration/data/exec-smir/intrinsic/blackbox_function_symbols_reverse.expected.json +++ b/kmir/src/tests/integration/data/exec-smir/intrinsic/blackbox_function_symbols_reverse.expected.json @@ -1,62 +1,62 @@ { - "_ZN3std2rt10lang_start17h17250425291430deE": [ + "_ZN3std2rt10lang_start17hE": [ -2 ], - "_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17h5c121846c1652782E": [ + "_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hE": [ 32 ], - "_ZN3std2rt19lang_start_internal17h018b8394ba015d86E": [ + "_ZN3std2rt19lang_start_internal17hE": [ 0 ], - "_ZN3std3sys9backtrace28__rust_begin_short_backtrace17h3ac302c9481e885fE": [ + "_ZN3std3sys9backtrace28__rust_begin_short_backtrace17hE": [ 13 ], - "_ZN42_$LT$$RF$T$u20$as$u20$core..fmt..Debug$GT$3fmt17h3a8781eea2f9ddb7E": [ + "_ZN42_$LT$$RF$T$u20$as$u20$core..fmt..Debug$GT$3fmt17hE": [ -3 ], - "_ZN4core3fmt3num3imp52_$LT$impl$u20$core..fmt..Display$u20$for$u20$u32$GT$3fmt17hec74c53b91325b16E": [ + "_ZN4core3fmt3num3imp52_$LT$impl$u20$core..fmt..Display$u20$for$u20$u32$GT$3fmt17hE": [ 29 ], - "_ZN4core3fmt3num50_$LT$impl$u20$core..fmt..Debug$u20$for$u20$u32$GT$3fmt17h99c61f0bde9a2afdE": [ + "_ZN4core3fmt3num50_$LT$impl$u20$core..fmt..Debug$u20$for$u20$u32$GT$3fmt17hE": [ 21 ], - "_ZN4core3fmt3num53_$LT$impl$u20$core..fmt..LowerHex$u20$for$u20$u32$GT$3fmt17hb987357f13dc6cc8E": [ + "_ZN4core3fmt3num53_$LT$impl$u20$core..fmt..LowerHex$u20$for$u20$u32$GT$3fmt17hE": [ 27 ], - "_ZN4core3fmt3num53_$LT$impl$u20$core..fmt..UpperHex$u20$for$u20$u32$GT$3fmt17h7baa47f3e5cbe44cE": [ + "_ZN4core3fmt3num53_$LT$impl$u20$core..fmt..UpperHex$u20$for$u20$u32$GT$3fmt17hE": [ 28 ], - "_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h526a5c5d4d9d3202E": [ + "_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17hE": [ -4 ], - "_ZN4core3ops8function6FnOnce9call_once17h2d8e0aae13049ae8E": [ + "_ZN4core3ops8function6FnOnce9call_once17hE": [ 30 ], - "_ZN4core3ops8function6FnOnce9call_once17haae505bd39892fd2E": [ + "_ZN4core3ops8function6FnOnce9call_once17hE": [ 19 ], - "_ZN4core3ptr28drop_in_place$LT$$RF$u32$GT$17hb92e31f0aaa3d322E": [ + "_ZN4core3ptr28drop_in_place$LT$$RF$u32$GT$17hE": [ -5 ], - "_ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17hb524060ed0e83bbbE": [ + "_ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17hE": [ -6 ], - "_ZN4core4hint9black_box17h0bfc654765aa2ddfE": [ + "_ZN4core4hint9black_box17hE": [ 44 ], - "_ZN4core9panicking13assert_failed17h9acd0d94a91ca0eaE": [ + "_ZN4core9panicking13assert_failed17hE": [ 45 ], - "_ZN4core9panicking19assert_failed_inner17h1d286061ca0adfe7E": [ + "_ZN4core9panicking19assert_failed_inner17hE": [ 36 ], - "_ZN54_$LT$$LP$$RP$$u20$as$u20$std..process..Termination$GT$6report17h8eaae5c69aab66e9E": [ + "_ZN54_$LT$$LP$$RP$$u20$as$u20$std..process..Termination$GT$6report17hE": [ 14 ], - "_ZN8blackbox4main17h56268fefa1135d9eE": [ + "_ZN8blackbox4main17hE": [ -1 ], - "_ZN8blackbox7add_one17h19d5f3b41fdf13daE": [ + "_ZN8blackbox7add_one17hE": [ 43 ], "black_box": [ diff --git a/kmir/src/tests/integration/data/exec-smir/intrinsic/blackbox_functions.expected.json b/kmir/src/tests/integration/data/exec-smir/intrinsic/blackbox_functions.expected.json index 8c767e34e..029619a88 100644 --- a/kmir/src/tests/integration/data/exec-smir/intrinsic/blackbox_functions.expected.json +++ b/kmir/src/tests/integration/data/exec-smir/intrinsic/blackbox_functions.expected.json @@ -13569,6 +13569,69 @@ "node": "KApply", "variable": false }, + "0": { + "args": [ + { + "args": [ + { + "node": "KToken", + "sort": { + "name": "String", + "node": "KSort" + }, + "token": "\"_ZN3std2rt19lang_start_internal17hE\"" + } + ], + "arity": 1, + "label": { + "name": "symbol(_)_LIB_Symbol_String", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + }, + { + "args": [ + { + "node": "KToken", + "sort": { + "name": "Int", + "node": "KSort" + }, + "token": "0" + } + ], + "arity": 1, + "label": { + "name": "defId(_)_BODY_DefId_Int", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + }, + { + "args": [], + "arity": 0, + "label": { + "name": "noBody_BODY_MaybeBody", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + } + ], + "arity": 3, + "label": { + "name": "MonoItemKind::MonoItemFn", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + }, "13": { "args": [ { @@ -22521,6 +22584,195 @@ "node": "KApply", "variable": false }, + "27": { + "args": [ + { + "args": [ + { + "node": "KToken", + "sort": { + "name": "String", + "node": "KSort" + }, + "token": "\"_ZN4core3fmt3num53_$LT$impl$u20$core..fmt..LowerHex$u20$for$u20$u32$GT$3fmt17hE\"" + } + ], + "arity": 1, + "label": { + "name": "symbol(_)_LIB_Symbol_String", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + }, + { + "args": [ + { + "node": "KToken", + "sort": { + "name": "Int", + "node": "KSort" + }, + "token": "27" + } + ], + "arity": 1, + "label": { + "name": "defId(_)_BODY_DefId_Int", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + }, + { + "args": [], + "arity": 0, + "label": { + "name": "noBody_BODY_MaybeBody", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + } + ], + "arity": 3, + "label": { + "name": "MonoItemKind::MonoItemFn", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + }, + "28": { + "args": [ + { + "args": [ + { + "node": "KToken", + "sort": { + "name": "String", + "node": "KSort" + }, + "token": "\"_ZN4core3fmt3num53_$LT$impl$u20$core..fmt..UpperHex$u20$for$u20$u32$GT$3fmt17hE\"" + } + ], + "arity": 1, + "label": { + "name": "symbol(_)_LIB_Symbol_String", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + }, + { + "args": [ + { + "node": "KToken", + "sort": { + "name": "Int", + "node": "KSort" + }, + "token": "28" + } + ], + "arity": 1, + "label": { + "name": "defId(_)_BODY_DefId_Int", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + }, + { + "args": [], + "arity": 0, + "label": { + "name": "noBody_BODY_MaybeBody", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + } + ], + "arity": 3, + "label": { + "name": "MonoItemKind::MonoItemFn", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + }, + "29": { + "args": [ + { + "args": [ + { + "node": "KToken", + "sort": { + "name": "String", + "node": "KSort" + }, + "token": "\"_ZN4core3fmt3num3imp52_$LT$impl$u20$core..fmt..Display$u20$for$u20$u32$GT$3fmt17hE\"" + } + ], + "arity": 1, + "label": { + "name": "symbol(_)_LIB_Symbol_String", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + }, + { + "args": [ + { + "node": "KToken", + "sort": { + "name": "Int", + "node": "KSort" + }, + "token": "29" + } + ], + "arity": 1, + "label": { + "name": "defId(_)_BODY_DefId_Int", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + }, + { + "args": [], + "arity": 0, + "label": { + "name": "noBody_BODY_MaybeBody", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + } + ], + "arity": 3, + "label": { + "name": "MonoItemKind::MonoItemFn", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + }, "30": { "args": [ { @@ -27986,6 +28238,69 @@ "node": "KApply", "variable": false }, + "36": { + "args": [ + { + "args": [ + { + "node": "KToken", + "sort": { + "name": "String", + "node": "KSort" + }, + "token": "\"_ZN4core9panicking19assert_failed_inner17hE\"" + } + ], + "arity": 1, + "label": { + "name": "symbol(_)_LIB_Symbol_String", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + }, + { + "args": [ + { + "node": "KToken", + "sort": { + "name": "Int", + "node": "KSort" + }, + "token": "36" + } + ], + "arity": 1, + "label": { + "name": "defId(_)_BODY_DefId_Int", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + }, + { + "args": [], + "arity": 0, + "label": { + "name": "noBody_BODY_MaybeBody", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + } + ], + "arity": 3, + "label": { + "name": "MonoItemKind::MonoItemFn", + "node": "KLabel", + "params": [] + }, + "node": "KApply", + "variable": false + }, "43": { "args": [ { diff --git a/kmir/src/tests/integration/data/prove-rs/show/assume-cheatcode-conflict-fail.check_assume_conflict.expected b/kmir/src/tests/integration/data/prove-rs/show/assume-cheatcode-conflict-fail.check_assume_conflict.expected index 700446f6e..470f41c25 100644 --- a/kmir/src/tests/integration/data/prove-rs/show/assume-cheatcode-conflict-fail.check_assume_conflict.expected +++ b/kmir/src/tests/integration/data/prove-rs/show/assume-cheatcode-conflict-fail.check_assume_conflict.expected @@ -5,7 +5,7 @@ │ │ (61 steps) └─ 3 (stuck, leaf) - #setUpCalleeData ( monoItemFn ( ... name: symbol ( "** UNKNOWN FUNCTION **" ) , + #setUpCalleeData ( monoItemFn ( ... name: symbol ( "_ZN4core9panicking5panic17h span: 32 diff --git a/kmir/src/tests/integration/data/prove-rs/show/interior-mut-fail.main.expected b/kmir/src/tests/integration/data/prove-rs/show/interior-mut-fail.main.expected index 44581b4f2..4c165cf72 100644 --- a/kmir/src/tests/integration/data/prove-rs/show/interior-mut-fail.main.expected +++ b/kmir/src/tests/integration/data/prove-rs/show/interior-mut-fail.main.expected @@ -5,7 +5,7 @@ │ │ (877 steps) └─ 3 (stuck, leaf) - #setUpCalleeData ( monoItemFn ( ... name: symbol ( "** UNKNOWN FUNCTION **" ) , + #setUpCalleeData ( monoItemFn ( ... name: symbol ( "_ZN4core4cell22panic_already span: 32 diff --git a/kmir/src/tests/integration/data/prove-rs/show/pointer-cast-length-test-fail.array_cast_test.expected b/kmir/src/tests/integration/data/prove-rs/show/pointer-cast-length-test-fail.array_cast_test.expected index 1a3c758c5..9198552ba 100644 --- a/kmir/src/tests/integration/data/prove-rs/show/pointer-cast-length-test-fail.array_cast_test.expected +++ b/kmir/src/tests/integration/data/prove-rs/show/pointer-cast-length-test-fail.array_cast_test.expected @@ -17,7 +17,7 @@ ┃ │ ┃ │ (6 steps) ┃ └─ 6 (stuck, leaf) -┃ #setUpCalleeData ( monoItemFn ( ... name: symbol ( "** UNKNOWN FUNCTION **" ) , +┃ #setUpCalleeData ( monoItemFn ( ... name: symbol ( "_ZN4core9panicking5panic17h ┃ span: 32 ┃ ┗━━┓ subst: .Subst diff --git a/kmir/src/tests/integration/data/prove-rs/show/symbolic-args-fail.main.cli-stats-leaves.expected b/kmir/src/tests/integration/data/prove-rs/show/symbolic-args-fail.main.cli-stats-leaves.expected index 84737597a..e4e10b74c 100644 --- a/kmir/src/tests/integration/data/prove-rs/show/symbolic-args-fail.main.cli-stats-leaves.expected +++ b/kmir/src/tests/integration/data/prove-rs/show/symbolic-args-fail.main.cli-stats-leaves.expected @@ -5,7 +5,7 @@ │ │ (566 steps) └─ 3 (stuck, leaf) - #setUpCalleeData ( monoItemFn ( ... name: symbol ( "** UNKNOWN FUNCTION **" ) , + #setUpCalleeData ( monoItemFn ( ... name: symbol ( "_ZN4core9panicking5panic17h span: no-location:0 @@ -32,7 +32,7 @@ Leaf paths from init: LEAF CELLS --------------- Node 3: - #setUpCalleeData ( monoItemFn ( ... name: symbol ( "** UNKNOWN FUNCTION **" ) , id: defId ( 38 ) , body: noBody ) , operandConstant ( constOperand ( ... span: span ( 32 ) , userTy: noUserTypeAnnotationIndex , const: mirConst ( ... kind: constantKindAllocated ( allocation ( ... bytes: b"\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x00\x00\x00\x00\x00\x00" , provenance: provenanceMap ( ... ptrs: provenanceMapEntry ( ... offset: 0 , allocId: allocId ( 1 ) ) .ProvenanceMapEntries ) , align: align ( 8 ) , mutability: mutabilityMut ) ) , ty: ty ( 39 ) , id: mirConstId ( 25 ) ) ) ) .Operands , span ( 117 ) ) ~> .K - >> function: core::panicking::panic::h941160ead03e2d54 + #setUpCalleeData ( monoItemFn ( ... name: symbol ( "_ZN4core9panicking5panic17hE" ) , id: defId ( 38 ) , body: noBody ) , operandConstant ( constOperand ( ... span: span ( 32 ) , userTy: noUserTypeAnnotationIndex , const: mirConst ( ... kind: constantKindAllocated ( allocation ( ... bytes: b"\x00\x00\x00\x00\x00\x00\x00\x00\x17\x00\x00\x00\x00\x00\x00\x00" , provenance: provenanceMap ( ... ptrs: provenanceMapEntry ( ... offset: 0 , allocId: allocId ( 1 ) ) .ProvenanceMapEntries ) , align: align ( 8 ) , mutability: mutabilityMut ) ) , ty: ty ( 39 ) , id: mirConstId ( 25 ) ) ) ) .Operands , span ( 117 ) ) ~> .K + >> function: core::panicking::panic::h >> call span: /kmir/src/tests/integration/data/prove-rs/symbolic-args-fail.rs:53:5 >> message: 'assertion failed: false' \ No newline at end of file diff --git a/kmir/src/tests/integration/data/prove-rs/show/symbolic-args-fail.main.expected b/kmir/src/tests/integration/data/prove-rs/show/symbolic-args-fail.main.expected index ef7740af7..e5b630195 100644 --- a/kmir/src/tests/integration/data/prove-rs/show/symbolic-args-fail.main.expected +++ b/kmir/src/tests/integration/data/prove-rs/show/symbolic-args-fail.main.expected @@ -5,7 +5,7 @@ │ │ (566 steps) └─ 3 (stuck, leaf) - #setUpCalleeData ( monoItemFn ( ... name: symbol ( "** UNKNOWN FUNCTION **" ) , + #setUpCalleeData ( monoItemFn ( ... name: symbol ( "_ZN4core9panicking5panic17h span: 32 diff --git a/kmir/src/tests/integration/data/prove-rs/show/symbolic-structs-fail.eats_struct_args.expected b/kmir/src/tests/integration/data/prove-rs/show/symbolic-structs-fail.eats_struct_args.expected index a3abc238d..673eb0193 100644 --- a/kmir/src/tests/integration/data/prove-rs/show/symbolic-structs-fail.eats_struct_args.expected +++ b/kmir/src/tests/integration/data/prove-rs/show/symbolic-structs-fail.eats_struct_args.expected @@ -29,7 +29,7 @@ ┃ ┃ │ ┃ ┃ │ (6 steps) ┃ ┃ └─ 10 (stuck, leaf) -┃ ┃ #setUpCalleeData ( monoItemFn ( ... name: symbol ( "** UNKNOWN FUNCTION **" ) , +┃ ┃ #setUpCalleeData ( monoItemFn ( ... name: symbol ( "_ZN4core9panicking5panic17h ┃ ┃ span: 32 ┃ ┃ ┃ ┗━━┓ subst: .Subst diff --git a/kmir/src/tests/integration/data/prove-rs/show/test_offset_from-fail.testing.expected b/kmir/src/tests/integration/data/prove-rs/show/test_offset_from-fail.testing.expected index a0ac24cae..8fd816dd8 100644 --- a/kmir/src/tests/integration/data/prove-rs/show/test_offset_from-fail.testing.expected +++ b/kmir/src/tests/integration/data/prove-rs/show/test_offset_from-fail.testing.expected @@ -114,7 +114,7 @@ ┃ │ ┃ │ (70 steps) ┃ └─ 22 (stuck, leaf) - ┃ #setUpCalleeData ( monoItemFn ( ... name: symbol ( "** UNKNOWN FUNCTION **" ) , + ┃ #setUpCalleeData ( monoItemFn ( ... name: symbol ( "_ZN4core9panicking5panic17h ┃ span: 32 ┃ ┗━━┓ subst: .Subst diff --git a/kmir/src/tests/unit/test_fixtures.py b/kmir/src/tests/unit/test_fixtures.py new file mode 100644 index 000000000..b9a3de5b5 --- /dev/null +++ b/kmir/src/tests/unit/test_fixtures.py @@ -0,0 +1,27 @@ +from __future__ import annotations + +import pytest + +from kmir.testing.fixtures import _normalize_symbol_hashes + + +@pytest.mark.parametrize( + ('raw', 'expected'), + [ + ( + '_ZN4core3fmt3num53_$LT$impl$u20$core..fmt..LowerHex$u20$for$u20$u32$GT$3fmt17hb987357f13dc6cc8E', + '_ZN4core3fmt3num53_$LT$impl$u20$core..fmt..LowerHex$u20$for$u20$u32$GT$3fmt17hE', + ), + ( + '_ZN4core3fmt3num53_$LT$impl$u20$core..fmt..LowerHex$u20$for$u20$u32$GT$3fmt17hb987357f13dc6cc8', + '_ZN4core3fmt3num53_$LT$impl$u20$core..fmt..LowerHex$u20$for$u20$u32$GT$3fmt17h', + ), + ( + 'core::panicking::panic::h941160ead03e2d54', + 'core::panicking::panic::h', + ), + ], + ids=['generic-mangled-full', 'generic-mangled-truncated', 'demangled'], +) +def test_normalize_symbol_hashes(raw: str, expected: str) -> None: + assert _normalize_symbol_hashes(raw) == expected