mirror of
https://github.com/intel/llvm.git
synced 2026-02-08 17:28:30 +08:00
[NFC][Py Reformat] Reformat python files in lldb
This is an ongoing series of commits that are reformatting our Python code. Reformatting is done with `black` (23.1.0). If you end up having problems merging this commit because you have made changes to a python file, the best way to handle that is to run `git checkout --ours <yourfile>` and then reformat it with black. RFC: https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style Differential revision: https://reviews.llvm.org/D151460
This commit is contained in:
@@ -10,79 +10,77 @@ import time
|
||||
|
||||
|
||||
class ModuleCacheTestcaseBSD(TestBase):
|
||||
|
||||
def setUp(self):
|
||||
# Call super's setUp().
|
||||
TestBase.setUp(self)
|
||||
# Find the line number in a(int) to break at.
|
||||
self.line_a = line_number(
|
||||
'a.c', '// Set file and line breakpoint inside a().')
|
||||
self.line_b = line_number(
|
||||
'b.c', '// Set file and line breakpoint inside b().')
|
||||
self.line_c = line_number(
|
||||
'c.c', '// Set file and line breakpoint inside c().')
|
||||
self.cache_dir = os.path.join(self.getBuildDir(), 'lldb-module-cache')
|
||||
self.line_a = line_number("a.c", "// Set file and line breakpoint inside a().")
|
||||
self.line_b = line_number("b.c", "// Set file and line breakpoint inside b().")
|
||||
self.line_c = line_number("c.c", "// Set file and line breakpoint inside c().")
|
||||
self.cache_dir = os.path.join(self.getBuildDir(), "lldb-module-cache")
|
||||
# Set the lldb module cache directory to a directory inside the build
|
||||
# artifacts directory so no other tests are interfered with.
|
||||
self.runCmd('settings set symbols.lldb-index-cache-path "%s"' % (self.cache_dir))
|
||||
self.runCmd('settings set symbols.enable-lldb-index-cache true')
|
||||
self.runCmd(
|
||||
'settings set symbols.lldb-index-cache-path "%s"' % (self.cache_dir)
|
||||
)
|
||||
self.runCmd("settings set symbols.enable-lldb-index-cache true")
|
||||
self.build()
|
||||
|
||||
|
||||
def get_module_cache_files(self, basename):
|
||||
module_cache_glob = os.path.join(self.cache_dir, "llvmcache-*%s*symtab*" % (basename))
|
||||
module_cache_glob = os.path.join(
|
||||
self.cache_dir, "llvmcache-*%s*symtab*" % (basename)
|
||||
)
|
||||
return glob.glob(module_cache_glob)
|
||||
|
||||
|
||||
# Requires no dSYM, so we let the Makefile make the right stuff for us
|
||||
@no_debug_info_test
|
||||
@skipUnlessDarwin
|
||||
def test(self):
|
||||
"""
|
||||
This test has been modified to make sure .o files that don't have
|
||||
UUIDs are not cached after discovering build systems that play with
|
||||
modification times of .o files that the modification times are not
|
||||
unique enough to ensure the .o file within the .a file are the right
|
||||
files as this was causing older cache files to be accepted for new
|
||||
updated .o files.
|
||||
This test has been modified to make sure .o files that don't have
|
||||
UUIDs are not cached after discovering build systems that play with
|
||||
modification times of .o files that the modification times are not
|
||||
unique enough to ensure the .o file within the .a file are the right
|
||||
files as this was causing older cache files to be accepted for new
|
||||
updated .o files.
|
||||
|
||||
ELF .o files do calculate a UUID from the contents of the file,
|
||||
which is expensive, but no one loads .o files into a debug sessions
|
||||
when using ELF files. Mach-o .o files do not have UUID values and do
|
||||
no calculate one as they _are_ used during debug sessions when no
|
||||
dSYM file is generated. If we can find a way to uniquely and cheaply
|
||||
create UUID values for mach-o .o files in the future, this test will
|
||||
be updated to test this functionality. This test will now make sure
|
||||
there are no cache entries for any .o files in BSD archives.
|
||||
ELF .o files do calculate a UUID from the contents of the file,
|
||||
which is expensive, but no one loads .o files into a debug sessions
|
||||
when using ELF files. Mach-o .o files do not have UUID values and do
|
||||
no calculate one as they _are_ used during debug sessions when no
|
||||
dSYM file is generated. If we can find a way to uniquely and cheaply
|
||||
create UUID values for mach-o .o files in the future, this test will
|
||||
be updated to test this functionality. This test will now make sure
|
||||
there are no cache entries for any .o files in BSD archives.
|
||||
|
||||
The old test case description is below in case we enable caching for
|
||||
.o files again:
|
||||
The old test case description is below in case we enable caching for
|
||||
.o files again:
|
||||
|
||||
Test module cache functionality for bsd archive object files.
|
||||
Test module cache functionality for bsd archive object files.
|
||||
|
||||
This will test that if we enable the module cache, we have a
|
||||
corresponding cache entry for the .o files in libfoo.a.
|
||||
This will test that if we enable the module cache, we have a
|
||||
corresponding cache entry for the .o files in libfoo.a.
|
||||
|
||||
The static library has two entries for "a.o":
|
||||
- one from a.c
|
||||
- one from c.c which had c.o renamed to a.o and then put into the
|
||||
libfoo.a as an extra .o file with different contents from the
|
||||
original a.o
|
||||
The static library has two entries for "a.o":
|
||||
- one from a.c
|
||||
- one from c.c which had c.o renamed to a.o and then put into the
|
||||
libfoo.a as an extra .o file with different contents from the
|
||||
original a.o
|
||||
|
||||
We do this to test that we can correctly cache duplicate .o files
|
||||
that appear in .a files.
|
||||
We do this to test that we can correctly cache duplicate .o files
|
||||
that appear in .a files.
|
||||
|
||||
This test only works on darwin because of the way DWARF is stored
|
||||
where the debug map will refer to .o files inside of .a files.
|
||||
This test only works on darwin because of the way DWARF is stored
|
||||
where the debug map will refer to .o files inside of .a files.
|
||||
"""
|
||||
exe = self.getBuildArtifact("a.out")
|
||||
|
||||
# Create a module with no dependencies.
|
||||
target = self.createTestTarget(load_dependent_modules=False)
|
||||
|
||||
self.runCmd('breakpoint set -f a.c -l %d' % (self.line_a))
|
||||
self.runCmd('breakpoint set -f b.c -l %d' % (self.line_b))
|
||||
self.runCmd('breakpoint set -f c.c -l %d' % (self.line_c))
|
||||
self.runCmd("breakpoint set -f a.c -l %d" % (self.line_a))
|
||||
self.runCmd("breakpoint set -f b.c -l %d" % (self.line_b))
|
||||
self.runCmd("breakpoint set -f c.c -l %d" % (self.line_c))
|
||||
|
||||
# Get the executable module and get the number of symbols to make
|
||||
# sure the symbol table gets parsed and cached. The module cache is
|
||||
@@ -94,7 +92,6 @@ class ModuleCacheTestcaseBSD(TestBase):
|
||||
a_o_cache_files = self.get_module_cache_files("libfoo.a(a.o)")
|
||||
b_o_cache_files = self.get_module_cache_files("libfoo.a(b.o)")
|
||||
|
||||
|
||||
# We expect the directory for a.o to have two cache directories:
|
||||
# - 1 for the a.o with a earlier mod time
|
||||
# - 1 for the a.o that was renamed from c.o that should be 2 seconds older
|
||||
@@ -106,7 +103,15 @@ class ModuleCacheTestcaseBSD(TestBase):
|
||||
# We are no longer caching .o files in the lldb index cache. If we ever
|
||||
# re-enable this functionality, we can uncomment out the above lines of
|
||||
# code.
|
||||
self.assertEqual(len(a_o_cache_files), 0,
|
||||
"make sure there are no files in the module cache directory (%s) for libfoo.a(a.o)" % (self.cache_dir))
|
||||
self.assertEqual(len(b_o_cache_files), 0,
|
||||
"make sure there are no files in the module cache directory (%s) for libfoo.a(b.o)" % (self.cache_dir))
|
||||
self.assertEqual(
|
||||
len(a_o_cache_files),
|
||||
0,
|
||||
"make sure there are no files in the module cache directory (%s) for libfoo.a(a.o)"
|
||||
% (self.cache_dir),
|
||||
)
|
||||
self.assertEqual(
|
||||
len(b_o_cache_files),
|
||||
0,
|
||||
"make sure there are no files in the module cache directory (%s) for libfoo.a(b.o)"
|
||||
% (self.cache_dir),
|
||||
)
|
||||
|
||||
@@ -9,34 +9,34 @@ import time
|
||||
|
||||
|
||||
class DebugIndexCacheTestcase(TestBase):
|
||||
|
||||
def setUp(self):
|
||||
# Call super's setUp().
|
||||
TestBase.setUp(self)
|
||||
# Set the lldb module cache directory to a directory inside the build
|
||||
# artifacts directory so no other tests are interfered with.
|
||||
self.cache_dir = os.path.join(self.getBuildDir(), 'lldb-module-cache')
|
||||
self.cache_dir = os.path.join(self.getBuildDir(), "lldb-module-cache")
|
||||
|
||||
def get_module_cache_files(self, basename):
|
||||
module_cache_glob = os.path.join(self.cache_dir,
|
||||
"llvmcache-*%s*dwarf-index*" % (basename))
|
||||
module_cache_glob = os.path.join(
|
||||
self.cache_dir, "llvmcache-*%s*dwarf-index*" % (basename)
|
||||
)
|
||||
return glob.glob(module_cache_glob)
|
||||
|
||||
def get_stats(self, log_path=None):
|
||||
"""
|
||||
Get the output of the "statistics dump" and return the JSON as a
|
||||
python dictionary.
|
||||
Get the output of the "statistics dump" and return the JSON as a
|
||||
python dictionary.
|
||||
"""
|
||||
# If log_path is set, open the path and emit the output of the command
|
||||
# for debugging purposes.
|
||||
if log_path is not None:
|
||||
f = open(log_path, 'w')
|
||||
f = open(log_path, "w")
|
||||
else:
|
||||
f = None
|
||||
return_obj = lldb.SBCommandReturnObject()
|
||||
command = "statistics dump "
|
||||
if f:
|
||||
f.write('(lldb) %s\n' % (command))
|
||||
f.write("(lldb) %s\n" % (command))
|
||||
self.ci.HandleCommand(command, return_obj, False)
|
||||
metrics_json = return_obj.GetOutput()
|
||||
if f:
|
||||
@@ -44,24 +44,26 @@ class DebugIndexCacheTestcase(TestBase):
|
||||
return json.loads(metrics_json)
|
||||
|
||||
def enable_lldb_index_cache(self):
|
||||
self.runCmd('settings set symbols.lldb-index-cache-path "%s"' % (self.cache_dir))
|
||||
self.runCmd('settings set symbols.enable-lldb-index-cache true')
|
||||
self.runCmd(
|
||||
'settings set symbols.lldb-index-cache-path "%s"' % (self.cache_dir)
|
||||
)
|
||||
self.runCmd("settings set symbols.enable-lldb-index-cache true")
|
||||
|
||||
@no_debug_info_test
|
||||
def test_with_caching_enabled(self):
|
||||
"""
|
||||
Test module cache functionality for debug info index caching.
|
||||
Test module cache functionality for debug info index caching.
|
||||
|
||||
We test that a debug info index file is created for the debug
|
||||
information when caching is enabled with a file that contains
|
||||
at least one of each kind of DIE in ManualDWARFIndex::IndexSet.
|
||||
We test that a debug info index file is created for the debug
|
||||
information when caching is enabled with a file that contains
|
||||
at least one of each kind of DIE in ManualDWARFIndex::IndexSet.
|
||||
|
||||
The input file has DWARF that will fill in every member of the
|
||||
ManualDWARFIndex::IndexSet class to ensure we can encode all of the
|
||||
required information.
|
||||
The input file has DWARF that will fill in every member of the
|
||||
ManualDWARFIndex::IndexSet class to ensure we can encode all of the
|
||||
required information.
|
||||
|
||||
With caching enabled, we also verify that the appropriate statistics
|
||||
specify that the cache file was saved to the cache.
|
||||
With caching enabled, we also verify that the appropriate statistics
|
||||
specify that the cache file was saved to the cache.
|
||||
"""
|
||||
self.enable_lldb_index_cache()
|
||||
src_dir = self.getSourceDir()
|
||||
@@ -74,18 +76,22 @@ class DebugIndexCacheTestcase(TestBase):
|
||||
target = self.dbg.CreateTarget(obj_path)
|
||||
self.assertTrue(target, VALID_TARGET)
|
||||
|
||||
debug_index_cache_files = self.get_module_cache_files('main.o')
|
||||
self.assertEqual(len(debug_index_cache_files), 1,
|
||||
"make sure there is one file in the module cache directory (%s) for main.o that is a debug info cache" % (self.cache_dir))
|
||||
debug_index_cache_files = self.get_module_cache_files("main.o")
|
||||
self.assertEqual(
|
||||
len(debug_index_cache_files),
|
||||
1,
|
||||
"make sure there is one file in the module cache directory (%s) for main.o that is a debug info cache"
|
||||
% (self.cache_dir),
|
||||
)
|
||||
|
||||
# Verify that the module statistics have the information that specifies
|
||||
# if we loaded or saved the debug index and symtab to the cache
|
||||
stats = self.get_stats()
|
||||
module_stats = stats['modules'][0]
|
||||
self.assertFalse(module_stats['debugInfoIndexLoadedFromCache'])
|
||||
self.assertTrue(module_stats['debugInfoIndexSavedToCache'])
|
||||
self.assertFalse(module_stats['symbolTableLoadedFromCache'])
|
||||
self.assertTrue(module_stats['symbolTableSavedToCache'])
|
||||
module_stats = stats["modules"][0]
|
||||
self.assertFalse(module_stats["debugInfoIndexLoadedFromCache"])
|
||||
self.assertTrue(module_stats["debugInfoIndexSavedToCache"])
|
||||
self.assertFalse(module_stats["symbolTableLoadedFromCache"])
|
||||
self.assertTrue(module_stats["symbolTableSavedToCache"])
|
||||
# Verify the top level stats track how many things were loaded or saved
|
||||
# to the cache.
|
||||
self.assertEqual(stats["totalDebugInfoIndexLoadedFromCache"], 0)
|
||||
@@ -96,18 +102,18 @@ class DebugIndexCacheTestcase(TestBase):
|
||||
@no_debug_info_test
|
||||
def test_with_caching_disabled(self):
|
||||
"""
|
||||
Test module cache functionality for debug info index caching.
|
||||
Test module cache functionality for debug info index caching.
|
||||
|
||||
We test that a debug info index file is not created for the debug
|
||||
information when caching is disabled with a file that contains
|
||||
at least one of each kind of DIE in ManualDWARFIndex::IndexSet.
|
||||
We test that a debug info index file is not created for the debug
|
||||
information when caching is disabled with a file that contains
|
||||
at least one of each kind of DIE in ManualDWARFIndex::IndexSet.
|
||||
|
||||
The input file has DWARF that will fill in every member of the
|
||||
ManualDWARFIndex::IndexSet class to ensure we can encode all of the
|
||||
required information.
|
||||
The input file has DWARF that will fill in every member of the
|
||||
ManualDWARFIndex::IndexSet class to ensure we can encode all of the
|
||||
required information.
|
||||
|
||||
With caching disabled, we also verify that the appropriate
|
||||
statistics specify that the cache file was not saved to the cache.
|
||||
With caching disabled, we also verify that the appropriate
|
||||
statistics specify that the cache file was not saved to the cache.
|
||||
"""
|
||||
src_dir = self.getSourceDir()
|
||||
yaml_path = os.path.join(src_dir, "exe.yaml")
|
||||
@@ -119,18 +125,22 @@ class DebugIndexCacheTestcase(TestBase):
|
||||
target = self.dbg.CreateTarget(obj_path)
|
||||
self.assertTrue(target, VALID_TARGET)
|
||||
|
||||
debug_index_cache_files = self.get_module_cache_files('main.o')
|
||||
self.assertEqual(len(debug_index_cache_files), 0,
|
||||
"make sure there is no file in the module cache directory (%s) for main.o that is a debug info cache" % (self.cache_dir))
|
||||
debug_index_cache_files = self.get_module_cache_files("main.o")
|
||||
self.assertEqual(
|
||||
len(debug_index_cache_files),
|
||||
0,
|
||||
"make sure there is no file in the module cache directory (%s) for main.o that is a debug info cache"
|
||||
% (self.cache_dir),
|
||||
)
|
||||
|
||||
# Verify that the module statistics have the information that specifies
|
||||
# if we loaded or saved the debug index and symtab to the cache
|
||||
stats = self.get_stats()
|
||||
module_stats = stats['modules'][0]
|
||||
self.assertFalse(module_stats['debugInfoIndexLoadedFromCache'])
|
||||
self.assertFalse(module_stats['debugInfoIndexSavedToCache'])
|
||||
self.assertFalse(module_stats['symbolTableLoadedFromCache'])
|
||||
self.assertFalse(module_stats['symbolTableSavedToCache'])
|
||||
module_stats = stats["modules"][0]
|
||||
self.assertFalse(module_stats["debugInfoIndexLoadedFromCache"])
|
||||
self.assertFalse(module_stats["debugInfoIndexSavedToCache"])
|
||||
self.assertFalse(module_stats["symbolTableLoadedFromCache"])
|
||||
self.assertFalse(module_stats["symbolTableSavedToCache"])
|
||||
# Verify the top level stats track how many things were loaded or saved
|
||||
# to the cache.
|
||||
self.assertEqual(stats["totalDebugInfoIndexLoadedFromCache"], 0)
|
||||
|
||||
@@ -10,22 +10,23 @@ import time
|
||||
|
||||
|
||||
class ModuleCacheTestcaseSimple(TestBase):
|
||||
|
||||
def setUp(self):
|
||||
# Call super's setUp().
|
||||
TestBase.setUp(self)
|
||||
# Find the line number in a(int) to break at.
|
||||
self.cache_dir = os.path.join(self.getBuildDir(), 'lldb-module-cache')
|
||||
self.cache_dir = os.path.join(self.getBuildDir(), "lldb-module-cache")
|
||||
# Set the lldb module cache directory to a directory inside the build
|
||||
# artifacts directory so no other tests are interfered with.
|
||||
self.runCmd('settings set symbols.lldb-index-cache-path "%s"' % (self.cache_dir))
|
||||
self.runCmd('settings set symbols.enable-lldb-index-cache true')
|
||||
self.runCmd(
|
||||
'settings set symbols.lldb-index-cache-path "%s"' % (self.cache_dir)
|
||||
)
|
||||
self.runCmd("settings set symbols.enable-lldb-index-cache true")
|
||||
self.build()
|
||||
|
||||
|
||||
def get_module_cache_files(self, basename):
|
||||
module_file_glob = os.path.join(self.cache_dir,
|
||||
"llvmcache-*%s*-symtab-*" % (basename))
|
||||
module_file_glob = os.path.join(
|
||||
self.cache_dir, "llvmcache-*%s*-symtab-*" % (basename)
|
||||
)
|
||||
return glob.glob(module_file_glob)
|
||||
|
||||
# Doesn't depend on any specific debug information.
|
||||
@@ -33,14 +34,14 @@ class ModuleCacheTestcaseSimple(TestBase):
|
||||
@skipIfWindows
|
||||
def test(self):
|
||||
"""
|
||||
Test module cache functionality for a simple object file.
|
||||
Test module cache functionality for a simple object file.
|
||||
|
||||
This will test that if we enable the module cache, we have a
|
||||
corresponding index cache entry for the symbol table for the
|
||||
executable. It also removes the executable, rebuilds so that the
|
||||
modification time of the binary gets updated, and then creates a new
|
||||
target and should cause the cache to get updated so the cache file
|
||||
should get an updated modification time.
|
||||
This will test that if we enable the module cache, we have a
|
||||
corresponding index cache entry for the symbol table for the
|
||||
executable. It also removes the executable, rebuilds so that the
|
||||
modification time of the binary gets updated, and then creates a new
|
||||
target and should cause the cache to get updated so the cache file
|
||||
should get an updated modification time.
|
||||
"""
|
||||
exe = self.getBuildArtifact("a.out")
|
||||
|
||||
@@ -55,8 +56,9 @@ class ModuleCacheTestcaseSimple(TestBase):
|
||||
# Make sure the symbol table gets loaded and cached
|
||||
main_module.GetNumSymbols()
|
||||
cache_files = self.get_module_cache_files("a.out")
|
||||
self.assertEqual(len(cache_files), 1,
|
||||
"make sure there is only one cache file for 'a.out'")
|
||||
self.assertEqual(
|
||||
len(cache_files), 1, "make sure there is only one cache file for 'a.out'"
|
||||
)
|
||||
symtab_cache_path = cache_files[0]
|
||||
exe_mtime_1 = os.path.getmtime(exe)
|
||||
symtab_mtime_1 = os.path.getmtime(symtab_cache_path)
|
||||
@@ -64,36 +66,47 @@ class ModuleCacheTestcaseSimple(TestBase):
|
||||
# get a different creation and modification time for the file since some
|
||||
# OSs store the modification time in seconds since Jan 1, 1970.
|
||||
os.remove(exe)
|
||||
self.assertEqual(os.path.exists(exe), False,
|
||||
'make sure we were able to remove the executable')
|
||||
self.assertEqual(
|
||||
os.path.exists(exe),
|
||||
False,
|
||||
"make sure we were able to remove the executable",
|
||||
)
|
||||
time.sleep(2)
|
||||
# Now rebuild the binary so it has a different content which should
|
||||
# update the UUID to make the cache miss when it tries to load the
|
||||
# symbol table from the binary at the same path.
|
||||
self.build(dictionary={'CFLAGS_EXTRAS': '-DEXTRA_FUNCTION'})
|
||||
self.assertEqual(os.path.exists(exe), True,
|
||||
'make sure executable exists after rebuild')
|
||||
self.build(dictionary={"CFLAGS_EXTRAS": "-DEXTRA_FUNCTION"})
|
||||
self.assertEqual(
|
||||
os.path.exists(exe), True, "make sure executable exists after rebuild"
|
||||
)
|
||||
# Make sure the modification time has changed or this test will fail.
|
||||
exe_mtime_2 = os.path.getmtime(exe)
|
||||
self.assertNotEqual(
|
||||
exe_mtime_1,
|
||||
exe_mtime_2,
|
||||
"make sure the modification time of the executable has changed")
|
||||
exe_mtime_1,
|
||||
exe_mtime_2,
|
||||
"make sure the modification time of the executable has changed",
|
||||
)
|
||||
# Make sure the module cache still has an out of date cache with the
|
||||
# same old modification time.
|
||||
self.assertEqual(symtab_mtime_1,
|
||||
os.path.getmtime(symtab_cache_path),
|
||||
"check that the 'symtab' cache file modification time doesn't match the executable modification time after rebuild")
|
||||
self.assertEqual(
|
||||
symtab_mtime_1,
|
||||
os.path.getmtime(symtab_cache_path),
|
||||
"check that the 'symtab' cache file modification time doesn't match the executable modification time after rebuild",
|
||||
)
|
||||
# Create a new target and get the symbols again, and make sure the cache
|
||||
# gets updated for the symbol table cache
|
||||
target = self.createTestTarget(load_dependent_modules=False)
|
||||
main_module = target.GetModuleAtIndex(0)
|
||||
self.assertTrue(main_module.IsValid())
|
||||
main_module.GetNumSymbols()
|
||||
self.assertEqual(os.path.exists(symtab_cache_path), True,
|
||||
'make sure "symtab" cache files exists after cache is updated')
|
||||
self.assertEqual(
|
||||
os.path.exists(symtab_cache_path),
|
||||
True,
|
||||
'make sure "symtab" cache files exists after cache is updated',
|
||||
)
|
||||
symtab_mtime_2 = os.path.getmtime(symtab_cache_path)
|
||||
self.assertNotEqual(
|
||||
symtab_mtime_1,
|
||||
symtab_mtime_2,
|
||||
'make sure modification time of "symtab-..." changed')
|
||||
symtab_mtime_1,
|
||||
symtab_mtime_2,
|
||||
'make sure modification time of "symtab-..." changed',
|
||||
)
|
||||
|
||||
@@ -10,31 +10,31 @@ import time
|
||||
|
||||
|
||||
class ModuleCacheTestcaseUniversal(TestBase):
|
||||
|
||||
def setUp(self):
|
||||
# Call super's setUp().
|
||||
TestBase.setUp(self)
|
||||
# Find the line number in a(int) to break at.
|
||||
self.cache_dir = os.path.join(self.getBuildDir(), 'lldb-module-cache')
|
||||
self.cache_dir = os.path.join(self.getBuildDir(), "lldb-module-cache")
|
||||
# Set the lldb module cache directory to a directory inside the build
|
||||
# artifacts directory so no other tests are interfered with.
|
||||
self.runCmd('settings set symbols.lldb-index-cache-path "%s"' % (self.cache_dir))
|
||||
self.runCmd('settings set symbols.enable-lldb-index-cache true')
|
||||
self.runCmd(
|
||||
'settings set symbols.lldb-index-cache-path "%s"' % (self.cache_dir)
|
||||
)
|
||||
self.runCmd("settings set symbols.enable-lldb-index-cache true")
|
||||
|
||||
def get_module_cache_files(self, basename):
|
||||
module_file_glob = os.path.join(self.cache_dir, "llvmcache-*%s*" % (basename))
|
||||
return glob.glob(module_file_glob)
|
||||
|
||||
|
||||
# Doesn't depend on any specific debug information.
|
||||
@no_debug_info_test
|
||||
def test(self):
|
||||
"""
|
||||
Test module cache functionality for a universal mach-o files.
|
||||
Test module cache functionality for a universal mach-o files.
|
||||
|
||||
This will test that if we enable the module cache, we can create
|
||||
lldb module caches for each slice of a universal mach-o file and
|
||||
they will each have a unique directory.
|
||||
This will test that if we enable the module cache, we can create
|
||||
lldb module caches for each slice of a universal mach-o file and
|
||||
they will each have a unique directory.
|
||||
"""
|
||||
exe_basename = "testit"
|
||||
src_dir = self.getSourceDir()
|
||||
@@ -44,12 +44,16 @@ class ModuleCacheTestcaseUniversal(TestBase):
|
||||
self.yaml2obj(yaml_path, exe)
|
||||
self.assertTrue(os.path.exists(exe))
|
||||
# Create a module with no dependencies.
|
||||
self.runCmd('target create -d --arch x86_64 %s' % (exe))
|
||||
self.runCmd('image dump symtab %s' % (exe_basename))
|
||||
self.runCmd('target create -d --arch arm64 %s' % (exe))
|
||||
self.runCmd('image dump symtab %s' % (exe_basename))
|
||||
self.runCmd("target create -d --arch x86_64 %s" % (exe))
|
||||
self.runCmd("image dump symtab %s" % (exe_basename))
|
||||
self.runCmd("target create -d --arch arm64 %s" % (exe))
|
||||
self.runCmd("image dump symtab %s" % (exe_basename))
|
||||
|
||||
cache_files = self.get_module_cache_files(exe_basename)
|
||||
|
||||
self.assertEqual(len(cache_files), 2,
|
||||
"make sure there are two files in the module cache directory (%s) for %s" % (self.cache_dir, exe_basename))
|
||||
self.assertEqual(
|
||||
len(cache_files),
|
||||
2,
|
||||
"make sure there are two files in the module cache directory (%s) for %s"
|
||||
% (self.cache_dir, exe_basename),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user