diff options
| author | Sean Callanan <scallanan@apple.com> | 2010-10-29 00:29:03 +0000 |
|---|---|---|
| committer | Sean Callanan <scallanan@apple.com> | 2010-10-29 00:29:03 +0000 |
| commit | 322f529b37673527a61693f496b3b1ad5356f720 (patch) | |
| tree | e6cdc37e3a6badaa74c2d28590fb4bc61006d676 /lldb/source/Expression/ClangUserExpression.cpp | |
| parent | 5d6f6a061b5fa81addedba29ca26a276fd51e7cc (diff) | |
| download | bcm5719-llvm-322f529b37673527a61693f496b3b1ad5356f720.tar.gz bcm5719-llvm-322f529b37673527a61693f496b3b1ad5356f720.zip | |
Added a user-settable variable, 'target.expr-prefix',
which holds the name of a file whose contents are
prefixed to each expression. For example, if the file
~/lldb.prefix.header contains:
typedef unsigned short my_type;
then you can do this:
(lldb) settings set target.expr-prefix '~/lldb.prefix.header'
(lldb) expr sizeof(my_type)
(unsigned long) $0 = 2
When the variable is changed, the corresponding file
is loaded and its contents are fetched into a string
that is stored along with the target. This string
is then passed to each expression and inserted into
it during parsing, like this:
typedef unsigned short my_type;
void
$__lldb_expr(void *$__lldb_arg)
{
sizeof(my_type);
}
llvm-svn: 117627
Diffstat (limited to 'lldb/source/Expression/ClangUserExpression.cpp')
| -rw-r--r-- | lldb/source/Expression/ClangUserExpression.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lldb/source/Expression/ClangUserExpression.cpp b/lldb/source/Expression/ClangUserExpression.cpp index 60f3e754a26..bd67bbdae62 100644 --- a/lldb/source/Expression/ClangUserExpression.cpp +++ b/lldb/source/Expression/ClangUserExpression.cpp @@ -35,8 +35,10 @@ using namespace lldb_private; -ClangUserExpression::ClangUserExpression (const char *expr) : +ClangUserExpression::ClangUserExpression (const char *expr, + const char *expr_prefix) : m_expr_text(expr), + m_expr_prefix(expr_prefix), m_transformed_text(), m_jit_addr(LLDB_INVALID_ADDRESS), m_cplusplus(false), @@ -129,12 +131,14 @@ ClangUserExpression::Parse (Stream &error_stream, ExecutionContext &exe_ctx) if (m_cplusplus) { - m_transformed_stream.Printf("typedef unsigned short unichar; \n" + m_transformed_stream.Printf("%s \n" + "typedef unsigned short unichar; \n" "void \n" "$__lldb_class::%s(void *$__lldb_arg) \n" "{ \n" " %s; \n" "} \n", + m_expr_prefix.c_str(), FunctionName(), m_expr_text.c_str()); @@ -142,12 +146,14 @@ ClangUserExpression::Parse (Stream &error_stream, ExecutionContext &exe_ctx) } else { - m_transformed_stream.Printf("typedef unsigned short unichar;\n" + m_transformed_stream.Printf("%s \n" + "typedef unsigned short unichar;\n" "void \n" "%s(void *$__lldb_arg) \n" "{ \n" " %s; \n" "} \n", + m_expr_prefix.c_str(), FunctionName(), m_expr_text.c_str()); } @@ -425,11 +431,13 @@ ClangUserExpression::DwarfOpcodeStream () lldb::ValueObjectSP -ClangUserExpression::Evaluate (ExecutionContext &exe_ctx, const char *expr_cstr) +ClangUserExpression::Evaluate (ExecutionContext &exe_ctx, + const char *expr_cstr, + const char *expr_prefix) { Error error; lldb::ValueObjectSP result_valobj_sp; - ClangUserExpression user_expression (expr_cstr); + ClangUserExpression user_expression (expr_cstr, expr_prefix); StreamString error_stream; |

