Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lldb] Remove m_last_file_sp from SourceManager
Summary: ...and replace it with m_last_file_spec instead. When Source Cache is enabled, the value stored in m_last_file_sp is already in the Source Cache, and caching it again in SourceManager brings no extra benefit. All we need is to "remember" the last used file, and FileSpec can serve the same purpose. When Source Cache is disabled, the user explicitly requested no caching of source files, and therefore, m_last_file_sp should NOT be used. Bug: llvm.org/PR45310 Depends on D76805. Reviewers: labath, jingham Reviewed By: jingham Subscribers: labath, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D76806
- Loading branch information
1 parent
1f820fa
commit 865996d
Showing
5 changed files
with
721 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CXX_SOURCES := main-copy.cpp | ||
|
||
include Makefile.rules | ||
|
||
|
||
# Copy file into the build folder to enable the test to modify it. | ||
main-copy.cpp: main.cpp | ||
cp -f $< $@ |
69 changes: 69 additions & 0 deletions
69
lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
""" | ||
Tests large source files are not locked on Windows when source cache is disabled | ||
""" | ||
|
||
import lldb | ||
import os | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test import lldbutil | ||
from shutil import copy | ||
|
||
class SettingsUseSourceCacheTestCase(TestBase): | ||
|
||
mydir = TestBase.compute_mydir(__file__) | ||
NO_DEBUG_INFO_TESTCASE = True | ||
|
||
def test_set_use_source_cache_false(self): | ||
"""Test that after 'set use-source-cache false', files are not locked.""" | ||
self.set_use_source_cache_and_test(False) | ||
|
||
@skipIf(hostoslist=no_match(["windows"])) | ||
def test_set_use_source_cache_true(self): | ||
"""Test that after 'set use-source-cache false', files are locked.""" | ||
self.set_use_source_cache_and_test(True) | ||
|
||
def set_use_source_cache_and_test(self, is_cache_enabled): | ||
"""Common test for both True/False values of use-source-cache.""" | ||
self.build() | ||
|
||
# Enable/Disable source cache | ||
self.runCmd( | ||
"settings set use-source-cache " + | ||
("true" if is_cache_enabled else "false")) | ||
|
||
# Get paths for the main source file. | ||
src = self.getBuildArtifact("main-copy.cpp") | ||
self.assertTrue(src) | ||
|
||
# Make sure source file is bigger than 16K to trigger memory mapping | ||
self.assertGreater(os.stat(src).st_size, 4*4096) | ||
|
||
target, process, thread, breakpoint = lldbutil.run_to_name_breakpoint( | ||
self, | ||
"calc") | ||
|
||
# Show the source file contents to make sure LLDB loads src file. | ||
self.runCmd("source list") | ||
|
||
# Try deleting the source file. | ||
is_file_removed = self.removeFile(src) | ||
|
||
if is_cache_enabled: | ||
self.assertFalse( | ||
is_file_removed, | ||
"Source cache is enabled, but delete file succeeded") | ||
|
||
if not is_cache_enabled: | ||
self.assertTrue( | ||
is_file_removed, | ||
"Source cache is disabled, but delete file failed") | ||
|
||
def removeFile(self, src): | ||
"""Remove file and return true iff file was successfully removed.""" | ||
try: | ||
os.remove(src) | ||
return True | ||
except Exception: | ||
return False | ||
|
Oops, something went wrong.