summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2019-05-02 10:12:56 +0000
committerRaphael Isemann <teemperor@gmail.com>2019-05-02 10:12:56 +0000
commit71569d0d523465203ba465a89c37d75075a5e2c2 (patch)
treec4fb9169881afb91cdb29de5d5736b7214ab6721 /lldb/packages/Python/lldbsuite
parent1136ea2d446dcf02d11cb1e9862e9d290eaa8a68 (diff)
downloadbcm5719-llvm-71569d0d523465203ba465a89c37d75075a5e2c2.tar.gz
bcm5719-llvm-71569d0d523465203ba465a89c37d75075a5e2c2.zip
Inject only relevant local variables in the expression evaluation context
Summary: In r259902, LLDB started injecting all the locals in every expression evaluation. This fixed a bunch of issues, but also caused others, mostly performance regressions on some codebases. The regressions were bad enough that we added a setting in r274783 to control the behavior and we have been shipping with the setting off to avoid the perf regressions. This patch changes the logic injecting the local variables to only inject the ones present in the expression typed by the user. The approach is fairly simple and just scans the typed expression for every local name. Hopefully this gives us the best of both world as it just realizes the types of the variables really used by the expression. Landing this requires the 2 other issues I pointed out today to be addressed but I wanted to gather comments right away. Original patch by Frédéric Riss! Reviewers: jingham, clayborg, friss, shafik Reviewed By: jingham, clayborg Subscribers: teemperor, labath, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D46551 llvm-svn: 359773
Diffstat (limited to 'lldb/packages/Python/lldbsuite')
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/TestMembersAndLocalsWithSameName.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/TestMembersAndLocalsWithSameName.py b/lldb/packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/TestMembersAndLocalsWithSameName.py
index 011cf499291..c07acf9c540 100644
--- a/lldb/packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/TestMembersAndLocalsWithSameName.py
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/member-and-local-vars-with-same-name/TestMembersAndLocalsWithSameName.py
@@ -155,7 +155,9 @@ class TestMembersAndLocalsWithSameName(TestBase):
frame = thread.GetSelectedFrame()
self.assertTrue(frame.IsValid())
+ self.enable_expression_log()
val = frame.EvaluateExpression("a")
+ self.disable_expression_log_and_check_for_locals(['a'])
self.assertTrue(val.IsValid())
self.assertEqual(val.GetValueAsUnsigned(), 12345)
@@ -189,6 +191,12 @@ class TestMembersAndLocalsWithSameName(TestBase):
self.assertTrue(val.IsValid())
self.assertEqual(val.GetValueAsUnsigned(), 10003)
+ self.enable_expression_log()
+ val = frame.EvaluateExpression("c-b")
+ self.disable_expression_log_and_check_for_locals(['c','b'])
+ self.assertTrue(val.IsValid())
+ self.assertEqual(val.GetValueAsUnsigned(), 1)
+
self.process.Continue()
self.assertTrue(
self.process.GetState() == lldb.eStateStopped,
@@ -211,6 +219,13 @@ class TestMembersAndLocalsWithSameName(TestBase):
self.assertTrue(val.IsValid())
self.assertEqual(val.GetValueAsUnsigned(), 778899)
+ self.enable_expression_log()
+ val = frame.EvaluateExpression("a+b")
+ self.disable_expression_log_and_check_for_locals(['a','b'])
+ self.assertTrue(val.IsValid())
+ self.assertEqual(val.GetValueAsUnsigned(), 3)
+
+
def _load_exe(self):
self.build()
@@ -234,7 +249,9 @@ class TestMembersAndLocalsWithSameName(TestBase):
frame = thread.GetSelectedFrame()
self.assertTrue(frame.IsValid())
+ self.enable_expression_log()
val = frame.EvaluateExpression("a")
+ self.disable_expression_log_and_check_for_locals([])
self.assertTrue(val.IsValid())
self.assertEqual(val.GetValueAsUnsigned(), 112233)
@@ -245,3 +262,23 @@ class TestMembersAndLocalsWithSameName(TestBase):
val = frame.EvaluateExpression("c")
self.assertTrue(val.IsValid())
self.assertEqual(val.GetValueAsUnsigned(), 778899)
+
+ def enable_expression_log(self):
+ log_file = os.path.join(self.getBuildDir(), "expr.log")
+ self.runCmd("log enable -f '%s' lldb expr" % (log_file))
+
+ def disable_expression_log_and_check_for_locals(self, variables):
+ log_file = os.path.join(self.getBuildDir(), "expr.log")
+ self.runCmd("log disable lldb expr")
+ local_var_regex = re.compile(r".*__lldb_local_vars::(.*);")
+ matched = []
+ with open(log_file, 'r') as log:
+ for line in log:
+ if line.find('LLDB_BODY_START') != -1:
+ break
+ m = re.match(local_var_regex, line)
+ if m:
+ self.assertIn(m.group(1), variables)
+ matched.append(m.group(1))
+ self.assertEqual([item for item in variables if item not in matched],
+ [])
OpenPOWER on IntegriCloud