[Lldb-commits] [PATCH] D55318: [Expressions] Add support of expressions evaluation in some object's context

Aleksandr Urakov via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Dec 5 05:55:24 PST 2018


aleksandr.urakov created this revision.
aleksandr.urakov added reviewers: teemperor, clayborg, jingham, zturner, labath, davide, spyffe.
aleksandr.urakov added a project: LLDB.
Herald added subscribers: lldb-commits, abidh.

This patch adds support of expression evaluation in a context of some object. Consider the following example:

  struct S {
    int a = 11;
    int b = 12;
  };
  
  int main() {
    S s;
    int a = 1;
    int b = 2;
    // We have stopped here
    return 0;
  }

This patch allows to do something like that:

  lldb.frame.FindVariable("s").EvaluateExpression("a + b")

and the result will be `33` (not `3`) because fields `a` and `b` of `s` will be used (not locals `a` and `b`).

This is achieved by replacing of `this` type and object for the expression. This has some limitations: an expression can be evaluated only for values located in the debuggee process memory (they must have an address of `eAddressTypeLoad` type).

Our company needs this functionality to implement some UI visualization of variables in our IDEs. I understand that the community may be not interested in this functionality, and I'll just abandon it if so. But if the community is interested in this, we can save some time on merging in the future :)


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D55318

Files:
  include/lldb/API/SBValue.h
  include/lldb/Expression/ExpressionSourceCode.h
  include/lldb/Expression/UserExpression.h
  include/lldb/Symbol/ClangASTContext.h
  include/lldb/Symbol/TypeSystem.h
  include/lldb/Target/Target.h
  packages/Python/lldbsuite/test/expression_command/context-object/Makefile
  packages/Python/lldbsuite/test/expression_command/context-object/TestContextObject.py
  packages/Python/lldbsuite/test/expression_command/context-object/main.cpp
  scripts/interface/SBValue.i
  source/API/SBValue.cpp
  source/Breakpoint/BreakpointLocation.cpp
  source/Breakpoint/Watchpoint.cpp
  source/Commands/CommandObjectExpression.cpp
  source/Expression/ExpressionSourceCode.cpp
  source/Expression/UserExpression.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
  source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
  source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
  source/Symbol/ClangASTContext.cpp
  source/Target/Target.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55318.176800.patch
Type: text/x-patch
Size: 30747 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20181205/8c21891a/attachment-0001.bin>


More information about the lldb-commits mailing list