From b90b2953ea5b8d4387038aec46730afae13545d2 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Wed, 4 Dec 2024 01:02:50 -0600 Subject: [PATCH] scripts: Some minor regex cleanup Just trying to make regex in scripts a bit more consistent. Though regex being regex this may be fruitless. --- scripts/code.py | 8 ++++---- scripts/ctx.py | 8 ++++---- scripts/data.py | 8 ++++---- scripts/perf.py | 27 +++++++++++++-------------- scripts/perfbd.py | 27 +++++++++++++-------------- scripts/structs.py | 8 ++++---- 6 files changed, 42 insertions(+), 44 deletions(-) diff --git a/scripts/code.py b/scripts/code.py index 7da027c2..9db4502f 100755 --- a/scripts/code.py +++ b/scripts/code.py @@ -420,12 +420,12 @@ def collect_dwarf_info(obj_path, tags=None, *, objdump_path=OBJDUMP_PATH, **args): info_pattern = re.compile( - '^\s*(?:<(?P[^>]*)>' + '^\s*<(?P[^>]*)>' '\s*<(?P[^>]*)>' - '.*\(\s*(?P[^)]*?)\s*\)' - '|\s*<(?P[^>]*)>' + '.*\(\s*(?P[^)]*?)\s*\)\s*$' + '|' '^\s*<(?P[^>]*)>' '\s*(?P[^>:]*?)' - '\s*:(?P.*))\s*$') + '\s*:(?P.*)\s*$') # collect dwarf entries info = co.OrderedDict() diff --git a/scripts/ctx.py b/scripts/ctx.py index 017d8d24..8a644b3d 100755 --- a/scripts/ctx.py +++ b/scripts/ctx.py @@ -429,12 +429,12 @@ def collect_dwarf_info(obj_path, tags=None, *, objdump_path=OBJDUMP_PATH, **args): info_pattern = re.compile( - '^\s*(?:<(?P[^>]*)>' + '^\s*<(?P[^>]*)>' '\s*<(?P[^>]*)>' - '.*\(\s*(?P[^)]*?)\s*\)' - '|\s*<(?P[^>]*)>' + '.*\(\s*(?P[^)]*?)\s*\)\s*$' + '|' '^\s*<(?P[^>]*)>' '\s*(?P[^>:]*?)' - '\s*:(?P.*))\s*$') + '\s*:(?P.*)\s*$') # collect dwarf entries info = co.OrderedDict() diff --git a/scripts/data.py b/scripts/data.py index e8c09347..63c636fc 100755 --- a/scripts/data.py +++ b/scripts/data.py @@ -420,12 +420,12 @@ def collect_dwarf_info(obj_path, tags=None, *, objdump_path=OBJDUMP_PATH, **args): info_pattern = re.compile( - '^\s*(?:<(?P[^>]*)>' + '^\s*<(?P[^>]*)>' '\s*<(?P[^>]*)>' - '.*\(\s*(?P[^)]*?)\s*\)' - '|\s*<(?P[^>]*)>' + '.*\(\s*(?P[^)]*?)\s*\)\s*$' + '|' '^\s*<(?P[^>]*)>' '\s*(?P[^>:]*?)' - '\s*:(?P.*))\s*$') + '\s*:(?P.*)\s*$') # collect dwarf entries info = co.OrderedDict() diff --git a/scripts/perf.py b/scripts/perf.py index 3edd1b86..4674768d 100755 --- a/scripts/perf.py +++ b/scripts/perf.py @@ -447,22 +447,21 @@ def collect_dwarf_lines(obj_path, *, objdump_path=OBJDUMP_PATH, **args): line_pattern = re.compile( - '^\s*(?:' - # matches dir/file table - '(?P[0-9]+)' + # matches dir/file table + '^\s*(?P[0-9]+)' '(?:\s+(?P[0-9]+))?' - '.*\s+(?P[^\s]+)' + '.*\s+(?P[^\s]+)\s*$' # matches line opcodes - '|' '\[[^\]]*\]\s+' '(?:' - '(?PSpecial)' - '|' '(?PCopy)' - '|' '(?PEnd of Sequence)' - '|' 'File .*?to (?:entry )?(?P\d+)' - '|' 'Line .*?to (?P[0-9]+)' - '|' '(?:Address|PC) .*?to (?P[0x0-9a-fA-F]+)' - '|' '.' - ')*' - ')\s*$', re.IGNORECASE) + '|' '^\s*\[[^\]]*\]' '(?:' + '\s+(?PSpecial)' + '|' '\s+(?PCopy)' + '|' '\s+(?PEnd of Sequence)' + '|' '\s+File.*?to.*?(?P[0-9]+)' + '|' '\s+Line.*?to.*?(?P[0-9]+)' + '|' '\s+(?:Address|PC)' + '\s+.*?to.*?(?P[0xX0-9a-fA-F]+)' + '|' '\s+[^\s]+' ')+\s*$', + re.IGNORECASE) # state machine for dwarf line numbers, note that objdump's # decodedline seems to have issues with multiple dir/file diff --git a/scripts/perfbd.py b/scripts/perfbd.py index 61f8bf52..51682194 100755 --- a/scripts/perfbd.py +++ b/scripts/perfbd.py @@ -352,22 +352,21 @@ def collect_dwarf_lines(obj_path, *, objdump_path=OBJDUMP_PATH, **args): line_pattern = re.compile( - '^\s*(?:' - # matches dir/file table - '(?P[0-9]+)' + # matches dir/file table + '^\s*(?P[0-9]+)' '(?:\s+(?P[0-9]+))?' - '.*\s+(?P[^\s]+)' + '.*\s+(?P[^\s]+)\s*$' # matches line opcodes - '|' '\[[^\]]*\]\s+' '(?:' - '(?PSpecial)' - '|' '(?PCopy)' - '|' '(?PEnd of Sequence)' - '|' 'File .*?to (?:entry )?(?P\d+)' - '|' 'Line .*?to (?P[0-9]+)' - '|' '(?:Address|PC) .*?to (?P[0x0-9a-fA-F]+)' - '|' '.' - ')*' - ')\s*$', re.IGNORECASE) + '|' '^\s*\[[^\]]*\]' '(?:' + '\s+(?PSpecial)' + '|' '\s+(?PCopy)' + '|' '\s+(?PEnd of Sequence)' + '|' '\s+File.*?to.*?(?P[0-9]+)' + '|' '\s+Line.*?to.*?(?P[0-9]+)' + '|' '\s+(?:Address|PC)' + '\s+.*?to.*?(?P[0xX0-9a-fA-F]+)' + '|' '\s+[^\s]+' ')+\s*$', + re.IGNORECASE) # state machine for dwarf line numbers, note that objdump's # decodedline seems to have issues with multiple dir/file diff --git a/scripts/structs.py b/scripts/structs.py index 353dbc16..3f9ddba4 100755 --- a/scripts/structs.py +++ b/scripts/structs.py @@ -317,12 +317,12 @@ def collect_dwarf_info(obj_path, tags=None, *, objdump_path=OBJDUMP_PATH, **args): info_pattern = re.compile( - '^\s*(?:<(?P[^>]*)>' + '^\s*<(?P[^>]*)>' '\s*<(?P[^>]*)>' - '.*\(\s*(?P[^)]*?)\s*\)' - '|\s*<(?P[^>]*)>' + '.*\(\s*(?P[^)]*?)\s*\)\s*$' + '|' '^\s*<(?P[^>]*)>' '\s*(?P[^>:]*?)' - '\s*:(?P.*))\s*$') + '\s*:(?P.*)\s*$') # collect dwarf entries info = co.OrderedDict()