scripts: Some minor regex cleanup

Just trying to make regex in scripts a bit more consistent. Though regex
being regex this may be fruitless.
This commit is contained in:
Christopher Haster
2024-12-04 01:02:50 -06:00
parent 28d89eb009
commit b90b2953ea
6 changed files with 42 additions and 44 deletions
+4 -4
View File
@@ -420,12 +420,12 @@ def collect_dwarf_info(obj_path, tags=None, *,
objdump_path=OBJDUMP_PATH, objdump_path=OBJDUMP_PATH,
**args): **args):
info_pattern = re.compile( info_pattern = re.compile(
'^\s*(?:<(?P<level>[^>]*)>' '^\s*<(?P<level>[^>]*)>'
'\s*<(?P<off>[^>]*)>' '\s*<(?P<off>[^>]*)>'
'.*\(\s*(?P<tag>[^)]*?)\s*\)' '.*\(\s*(?P<tag>[^)]*?)\s*\)\s*$'
'|\s*<(?P<off_>[^>]*)>' '|' '^\s*<(?P<off_>[^>]*)>'
'\s*(?P<at>[^>:]*?)' '\s*(?P<at>[^>:]*?)'
'\s*:(?P<v>.*))\s*$') '\s*:(?P<v>.*)\s*$')
# collect dwarf entries # collect dwarf entries
info = co.OrderedDict() info = co.OrderedDict()
+4 -4
View File
@@ -429,12 +429,12 @@ def collect_dwarf_info(obj_path, tags=None, *,
objdump_path=OBJDUMP_PATH, objdump_path=OBJDUMP_PATH,
**args): **args):
info_pattern = re.compile( info_pattern = re.compile(
'^\s*(?:<(?P<level>[^>]*)>' '^\s*<(?P<level>[^>]*)>'
'\s*<(?P<off>[^>]*)>' '\s*<(?P<off>[^>]*)>'
'.*\(\s*(?P<tag>[^)]*?)\s*\)' '.*\(\s*(?P<tag>[^)]*?)\s*\)\s*$'
'|\s*<(?P<off_>[^>]*)>' '|' '^\s*<(?P<off_>[^>]*)>'
'\s*(?P<at>[^>:]*?)' '\s*(?P<at>[^>:]*?)'
'\s*:(?P<v>.*))\s*$') '\s*:(?P<v>.*)\s*$')
# collect dwarf entries # collect dwarf entries
info = co.OrderedDict() info = co.OrderedDict()
+4 -4
View File
@@ -420,12 +420,12 @@ def collect_dwarf_info(obj_path, tags=None, *,
objdump_path=OBJDUMP_PATH, objdump_path=OBJDUMP_PATH,
**args): **args):
info_pattern = re.compile( info_pattern = re.compile(
'^\s*(?:<(?P<level>[^>]*)>' '^\s*<(?P<level>[^>]*)>'
'\s*<(?P<off>[^>]*)>' '\s*<(?P<off>[^>]*)>'
'.*\(\s*(?P<tag>[^)]*?)\s*\)' '.*\(\s*(?P<tag>[^)]*?)\s*\)\s*$'
'|\s*<(?P<off_>[^>]*)>' '|' '^\s*<(?P<off_>[^>]*)>'
'\s*(?P<at>[^>:]*?)' '\s*(?P<at>[^>:]*?)'
'\s*:(?P<v>.*))\s*$') '\s*:(?P<v>.*)\s*$')
# collect dwarf entries # collect dwarf entries
info = co.OrderedDict() info = co.OrderedDict()
+13 -14
View File
@@ -447,22 +447,21 @@ def collect_dwarf_lines(obj_path, *,
objdump_path=OBJDUMP_PATH, objdump_path=OBJDUMP_PATH,
**args): **args):
line_pattern = re.compile( line_pattern = re.compile(
'^\s*(?:' # matches dir/file table
# matches dir/file table '^\s*(?P<no>[0-9]+)'
'(?P<no>[0-9]+)'
'(?:\s+(?P<dir>[0-9]+))?' '(?:\s+(?P<dir>[0-9]+))?'
'.*\s+(?P<path>[^\s]+)' '.*\s+(?P<path>[^\s]+)\s*$'
# matches line opcodes # matches line opcodes
'|' '\[[^\]]*\]\s+' '(?:' '|' '^\s*\[[^\]]*\]' '(?:'
'(?P<op_special>Special)' '\s+(?P<op_special>Special)'
'|' '(?P<op_copy>Copy)' '|' '\s+(?P<op_copy>Copy)'
'|' '(?P<op_end>End of Sequence)' '|' '\s+(?P<op_end>End of Sequence)'
'|' 'File .*?to (?:entry )?(?P<op_file>\d+)' '|' '\s+File.*?to.*?(?P<op_file>[0-9]+)'
'|' 'Line .*?to (?P<op_line>[0-9]+)' '|' '\s+Line.*?to.*?(?P<op_line>[0-9]+)'
'|' '(?:Address|PC) .*?to (?P<op_addr>[0x0-9a-fA-F]+)' '|' '\s+(?:Address|PC)'
'|' '.' '\s+.*?to.*?(?P<op_addr>[0xX0-9a-fA-F]+)'
')*' '|' '\s+[^\s]+' ')+\s*$',
')\s*$', re.IGNORECASE) re.IGNORECASE)
# state machine for dwarf line numbers, note that objdump's # state machine for dwarf line numbers, note that objdump's
# decodedline seems to have issues with multiple dir/file # decodedline seems to have issues with multiple dir/file
+13 -14
View File
@@ -352,22 +352,21 @@ def collect_dwarf_lines(obj_path, *,
objdump_path=OBJDUMP_PATH, objdump_path=OBJDUMP_PATH,
**args): **args):
line_pattern = re.compile( line_pattern = re.compile(
'^\s*(?:' # matches dir/file table
# matches dir/file table '^\s*(?P<no>[0-9]+)'
'(?P<no>[0-9]+)'
'(?:\s+(?P<dir>[0-9]+))?' '(?:\s+(?P<dir>[0-9]+))?'
'.*\s+(?P<path>[^\s]+)' '.*\s+(?P<path>[^\s]+)\s*$'
# matches line opcodes # matches line opcodes
'|' '\[[^\]]*\]\s+' '(?:' '|' '^\s*\[[^\]]*\]' '(?:'
'(?P<op_special>Special)' '\s+(?P<op_special>Special)'
'|' '(?P<op_copy>Copy)' '|' '\s+(?P<op_copy>Copy)'
'|' '(?P<op_end>End of Sequence)' '|' '\s+(?P<op_end>End of Sequence)'
'|' 'File .*?to (?:entry )?(?P<op_file>\d+)' '|' '\s+File.*?to.*?(?P<op_file>[0-9]+)'
'|' 'Line .*?to (?P<op_line>[0-9]+)' '|' '\s+Line.*?to.*?(?P<op_line>[0-9]+)'
'|' '(?:Address|PC) .*?to (?P<op_addr>[0x0-9a-fA-F]+)' '|' '\s+(?:Address|PC)'
'|' '.' '\s+.*?to.*?(?P<op_addr>[0xX0-9a-fA-F]+)'
')*' '|' '\s+[^\s]+' ')+\s*$',
')\s*$', re.IGNORECASE) re.IGNORECASE)
# state machine for dwarf line numbers, note that objdump's # state machine for dwarf line numbers, note that objdump's
# decodedline seems to have issues with multiple dir/file # decodedline seems to have issues with multiple dir/file
+4 -4
View File
@@ -317,12 +317,12 @@ def collect_dwarf_info(obj_path, tags=None, *,
objdump_path=OBJDUMP_PATH, objdump_path=OBJDUMP_PATH,
**args): **args):
info_pattern = re.compile( info_pattern = re.compile(
'^\s*(?:<(?P<level>[^>]*)>' '^\s*<(?P<level>[^>]*)>'
'\s*<(?P<off>[^>]*)>' '\s*<(?P<off>[^>]*)>'
'.*\(\s*(?P<tag>[^)]*?)\s*\)' '.*\(\s*(?P<tag>[^)]*?)\s*\)\s*$'
'|\s*<(?P<off_>[^>]*)>' '|' '^\s*<(?P<off_>[^>]*)>'
'\s*(?P<at>[^>:]*?)' '\s*(?P<at>[^>:]*?)'
'\s*:(?P<v>.*))\s*$') '\s*:(?P<v>.*)\s*$')
# collect dwarf entries # collect dwarf entries
info = co.OrderedDict() info = co.OrderedDict()