[Lldb-commits] [lldb] DebugInfoD tests + fixing issues exposed by tests (PR #85693)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Mar 18 13:30:27 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
darker --check --diff -r 18da51b2b227bcaee0efd13c4bc9ba408ea6b6e6...2998d958d242210601678e40606720520259ecd7 lldb/test/API/debuginfod/Normal/TestDebuginfod.py lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py
``````````
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- Normal/TestDebuginfod.py 2024-03-18 20:24:00.000000 +0000
+++ Normal/TestDebuginfod.py 2024-03-18 20:30:18.700337 +0000
@@ -20,11 +20,11 @@
return None
header = struct.unpack_from("<4I", data)
if len(header) != 4:
return None
# 4 element 'prefix', 20 bytes of uuid, 3 byte long string: 'GNU':
- if header[0] != 4 or header[1] != 20 or header[2] != 3 or header[3] != 0x554e47:
+ if header[0] != 4 or header[1] != 20 or header[2] != 3 or header[3] != 0x554E47:
return None
return data[16:].hex()
"""
@@ -33,10 +33,12 @@
For no-split-dwarf scenarios, there are 2 variations:
1 - A stripped binary with it's corresponding unstripped binary:
2 - A stripped binary with a corresponding --only-keep-debug symbols file
"""
+
+
@skipUnlessPlatform(["linux", "freebsd"])
class DebugInfodTests(TestBase):
# No need to try every flavor of debug inf.
NO_DEBUG_INFO_TESTCASE = True
@@ -97,18 +99,25 @@
loc = bp.GetLocationAtIndex(0)
self.assertTrue(loc and loc.IsValid(), "Location is valid")
addr = loc.GetAddress()
self.assertTrue(addr and addr.IsValid(), "Loc address is valid")
line_entry = addr.GetLineEntry()
- self.assertEqual(should_have_loc, line_entry != None and line_entry.IsValid(), "Loc line entry is valid")
+ self.assertEqual(
+ should_have_loc,
+ line_entry != None and line_entry.IsValid(),
+ "Loc line entry is valid",
+ )
if should_have_loc:
self.assertEqual(line_entry.GetLine(), 4)
- self.assertEqual(line_entry.GetFileSpec().GetFilename(), self.main_source_file.GetFilename())
+ self.assertEqual(
+ line_entry.GetFileSpec().GetFilename(),
+ self.main_source_file.GetFilename(),
+ )
self.dbg.DeleteTarget(target)
shutil.rmtree(self.tmp_dir)
- def config_test(self, local_files, debuginfo = None, executable = None):
+ def config_test(self, local_files, debuginfo=None, executable=None):
"""
Set up a test with local_files[] copied to a different location
so that we control which files are, or are not, found in the file system.
Also, create a stand-alone file-system 'hosted' debuginfod server with the
provided debuginfo and executable files (if they exist)
@@ -136,26 +145,41 @@
self.aout = ""
# Copy the files used by the test:
for f in local_files:
shutil.copy(self.getBuildArtifact(f), test_dir)
# The first item is the binary to be used for the test
- if (self.aout == ""):
+ if self.aout == "":
self.aout = os.path.join(test_dir, f)
use_debuginfod = debuginfo != None or executable != None
# Populated the 'file://... mocked' Debuginfod server:
if use_debuginfod:
os.makedirs(os.path.join(self.tmp_dir, "cache"))
uuid_dir = os.path.join(self.tmp_dir, "buildid", uuid)
os.makedirs(uuid_dir)
if debuginfo:
- shutil.copy(self.getBuildArtifact(debuginfo), os.path.join(uuid_dir, "debuginfo"))
+ shutil.copy(
+ self.getBuildArtifact(debuginfo),
+ os.path.join(uuid_dir, "debuginfo"),
+ )
if executable:
- shutil.copy(self.getBuildArtifact(executable), os.path.join(uuid_dir, "executable"))
+ shutil.copy(
+ self.getBuildArtifact(executable),
+ os.path.join(uuid_dir, "executable"),
+ )
# Configure LLDB for the test:
- self.runCmd("settings set symbols.enable-external-lookup %s" % str(use_debuginfod).lower())
+ self.runCmd(
+ "settings set symbols.enable-external-lookup %s"
+ % str(use_debuginfod).lower()
+ )
self.runCmd("settings clear plugin.symbol-locator.debuginfod.server-urls")
if use_debuginfod:
- self.runCmd("settings set plugin.symbol-locator.debuginfod.cache-path %s/cache" % self.tmp_dir)
- self.runCmd("settings insert-before plugin.symbol-locator.debuginfod.server-urls 0 file://%s" % self.tmp_dir)
+ self.runCmd(
+ "settings set plugin.symbol-locator.debuginfod.cache-path %s/cache"
+ % self.tmp_dir
+ )
+ self.runCmd(
+ "settings insert-before plugin.symbol-locator.debuginfod.server-urls 0 file://%s"
+ % self.tmp_dir
+ )
--- SplitDWARF/TestDebuginfodDWP.py 2024-03-18 20:24:00.000000 +0000
+++ SplitDWARF/TestDebuginfodDWP.py 2024-03-18 20:30:18.750514 +0000
@@ -23,22 +23,25 @@
return None
header = struct.unpack_from("<4I", data)
if len(header) != 4:
return None
# 4 element 'prefix', 20 bytes of uuid, 3 byte long string: 'GNU':
- if header[0] != 4 or header[1] != 20 or header[2] != 3 or header[3] != 0x554e47:
+ if header[0] != 4 or header[1] != 20 or header[2] != 3 or header[3] != 0x554E47:
return None
return data[16:].hex()
+
"""
Test support for the DebugInfoD network symbol acquisition protocol.
This file is for split-dwarf (dwp) scenarios.
1 - A split binary target with it's corresponding DWP file
2 - A stripped, split binary target with an unstripped binary and a DWP file
3 - A stripped, split binary target with an --only-keep-debug symbols file and a DWP file
"""
+
+
@skipUnlessPlatform(["linux", "freebsd"])
class DebugInfodDWPTests(TestBase):
# No need to try every flavor of debug inf.
NO_DEBUG_INFO_TESTCASE = True
@@ -106,18 +109,25 @@
loc = bp.GetLocationAtIndex(0)
self.assertTrue(loc and loc.IsValid(), "Location is valid")
addr = loc.GetAddress()
self.assertTrue(addr and addr.IsValid(), "Loc address is valid")
line_entry = addr.GetLineEntry()
- self.assertEqual(should_have_loc, line_entry != None and line_entry.IsValid(), "Loc line entry is valid")
+ self.assertEqual(
+ should_have_loc,
+ line_entry != None and line_entry.IsValid(),
+ "Loc line entry is valid",
+ )
if should_have_loc:
self.assertEqual(line_entry.GetLine(), 4)
- self.assertEqual(line_entry.GetFileSpec().GetFilename(), self.main_source_file.GetFilename())
+ self.assertEqual(
+ line_entry.GetFileSpec().GetFilename(),
+ self.main_source_file.GetFilename(),
+ )
self.dbg.DeleteTarget(target)
shutil.rmtree(self.tmp_dir)
- def config_test(self, local_files, debuginfo = None, executable = None):
+ def config_test(self, local_files, debuginfo=None, executable=None):
"""
Set up a test with local_files[] copied to a different location
so that we control which files are, or are not, found in the file system.
Also, create a stand-alone file-system 'hosted' debuginfod server with the
provided debuginfo and executable files (if they exist)
@@ -144,26 +154,41 @@
self.aout = ""
# Copy the files used by the test:
for f in local_files:
shutil.copy(self.getBuildArtifact(f), self.test_dir)
- if (self.aout == ""):
+ if self.aout == "":
self.aout = os.path.join(self.test_dir, f)
use_debuginfod = debuginfo != None or executable != None
# Populated the 'file://... mocked' Debuginfod server:
if use_debuginfod:
os.makedirs(os.path.join(self.tmp_dir, "cache"))
uuid_dir = os.path.join(self.tmp_dir, "buildid", uuid)
os.makedirs(uuid_dir)
if debuginfo:
- shutil.copy(self.getBuildArtifact(debuginfo), os.path.join(uuid_dir, "debuginfo"))
+ shutil.copy(
+ self.getBuildArtifact(debuginfo),
+ os.path.join(uuid_dir, "debuginfo"),
+ )
if executable:
- shutil.copy(self.getBuildArtifact(executable), os.path.join(uuid_dir, "executable"))
+ shutil.copy(
+ self.getBuildArtifact(executable),
+ os.path.join(uuid_dir, "executable"),
+ )
os.remove(self.getBuildArtifact("main.dwo"))
# Configure LLDB for the test:
- self.runCmd("settings set symbols.enable-external-lookup %s" % str(use_debuginfod).lower())
+ self.runCmd(
+ "settings set symbols.enable-external-lookup %s"
+ % str(use_debuginfod).lower()
+ )
self.runCmd("settings clear plugin.symbol-locator.debuginfod.server-urls")
if use_debuginfod:
- self.runCmd("settings set plugin.symbol-locator.debuginfod.cache-path %s/cache" % self.tmp_dir)
- self.runCmd("settings insert-before plugin.symbol-locator.debuginfod.server-urls 0 file://%s" % self.tmp_dir)
+ self.runCmd(
+ "settings set plugin.symbol-locator.debuginfod.cache-path %s/cache"
+ % self.tmp_dir
+ )
+ self.runCmd(
+ "settings insert-before plugin.symbol-locator.debuginfod.server-urls 0 file://%s"
+ % self.tmp_dir
+ )
``````````
</details>
https://github.com/llvm/llvm-project/pull/85693
More information about the lldb-commits
mailing list