0
0
mirror of https://github.com/llvm/llvm-project.git synced 2025-04-26 18:46:06 +00:00

[lldb] fix(lldb/**.py): fix invalid escape sequences ()

Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
This commit is contained in:
Eisuke Kawashima 2025-02-28 23:59:35 +09:00 committed by GitHub
parent 037cf12b07
commit 24abf2c728
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
76 changed files with 282 additions and 276 deletions
lldb
examples/python
packages/Python/lldbsuite/test
test/API
commands
driver/quit_speed
functionalities
breakpoint
breakpoint_by_line_and_column
breakpoint_locations
data-formatter
data-formatter-advanced
data-formatter-cpp
data-formatter-objc
data-formatter-stl/generic/unordered
type_summary_list_arg
gdb_remote_client
memory-region
target_var
iohandler/completion
lang
linux/aarch64
macosx
python_api
address_range
target-arch-from-module
source-manager
tools
types
utils/lui

@ -296,7 +296,7 @@ class CrashLog(symbolication.Symbolicator):
except: except:
dsymForUUIDBinary = "" dsymForUUIDBinary = ""
dwarfdump_uuid_regex = re.compile("UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*") dwarfdump_uuid_regex = re.compile(r"UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
def __init__( def __init__(
self, text_addr_lo, text_addr_hi, identifier, version, uuid, path, verbose self, text_addr_lo, text_addr_hi, identifier, version, uuid, path, verbose
@ -501,7 +501,7 @@ class CrashLog(symbolication.Symbolicator):
for image in self.images: for image in self.images:
if image.identifier == identifier: if image.identifier == identifier:
return image return image
regex_text = "^.*\.%s$" % (re.escape(identifier)) regex_text = r"^.*\.%s$" % (re.escape(identifier))
regex = re.compile(regex_text) regex = re.compile(regex_text)
for image in self.images: for image in self.images:
if regex.match(image.identifier): if regex.match(image.identifier):
@ -925,7 +925,7 @@ class TextCrashLogParser(CrashLogParser):
version = r"(?:" + super().version + r"\s+)?" version = r"(?:" + super().version + r"\s+)?"
address = r"(0x[0-9a-fA-F]{4,})" # 4 digits or more address = r"(0x[0-9a-fA-F]{4,})" # 4 digits or more
symbol = """ symbol = r"""
(?: (?:
[ ]+ [ ]+
(?P<symbol>.+) (?P<symbol>.+)
@ -1095,7 +1095,7 @@ class TextCrashLogParser(CrashLogParser):
self.crashlog.process_identifier = line[11:].strip() self.crashlog.process_identifier = line[11:].strip()
elif line.startswith("Version:"): elif line.startswith("Version:"):
version_string = line[8:].strip() version_string = line[8:].strip()
matched_pair = re.search("(.+)\((.+)\)", version_string) matched_pair = re.search(r"(.+)\((.+)\)", version_string)
if matched_pair: if matched_pair:
self.crashlog.process_version = matched_pair.group(1) self.crashlog.process_version = matched_pair.group(1)
self.crashlog.process_compatability_version = matched_pair.group(2) self.crashlog.process_compatability_version = matched_pair.group(2)

@ -99,7 +99,7 @@ def parse_log_file(file, options):
print("# Log file: '%s'" % file) print("# Log file: '%s'" % file)
print("#----------------------------------------------------------------------") print("#----------------------------------------------------------------------")
timestamp_regex = re.compile("(\s*)([1-9][0-9]+\.[0-9]+)([^0-9].*)$") timestamp_regex = re.compile(r"(\s*)([1-9][0-9]+\.[0-9]+)([^0-9].*)$")
base_time = 0.0 base_time = 0.0
last_time = 0.0 last_time = 0.0

@ -1537,12 +1537,12 @@ def parse_gdb_log(file, options):
a long time during a preset set of debugger commands.""" a long time during a preset set of debugger commands."""
tricky_commands = ["qRegisterInfo"] tricky_commands = ["qRegisterInfo"]
timestamp_regex = re.compile("(\s*)([1-9][0-9]+\.[0-9]+)([^0-9].*)$") timestamp_regex = re.compile(r"(\s*)([1-9][0-9]+\.[0-9]+)([^0-9].*)$")
packet_name_regex = re.compile("([A-Za-z_]+)[^a-z]") packet_name_regex = re.compile("([A-Za-z_]+)[^a-z]")
packet_transmit_name_regex = re.compile( packet_transmit_name_regex = re.compile(
"(?P<direction>send|read) packet: (?P<packet>.*)" "(?P<direction>send|read) packet: (?P<packet>.*)"
) )
packet_contents_name_regex = re.compile("\$([^#]*)#[0-9a-fA-F]{2}") packet_contents_name_regex = re.compile(r"\$([^#]*)#[0-9a-fA-F]{2}")
packet_checksum_regex = re.compile(".*#[0-9a-fA-F]{2}$") packet_checksum_regex = re.compile(".*#[0-9a-fA-F]{2}$")
packet_names_regex_str = "(" + "|".join(gdb_remote_commands.keys()) + ")(.*)" packet_names_regex_str = "(" + "|".join(gdb_remote_commands.keys()) + ")(.*)"
packet_names_regex = re.compile(packet_names_regex_str) packet_names_regex = re.compile(packet_names_regex_str)

@ -38,7 +38,7 @@ def parse_linespec(linespec, frame, result):
) )
if not matched: if not matched:
mo = re.match("^\+([0-9]+)$", linespec) mo = re.match(r"^\+([0-9]+)$", linespec)
if mo is not None: if mo is not None:
matched = True matched = True
# print "Matched +<count>" # print "Matched +<count>"
@ -54,7 +54,7 @@ def parse_linespec(linespec, frame, result):
) )
if not matched: if not matched:
mo = re.match("^\-([0-9]+)$", linespec) mo = re.match(r"^\-([0-9]+)$", linespec)
if mo is not None: if mo is not None:
matched = True matched = True
# print "Matched -<count>" # print "Matched -<count>"
@ -79,7 +79,7 @@ def parse_linespec(linespec, frame, result):
breakpoint = target.BreakpointCreateByLocation(file_name, line_number) breakpoint = target.BreakpointCreateByLocation(file_name, line_number)
if not matched: if not matched:
mo = re.match("\*((0x)?([0-9a-f]+))$", linespec) mo = re.match(r"\*((0x)?([0-9a-f]+))$", linespec)
if mo is not None: if mo is not None:
matched = True matched = True
# print "Matched <address-expression>" # print "Matched <address-expression>"

@ -346,7 +346,7 @@ class MemoryMeasurement(Measurement):
def Measure(self): def Measure(self):
output = subprocess.getoutput(self.command).split("\n")[-1] output = subprocess.getoutput(self.command).split("\n")[-1]
values = re.split("[-+\s]+", output) values = re.split(r"[-+\s]+", output)
for idx, stat in enumerate(values): for idx, stat in enumerate(values):
multiplier = 1 multiplier = 1
if stat: if stat:

@ -177,9 +177,9 @@ class Section:
"""Class that represents an load address range""" """Class that represents an load address range"""
sect_info_regex = re.compile("(?P<name>[^=]+)=(?P<range>.*)") sect_info_regex = re.compile("(?P<name>[^=]+)=(?P<range>.*)")
addr_regex = re.compile("^\s*(?P<start>0x[0-9A-Fa-f]+)\s*$") addr_regex = re.compile(r"^\s*(?P<start>0x[0-9A-Fa-f]+)\s*$")
range_regex = re.compile( range_regex = re.compile(
"^\s*(?P<start>0x[0-9A-Fa-f]+)\s*(?P<op>[-+])\s*(?P<end>0x[0-9A-Fa-f]+)\s*$" r"^\s*(?P<start>0x[0-9A-Fa-f]+)\s*(?P<op>[-+])\s*(?P<end>0x[0-9A-Fa-f]+)\s*$"
) )
def __init__(self, start_addr=None, end_addr=None, name=None): def __init__(self, start_addr=None, end_addr=None, name=None):
@ -557,7 +557,7 @@ class Symbolicator:
if image.identifier == identifier: if image.identifier == identifier:
images.append(image) images.append(image)
if len(images) == 0: if len(images) == 0:
regex_text = "^.*\.%s$" % (re.escape(identifier)) regex_text = r"^.*\.%s$" % (re.escape(identifier))
regex = re.compile(regex_text) regex = re.compile(regex_text)
for image in self.images: for image in self.images:
if regex.match(image.identifier): if regex.match(image.identifier):

@ -104,4 +104,4 @@ class PExpectTest(TestBase):
Returns the escape sequence to move the cursor forward/right Returns the escape sequence to move the cursor forward/right
by a certain amount of characters. by a certain amount of characters.
""" """
return b"\x1b\[" + str(chars_to_move).encode("utf-8") + b"C" return b"\x1b\\[" + str(chars_to_move).encode("utf-8") + b"C"

@ -91,7 +91,7 @@ def timeout_to_seconds(timeout):
class ProcessHelper(object): class ProcessHelper(object):
"""Provides an interface for accessing process-related functionality. r"""Provides an interface for accessing process-related functionality.
This class provides a factory method that gives the caller a This class provides a factory method that gives the caller a
platform-specific implementation instance of the class. platform-specific implementation instance of the class.

@ -20,7 +20,7 @@ class TestBackticksInAlias(TestBase):
interp = self.dbg.GetCommandInterpreter() interp = self.dbg.GetCommandInterpreter()
result = lldb.SBCommandReturnObject() result = lldb.SBCommandReturnObject()
interp.HandleCommand( interp.HandleCommand(
"command alias _test-argv-cmd expression -Z \`argc\` -- argv", result r"command alias _test-argv-cmd expression -Z \`argc\` -- argv", result
) )
self.assertCommandReturn(result, "Made the alias") self.assertCommandReturn(result, "Made the alias")
interp.HandleCommand("_test-argv-cmd", result) interp.HandleCommand("_test-argv-cmd", result)
@ -28,7 +28,7 @@ class TestBackticksInAlias(TestBase):
# Now try a harder case where we create this using an alias: # Now try a harder case where we create this using an alias:
interp.HandleCommand( interp.HandleCommand(
"command alias _test-argv-parray-cmd parray \`argc\` argv", result r"command alias _test-argv-parray-cmd parray \`argc\` argv", result
) )
self.assertCommandReturn(result, "Made the alias") self.assertCommandReturn(result, "Made the alias")
interp.HandleCommand("_test-argv-parray-cmd", result) interp.HandleCommand("_test-argv-parray-cmd", result)

@ -30,7 +30,7 @@ class TestMemoryAllocSettings(TestBase):
alloc0 = re.search("^.*IRMemoryMap::Malloc.+?0xdead0000.*$", log, re.MULTILINE) alloc0 = re.search("^.*IRMemoryMap::Malloc.+?0xdead0000.*$", log, re.MULTILINE)
# Malloc adds additional bytes to allocation size, hence 10007 # Malloc adds additional bytes to allocation size, hence 10007
alloc1 = re.search( alloc1 = re.search(
"^.*IRMemoryMap::Malloc\s*?\(10007.+?0xdead1000.*$", log, re.MULTILINE r"^.*IRMemoryMap::Malloc\s*?\(10007.+?0xdead1000.*$", log, re.MULTILINE
) )
self.assertTrue(alloc0, "Couldn't find an allocation at a given address.") self.assertTrue(alloc0, "Couldn't find an allocation at a given address.")
self.assertTrue( self.assertTrue(

@ -50,7 +50,7 @@ class BasicExprCommandsTestCase(TestBase):
def test_floating_point_expr_commands(self): def test_floating_point_expr_commands(self):
self.build_and_run() self.build_and_run()
self.expect("expression 2.234f", patterns=["\(float\) \$.* = 2\.234"]) self.expect("expression 2.234f", patterns=[r"\(float\) \$.* = 2\.234"])
# (float) $2 = 2.234 # (float) $2 = 2.234
def test_many_expr_commands(self): def test_many_expr_commands(self):

@ -48,7 +48,7 @@ class TestGuiExpandThreadsTree(PExpectTest):
self.child.expect_exact("Threads") self.child.expect_exact("Threads")
# The main thread should be expanded. # The main thread should be expanded.
self.child.expect("#\d+: main") self.child.expect(r"#\d+: main")
# Quit the GUI # Quit the GUI
self.child.send(escape_key) self.child.send(escape_key)

@ -349,13 +349,13 @@ class HelpCommandTestCase(TestBase):
self.expect( self.expect(
"help memory read", "help memory read",
patterns=[ patterns=[
"--show-tags\n\s+Include memory tags in output " "--show-tags\n\\s+Include memory tags in output "
"\(does not apply to binary output\)." "\\(does not apply to binary output\\)."
], ],
) )
self.expect( self.expect(
"help memory find", "help memory find",
patterns=["--show-tags\n\s+Include memory tags in output."], patterns=["--show-tags\n\\s+Include memory tags in output."],
) )
@no_debug_info_test @no_debug_info_test

@ -93,7 +93,7 @@ class LaunchWithShellExpandTestCase(TestBase):
self.runCmd("process kill") self.runCmd("process kill")
self.runCmd("process launch -X true -w %s -- foo\ bar" % (self.getBuildDir())) self.runCmd(r"process launch -X true -w %s -- foo\ bar" % (self.getBuildDir()))
process = self.process() process = self.process()

@ -48,12 +48,12 @@ class TestRegistersUnavailable(GDBRemoteTestBase):
"register read --all", "register read --all",
patterns=[ patterns=[
"(?sm)^general purpose registers:\n" "(?sm)^general purpose registers:\n"
"^\s+rdx = 0x5555555555555555\n" "^\\s+rdx = 0x5555555555555555\n"
".*" ".*"
"^3 registers were unavailable.\n" "^3 registers were unavailable.\n"
"\n" "\n"
"^supplementary registers:\n" "^supplementary registers:\n"
"^\s+edx = 0x55555555\n" "^\\s+edx = 0x55555555\n"
".*" ".*"
"^12 registers were unavailable." "^12 registers were unavailable."
], ],

@ -662,14 +662,14 @@ class RegisterCommandsTestCase(TestBase):
# N/Z/C/V bits will always be present, so check only for those. # N/Z/C/V bits will always be present, so check only for those.
self.expect( self.expect(
"register read cpsr", "register read cpsr",
patterns=["= \(N = [0|1], Z = [0|1], C = [0|1], V = [0|1]"], patterns=[r"= \(N = [0|1], Z = [0|1], C = [0|1], V = [0|1]"],
) )
self.expect( self.expect(
"register read fpsr", patterns=["= \(QC = [0|1], IDC = [0|1], IXC = [0|1]"] "register read fpsr", patterns=[r"= \(QC = [0|1], IDC = [0|1], IXC = [0|1]"]
) )
# AHP/DN/FZ always present, others may vary. # AHP/DN/FZ always present, others may vary.
self.expect( self.expect(
"register read fpcr", patterns=["= \(AHP = [0|1], DN = [0|1], FZ = [0|1]"] "register read fpcr", patterns=[r"= \(AHP = [0|1], DN = [0|1], FZ = [0|1]"]
) )
# Should get enumerator descriptions for RMode. # Should get enumerator descriptions for RMode.

@ -186,13 +186,13 @@ class SettingsCommandTestCase(TestBase):
self.addTearDownHook(cleanup) self.addTearDownHook(cleanup)
self.runCmd("settings show frame-format") self.runCmd("settings show frame-format")
m = re.match('^frame-format \(format-string\) = "(.*)"$', self.res.GetOutput()) m = re.match(r'^frame-format \(format-string\) = "(.*)"$', self.res.GetOutput())
self.assertTrue(m, "Bad settings string") self.assertTrue(m, "Bad settings string")
self.format_string = m.group(1) self.format_string = m.group(1)
# Change the default format to print function.name rather than # Change the default format to print function.name rather than
# function.name-with-args # function.name-with-args
format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}\`${function.name}{${function.pc-offset}}}{ at ${line.file.fullpath}:${line.number}}{, lang=${language}}\n" format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}\\`${function.name}{${function.pc-offset}}}{ at ${line.file.fullpath}:${line.number}}{, lang=${language}}\n"
self.runCmd("settings set frame-format %s" % format_string) self.runCmd("settings set frame-format %s" % format_string)
# Immediately test the setting. # Immediately test the setting.
@ -724,7 +724,7 @@ class SettingsCommandTestCase(TestBase):
) )
self.runCmd("settings set target.run-args 1 2 3") # Set to known value self.runCmd("settings set target.run-args 1 2 3") # Set to known value
# Set to new value with trailing whitespaces # Set to new value with trailing whitespaces
self.runCmd("settings set target.run-args 3 \ \ ") self.runCmd(r"settings set target.run-args 3 \ \ ")
self.expect( self.expect(
"settings show target.run-args", "settings show target.run-args",
SETTING_MSG("target.run-args"), SETTING_MSG("target.run-args"),
@ -846,11 +846,11 @@ class SettingsCommandTestCase(TestBase):
# Check that settings have their default values after clearing. # Check that settings have their default values after clearing.
self.expect( self.expect(
"settings show target.env-vars", "settings show target.env-vars",
patterns=["^target.env-vars \(dictionary of strings\) =\s*$"], patterns=[r"^target.env-vars \(dictionary of strings\) =\s*$"],
) )
self.expect( self.expect(
"settings show target.run-args", "settings show target.run-args",
patterns=["^target.run-args \(arguments\) =\s*$"], patterns=[r"^target.run-args \(arguments\) =\s*$"],
) )
self.expect("settings show auto-confirm", substrs=["false"]) self.expect("settings show auto-confirm", substrs=["false"])
self.expect("settings show tab-size", substrs=["2"]) self.expect("settings show tab-size", substrs=["2"])
@ -947,7 +947,7 @@ class SettingsCommandTestCase(TestBase):
# showing & setting an undefined .experimental. setting should generate no errors. # showing & setting an undefined .experimental. setting should generate no errors.
self.expect( self.expect(
"settings show target.experimental.setting-which-does-not-exist", "settings show target.experimental.setting-which-does-not-exist",
patterns=["^\s$"], patterns=[r"^\s$"],
error=False, error=False,
) )
self.expect( self.expect(

@ -74,7 +74,7 @@ class targetCommandTestCase(TestBase):
# Find the largest index of the existing list. # Find the largest index of the existing list.
import re import re
pattern = re.compile("target #(\d+):") pattern = re.compile(r"target #(\d+):")
for line in reversed(output.split(os.linesep)): for line in reversed(output.split(os.linesep)):
match = pattern.search(line) match = pattern.search(line)
if match: if match:

@ -94,11 +94,11 @@ class TestDumpDWO(lldbtest.TestBase):
self.expect( self.expect(
"target modules dump separate-debug-info", "target modules dump separate-debug-info",
patterns=[ patterns=[
"Symbol file: .*?a\.out", r"Symbol file: .*?a\.out",
'Type: "dwo"', 'Type: "dwo"',
"Dwo ID\s+Err\s+Dwo Path", r"Dwo ID\s+Err\s+Dwo Path",
"0x[a-zA-Z0-9]{16}\s+.*main\.dwo", r"0x[a-zA-Z0-9]{16}\s+.*main\.dwo",
"0x[a-zA-Z0-9]{16}\s+.*foo\.dwo", r"0x[a-zA-Z0-9]{16}\s+.*foo\.dwo",
], ],
) )
@ -118,11 +118,11 @@ class TestDumpDWO(lldbtest.TestBase):
self.expect( self.expect(
"target modules dump separate-debug-info", "target modules dump separate-debug-info",
patterns=[ patterns=[
"Symbol file: .*?a\.out", r"Symbol file: .*?a\.out",
'Type: "dwo"', 'Type: "dwo"',
"Dwo ID\s+Err\s+Dwo Path", r"Dwo ID\s+Err\s+Dwo Path",
"0x[a-zA-Z0-9]{16}\s+E\s+.*main\.dwo", r"0x[a-zA-Z0-9]{16}\s+E\s+.*main\.dwo",
"0x[a-zA-Z0-9]{16}\s+E\s+.*foo\.dwo", r"0x[a-zA-Z0-9]{16}\s+E\s+.*foo\.dwo",
], ],
) )

@ -93,11 +93,11 @@ class TestDumpOso(lldbtest.TestBase):
self.expect( self.expect(
"target modules dump separate-debug-info", "target modules dump separate-debug-info",
patterns=[ patterns=[
"Symbol file: .*?a\.out", r"Symbol file: .*?a\.out",
'Type: "oso"', 'Type: "oso"',
"Mod Time\s+Err\s+Oso Path", r"Mod Time\s+Err\s+Oso Path",
"0x[a-zA-Z0-9]{16}\s+.*main\.o", r"0x[a-zA-Z0-9]{16}\s+.*main\.o",
"0x[a-zA-Z0-9]{16}\s+.*foo\.o", r"0x[a-zA-Z0-9]{16}\s+.*foo\.o",
], ],
) )
@ -119,11 +119,11 @@ class TestDumpOso(lldbtest.TestBase):
self.expect( self.expect(
"target modules dump separate-debug-info", "target modules dump separate-debug-info",
patterns=[ patterns=[
"Symbol file: .*?a\.out", r"Symbol file: .*?a\.out",
'Type: "oso"', 'Type: "oso"',
"Mod Time\s+Err\s+Oso Path", r"Mod Time\s+Err\s+Oso Path",
"0x[a-zA-Z0-9]{16}\s+E\s+.*main\.o", r"0x[a-zA-Z0-9]{16}\s+E\s+.*main\.o",
"0x[a-zA-Z0-9]{16}\s+E\s+.*foo\.o", r"0x[a-zA-Z0-9]{16}\s+E\s+.*foo\.o",
], ],
) )

@ -64,7 +64,7 @@ class TestTraceDumpInfo(TraceIntelPTTestCaseBase):
hardware disabled tracing: 4 hardware disabled tracing: 4
trace synchronization point: 1""", trace synchronization point: 1""",
], ],
patterns=["Decoding instructions: \d.\d\ds"], patterns=[r"Decoding instructions: \d.\d\ds"],
) )
def testDumpRawTraceSizeJSON(self): def testDumpRawTraceSizeJSON(self):

@ -68,7 +68,7 @@ class TestTraceEvents(TraceIntelPTTestCaseBase):
self.expect( self.expect(
"thread trace dump instructions -e -f", "thread trace dump instructions -e -f",
patterns=[ patterns=[
f"""thread #1: tid = .* rf"""thread #1: tid = .*
0: \(event\) trace synchronization point \[offset \= 0x0xec0\] 0: \(event\) trace synchronization point \[offset \= 0x0xec0\]
1: \(event\) hardware disabled tracing 1: \(event\) hardware disabled tracing
a.out`main \+ 23 at main.cpp:12 a.out`main \+ 23 at main.cpp:12
@ -102,7 +102,7 @@ class TestTraceEvents(TraceIntelPTTestCaseBase):
self.expect( self.expect(
"thread trace dump instructions -e --id 18", "thread trace dump instructions -e --id 18",
patterns=[ patterns=[
f"""thread #1: tid = .* rf"""thread #1: tid = .*
a.out`symbol stub for: foo\(\) a.out`symbol stub for: foo\(\)
18: {ADDRESS_REGEX} jmpq .* 18: {ADDRESS_REGEX} jmpq .*
17: \(event\) software disabled tracing 17: \(event\) software disabled tracing

@ -244,7 +244,7 @@ class TestTraceStartStop(TraceIntelPTTestCaseBase):
self.expect( self.expect(
"thread trace dump instructions -f", "thread trace dump instructions -f",
patterns=[ patterns=[
f"""thread #1: tid = .* rf"""thread #1: tid = .*
a.out`main \+ 4 at main.cpp:2 a.out`main \+ 4 at main.cpp:2
2: {ADDRESS_REGEX} movl""" 2: {ADDRESS_REGEX} movl"""
], ],
@ -255,7 +255,7 @@ class TestTraceStartStop(TraceIntelPTTestCaseBase):
self.expect( self.expect(
"thread trace dump instructions -f", "thread trace dump instructions -f",
patterns=[ patterns=[
f"""thread #1: tid = .* rf"""thread #1: tid = .*
a.out`main \+ 4 at main.cpp:2 a.out`main \+ 4 at main.cpp:2
2: {ADDRESS_REGEX} movl .* 2: {ADDRESS_REGEX} movl .*
a.out`main \+ 11 at main.cpp:4 a.out`main \+ 11 at main.cpp:4
@ -269,7 +269,7 @@ class TestTraceStartStop(TraceIntelPTTestCaseBase):
self.expect( self.expect(
"thread trace dump instructions", "thread trace dump instructions",
patterns=[ patterns=[
f"""thread #1: tid = .* rf"""thread #1: tid = .*
a.out`main \+ 32 at main.cpp:4 a.out`main \+ 32 at main.cpp:4
10: {ADDRESS_REGEX} jle .* ; <\+20> at main.cpp:5 10: {ADDRESS_REGEX} jle .* ; <\+20> at main.cpp:5
8: {ADDRESS_REGEX} cmpl .* 8: {ADDRESS_REGEX} cmpl .*
@ -297,7 +297,7 @@ class TestTraceStartStop(TraceIntelPTTestCaseBase):
self.expect( self.expect(
"thread trace dump instructions -f", "thread trace dump instructions -f",
patterns=[ patterns=[
f"""thread #1: tid = .* rf"""thread #1: tid = .*
a.out`main \+ 20 at main.cpp:5 a.out`main \+ 20 at main.cpp:5
2: {ADDRESS_REGEX} xorl""" 2: {ADDRESS_REGEX} xorl"""
], ],
@ -306,7 +306,7 @@ class TestTraceStartStop(TraceIntelPTTestCaseBase):
self.expect( self.expect(
"thread trace dump instructions", "thread trace dump instructions",
patterns=[ patterns=[
f"""thread #1: tid = .* rf"""thread #1: tid = .*
a.out`main \+ 20 at main.cpp:5 a.out`main \+ 20 at main.cpp:5
2: {ADDRESS_REGEX} xorl""" 2: {ADDRESS_REGEX} xorl"""
], ],
@ -336,7 +336,7 @@ class TestTraceStartStop(TraceIntelPTTestCaseBase):
self.expect( self.expect(
"thread trace dump instructions -c 1", "thread trace dump instructions -c 1",
patterns=[ patterns=[
f"""thread #1: tid = .* rf"""thread #1: tid = .*
a.out`main \+ 11 at main.cpp:4""" a.out`main \+ 11 at main.cpp:4"""
], ],
) )

@ -20,7 +20,7 @@ class TestTraceTimestampCounters(TraceIntelPTTestCaseBase):
self.expect("n") self.expect("n")
self.expect( self.expect(
"thread trace dump instructions -t -c 1", "thread trace dump instructions -t -c 1",
patterns=[": \[\d+.\d+ ns\] 0x0000000000400511 movl"], patterns=[r": \[\d+.\d+ ns\] 0x0000000000400511 movl"],
) )
@testSBAPIAndCommands @testSBAPIAndCommands
@ -43,7 +43,7 @@ class TestTraceTimestampCounters(TraceIntelPTTestCaseBase):
self.runCmd("thread trace dump instructions -t --raw --forward") self.runCmd("thread trace dump instructions -t --raw --forward")
id_to_timestamp = {} id_to_timestamp = {}
for line in self.res.GetOutput().splitlines(): for line in self.res.GetOutput().splitlines():
m = re.search(" (.+): \[(.+)\ ns].*", line) m = re.search(r" (.+): \[(.+)\ ns].*", line)
if m: if m:
id_to_timestamp[int(m.group(1))] = m.group(2) id_to_timestamp[int(m.group(1))] = m.group(2)
self.assertEqual(len(id_to_timestamp), 3) self.assertEqual(len(id_to_timestamp), 3)
@ -69,12 +69,12 @@ class TestTraceTimestampCounters(TraceIntelPTTestCaseBase):
self.expect("n") self.expect("n")
self.expect( self.expect(
"thread trace dump instructions -t -c 1", "thread trace dump instructions -t -c 1",
patterns=[": \[\d+.\d+ ns\] 0x0000000000400511 movl"], patterns=[r": \[\d+.\d+ ns\] 0x0000000000400511 movl"],
) )
self.expect( self.expect(
"thread trace dump instructions -t -c 1 --pretty-json", "thread trace dump instructions -t -c 1 --pretty-json",
patterns=['''"timestamp_ns": "\d+.\d+"'''], patterns=[r'''"timestamp_ns": "\d+.\d+"'''],
) )
@testSBAPIAndCommands @testSBAPIAndCommands
@ -91,7 +91,7 @@ class TestTraceTimestampCounters(TraceIntelPTTestCaseBase):
self.expect("n") self.expect("n")
self.expect( self.expect(
"thread trace dump instructions -t -c 1", "thread trace dump instructions -t -c 1",
patterns=[": \[unavailable\] 0x0000000000400511 movl"], patterns=[r": \[unavailable\] 0x0000000000400511 movl"],
) )
self.expect( self.expect(

@ -28,7 +28,7 @@ class DriverQuitSpeedTest(PExpectTest):
# Launch the process without a TTY so we don't have to interrupt: # Launch the process without a TTY so we don't have to interrupt:
child.sendline("process launch -n") child.sendline("process launch -n")
print("launched process") print("launched process")
child.expect("Process ([\d]*) launched:") child.expect(r"Process ([\d]*) launched:")
print("Got launch message") print("Got launch message")
child.sendline("quit") child.sendline("quit")
print("sent quit") print("sent quit")

@ -60,7 +60,7 @@ class BreakpointByLineAndColumnTestCase(TestBase):
for pattern in patterns: for pattern in patterns:
line = line_number("main.cpp", pattern) + 1 line = line_number("main.cpp", pattern) + 1
column = int(re.search("\(col:([0-9]+)\)", pattern).group(1)) column = int(re.search(r"\(col:([0-9]+)\)", pattern).group(1))
source_loc.append({"line": line, "column": column}) source_loc.append({"line": line, "column": column})
target = self.createTestTarget() target = self.createTestTarget()

@ -53,7 +53,7 @@ class BreakpointLocationsTestCase(TestBase):
], ],
patterns=[ patterns=[
"where = a.out`func_inlined .+unresolved, hit count = 0", "where = a.out`func_inlined .+unresolved, hit count = 0",
"where = a.out`main .+\[inlined\].+unresolved, hit count = 0", r"where = a.out`main .+\[inlined\].+unresolved, hit count = 0",
], ],
) )

@ -104,7 +104,9 @@ class AdvDataFormatterTestCase(TestBase):
self.runCmd("type summary clear") self.runCmd("type summary clear")
self.runCmd('type summary add --summary-string "${var[0-1]}" -x "int\[[0-9]\]"') self.runCmd(
r'type summary add --summary-string "${var[0-1]}" -x "int\[[0-9]\]"'
)
self.expect("frame variable int_array", substrs=["1,2"]) self.expect("frame variable int_array", substrs=["1,2"])
@ -119,7 +121,7 @@ class AdvDataFormatterTestCase(TestBase):
self.runCmd("type summary clear") self.runCmd("type summary clear")
self.runCmd('type summary add -c -x "i_am_cool\[[0-9]\]"') self.runCmd(r'type summary add -c -x "i_am_cool\[[0-9]\]"')
self.runCmd("type summary add -c i_am_cool") self.runCmd("type summary add -c i_am_cool")
self.expect( self.expect(
@ -172,7 +174,7 @@ class AdvDataFormatterTestCase(TestBase):
self.runCmd("type summary clear") self.runCmd("type summary clear")
self.runCmd( self.runCmd(
'type summary add --summary-string "${*var[].x[0-3]%hex} is a bitfield on a set of integers" -x "SimpleWithPointers\[[0-9]\]"' r'type summary add --summary-string "${*var[].x[0-3]%hex} is a bitfield on a set of integers" -x "SimpleWithPointers\[[0-9]\]"'
) )
self.expect( self.expect(

@ -62,7 +62,7 @@ class CppDataFormatterTestCase(TestBase):
self.expect( self.expect(
"frame variable", "frame variable",
patterns=[ patterns=[
"\(Speed\) SPILookHex = 0x[0-9a-f]+" # Speed should look hex-ish now. r"\(Speed\) SPILookHex = 0x[0-9a-f]+" # Speed should look hex-ish now.
], ],
) )
@ -71,14 +71,14 @@ class CppDataFormatterTestCase(TestBase):
self.expect( self.expect(
"frame variable", "frame variable",
patterns=[ patterns=[
"\(SignalMask\) SMILookHex = 0x[0-9a-f]+" # SignalMask should look hex-ish now. r"\(SignalMask\) SMILookHex = 0x[0-9a-f]+" # SignalMask should look hex-ish now.
], ],
) )
self.expect( self.expect(
"frame variable", "frame variable",
matching=False, matching=False,
patterns=[ patterns=[
"\(Type4\) T4ILookChar = 0x[0-9a-f]+" # Type4 should NOT look hex-ish now. r"\(Type4\) T4ILookChar = 0x[0-9a-f]+" # Type4 should NOT look hex-ish now.
], ],
) )

@ -53,7 +53,7 @@ class ObjCDataFormatterNSContainer(ObjCDataFormatterTestCase):
self.expect( self.expect(
"frame variable -d run-target *nscfDictionary", "frame variable -d run-target *nscfDictionary",
patterns=[ patterns=[
"\(__NSCFDictionary\) \*nscfDictionary =", r"\(__NSCFDictionary\) \*nscfDictionary =",
'key = 0x.* @"foo"', 'key = 0x.* @"foo"',
'value = 0x.* @"foo"', 'value = 0x.* @"foo"',
'key = 0x.* @"bar"', 'key = 0x.* @"bar"',
@ -68,7 +68,7 @@ class ObjCDataFormatterNSContainer(ObjCDataFormatterTestCase):
self.expect( self.expect(
"frame variable -d run-target *cfDictionaryRef", "frame variable -d run-target *cfDictionaryRef",
patterns=[ patterns=[
"\(const __CFDictionary\) \*cfDictionaryRef =", r"\(const __CFDictionary\) \*cfDictionaryRef =",
'key = 0x.* @"foo"', 'key = 0x.* @"foo"',
'value = 0x.* @"foo"', 'value = 0x.* @"foo"',
'key = 0x.* @"bar"', 'key = 0x.* @"bar"',
@ -89,18 +89,18 @@ class ObjCDataFormatterNSContainer(ObjCDataFormatterTestCase):
self.expect( self.expect(
"frame variable -d run-target *nscfSet", "frame variable -d run-target *nscfSet",
patterns=[ patterns=[
"\(__NSCFSet\) \*nscfSet =", r"\(__NSCFSet\) \*nscfSet =",
'\[0\] = 0x.* @".*"', r'\[0\] = 0x.* @".*"',
'\[1\] = 0x.* @".*"', r'\[1\] = 0x.* @".*"',
], ],
) )
self.expect( self.expect(
"frame variable -d run-target *cfSetRef", "frame variable -d run-target *cfSetRef",
patterns=[ patterns=[
"\(const __CFSet\) \*cfSetRef =", r"\(const __CFSet\) \*cfSetRef =",
'\[0\] = 0x.* @".*"', r'\[0\] = 0x.* @".*"',
'\[1\] = 0x.* @".*"', r'\[1\] = 0x.* @".*"',
], ],
) )

@ -83,9 +83,9 @@ class GenericUnorderedDataFormatterTestCase(TestBase):
[ [
"IntsUnorderedSet", "IntsUnorderedSet",
"size=5 {", "size=5 {",
"\[\d\] = 5", r"\[\d\] = 5",
"\[\d\] = 3", r"\[\d\] = 3",
"\[\d\] = 2", r"\[\d\] = 2",
], ],
) )
@ -94,9 +94,9 @@ class GenericUnorderedDataFormatterTestCase(TestBase):
[ [
"StringsUnorderedSet", "StringsUnorderedSet",
"size=5 {", "size=5 {",
'\[\d\] = "is"', r'\[\d\] = "is"',
'\[\d\] = "world"', r'\[\d\] = "world"',
'\[\d\] = "hello"', r'\[\d\] = "hello"',
], ],
) )
@ -105,9 +105,9 @@ class GenericUnorderedDataFormatterTestCase(TestBase):
[ [
"IntsUnorderedMultiSet", "IntsUnorderedMultiSet",
"size=6 {", "size=6 {",
"(\[\d\] = 3(\\n|.)+){3}", "(\\[\\d\\] = 3(\\n|.)+){3}",
"\[\d\] = 2", r"\[\d\] = 2",
"\[\d\] = 1", r"\[\d\] = 1",
], ],
) )
@ -116,8 +116,8 @@ class GenericUnorderedDataFormatterTestCase(TestBase):
[ [
"StringsUnorderedMultiSet", "StringsUnorderedMultiSet",
"size=5 {", "size=5 {",
'(\[\d\] = "is"(\\n|.)+){2}', '(\\[\\d\\] = "is"(\\n|.)+){2}',
'(\[\d\] = "world"(\\n|.)+){2}', '(\\[\\d\\] = "world"(\\n|.)+){2}',
], ],
) )

@ -17,7 +17,7 @@ class TypeSummaryListArgumentTestCase(TestBase):
"type summary list Foo", substrs=["Category: default", "Category: system"] "type summary list Foo", substrs=["Category: default", "Category: system"]
) )
self.expect( self.expect(
"type summary list char", substrs=["char ?(\*|\[\])", "char ?\[[0-9]+\]"] "type summary list char", substrs=[r"char ?(\*|\[\])", r"char ?\[[0-9]+\]"]
) )
self.expect("type summary list -w default", substrs=["system"], matching=False) self.expect("type summary list -w default", substrs=["system"], matching=False)
@ -28,6 +28,6 @@ class TypeSummaryListArgumentTestCase(TestBase):
) )
self.expect( self.expect(
"type summary list -w system char", "type summary list -w system char",
substrs=["char ?(\*|\[\])", "char ?\[[0-9]+\]"], substrs=[r"char ?(\*|\[\])", r"char ?\[[0-9]+\]"],
matching=True, matching=True,
) )

@ -678,7 +678,7 @@ class TestXMLRegisterFlags(GDBRemoteTestBase):
<reg name="cpsr" regnum="33" bitsize="32" type="cpsr_flags"/>""" <reg name="cpsr" regnum="33" bitsize="32" type="cpsr_flags"/>"""
) )
self.expect("register read cpsr", patterns=["\(E = 1\)$"]) self.expect("register read cpsr", patterns=[r"\(E = 1\)$"])
@skipIfXmlSupportMissing @skipIfXmlSupportMissing
@skipIfRemote @skipIfRemote
@ -701,7 +701,7 @@ class TestXMLRegisterFlags(GDBRemoteTestBase):
) )
self.expect("register info cpsr", patterns=["E: 1 = def, 2 = geh$"]) self.expect("register info cpsr", patterns=["E: 1 = def, 2 = geh$"])
self.expect("register read cpsr", patterns=["\(E = def \| geh\)$"]) self.expect("register read cpsr", patterns=[r"\(E = def \| geh\)$"])
@skipIfXmlSupportMissing @skipIfXmlSupportMissing
@skipIfRemote @skipIfRemote
@ -725,7 +725,7 @@ class TestXMLRegisterFlags(GDBRemoteTestBase):
) )
self.expect("register info cpsr", patterns=["E: 1 = def$"]) self.expect("register info cpsr", patterns=["E: 1 = def$"])
self.expect("register read cpsr", patterns=["\(E = def\)$"]) self.expect("register read cpsr", patterns=[r"\(E = def\)$"])
@skipIfXmlSupportMissing @skipIfXmlSupportMissing
@skipIfRemote @skipIfRemote
@ -1014,7 +1014,7 @@ class TestXMLRegisterFlags(GDBRemoteTestBase):
self.expect("register info cpsr", patterns=expected_info) self.expect("register info cpsr", patterns=expected_info)
expected_read = ["\(f2 = valid, f1 = valid\)$"] expected_read = [r"\(f2 = valid, f1 = valid\)$"]
self.expect("register read x0", patterns=expected_read) self.expect("register read x0", patterns=expected_read)
self.expect("register read cpsr", patterns=expected_read) self.expect("register read cpsr", patterns=expected_read)
@ -1055,4 +1055,4 @@ class TestXMLRegisterFlags(GDBRemoteTestBase):
], ],
) )
self.expect("register read x0", patterns=["\(foo = foo_1, foo = foo_0\)$"]) self.expect("register read x0", patterns=[r"\(foo = foo_1, foo = foo_0\)$"])

@ -95,7 +95,7 @@ class MemoryCommandRegion(TestBase):
self.assertFalse(result.Succeeded()) self.assertFalse(result.Succeeded())
self.assertRegex( self.assertRegex(
result.GetError(), result.GetError(),
"Usage: memory region <address\-expression> \(or \-\-all\)", r"Usage: memory region <address\-expression> \(or \-\-all\)",
) )
# --all should match what repeating the command gives you # --all should match what repeating the command gives you

@ -27,7 +27,7 @@ class targetCommandTestCase(TestBase):
) )
self.expect("target variable i", substrs=["i", "42"]) self.expect("target variable i", substrs=["i", "42"])
self.expect( self.expect(
"target variable var", patterns=["\(incomplete \*\) var = 0[xX](0)*dead"] "target variable var", patterns=[r"\(incomplete \*\) var = 0[xX](0)*dead"]
) )
self.expect( self.expect(
"target variable var[0]", "target variable var[0]",

@ -55,7 +55,7 @@ class IOHandlerCompletionTest(PExpectTest):
self.child.expect( self.child.expect(
re.compile( re.compile(
b"TestIOHandler(\r" b"TestIOHandler(\r"
+ self.cursor_forward_escape_seq("\d+") + self.cursor_forward_escape_seq(r"\d+")
+ b")?Completion.py" + b")?Completion.py"
) )
) )

@ -27,7 +27,7 @@ class EnumTypesTestCase(TestBase):
self.expect("fr var c", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = C$"]) self.expect("fr var c", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = C$"])
self.expect("fr var ab", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = AB$"]) self.expect("fr var ab", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = AB$"])
self.expect( self.expect(
"fr var ac", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = A \| C$"] "fr var ac", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[r" = A \| C$"]
) )
self.expect("fr var all", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = ALL$"]) self.expect("fr var all", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = ALL$"])
# Test that an enum that doesn't match the heuristic we use in # Test that an enum that doesn't match the heuristic we use in
@ -39,7 +39,7 @@ class EnumTypesTestCase(TestBase):
self.expect( self.expect(
"expression (enum bitfield)nonsense", "expression (enum bitfield)nonsense",
DATA_TYPES_DISPLAYED_CORRECTLY, DATA_TYPES_DISPLAYED_CORRECTLY,
patterns=[" = B \| C \| 0x10$"], patterns=[r" = B \| C \| 0x10$"],
) )
# Break inside the main. # Break inside the main.

@ -54,7 +54,7 @@ class FunctionTypesTestCase(TestBase):
) )
if self.platformIsDarwin(): if self.platformIsDarwin():
regexps = ["lib.*\.dylib`printf"] regexps = [r"lib.*\.dylib`printf"]
else: else:
regexps = ["printf"] regexps = ["printf"]
self.expect( self.expect(

@ -9,7 +9,7 @@ from lldbsuite.test import lldbutil
def re_expr_equals(val_type, val): def re_expr_equals(val_type, val):
# Match ({val_type}) ${sum_digits} = {val} # Match ({val_type}) ${sum_digits} = {val}
return re.compile(r"\(" + val_type + "\) \$\d+ = " + str(val)) return re.compile(r"\(" + val_type + r"\) \$\d+ = " + str(val))
class RegisterVariableTestCase(TestBase): class RegisterVariableTestCase(TestBase):

@ -82,7 +82,7 @@ class SetValuesTestCase(TestBase):
self.expect( self.expect(
"frame variable --show-types", "frame variable --show-types",
VARIABLES_DISPLAYED_CORRECTLY, VARIABLES_DISPLAYED_CORRECTLY,
patterns=["\((short unsigned int|unsigned short)\) i = 33"], patterns=[r"\((short unsigned int|unsigned short)\) i = 33"],
) )
# Now set variable 'i' and check that it is correctly displayed. # Now set variable 'i' and check that it is correctly displayed.
@ -90,7 +90,7 @@ class SetValuesTestCase(TestBase):
self.expect( self.expect(
"frame variable --show-types", "frame variable --show-types",
VARIABLES_DISPLAYED_CORRECTLY, VARIABLES_DISPLAYED_CORRECTLY,
patterns=["\((short unsigned int|unsigned short)\) i = 333"], patterns=[r"\((short unsigned int|unsigned short)\) i = 333"],
) )
self.runCmd("continue") self.runCmd("continue")

@ -20,7 +20,7 @@ class CStringsTestCase(TestBase):
self.runCmd("process launch", RUN_SUCCEEDED) self.runCmd("process launch", RUN_SUCCEEDED)
self.expect("expression -- a[2]", patterns=["\((const )?char\) \$0 = 'c'"]) self.expect("expression -- a[2]", patterns=[r"\((const )?char\) \$0 = 'c'"])
self.expect("expression -- z[2]", startstr="(const char) $1 = 'x'") self.expect("expression -- z[2]", startstr="(const char) $1 = 'x'")

@ -71,12 +71,12 @@ class TlsGlobalTestCase(TestBase):
self.expect( self.expect(
"expr var_static", "expr var_static",
VARIABLES_DISPLAYED_CORRECTLY, VARIABLES_DISPLAYED_CORRECTLY,
patterns=["\(int\) \$.* = 88"], patterns=[r"\(int\) \$.* = 88"],
) )
self.expect( self.expect(
"expr var_shared", "expr var_shared",
VARIABLES_DISPLAYED_CORRECTLY, VARIABLES_DISPLAYED_CORRECTLY,
patterns=["\(int\) \$.* = 66"], patterns=[r"\(int\) \$.* = 66"],
) )
# Continue on the main thread # Continue on the main thread
@ -102,10 +102,10 @@ class TlsGlobalTestCase(TestBase):
self.expect( self.expect(
"expr var_static", "expr var_static",
VARIABLES_DISPLAYED_CORRECTLY, VARIABLES_DISPLAYED_CORRECTLY,
patterns=["\(int\) \$.* = 44"], patterns=[r"\(int\) \$.* = 44"],
) )
self.expect( self.expect(
"expr var_shared", "expr var_shared",
VARIABLES_DISPLAYED_CORRECTLY, VARIABLES_DISPLAYED_CORRECTLY,
patterns=["\(int\) \$.* = 33"], patterns=[r"\(int\) \$.* = 33"],
) )

@ -74,8 +74,8 @@ class Char1632TestCase(TestBase):
self.expect( self.expect(
"frame variable as16 as32", "frame variable as16 as32",
patterns=[ patterns=[
"\(char16_t\[[0-9]+\]\) as16 = ", r"\(char16_t\[[0-9]+\]\) as16 = ",
"\(char32_t\[[0-9]+\]\) as32 = ", r"\(char32_t\[[0-9]+\]\) as32 = ",
], ],
substrs=['u"ﺸﺵۻ"', 'U"ЕЙРГЖО"'], substrs=['u"ﺸﺵۻ"', 'U"ЕЙРГЖО"'],
) )
@ -103,8 +103,8 @@ class Char1632TestCase(TestBase):
self.expect( self.expect(
"frame variable as16 as32", "frame variable as16 as32",
patterns=[ patterns=[
"\(char16_t\[[0-9]+\]\) as16 = ", r"\(char16_t\[[0-9]+\]\) as16 = ",
"\(char32_t\[[0-9]+\]\) as32 = ", r"\(char32_t\[[0-9]+\]\) as32 = ",
], ],
substrs=['"色ハ匂ヘト散リヌルヲ"', '""'], substrs=['"色ハ匂ヘト散リヌルヲ"', '""'],
) )

@ -38,7 +38,7 @@ class StaticVariableTestCase(TestBase):
self.expect( self.expect(
"target variable A::g_points", "target variable A::g_points",
VARIABLES_DISPLAYED_CORRECTLY, VARIABLES_DISPLAYED_CORRECTLY,
patterns=["\(PointType\[[1-9]*\]\) A::g_points = {"], patterns=[r"\(PointType\[[1-9]*\]\) A::g_points = {"],
) )
self.expect( self.expect(
"target variable g_points", "target variable g_points",
@ -76,7 +76,7 @@ class StaticVariableTestCase(TestBase):
"target variable A::g_points", "target variable A::g_points",
VARIABLES_DISPLAYED_CORRECTLY, VARIABLES_DISPLAYED_CORRECTLY,
patterns=[ patterns=[
"\(PointType\[[1-9]*\]\) A::g_points = {", r"\(PointType\[[1-9]*\]\) A::g_points = {",
"(x = 1, y = 2)", "(x = 1, y = 2)",
"(x = 11, y = 22)", "(x = 11, y = 22)",
], ],

@ -179,7 +179,7 @@ class ClassTypesTestCase(TestBase):
self.expect( self.expect(
"expression this->m_c_int", "expression this->m_c_int",
VARIABLES_DISPLAYED_CORRECTLY, VARIABLES_DISPLAYED_CORRECTLY,
patterns=["\(int\) \$[0-9]+ = 66"], patterns=[r"\(int\) \$[0-9]+ = 66"],
) )
def test_with_constructor_name(self): def test_with_constructor_name(self):

@ -129,7 +129,7 @@ class DynamicValueTestCase(TestBase):
self.expect( self.expect(
"frame var -d run-target --ptr-depth=2 --show-types anotherA.m_client_A", "frame var -d run-target --ptr-depth=2 --show-types anotherA.m_client_A",
"frame var finds its way into a child member", "frame var finds its way into a child member",
patterns=["\(B \*\)"], patterns=[r"\(B \*\)"],
) )
# Now make sure we also get it right for a reference as well: # Now make sure we also get it right for a reference as well:

@ -23,7 +23,7 @@ class LibCxxInternalsRecognizerTestCase(TestBase):
# We never hide the frame of the entry-point into the standard library, even # We never hide the frame of the entry-point into the standard library, even
# if the name starts with `__` which usually indicates an internal function. # if the name starts with `__` which usually indicates an internal function.
"ranges_sort_less(int, int)": [ "ranges_sort_less(int, int)": [
re.compile("ranges::__sort::(__fn::)?operator\(\)"), re.compile(r"ranges::__sort::(__fn::)?operator\(\)"),
"test_algorithms", "test_algorithms",
], ],
# `ranges::views::transform` internally uses `std::invoke`, and that # `ranges::views::transform` internally uses `std::invoke`, and that

@ -237,12 +237,12 @@ class NamespaceTestCase(TestBase):
self.expect( self.expect(
"expression myanonfunc", "expression myanonfunc",
patterns=["\(anonymous namespace\)::myanonfunc\(int\)"], patterns=[r"\(anonymous namespace\)::myanonfunc\(int\)"],
) )
self.expect( self.expect(
"expression variadic_sum", "expression variadic_sum",
patterns=["\(anonymous namespace\)::variadic_sum\(int, ...\)"], patterns=[r"\(anonymous namespace\)::variadic_sum\(int, ...\)"],
) )
self.expect_expr("::B::Bar b; b.x()", result_type="int", result_value="42") self.expect_expr("::B::Bar b; b.x()", result_type="int", result_value="42")

@ -57,8 +57,8 @@ class SignedTypesTestCase(TestBase):
"frame variable --show-types --no-args", "frame variable --show-types --no-args",
VARIABLES_DISPLAYED_CORRECTLY, VARIABLES_DISPLAYED_CORRECTLY,
patterns=[ patterns=[
"\((short int|short)\) the_signed_short = 99", r"\((short int|short)\) the_signed_short = 99",
"\((signed char|char)\) the_signed_char = 'c'", r"\((signed char|char)\) the_signed_char = 'c'",
], ],
substrs=[ substrs=[
"(int) the_signed_int = 99", "(int) the_signed_int = 99",

@ -22,7 +22,7 @@ class UnsignedTypesTestCase(TestBase):
"frame variable --show-types --no-args", "frame variable --show-types --no-args",
VARIABLES_DISPLAYED_CORRECTLY, VARIABLES_DISPLAYED_CORRECTLY,
patterns=[ patterns=[
"\((short unsigned int|unsigned short)\) the_unsigned_short = 99" r"\((short unsigned int|unsigned short)\) the_unsigned_short = 99"
], ],
substrs=[ substrs=[
"(unsigned char) the_unsigned_char = 'c'", "(unsigned char) the_unsigned_char = 'c'",

@ -22,12 +22,12 @@ class MixedLanguagesTestCase(TestBase):
self.addTearDownHook(cleanup) self.addTearDownHook(cleanup)
self.runCmd("settings show frame-format") self.runCmd("settings show frame-format")
m = re.match('^frame-format \(format-string\) = "(.*)"$', self.res.GetOutput()) m = re.match(r'^frame-format \(format-string\) = "(.*)"$', self.res.GetOutput())
self.assertTrue(m, "Bad settings string") self.assertTrue(m, "Bad settings string")
self.format_string = m.group(1) self.format_string = m.group(1)
# Change the default format to print the language. # Change the default format to print the language.
format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}\`${function.name}{${function.pc-offset}}}{, lang=${language}}\n" format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}\\`${function.name}{${function.pc-offset}}}{, lang=${language}}\n"
self.runCmd("settings set frame-format %s" % format_string) self.runCmd("settings set frame-format %s" % format_string)
self.expect( self.expect(
"settings show frame-format", "settings show frame-format",

@ -166,7 +166,7 @@ class FoundationTestCase(TestBase):
"frame variable --show-types --scope", "frame variable --show-types --scope",
VARIABLES_DISPLAYED_CORRECTLY, VARIABLES_DISPLAYED_CORRECTLY,
substrs=["ARG: (MyString *) self"], substrs=["ARG: (MyString *) self"],
patterns=["ARG: \(.*\) _cmd", "(objc_selector *)|(SEL)"], patterns=[r"ARG: \(.*\) _cmd", "(objc_selector *)|(SEL)"],
) )
# rdar://problem/8651752 # rdar://problem/8651752

@ -19,10 +19,10 @@ class FoundationTestCaseNSArray(TestBase):
self.runCmd("thread backtrace") self.runCmd("thread backtrace")
self.expect( self.expect(
"expression (int)[nil_mutable_array count]", patterns=["\(int\) \$.* = 0"] "expression (int)[nil_mutable_array count]", patterns=[r"\(int\) \$.* = 0"]
) )
self.expect("expression (int)[array1 count]", patterns=["\(int\) \$.* = 3"]) self.expect("expression (int)[array1 count]", patterns=[r"\(int\) \$.* = 3"])
self.expect("expression (int)[array2 count]", patterns=["\(int\) \$.* = 3"]) self.expect("expression (int)[array2 count]", patterns=[r"\(int\) \$.* = 3"])
self.expect("expression (int)array1.count", patterns=["\(int\) \$.* = 3"]) self.expect("expression (int)array1.count", patterns=[r"\(int\) \$.* = 3"])
self.expect("expression (int)array2.count", patterns=["\(int\) \$.* = 3"]) self.expect("expression (int)array2.count", patterns=[r"\(int\) \$.* = 3"])
self.runCmd("process continue") self.runCmd("process continue")

@ -20,7 +20,7 @@ class FoundationTestCaseNSError(TestBase):
# Test_NSString: # Test_NSString:
self.runCmd("thread backtrace") self.runCmd("thread backtrace")
self.expect("expression [str length]", patterns=["\(NSUInteger\) \$.* ="]) self.expect("expression [str length]", patterns=[r"\(NSUInteger\) \$.* ="])
self.expect("expression str.length") self.expect("expression str.length")
self.expect('expression str = [NSString stringWithCString: "new"]') self.expect('expression str = [NSString stringWithCString: "new"]')
self.expect( self.expect(

@ -21,11 +21,11 @@ class FoundationTestCaseString(TestBase):
# Test_NSString: # Test_NSString:
self.runCmd("thread backtrace") self.runCmd("thread backtrace")
self.expect("expression (int)[str length]", patterns=["\(int\) \$.* ="]) self.expect("expression (int)[str length]", patterns=[r"\(int\) \$.* ="])
self.expect("expression (int)[str_id length]", patterns=["\(int\) \$.* ="]) self.expect("expression (int)[str_id length]", patterns=[r"\(int\) \$.* ="])
self.expect("expression (id)[str description]", patterns=["\(id\) \$.* = 0x"]) self.expect("expression (id)[str description]", patterns=[r"\(id\) \$.* = 0x"])
self.expect( self.expect(
"expression (id)[str_id description]", patterns=["\(id\) \$.* = 0x"] "expression (id)[str_id description]", patterns=[r"\(id\) \$.* = 0x"]
) )
self.expect("expression str.length") self.expect("expression str.length")
self.expect('expression str = @"new"') self.expect('expression str = @"new"')
@ -42,6 +42,6 @@ class FoundationTestCaseString(TestBase):
) )
self.expect( self.expect(
"expression --show-types -- *my", "expression --show-types -- *my",
patterns=["\(MyString\) \$.* = ", "\(MyBase\)"], patterns=[r"\(MyString\) \$.* = ", r"\(MyBase\)"],
) )
self.runCmd("process continue") self.runCmd("process continue")

@ -107,7 +107,7 @@ class ObjCDynamicValueTestCase(TestBase):
self.expect( self.expect(
"frame var -d run-target myObserver->_source", "frame var -d run-target myObserver->_source",
"frame var finds its way into a child member", "frame var finds its way into a child member",
patterns=["\(SourceDerived \*\)"], patterns=[r"\(SourceDerived \*\)"],
) )
# check that our ObjC GetISA() does a good job at hiding KVO swizzled # check that our ObjC GetISA() does a good job at hiding KVO swizzled

@ -51,11 +51,11 @@ class TestObjCBuiltinTypes(TestBase):
frame = thread_list[0].GetFrameAtIndex(0) frame = thread_list[0].GetFrameAtIndex(0)
self.assertTrue(frame, "Got a valid frame 0 frame.") self.assertTrue(frame, "Got a valid frame 0 frame.")
self.expect("expr (foo)", patterns=["\(ns::id\) \$.* = 0"]) self.expect("expr (foo)", patterns=[r"\(ns::id\) \$.* = 0"])
self.expect( self.expect(
"expr --language Objective-C++ -- id my_id = 0; my_id", "expr --language Objective-C++ -- id my_id = 0; my_id",
patterns=["\(id\) \$.* = nil"], patterns=[r"\(id\) \$.* = nil"],
) )
self.expect("expr --language C++ -- id my_id = 0; my_id", error=True) self.expect("expr --language C++ -- id my_id = 0; my_id", error=True)

@ -88,9 +88,9 @@ class AArch64LinuxMTEMemoryTagCoreFileTestCase(TestBase):
"memory tag read {addr}+16 {addr}".format(addr=self.MTE_BUF_ADDR), "memory tag read {addr}+16 {addr}".format(addr=self.MTE_BUF_ADDR),
error=True, error=True,
patterns=[ patterns=[
"error: End address \(0x[A-Fa-f0-9]+\) " r"error: End address \(0x[A-Fa-f0-9]+\) "
"must be greater than the start address " "must be greater than the start address "
"\(0x[A-Fa-f0-9]+\)" r"\(0x[A-Fa-f0-9]+\)"
], ],
) )
@ -100,8 +100,8 @@ class AArch64LinuxMTEMemoryTagCoreFileTestCase(TestBase):
"memory tag read {addr} {addr}+32".format(addr=self.MTE_BUF_ADDR), "memory tag read {addr} {addr}+32".format(addr=self.MTE_BUF_ADDR),
patterns=[ patterns=[
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\): 0x0\n" "\\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\\): 0x0\n"
"\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\): 0x1 \(mismatch\)$" "\\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\\): 0x1 \\(mismatch\\)$"
], ],
) )
@ -110,7 +110,7 @@ class AArch64LinuxMTEMemoryTagCoreFileTestCase(TestBase):
self.expect( self.expect(
"memory tag read {addr} {addr}+16".format(addr=self.MTE_BUF_ADDR), "memory tag read {addr} {addr}+16".format(addr=self.MTE_BUF_ADDR),
patterns=[ patterns=[
"Allocation tags:\n" "\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\): 0x0$" "Allocation tags:\n" r"\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\): 0x0$"
], ],
) )
# Get the other half of the first byte. # Get the other half of the first byte.
@ -119,7 +119,7 @@ class AArch64LinuxMTEMemoryTagCoreFileTestCase(TestBase):
"memory tag read {addr}+16 {addr}+32".format(addr=self.MTE_BUF_ADDR), "memory tag read {addr}+16 {addr}+32".format(addr=self.MTE_BUF_ADDR),
patterns=[ patterns=[
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\): 0x1 \(mismatch\)$" r"\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\): 0x1 \(mismatch\)$"
], ],
) )
@ -128,18 +128,18 @@ class AArch64LinuxMTEMemoryTagCoreFileTestCase(TestBase):
"memory tag read {addr} {addr}+48".format(addr=self.MTE_BUF_ADDR), "memory tag read {addr} {addr}+48".format(addr=self.MTE_BUF_ADDR),
patterns=[ patterns=[
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\): 0x0\n" "\\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\\): 0x0\n"
"\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\): 0x1 \(mismatch\)\n" "\\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\\): 0x1 \\(mismatch\\)\n"
"\[0x[A-Fa-f0-9]+20, 0x[A-Fa-f0-9]+30\): 0x2 \(mismatch\)$" "\\[0x[A-Fa-f0-9]+20, 0x[A-Fa-f0-9]+30\\): 0x2 \\(mismatch\\)$"
], ],
) )
self.expect( self.expect(
"memory tag read {addr}+16 {addr}+64".format(addr=self.MTE_BUF_ADDR), "memory tag read {addr}+16 {addr}+64".format(addr=self.MTE_BUF_ADDR),
patterns=[ patterns=[
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\): 0x1 \(mismatch\)\n" "\\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\\): 0x1 \\(mismatch\\)\n"
"\[0x[A-Fa-f0-9]+20, 0x[A-Fa-f0-9]+30\): 0x2 \(mismatch\)\n" "\\[0x[A-Fa-f0-9]+20, 0x[A-Fa-f0-9]+30\\): 0x2 \\(mismatch\\)\n"
"\[0x[A-Fa-f0-9]+30, 0x[A-Fa-f0-9]+40\): 0x3 \(mismatch\)$" "\\[0x[A-Fa-f0-9]+30, 0x[A-Fa-f0-9]+40\\): 0x3 \\(mismatch\\)$"
], ],
) )
# Here both start and end are unaligned. # Here both start and end are unaligned.
@ -147,10 +147,10 @@ class AArch64LinuxMTEMemoryTagCoreFileTestCase(TestBase):
"memory tag read {addr}+16 {addr}+80".format(addr=self.MTE_BUF_ADDR), "memory tag read {addr}+16 {addr}+80".format(addr=self.MTE_BUF_ADDR),
patterns=[ patterns=[
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\): 0x1 \(mismatch\)\n" "\\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\\): 0x1 \\(mismatch\\)\n"
"\[0x[A-Fa-f0-9]+20, 0x[A-Fa-f0-9]+30\): 0x2 \(mismatch\)\n" "\\[0x[A-Fa-f0-9]+20, 0x[A-Fa-f0-9]+30\\): 0x2 \\(mismatch\\)\n"
"\[0x[A-Fa-f0-9]+30, 0x[A-Fa-f0-9]+40\): 0x3 \(mismatch\)\n" "\\[0x[A-Fa-f0-9]+30, 0x[A-Fa-f0-9]+40\\): 0x3 \\(mismatch\\)\n"
"\[0x[A-Fa-f0-9]+40, 0x[A-Fa-f0-9]+50\): 0x4 \(mismatch\)$" "\\[0x[A-Fa-f0-9]+40, 0x[A-Fa-f0-9]+50\\): 0x4 \\(mismatch\\)$"
], ],
) )
@ -159,7 +159,7 @@ class AArch64LinuxMTEMemoryTagCoreFileTestCase(TestBase):
self.expect( self.expect(
"memory tag read {addr} {addr}+1".format(addr=self.MTE_BUF_ADDR), "memory tag read {addr} {addr}+1".format(addr=self.MTE_BUF_ADDR),
patterns=[ patterns=[
"Allocation tags:\n" "\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\): 0x0$" "Allocation tags:\n" r"\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\): 0x0$"
], ],
) )
@ -169,8 +169,8 @@ class AArch64LinuxMTEMemoryTagCoreFileTestCase(TestBase):
"memory tag read {addr} {addr}+17".format(addr=self.MTE_BUF_ADDR), "memory tag read {addr} {addr}+17".format(addr=self.MTE_BUF_ADDR),
patterns=[ patterns=[
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\): 0x0\n" "\\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\\): 0x0\n"
"\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\): 0x1 \(mismatch\)$" "\\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\\): 0x1 \\(mismatch\\)$"
], ],
) )
@ -179,9 +179,9 @@ class AArch64LinuxMTEMemoryTagCoreFileTestCase(TestBase):
"memory tag read {addr} {addr}+33".format(addr=self.MTE_BUF_ADDR), "memory tag read {addr} {addr}+33".format(addr=self.MTE_BUF_ADDR),
patterns=[ patterns=[
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\): 0x0\n" "\\[0x[A-Fa-f0-9]+00, 0x[A-Fa-f0-9]+10\\): 0x0\n"
"\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\): 0x1 \(mismatch\)\n", "\\[0x[A-Fa-f0-9]+10, 0x[A-Fa-f0-9]+20\\): 0x1 \\(mismatch\\)\n",
"\[0x[A-Fa-f0-9]+20, 0x[A-Fa-f0-9]+30\): 0x2 \(mismatch\)$", "\\[0x[A-Fa-f0-9]+20, 0x[A-Fa-f0-9]+30\\): 0x2 \\(mismatch\\)$",
], ],
) )

@ -86,8 +86,8 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
self.expect( self.expect(
"memory tag read mte_buf mte_buf-16", "memory tag read mte_buf mte_buf-16",
patterns=[ patterns=[
"error: End address \(0x[A-Fa-f0-9]+\) must be " r"error: End address \(0x[A-Fa-f0-9]+\) must be "
"greater than the start address \(0x[A-Fa-f0-9]+\)" r"greater than the start address \(0x[A-Fa-f0-9]+\)"
], ],
error=True, error=True,
) )
@ -95,8 +95,8 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
self.expect( self.expect(
"memory tag read mte_buf mte_buf", "memory tag read mte_buf mte_buf",
patterns=[ patterns=[
"error: End address \(0x[A-Fa-f0-9]+\) must be " r"error: End address \(0x[A-Fa-f0-9]+\) must be "
"greater than the start address \(0x[A-Fa-f0-9]+\)" r"greater than the start address \(0x[A-Fa-f0-9]+\)"
], ],
error=True, error=True,
) )
@ -117,7 +117,7 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
patterns=[ patterns=[
"Logical tag: 0x9\n" "Logical tag: 0x9\n"
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x0 \(mismatch\)$" r"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x0 \(mismatch\)$"
], ],
) )
@ -127,7 +127,7 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
patterns=[ patterns=[
"Logical tag: 0x9\n" "Logical tag: 0x9\n"
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x0 \(mismatch\)$" r"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x0 \(mismatch\)$"
], ],
) )
@ -137,8 +137,8 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
patterns=[ patterns=[
"Logical tag: 0x9\n" "Logical tag: 0x9\n"
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x0 \(mismatch\)\n" "\\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\\): 0x0 \\(mismatch\\)\n"
"\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\): 0x1 \(mismatch\)$" "\\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\\): 0x1 \\(mismatch\\)$"
], ],
) )
@ -150,7 +150,7 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
patterns=[ patterns=[
"Logical tag: 0x0\n" "Logical tag: 0x0\n"
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[0-9A-Fa-f]+, 0x[0-9A-Fa-f]+\): 0x0$" r"\[0x[0-9A-Fa-f]+, 0x[0-9A-Fa-f]+\): 0x0$"
], ],
) )
@ -179,8 +179,8 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
patterns=[ patterns=[
"Logical tag: 0x9\n" "Logical tag: 0x9\n"
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[0-9A-Fa-f]+f0, 0x[0-9A-Fa-f]+00\): 0xf \(mismatch\)\n" "\\[0x[0-9A-Fa-f]+f0, 0x[0-9A-Fa-f]+00\\): 0xf \\(mismatch\\)\n"
"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x0 \(mismatch\)$" "\\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\\): 0x0 \\(mismatch\\)$"
], ],
) )
@ -192,7 +192,7 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
patterns=[ patterns=[
"Logical tag: 0xa\n" "Logical tag: 0xa\n"
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x0 \(mismatch\)$" r"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x0 \(mismatch\)$"
], ],
) )
@ -202,9 +202,9 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
patterns=[ patterns=[
"Logical tag: 0x9\n" "Logical tag: 0x9\n"
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[0-9A-Fa-f]+80, 0x[0-9A-Fa-f]+90\): 0x8 \(mismatch\)\n" "\\[0x[0-9A-Fa-f]+80, 0x[0-9A-Fa-f]+90\\): 0x8 \\(mismatch\\)\n"
"\[0x[0-9A-Fa-f]+90, 0x[0-9A-Fa-f]+a0\): 0x9\n" "\\[0x[0-9A-Fa-f]+90, 0x[0-9A-Fa-f]+a0\\): 0x9\n"
"\[0x[0-9A-Fa-f]+a0, 0x[0-9A-Fa-f]+b0\): 0xa \(mismatch\)$" "\\[0x[0-9A-Fa-f]+a0, 0x[0-9A-Fa-f]+b0\\): 0xa \\(mismatch\\)$"
], ],
) )
@ -258,8 +258,8 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
patterns=[ patterns=[
"Logical tag: 0x9\n" "Logical tag: 0x9\n"
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x9\n" "\\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\\): 0x9\n"
"\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\): 0x1 \(mismatch\)$" "\\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\\): 0x1 \\(mismatch\\)$"
], ],
) )
@ -270,9 +270,9 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
patterns=[ patterns=[
"Logical tag: 0x9\n" "Logical tag: 0x9\n"
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0xa \(mismatch\)\n" "\\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\\): 0xa \\(mismatch\\)\n"
"\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\): 0xb \(mismatch\)\n" "\\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\\): 0xb \\(mismatch\\)\n"
"\[0x[0-9A-Fa-f]+20, 0x[0-9A-Fa-f]+30\): 0xc \(mismatch\)$" "\\[0x[0-9A-Fa-f]+20, 0x[0-9A-Fa-f]+30\\): 0xc \\(mismatch\\)$"
], ],
) )
@ -284,7 +284,7 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
patterns=[ patterns=[
"Logical tag: 0x0\n" "Logical tag: 0x0\n"
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[0-9A-Fa-f]+, 0x[0-9A-Fa-f]+\): 0xe \(mismatch\)$" r"\[0x[0-9A-Fa-f]+, 0x[0-9A-Fa-f]+\): 0xe \(mismatch\)$"
], ],
) )
@ -323,8 +323,8 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
patterns=[ patterns=[
"Logical tag: 0x9\n" "Logical tag: 0x9\n"
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[0-9A-Fa-f]+f0, 0x[0-9A-Fa-f]+00\): 0x1 \(mismatch\)\n" "\\[0x[0-9A-Fa-f]+f0, 0x[0-9A-Fa-f]+00\\): 0x1 \\(mismatch\\)\n"
"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x2 \(mismatch\)$" "\\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\\): 0x2 \\(mismatch\\)$"
], ],
) )
@ -335,7 +335,7 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
patterns=[ patterns=[
"Logical tag: 0x0\n" "Logical tag: 0x0\n"
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x1 \(mismatch\)$" r"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x1 \(mismatch\)$"
], ],
) )
@ -361,16 +361,16 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
self.expect( self.expect(
"memory tag write mte_buf_2 9 --end-addr mte_buf_2", "memory tag write mte_buf_2 9 --end-addr mte_buf_2",
patterns=[ patterns=[
"error: End address \(0x[A-Fa-f0-9]+\) must be " r"error: End address \(0x[A-Fa-f0-9]+\) must be "
"greater than the start address \(0x[A-Fa-f0-9]+\)" r"greater than the start address \(0x[A-Fa-f0-9]+\)"
], ],
error=True, error=True,
) )
self.expect( self.expect(
"memory tag write mte_buf_2 9 --end-addr mte_buf_2-16", "memory tag write mte_buf_2 9 --end-addr mte_buf_2-16",
patterns=[ patterns=[
"error: End address \(0x[A-Fa-f0-9]+\) must be " r"error: End address \(0x[A-Fa-f0-9]+\) must be "
"greater than the start address \(0x[A-Fa-f0-9]+\)" r"greater than the start address \(0x[A-Fa-f0-9]+\)"
], ],
error=True, error=True,
) )
@ -391,10 +391,10 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
patterns=[ patterns=[
"Logical tag: 0x0\n" "Logical tag: 0x0\n"
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x4 \(mismatch\)\n" "\\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\\): 0x4 \\(mismatch\\)\n"
"\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\): 0x5 \(mismatch\)\n" "\\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\\): 0x5 \\(mismatch\\)\n"
"\[0x[0-9A-Fa-f]+20, 0x[0-9A-Fa-f]+30\): 0x4 \(mismatch\)\n" "\\[0x[0-9A-Fa-f]+20, 0x[0-9A-Fa-f]+30\\): 0x4 \\(mismatch\\)\n"
"\[0x[0-9A-Fa-f]+30, 0x[0-9A-Fa-f]+40\): 0x0$" "\\[0x[0-9A-Fa-f]+30, 0x[0-9A-Fa-f]+40\\): 0x0$"
], ],
) )
@ -409,9 +409,9 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
patterns=[ patterns=[
"Logical tag: 0x0\n" "Logical tag: 0x0\n"
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x6 \(mismatch\)\n" "\\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\\): 0x6 \\(mismatch\\)\n"
"\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\): 0x6 \(mismatch\)\n" "\\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\\): 0x6 \\(mismatch\\)\n"
"\[0x[0-9A-Fa-f]+20, 0x[0-9A-Fa-f]+30\): 0x4 \(mismatch\)$" "\\[0x[0-9A-Fa-f]+20, 0x[0-9A-Fa-f]+30\\): 0x4 \\(mismatch\\)$"
], ],
) )
@ -423,10 +423,10 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
patterns=[ patterns=[
"Logical tag: 0x0\n" "Logical tag: 0x0\n"
"Allocation tags:\n" "Allocation tags:\n"
"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x3 \(mismatch\)\n" "\\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\\): 0x3 \\(mismatch\\)\n"
"\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\): 0x3 \(mismatch\)\n" "\\[0x[0-9A-Fa-f]+10, 0x[0-9A-Fa-f]+20\\): 0x3 \\(mismatch\\)\n"
"\[0x[0-9A-Fa-f]+20, 0x[0-9A-Fa-f]+30\): 0x3 \(mismatch\)\n" "\\[0x[0-9A-Fa-f]+20, 0x[0-9A-Fa-f]+30\\): 0x3 \\(mismatch\\)\n"
"\[0x[0-9A-Fa-f]+30, 0x[0-9A-Fa-f]+40\): 0x0$" "\\[0x[0-9A-Fa-f]+30, 0x[0-9A-Fa-f]+40\\): 0x0$"
], ],
) )
@ -452,8 +452,8 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
self.expect( self.expect(
'memory read mte_buf mte_buf+32 -f "x" -l 1 -s 16 --show-tags', 'memory read mte_buf mte_buf+32 -f "x" -l 1 -s 16 --show-tags',
patterns=[ patterns=[
"0x[0-9A-Fa-f]+00: 0x0+ \(tag: 0x0\)\n" "0x[0-9A-Fa-f]+00: 0x0+ \\(tag: 0x0\\)\n"
"0x[0-9A-Fa-f]+10: 0x0+ \(tag: 0x1\)" "0x[0-9A-Fa-f]+10: 0x0+ \\(tag: 0x1\\)"
], ],
) )
@ -461,13 +461,13 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
# per line. # per line.
self.expect( self.expect(
'memory read mte_buf mte_buf+32 -f "x" -l 1 -s 32 --show-tags', 'memory read mte_buf mte_buf+32 -f "x" -l 1 -s 32 --show-tags',
patterns=["0x[0-9A-Fa-f]+00: 0x0+ \(tags: 0x0 0x1\)\n"], patterns=["0x[0-9A-Fa-f]+00: 0x0+ \\(tags: 0x0 0x1\\)\n"],
) )
# Reading half a granule still shows you the tag for that granule # Reading half a granule still shows you the tag for that granule
self.expect( self.expect(
'memory read mte_buf mte_buf+8 -f "x" -l 1 -s 8 --show-tags', 'memory read mte_buf mte_buf+8 -f "x" -l 1 -s 8 --show-tags',
patterns=["0x[0-9A-Fa-f]+00: 0x0+ \(tag: 0x0\)\n"], patterns=["0x[0-9A-Fa-f]+00: 0x0+ \\(tag: 0x0\\)\n"],
) )
# We can read a whole number of granules but split them over more lines # We can read a whole number of granules but split them over more lines
@ -475,10 +475,10 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
self.expect( self.expect(
'memory read mte_buf+32 mte_buf+64 -f "x" -l 1 -s 8 --show-tags', 'memory read mte_buf+32 mte_buf+64 -f "x" -l 1 -s 8 --show-tags',
patterns=[ patterns=[
"0x[0-9A-Fa-f]+20: 0x0+ \(tag: 0x2\)\n" "0x[0-9A-Fa-f]+20: 0x0+ \\(tag: 0x2\\)\n"
"0x[0-9A-Fa-f]+28: 0x0+ \(tag: 0x2\)\n" "0x[0-9A-Fa-f]+28: 0x0+ \\(tag: 0x2\\)\n"
"0x[0-9A-Fa-f]+30: 0x0+ \(tag: 0x3\)\n" "0x[0-9A-Fa-f]+30: 0x0+ \\(tag: 0x3\\)\n"
"0x[0-9A-Fa-f]+38: 0x0+ \(tag: 0x3\)" "0x[0-9A-Fa-f]+38: 0x0+ \\(tag: 0x3\\)"
], ],
) )
@ -488,10 +488,10 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
self.expect( self.expect(
'memory read mte_buf+32+8 mte_buf+64+8 -f "x" -l 1 -s 8 --show-tags', 'memory read mte_buf+32+8 mte_buf+64+8 -f "x" -l 1 -s 8 --show-tags',
patterns=[ patterns=[
"0x[0-9A-Fa-f]+28: 0x0+ \(tag: 0x2\)\n" "0x[0-9A-Fa-f]+28: 0x0+ \\(tag: 0x2\\)\n"
"0x[0-9A-Fa-f]+30: 0x0+ \(tag: 0x3\)\n" "0x[0-9A-Fa-f]+30: 0x0+ \\(tag: 0x3\\)\n"
"0x[0-9A-Fa-f]+38: 0x0+ \(tag: 0x3\)\n" "0x[0-9A-Fa-f]+38: 0x0+ \\(tag: 0x3\\)\n"
"0x[0-9A-Fa-f]+40: 0x0+ \(tag: 0x4\)" "0x[0-9A-Fa-f]+40: 0x0+ \\(tag: 0x4\\)"
], ],
) )
@ -501,10 +501,10 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
self.expect( self.expect(
'memory read mte_buf+32+4 mte_buf+64+4 -f "x" -l 1 -s 8 --show-tags', 'memory read mte_buf+32+4 mte_buf+64+4 -f "x" -l 1 -s 8 --show-tags',
patterns=[ patterns=[
"0x[0-9A-Fa-f]+24: 0x0+ \(tag: 0x2\)\n" "0x[0-9A-Fa-f]+24: 0x0+ \\(tag: 0x2\\)\n"
"0x[0-9A-Fa-f]+2c: 0x0+ \(tags: 0x2 0x3\)\n" "0x[0-9A-Fa-f]+2c: 0x0+ \\(tags: 0x2 0x3\\)\n"
"0x[0-9A-Fa-f]+34: 0x0+ \(tag: 0x3\)\n" "0x[0-9A-Fa-f]+34: 0x0+ \\(tag: 0x3\\)\n"
"0x[0-9A-Fa-f]+3c: 0x0+ \(tags: 0x3 0x4\)" "0x[0-9A-Fa-f]+3c: 0x0+ \\(tags: 0x3 0x4\\)"
], ],
) )
@ -516,15 +516,17 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
'memory read mte_buf-16 mte_buf+32 -f "x" -l 1 -s 16 --show-tags', 'memory read mte_buf-16 mte_buf+32 -f "x" -l 1 -s 16 --show-tags',
patterns=[ patterns=[
"0x[0-9A-Fa-f]+f0: 0x0+\n" "0x[0-9A-Fa-f]+f0: 0x0+\n"
"0x[0-9A-Fa-f]+00: 0x0+ \(tag: 0x0\)\n" "0x[0-9A-Fa-f]+00: 0x0+ \\(tag: 0x0\\)\n"
"0x[0-9A-Fa-f]+10: 0x0+ \(tag: 0x1\)" "0x[0-9A-Fa-f]+10: 0x0+ \\(tag: 0x1\\)"
], ],
) )
# End of range is untagged # End of range is untagged
self.expect( self.expect(
'memory read mte_buf+page_size-16 mte_buf+page_size+16 -f "x" -l 1 -s 16 --show-tags', 'memory read mte_buf+page_size-16 mte_buf+page_size+16 -f "x" -l 1 -s 16 --show-tags',
patterns=["0x[0-9A-Fa-f]+f0: 0x0+ \(tag: 0xf\)\n" "0x[0-9A-Fa-f]+00: 0x0+"], patterns=[
"0x[0-9A-Fa-f]+f0: 0x0+ \\(tag: 0xf\\)\n" "0x[0-9A-Fa-f]+00: 0x0+"
],
) )
# The smallest MTE range we can get is a single page so we just check # The smallest MTE range we can get is a single page so we just check
@ -533,8 +535,8 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
self.expect( self.expect(
'memory read mte_read_only-16 mte_read_only+page_size+16 -f "x" -l 1 -s 16 --force --show-tags', 'memory read mte_read_only-16 mte_read_only+page_size+16 -f "x" -l 1 -s 16 --force --show-tags',
patterns=[ patterns=[
"0x[0-9A-Fa-f]+f0: 0x0+\n" "0x[0-9A-Fa-f]+00: 0x0+ \(tag: 0x0\)\n", "0x[0-9A-Fa-f]+f0: 0x0+\n" "0x[0-9A-Fa-f]+00: 0x0+ \\(tag: 0x0\\)\n",
"0x[0-9A-Fa-f]+f0: 0x0+ \(tag: 0x0\)\n" "0x[0-9A-Fa-f]+00: 0x0+", "0x[0-9A-Fa-f]+f0: 0x0+ \\(tag: 0x0\\)\n" "0x[0-9A-Fa-f]+00: 0x0+",
], ],
) )
@ -542,21 +544,21 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
# <no tag> is shown in where the tag would be, to keep the order intact. # <no tag> is shown in where the tag would be, to keep the order intact.
self.expect( self.expect(
'memory read mte_buf-16 mte_buf+32 -f "x" -l 1 -s 32 --show-tags', 'memory read mte_buf-16 mte_buf+32 -f "x" -l 1 -s 32 --show-tags',
patterns=["0x[0-9A-Fa-f]+f0: 0x0+ \(tags: <no tag> 0x0\)"], patterns=[r"0x[0-9A-Fa-f]+f0: 0x0+ \(tags: <no tag> 0x0\)"],
) )
self.expect( self.expect(
'memory read mte_read_only+page_size-16 mte_read_only+page_size+16 -f "x" -l 1 -s 32 --show-tags', 'memory read mte_read_only+page_size-16 mte_read_only+page_size+16 -f "x" -l 1 -s 32 --show-tags',
patterns=["0x[0-9A-Fa-f]+f0: 0x0+ \(tags: 0x0 <no tag>\)"], patterns=[r"0x[0-9A-Fa-f]+f0: 0x0+ \(tags: 0x0 <no tag>\)"],
) )
# Here the start address is unaligned so we cover 3 granules instead of 2 # Here the start address is unaligned so we cover 3 granules instead of 2
self.expect( self.expect(
'memory read mte_buf-16+4 mte_buf+32+4 -f "x" -l 1 -s 32 --show-tags', 'memory read mte_buf-16+4 mte_buf+32+4 -f "x" -l 1 -s 32 --show-tags',
patterns=["0x[0-9A-Fa-f]+f4: 0x0+ \(tags: <no tag> 0x0 0x1\)"], patterns=[r"0x[0-9A-Fa-f]+f4: 0x0+ \(tags: <no tag> 0x0 0x1\)"],
) )
self.expect( self.expect(
'memory read mte_read_only+page_size-16+4 mte_read_only+page_size+16+4 -f "x" -l 1 -s 32 --show-tags', 'memory read mte_read_only+page_size-16+4 mte_read_only+page_size+16+4 -f "x" -l 1 -s 32 --show-tags',
patterns=["0x[0-9A-Fa-f]+f4: 0x0+ \(tags: 0x0 <no tag> <no tag>\)"], patterns=[r"0x[0-9A-Fa-f]+f4: 0x0+ \(tags: 0x0 <no tag> <no tag>\)"],
) )
# Some formats call DumpDataExtractor multiple times, # Some formats call DumpDataExtractor multiple times,
@ -564,24 +566,24 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
self.expect( self.expect(
'memory read mte_buf mte_buf+32 -f "x" --show-tags', 'memory read mte_buf mte_buf+32 -f "x" --show-tags',
patterns=[ patterns=[
"0x[0-9A-Fa-f]+00: 0x0+ 0x0+ 0x0+ 0x0+ \(tag: 0x0\)\n", "0x[0-9A-Fa-f]+00: 0x0+ 0x0+ 0x0+ 0x0+ \\(tag: 0x0\\)\n",
"0x[0-9A-Fa-f]+10: 0x0+ 0x0+ 0x0+ 0x0+ \(tag: 0x1\)", "0x[0-9A-Fa-f]+10: 0x0+ 0x0+ 0x0+ 0x0+ \\(tag: 0x1\\)",
], ],
) )
self.expect( self.expect(
'memory read mte_buf mte_buf+32 -f "bytes with ASCII" --show-tags', 'memory read mte_buf mte_buf+32 -f "bytes with ASCII" --show-tags',
patterns=[ patterns=[
"0x[0-9A-Fa-f]+00: (00 ){16} \.{16} \(tag: 0x0\)\n", "0x[0-9A-Fa-f]+00: (00 ){16} \\.{16} \\(tag: 0x0\\)\n",
"0x[0-9A-Fa-f]+10: (00 ){16} \.{16} \(tag: 0x1\)", "0x[0-9A-Fa-f]+10: (00 ){16} \\.{16} \\(tag: 0x1\\)",
], ],
) )
self.expect( self.expect(
'memory read mte_buf mte_buf+32 -f "uint8_t[]" -s 16 -l 1 --show-tags', 'memory read mte_buf mte_buf+32 -f "uint8_t[]" -s 16 -l 1 --show-tags',
patterns=[ patterns=[
"0x[0-9A-Fa-f]+00: \{(0x00 ){15}0x00\} \(tag: 0x0\)\n" "0x[0-9A-Fa-f]+00: \\{(0x00 ){15}0x00\\} \\(tag: 0x0\\)\n"
"0x[0-9A-Fa-f]+10: \{(0x00 ){15}0x00\} \(tag: 0x1\)" "0x[0-9A-Fa-f]+10: \\{(0x00 ){15}0x00\\} \\(tag: 0x1\\)"
], ],
) )
@ -594,12 +596,12 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
self.expect( self.expect(
'memory read mte_buf mte_buf+16 -f "x" --show-tags', 'memory read mte_buf mte_buf+16 -f "x" --show-tags',
patterns=["0x[0-9A-fa-f]+00: 0x0+ 0x0+ 0x0+ 0x0+ \(tag: 0x0\)"], patterns=[r"0x[0-9A-fa-f]+00: 0x0+ 0x0+ 0x0+ 0x0+ \(tag: 0x0\)"],
) )
# Equivalent to just pressing enter on the command line. # Equivalent to just pressing enter on the command line.
self.expect( self.expect(
"memory read", "memory read",
patterns=["0x[0-9A-fa-f]+10: 0x0+ 0x0+ 0x0+ 0x0+ \(tag: 0x1\)"], patterns=[r"0x[0-9A-fa-f]+10: 0x0+ 0x0+ 0x0+ 0x0+ \(tag: 0x1\)"],
) )
# You can add the argument to an existing repetition without resetting # You can add the argument to an existing repetition without resetting
@ -613,10 +615,10 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
# Note that the formatting returns to default here. # Note that the formatting returns to default here.
self.expect( self.expect(
"memory read --show-tags", "memory read --show-tags",
patterns=["0x[0-9A-fa-f]+20: (00 )+ \.+ \(tag: 0x2\)"], patterns=[r"0x[0-9A-fa-f]+20: (00 )+ \.+ \(tag: 0x2\)"],
) )
self.expect( self.expect(
"memory read", patterns=["0x[0-9A-fa-f]+30: (00 )+ \.+ \(tag: 0x3\)"] "memory read", patterns=[r"0x[0-9A-fa-f]+30: (00 )+ \.+ \(tag: 0x3\)"]
) )
# A fresh command reverts to the default of tags being off. # A fresh command reverts to the default of tags being off.
@ -641,8 +643,8 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
cmd = 'memory find -s "LLDB" mte_buf+64 mte_buf+512' cmd = 'memory find -s "LLDB" mte_buf+64 mte_buf+512'
found_pattern = "data found at location: 0x[0-9A-Fa-f]+80" found_pattern = "data found at location: 0x[0-9A-Fa-f]+80"
results_patterns = [ results_patterns = [
"0x[0-9A-Fa-f]+80: 4c 4c 44 42 (00 )+ LLDB\.+", r"0x[0-9A-Fa-f]+80: 4c 4c 44 42 (00 )+ LLDB\.+",
"0x[0-9A-Fa-f]+90: 00 00 00 00 (00 )+ \.+", r"0x[0-9A-Fa-f]+90: 00 00 00 00 (00 )+ \.+",
] ]
# Default is not to show tags # Default is not to show tags
@ -651,8 +653,8 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
cmd + " --show-tags", cmd + " --show-tags",
patterns=[ patterns=[
found_pattern, found_pattern,
results_patterns[0] + " \(tag: 0x8\)", results_patterns[0] + r" \(tag: 0x8\)",
results_patterns[1] + " \(tag: 0x9\)", results_patterns[1] + r" \(tag: 0x9\)",
], ],
) )
@ -661,7 +663,7 @@ class AArch64LinuxMTEMemoryTagAccessTestCase(TestBase):
'memory find -s "DB" mte_buf+64 mte_buf+512 --show-tags', 'memory find -s "DB" mte_buf+64 mte_buf+512 --show-tags',
patterns=[ patterns=[
"data found at location: 0x[0-9A-Fa-f]+82\n" "data found at location: 0x[0-9A-Fa-f]+82\n"
"0x[0-9A-Fa-f]+82: 44 42 (00 )+ DB\.+ \(tags: 0x8 0x9\)\n", "0x[0-9A-Fa-f]+82: 44 42 (00 )+ DB\\.+ \\(tags: 0x8 0x9\\)\n",
"0x[0-9A-Fa-f]+92: 00 00 (00 )+ ..\.+ \(tags: 0x9 0xa\)", "0x[0-9A-Fa-f]+92: 00 00 (00 )+ ..\\.+ \\(tags: 0x9 0xa\\)",
], ],
) )

@ -50,9 +50,9 @@ class AArch64LinuxMTEMemoryTagFaultsTestCase(TestBase):
self.expect( self.expect(
"continue", "continue",
patterns=[ patterns=[
"\* thread #1, name = 'a.out', stop reason = signal SIGSEGV: " r"\* thread #1, name = 'a.out', stop reason = signal SIGSEGV: "
"sync tag check fault \(fault address=0x9[0-9A-Fa-f]+11\ " r"sync tag check fault \(fault address=0x9[0-9A-Fa-f]+11\ "
"logical tag=0x9 allocation tag=0xa\)" r"logical tag=0x9 allocation tag=0xa\)"
], ],
) )

@ -39,7 +39,8 @@ class AArch64LinuxTaggedMemoryRegionTestCase(TestBase):
# Despite the non address bits we should find a region # Despite the non address bits we should find a region
self.expect( self.expect(
"memory region the_page", patterns=["\[0x[0-9A-Fa-f]+-0x[0-9A-Fa-f]+\) r-x"] "memory region the_page",
patterns=[r"\[0x[0-9A-Fa-f]+-0x[0-9A-Fa-f]+\) r-x"],
) )
# Check that the usual error message is displayed after repeating # Check that the usual error message is displayed after repeating
@ -68,5 +69,6 @@ class AArch64LinuxTaggedMemoryRegionTestCase(TestBase):
# This should not error, since the user supplied address overrides # This should not error, since the user supplied address overrides
# the previous end address. # the previous end address.
self.expect( self.expect(
"memory region the_page", patterns=["\[0x[0-9A-Fa-f]+-0x[0-9A-Fa-f]+\) r-x"] "memory region the_page",
patterns=[r"\[0x[0-9A-Fa-f]+-0x[0-9A-Fa-f]+\) r-x"],
) )

@ -6,7 +6,7 @@ from lldbsuite.test import lldbutil
@skipUnlessDarwin @skipUnlessDarwin
class AddDsymDownload(TestBase): class AddDsymDownload(TestBase):
dwarfdump_uuid_regex = re.compile("UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*") dwarfdump_uuid_regex = re.compile(r"UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
def get_uuid(self): def get_uuid(self):
dwarfdump_cmd_output = subprocess.check_output( dwarfdump_cmd_output = subprocess.check_output(

@ -285,7 +285,7 @@ class TestFirmwareCorefiles(TestBase):
for l in python_init: for l in python_init:
writer.write(l + "\n") writer.write(l + "\n")
dwarfdump_uuid_regex = re.compile("UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*") dwarfdump_uuid_regex = re.compile(r"UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
dwarfdump_cmd_output = subprocess.check_output( dwarfdump_cmd_output = subprocess.check_output(
('/usr/bin/dwarfdump --uuid "%s"' % aout_exe), shell=True ('/usr/bin/dwarfdump --uuid "%s"' % aout_exe), shell=True
).decode("utf-8") ).decode("utf-8")

@ -32,7 +32,7 @@ class TestKernVerStrLCNOTE(TestBase):
lambda: os.environ.pop("LLDB_APPLE_DSYMFORUUID_EXECUTABLE", None) lambda: os.environ.pop("LLDB_APPLE_DSYMFORUUID_EXECUTABLE", None)
) )
dwarfdump_uuid_regex = re.compile("UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*") dwarfdump_uuid_regex = re.compile(r"UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
dwarfdump_cmd_output = subprocess.check_output( dwarfdump_cmd_output = subprocess.check_output(
('/usr/bin/dwarfdump --uuid "%s"' % self.test_exe), shell=True ('/usr/bin/dwarfdump --uuid "%s"' % self.test_exe), shell=True
).decode("utf-8") ).decode("utf-8")

@ -107,7 +107,7 @@ class TestMultipleBinaryCorefile(TestBase):
) )
) )
dwarfdump_uuid_regex = re.compile("UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*") dwarfdump_uuid_regex = re.compile(r"UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
dwarfdump_cmd_output = subprocess.check_output( dwarfdump_cmd_output = subprocess.check_output(
('/usr/bin/dwarfdump --uuid "%s"' % self.libtwo_exe), shell=True ('/usr/bin/dwarfdump --uuid "%s"' % self.libtwo_exe), shell=True
).decode("utf-8") ).decode("utf-8")

@ -72,7 +72,7 @@ class TestSimulatorPlatformLaunching(TestBase):
self, "break here", lldb.SBFileSpec("hello.c") self, "break here", lldb.SBFileSpec("hello.c")
) )
triple_re = "-".join([arch, "apple", os + vers + ".*"] + env_list) triple_re = "-".join([arch, "apple", os + vers + ".*"] + env_list)
self.expect("image list -b -t", patterns=["a\.out " + triple_re]) self.expect("image list -b -t", patterns=[r"a\.out " + triple_re])
self.check_debugserver(log, os + env, vers) self.check_debugserver(log, os + env, vers)
@skipIfAsan @skipIfAsan

@ -42,7 +42,7 @@ class TestSkinnyCorefile(TestBase):
lambda: os.environ.pop("LLDB_APPLE_DSYMFORUUID_EXECUTABLE", None) lambda: os.environ.pop("LLDB_APPLE_DSYMFORUUID_EXECUTABLE", None)
) )
dwarfdump_uuid_regex = re.compile("UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*") dwarfdump_uuid_regex = re.compile(r"UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
dwarfdump_cmd_output = subprocess.check_output( dwarfdump_cmd_output = subprocess.check_output(
('/usr/bin/dwarfdump --uuid "%s"' % self.aout_exe), shell=True ('/usr/bin/dwarfdump --uuid "%s"' % self.aout_exe), shell=True
).decode("utf-8") ).decode("utf-8")

@ -191,7 +191,7 @@ class AddressRangeTestCase(TestBase):
interp.HandleCommand(script, result, False) interp.HandleCommand(script, result, False)
self.assertTrue(result.Succeeded(), "script command succeeded") self.assertTrue(result.Succeeded(), "script command succeeded")
# [0x1000-0x2000] // Resolved with target or addresses without sections # [0x1000-0x2000] // Resolved with target or addresses without sections
self.assertRegex(result.GetOutput(), "^\[0x[0-9a-f]+\-0x[0-9a-f]+\)") self.assertRegex(result.GetOutput(), r"^\[0x[0-9a-f]+\-0x[0-9a-f]+\)")
process.Kill() process.Kill()
def test_address_range_print_no_section_resolved(self): def test_address_range_print_no_section_resolved(self):
@ -215,7 +215,7 @@ class AddressRangeTestCase(TestBase):
range_str = str(range) range_str = str(range)
# [0x1000-0x2000] // Resolved with target or addresses without sections # [0x1000-0x2000] // Resolved with target or addresses without sections
self.assertRegex(range_str, "^\[0x[0-9a-f]+\-0x[0-9a-f]+\)$") self.assertRegex(range_str, r"^\[0x[0-9a-f]+\-0x[0-9a-f]+\)$")
process.Kill() process.Kill()
def test_address_range_print_not_resolved(self): def test_address_range_print_not_resolved(self):
@ -223,7 +223,7 @@ class AddressRangeTestCase(TestBase):
range = lldb.SBAddressRange(self.addr1, 8) range = lldb.SBAddressRange(self.addr1, 8)
range_str = str(range) range_str = str(range)
# a.out[0x1000-0x2000] // Without target # a.out[0x1000-0x2000] // Without target
self.assertRegex(range_str, "^a.out\[0x[0-9a-f]+\-0x[0-9a-f]+\)$") self.assertRegex(range_str, r"^a.out\[0x[0-9a-f]+\-0x[0-9a-f]+\)$")
def test_address_range_list_print(self): def test_address_range_list_print(self):
"""Make sure the SBAddressRangeList can be printed.""" """Make sure the SBAddressRangeList can be printed."""

@ -34,7 +34,7 @@ class TargetArchFromModule(TestBase):
lambda: os.environ.pop("LLDB_APPLE_DSYMFORUUID_EXECUTABLE", None) lambda: os.environ.pop("LLDB_APPLE_DSYMFORUUID_EXECUTABLE", None)
) )
dwarfdump_uuid_regex = re.compile("UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*") dwarfdump_uuid_regex = re.compile(r"UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*")
dwarfdump_cmd_output = subprocess.check_output( dwarfdump_cmd_output = subprocess.check_output(
('/usr/bin/dwarfdump --uuid "%s"' % aout_exe), shell=True ('/usr/bin/dwarfdump --uuid "%s"' % aout_exe), shell=True
).decode("utf-8") ).decode("utf-8")

@ -256,7 +256,7 @@ class SourceManagerTestCase(TestBase):
# of breakpoints for the current line, i.e., self.line. # of breakpoints for the current line, i.e., self.line.
import re import re
m = re.search("^\[(\d+)\].*// Set break point at this line.", output) m = re.search(r"^\[(\d+)\].*// Set break point at this line.", output)
if not m: if not m:
self.fail("Fail to display source level breakpoints") self.fail("Fail to display source level breakpoints")
self.assertGreater(int(m.group(1)), 0) self.assertGreater(int(m.group(1)), 0)

@ -66,11 +66,11 @@ class TestDAP_extendedStackTrace(lldbdap_testcase.DAPTestCaseBase):
self.assertEqual(len(stackLabels), 2, "expected two label stack frames") self.assertEqual(len(stackLabels), 2, "expected two label stack frames")
self.assertRegex( self.assertRegex(
stackLabels[0][1]["name"], stackLabels[0][1]["name"],
"Enqueued from com.apple.root.default-qos \(Thread \d\)", r"Enqueued from com.apple.root.default-qos \(Thread \d\)",
) )
self.assertRegex( self.assertRegex(
stackLabels[1][1]["name"], stackLabels[1][1]["name"],
"Enqueued from com.apple.main-thread \(Thread \d\)", r"Enqueued from com.apple.main-thread \(Thread \d\)",
) )
for i, frame in stackLabels: for i, frame in stackLabels:

@ -42,7 +42,7 @@ class TestGdbRemoteModuleInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
context = self.expect_gdbremote_sequence() context = self.expect_gdbremote_sequence()
spec = context.get("spec") spec = context.get("spec")
self.assertRegex(spec, '"file_path":".*"') self.assertRegex(spec, '"file_path":".*"')
self.assertRegex(spec, '"file_offset":\d+') self.assertRegex(spec, r'"file_offset":\d+')
self.assertRegex(spec, '"file_size":\d+') self.assertRegex(spec, r'"file_size":\d+')
self.assertRegex(spec, '"triple":"\w*-\w*-.*"') self.assertRegex(spec, r'"triple":"\w*-\w*-.*"')
self.assertRegex(spec, '"uuid":"[A-Fa-f0-9]+"') self.assertRegex(spec, '"uuid":"[A-Fa-f0-9]+"')

@ -65,7 +65,7 @@ class PtyServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
"read packet: $qXfer:features:read:target.xml:0,200000#00", "read packet: $qXfer:features:read:target.xml:0,200000#00",
{ {
"direction": "send", "direction": "send",
"regex": re.compile("^\$l(.+)#[0-9a-fA-F]{2}$", flags=re.DOTALL), "regex": re.compile(r"^\$l(.+)#[0-9a-fA-F]{2}$", flags=re.DOTALL),
"capture": {1: "target_xml"}, "capture": {1: "target_xml"},
}, },
], ],

@ -24,7 +24,7 @@ class TestGdbRemoteTargetXmlPacket(gdbremote_testcase.GdbRemoteTestCaseBase):
), ),
{ {
"direction": "send", "direction": "send",
"regex": re.compile("^\$l(.+)#[0-9a-fA-F]{2}$", flags=re.DOTALL), "regex": re.compile(r"^\$l(.+)#[0-9a-fA-F]{2}$", flags=re.DOTALL),
"capture": {1: "target_xml"}, "capture": {1: "target_xml"},
}, },
], ],

@ -20,7 +20,7 @@ def Msg(var, val, using_frame_variable):
class GenericTester(TestBase): class GenericTester(TestBase):
# This is the pattern by design to match the " var = 'value'" output from # This is the pattern by design to match the " var = 'value'" output from
# printf() stmts (see basic_type.cpp). # printf() stmts (see basic_type.cpp).
pattern = re.compile(" (\*?a[^=]*) = '([^=]*)'$") pattern = re.compile(r" (\*?a[^=]*) = '([^=]*)'$")
# Assert message. # Assert message.
DATA_TYPE_GROKKED = "Data type from expr parser output is parsed correctly" DATA_TYPE_GROKKED = "Data type from expr parser output is parsed correctly"
@ -205,7 +205,7 @@ class GenericTester(TestBase):
# output: (char) a_array_bounded[0] = 'a' # output: (char) a_array_bounded[0] = 'a'
# #
try: try:
dt = re.match("^\((.*)\)", output).group(1) dt = re.match(r"^\((.*)\)", output).group(1)
except: except:
self.fail(self.DATA_TYPE_GROKKED) self.fail(self.DATA_TYPE_GROKKED)
@ -284,7 +284,7 @@ class GenericTester(TestBase):
# output: (double) $0 = 1100.12 # output: (double) $0 = 1100.12
# #
try: try:
dt = re.match("^\((.*)\) \$[0-9]+ = ", output).group(1) dt = re.match(r"^\((.*)\) \$[0-9]+ = ", output).group(1)
except: except:
self.fail(self.DATA_TYPE_GROKKED) self.fail(self.DATA_TYPE_GROKKED)

@ -210,7 +210,7 @@ class SourceWin(cui.TitledWin):
# inlined frames, so we get the description (which does take # inlined frames, so we get the description (which does take
# into account inlined functions) and parse it. # into account inlined functions) and parse it.
desc = lldbutil.get_description(location, lldb.eDescriptionLevelFull) desc = lldbutil.get_description(location, lldb.eDescriptionLevelFull)
match = re.search("at\ ([^:]+):([\d]+)", desc) match = re.search(r"at\ ([^:]+):([\d]+)", desc)
try: try:
path = match.group(1) path = match.group(1)
line = int(match.group(2).strip()) line = int(match.group(2).strip())