From 87f3b8f3872c261d380d5fbf49051bb7cc6b4f50 Mon Sep 17 00:00:00 2001 From: Med Ismail Bennani Date: Mon, 25 Aug 2025 16:43:17 -0700 Subject: [PATCH] [lldb/crashlog] Use raw strings to silence escape sequence warnings This patch silences from escapte sequence warnings from the crashlog script that were mostly due to regular expression strings. This is addresses by using raw strings so the escape character isn't interpreted by python and gets passed straight to the regular expression engine. Signed-off-by: Med Ismail Bennani --- lldb/examples/python/crashlog.py | 8 ++++---- lldb/examples/python/symbolication.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py index 14798592a1873..741d60d91921c 100755 --- a/lldb/examples/python/crashlog.py +++ b/lldb/examples/python/crashlog.py @@ -296,7 +296,7 @@ class DarwinImage(symbolication.Image): except: dsymForUUIDBinary = "" - dwarfdump_uuid_regex = re.compile("UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*") + dwarfdump_uuid_regex = re.compile(r"UUID: ([-0-9a-fA-F]+) \(([^\(]+)\) .*") def __init__( self, text_addr_lo, text_addr_hi, identifier, version, uuid, path, verbose @@ -501,7 +501,7 @@ def find_image_with_identifier(self, identifier): for image in self.images: if image.identifier == identifier: return image - regex_text = "^.*\.%s$" % (re.escape(identifier)) + regex_text = r"^.*\.%s$" % (re.escape(identifier)) regex = re.compile(regex_text) for image in self.images: if regex.match(image.identifier): @@ -925,7 +925,7 @@ def get(cls): version = r"(?:" + super().version + r"\s+)?" address = r"(0x[0-9a-fA-F]{4,})" # 4 digits or more - symbol = """ + symbol = r""" (?: [ ]+ (?P.+) @@ -1095,7 +1095,7 @@ def parse_normal(self, line): self.crashlog.process_identifier = line[11:].strip() elif line.startswith("Version:"): version_string = line[8:].strip() - matched_pair = re.search("(.+)\((.+)\)", version_string) + matched_pair = re.search(r"(.+)\((.+)\)", version_string) if matched_pair: self.crashlog.process_version = matched_pair.group(1) self.crashlog.process_compatability_version = matched_pair.group(2) diff --git a/lldb/examples/python/symbolication.py b/lldb/examples/python/symbolication.py index f6dcc8b9a7943..b16745ee963c9 100755 --- a/lldb/examples/python/symbolication.py +++ b/lldb/examples/python/symbolication.py @@ -177,9 +177,9 @@ class Section: """Class that represents an load address range""" sect_info_regex = re.compile("(?P[^=]+)=(?P.*)") - addr_regex = re.compile("^\s*(?P0x[0-9A-Fa-f]+)\s*$") + addr_regex = re.compile(r"^\s*(?P0x[0-9A-Fa-f]+)\s*$") range_regex = re.compile( - "^\s*(?P0x[0-9A-Fa-f]+)\s*(?P[-+])\s*(?P0x[0-9A-Fa-f]+)\s*$" + r"^\s*(?P0x[0-9A-Fa-f]+)\s*(?P[-+])\s*(?P0x[0-9A-Fa-f]+)\s*$" ) def __init__(self, start_addr=None, end_addr=None, name=None): @@ -557,7 +557,7 @@ def find_images_with_identifier(self, identifier): if image.identifier == identifier: images.append(image) if len(images) == 0: - regex_text = "^.*\.%s$" % (re.escape(identifier)) + regex_text = r"^.*\.%s$" % (re.escape(identifier)) regex = re.compile(regex_text) for image in self.images: if regex.match(image.identifier):