Allow expresions to have unique expression prefixes:
authorGreg Clayton <gclayton@apple.com>
Wed, 27 May 2015 22:32:39 +0000 (22:32 +0000)
committerGreg Clayton <gclayton@apple.com>
Wed, 27 May 2015 22:32:39 +0000 (22:32 +0000)
commit4e1042e1bf97313dab801d43a6aed47204e9524a
treee106b6733b007de23a8a26d32ff4de19d0c4893e
parent815a6eb55d8e4f27ee85a7b0ff44212b8150824b
Allow expresions to have unique expression prefixes:

expr_options = lldb.SBExpressionOptions()
expr_options.SetPrefix('''
struct Foo {
   int a;
   int b;
   int c;
}
'''
expr_result = frame.EvaluateExpression ("Foo foo = { 1, 2, 3}; foo", expr_options)

This fixed a current issue with ptr_refs, cstr_refs and malloc_info so that they can work. If expressions define their own types and then return expression results that use those types, those types get copied into the target's AST context so they persist and the expression results can be still printed and used in future expressions. Code was added to the expression parser to copy the context in which types are defined if they are used as the expression results. So in the case of types defined by expressions, they get defined in a lldb_expr function and that function and _all_ of its statements get copied. Many types of statements are not supported in this copy (array subscript, lambdas, etc) so this causes expressions to fail as they can't copy the result types. To work around this issue I have added code that allows expressions to specify an expression specific prefix. Then when you evaluate the expression you can pass the "expr_options" and have types that can be correctly copied out into the target. I added this as a way to work around an issue, but I also think it is nice to be allowed to specify an expression prefix that can be reused by many expressions, so this feature is very useful.

<rdar://problem/21130675>

llvm-svn: 238365
lldb/examples/darwin/heap_find/heap.py
lldb/include/lldb/API/SBExpressionOptions.h
lldb/include/lldb/Target/Target.h
lldb/scripts/interface/SBExpressionOptions.i
lldb/source/API/SBExpressionOptions.cpp
lldb/source/Expression/ClangUserExpression.cpp