From 110adf15c2eebb260a5a9e57f0bb4f9d2c22b3f0 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 1 May 2026 11:09:45 -0400 Subject: [PATCH] Let lldb dump display a variable when its name matches an id type name (#7148) `dump context facet_type` was an error before since we expected that to be followed with an id value. While `dump context facet_type 5` still works, if there's no id value, try to use `facet_type` as a variable name. This allows us to dump an inst id if it happens to be named `inst`, etc, without having to use `--` to disambiguate. --- scripts/lldbinit.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/lldbinit.py b/scripts/lldbinit.py index 6d831f8cfe33..75c56d654431 100644 --- a/scripts/lldbinit.py +++ b/scripts/lldbinit.py @@ -118,7 +118,7 @@ Example usage: # Look for as a single argument. if m := re.fullmatch("([a-z_]+)(?:0x)?([0-9A-Fa-f]+)", args[1]): if m[1] in id_types: - if len(args) != 2: + if len(args) > 2: print_usage() return make_id_fn = id_types[m[1]] @@ -126,16 +126,18 @@ Example usage: print_dump(context, f"{make_id_fn}({id})") found_id_type = True - # Look for as two arguments. + # Look for as two arguments. If there's no , the + # should just be treated as a variable name. if args[1] in id_types: - if len(args) != 3: + if len(args) > 3: print_usage() return - if m := re.fullmatch("(?:0x)?([0-9A-Fa-f]+)", args[2]): - make_id_fn = id_types[args[1]] - id = int(m[1], 16) - print_dump(context, f"{make_id_fn}({id})") - found_id_type = True + elif len(args) == 3: + if m := re.fullmatch("(?:0x)?([0-9A-Fa-f]+)", args[2]): + make_id_fn = id_types[args[1]] + id = int(m[1], 16) + print_dump(context, f"{make_id_fn}({id})") + found_id_type = True if not found_id_type: # Use `--` to escape a variable name like `inst22`.