[Lldb-commits] [PATCH] D76532: Internal expressions should not increment the next result variable numbering

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 20 15:45:11 PDT 2020


jingham created this revision.
jingham added a reviewer: davide.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

For instance, breakpoints run an expression when evaluating a condition.  If each of these expression evaluations incremented the result numbering, you could end up running an expression, and getting:

(lldb) expression foo
$1 = ...

Then do a continue, and then:

(lldb) expression foo
$14532 =

That would be disconcerting...

There was code (but no test, alas) to make this work, but when we refactored the PersistentExpression class, this got broken.

This patch goes back to using the original method of computing the number.  But I also changed the API's a bit.  When you went to get a result variable name in the current method you had to do:

  auto prefix = persistent_expression_state->GetPersistentVariablePrefix();
   ConstString persistent_variable_name =
      persistent_expression_state->GetNextPersistentVariableName(target,
                                                                 prefix);

The persistent variable prefix is only ever used to make the persistent variable name, so having this be done in two steps is unnecessary.  It was also odd that you needed the target - that was only because we the "next result variable index" had been errantly moved into the target.  So I made GetNextPersistentVariableName the public interface, and passed in only the is_error bool.  I left the GetPersistentVariablePrefix in as a protected method - it doesn't do anything for C, but it is used for swift.

I also added a test.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76532

Files:
  lldb/include/lldb/Expression/ExpressionVariable.h
  lldb/include/lldb/Target/Target.h
  lldb/source/Core/ValueObject.cpp
  lldb/source/Expression/ExpressionVariable.cpp
  lldb/source/Expression/Materializer.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/source/Target/ABI.cpp
  lldb/test/API/commands/expression/result_numbering/Makefile
  lldb/test/API/commands/expression/result_numbering/TestResultNumbering.py
  lldb/test/API/commands/expression/result_numbering/main.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76532.251784.patch
Type: text/x-patch
Size: 9325 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200320/82a9a87f/attachment-0001.bin>


More information about the lldb-commits mailing list