summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/lldb/source/Expression
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Expression')
-rw-r--r--contrib/llvm/tools/lldb/source/Expression/ClangASTSource.cpp47
-rw-r--r--contrib/llvm/tools/lldb/source/Expression/ClangExpressionDeclMap.cpp143
-rw-r--r--contrib/llvm/tools/lldb/source/Expression/ClangExpressionParser.cpp9
-rw-r--r--contrib/llvm/tools/lldb/source/Expression/ClangFunction.cpp15
-rw-r--r--contrib/llvm/tools/lldb/source/Expression/ClangUserExpression.cpp96
-rw-r--r--contrib/llvm/tools/lldb/source/Expression/DWARFExpression.cpp88
-rw-r--r--contrib/llvm/tools/lldb/source/Expression/IRForTarget.cpp6
-rw-r--r--contrib/llvm/tools/lldb/source/Expression/IRInterpreter.cpp50
-rw-r--r--contrib/llvm/tools/lldb/source/Expression/IRMemoryMap.cpp6
-rw-r--r--contrib/llvm/tools/lldb/source/Expression/Materializer.cpp14
10 files changed, 316 insertions, 158 deletions
diff --git a/contrib/llvm/tools/lldb/source/Expression/ClangASTSource.cpp b/contrib/llvm/tools/lldb/source/Expression/ClangASTSource.cpp
index 49513d7..316efdf9 100644
--- a/contrib/llvm/tools/lldb/source/Expression/ClangASTSource.cpp
+++ b/contrib/llvm/tools/lldb/source/Expression/ClangASTSource.cpp
@@ -878,31 +878,34 @@ FindObjCMethodDeclsWithOrigin (unsigned int current_id,
if (!result[0])
return false;
- ObjCMethodDecl *result_method = dyn_cast<ObjCMethodDecl>(result[0]);
-
- if (!result_method)
- return false;
-
- Decl *copied_decl = ast_importer->CopyDecl(ast_context, &result_method->getASTContext(), result_method);
-
- if (!copied_decl)
- return false;
-
- ObjCMethodDecl *copied_method_decl = dyn_cast<ObjCMethodDecl>(copied_decl);
-
- if (!copied_method_decl)
- return false;
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
-
- if (log)
+ for (NamedDecl *named_decl : result)
{
- ASTDumper dumper((Decl*)copied_method_decl);
- log->Printf(" CAS::FOMD[%d] found (%s) %s", current_id, log_info, dumper.GetCString());
+ ObjCMethodDecl *result_method = dyn_cast<ObjCMethodDecl>(named_decl);
+
+ if (!result_method)
+ return false;
+
+ Decl *copied_decl = ast_importer->CopyDecl(ast_context, &result_method->getASTContext(), result_method);
+
+ if (!copied_decl)
+ return false;
+
+ ObjCMethodDecl *copied_method_decl = dyn_cast<ObjCMethodDecl>(copied_decl);
+
+ if (!copied_method_decl)
+ return false;
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+
+ if (log)
+ {
+ ASTDumper dumper((Decl*)copied_method_decl);
+ log->Printf(" CAS::FOMD[%d] found (%s) %s", current_id, log_info, dumper.GetCString());
+ }
+
+ context.AddNamedDecl(copied_method_decl);
}
- context.AddNamedDecl(copied_method_decl);
-
return true;
}
diff --git a/contrib/llvm/tools/lldb/source/Expression/ClangExpressionDeclMap.cpp b/contrib/llvm/tools/lldb/source/Expression/ClangExpressionDeclMap.cpp
index 072e781..87c984d 100644
--- a/contrib/llvm/tools/lldb/source/Expression/ClangExpressionDeclMap.cpp
+++ b/contrib/llvm/tools/lldb/source/Expression/ClangExpressionDeclMap.cpp
@@ -21,6 +21,7 @@
#include "lldb/Core/Error.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectVariable.h"
@@ -514,6 +515,7 @@ FindCodeSymbolInContext
{
case eSymbolTypeCode:
case eSymbolTypeResolver:
+ case eSymbolTypeReExported:
sc_list.Append(sym_ctx);
break;
@@ -546,7 +548,8 @@ ClangExpressionDeclMap::GetFunctionAddress
FindCodeSymbolInContext(name, m_parser_vars->m_sym_ctx, sc_list);
- if (!sc_list.GetSize())
+ uint32_t sc_list_size = sc_list.GetSize();
+ if (sc_list_size == 0)
{
// We occasionally get debug information in which a const function is reported
// as non-const, so the mangled name is wrong. This is a hack to compensate.
@@ -562,40 +565,64 @@ ClangExpressionDeclMap::GetFunctionAddress
log->Printf("Failed to find symbols given non-const name %s; trying %s", name.GetCString(), fixed_name.GetCString());
FindCodeSymbolInContext(fixed_name, m_parser_vars->m_sym_ctx, sc_list);
+ sc_list_size = sc_list.GetSize();
}
}
-
- if (!sc_list.GetSize())
- return false;
-
- SymbolContext sym_ctx;
- sc_list.GetContextAtIndex(0, sym_ctx);
- const Address *func_so_addr = NULL;
- bool is_indirect_function = false;
-
- if (sym_ctx.function)
- func_so_addr = &sym_ctx.function->GetAddressRange().GetBaseAddress();
- else if (sym_ctx.symbol) {
- func_so_addr = &sym_ctx.symbol->GetAddress();
- is_indirect_function = sym_ctx.symbol->IsIndirect();
- } else
- return false;
-
- if (!func_so_addr || !func_so_addr->IsValid())
- return false;
+ for (uint32_t i=0; i<sc_list_size; ++i)
+ {
+ SymbolContext sym_ctx;
+ sc_list.GetContextAtIndex(i, sym_ctx);
- func_addr = func_so_addr->GetCallableLoadAddress (target, is_indirect_function);
+ const Address *func_so_addr = NULL;
+ bool is_indirect_function = false;
+ if (sym_ctx.function)
+ func_so_addr = &sym_ctx.function->GetAddressRange().GetBaseAddress();
+ else if (sym_ctx.symbol)
+ {
+ if (sym_ctx.symbol->GetType() == eSymbolTypeReExported)
+ {
+ Symbol *reexported_symbol = sym_ctx.symbol->ResolveReExportedSymbol(*target);
+ if (reexported_symbol)
+ {
+ func_so_addr = &reexported_symbol->GetAddress();
+ is_indirect_function = reexported_symbol->IsIndirect();
+ }
+ }
+ else
+ {
+ func_so_addr = &sym_ctx.symbol->GetAddress();
+ is_indirect_function = sym_ctx.symbol->IsIndirect();
+ }
+ }
- return true;
+ if (func_so_addr && func_so_addr->IsValid())
+ {
+ lldb::addr_t load_addr = func_so_addr->GetCallableLoadAddress (target, is_indirect_function);
+
+ if (load_addr != LLDB_INVALID_ADDRESS)
+ {
+ func_addr = load_addr;
+ return true;
+ }
+ }
+ }
+ return false;
}
addr_t
-ClangExpressionDeclMap::GetSymbolAddress (Target &target, Process *process, const ConstString &name, lldb::SymbolType symbol_type)
+ClangExpressionDeclMap::GetSymbolAddress (Target &target,
+ Process *process,
+ const ConstString &name,
+ lldb::SymbolType symbol_type,
+ lldb_private::Module *module)
{
SymbolContextList sc_list;
- target.GetImages().FindSymbolsWithNameAndType(name, symbol_type, sc_list);
+ if (module)
+ module->FindSymbolsWithNameAndType(name, symbol_type, sc_list);
+ else
+ target.GetImages().FindSymbolsWithNameAndType(name, symbol_type, sc_list);
const uint32_t num_matches = sc_list.GetSize();
addr_t symbol_load_addr = LLDB_INVALID_ADDRESS;
@@ -623,6 +650,28 @@ ClangExpressionDeclMap::GetSymbolAddress (Target &target, Process *process, cons
symbol_load_addr = sym_address->GetCallableLoadAddress (&target, true);
break;
+ case eSymbolTypeReExported:
+ {
+ ConstString reexport_name = sym_ctx.symbol->GetReExportedSymbolName();
+ if (reexport_name)
+ {
+ ModuleSP reexport_module_sp;
+ ModuleSpec reexport_module_spec;
+ reexport_module_spec.GetPlatformFileSpec() = sym_ctx.symbol->GetReExportedSymbolSharedLibrary();
+ if (reexport_module_spec.GetPlatformFileSpec())
+ {
+ reexport_module_sp = target.GetImages().FindFirstModule(reexport_module_spec);
+ if (!reexport_module_sp)
+ {
+ reexport_module_spec.GetPlatformFileSpec().GetDirectory().Clear();
+ reexport_module_sp = target.GetImages().FindFirstModule(reexport_module_spec);
+ }
+ }
+ symbol_load_addr = GetSymbolAddress(target, process, sym_ctx.symbol->GetReExportedSymbolName(), symbol_type, reexport_module_sp.get());
+ }
+ }
+ break;
+
case eSymbolTypeData:
case eSymbolTypeRuntime:
case eSymbolTypeVariable:
@@ -680,11 +729,15 @@ ClangExpressionDeclMap::GetSymbolAddress (const ConstString &name, lldb::SymbolT
const Symbol *
ClangExpressionDeclMap::FindGlobalDataSymbol (Target &target,
- const ConstString &name)
+ const ConstString &name,
+ lldb_private::Module *module)
{
SymbolContextList sc_list;
- target.GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeAny, sc_list);
+ if (module)
+ module->FindSymbolsWithNameAndType(name, eSymbolTypeAny, sc_list);
+ else
+ target.GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeAny, sc_list);
const uint32_t matches = sc_list.GetSize();
for (uint32_t i=0; i<matches; ++i)
@@ -716,6 +769,28 @@ ClangExpressionDeclMap::FindGlobalDataSymbol (Target &target,
}
return symbol;
+ case eSymbolTypeReExported:
+ {
+ ConstString reexport_name = symbol->GetReExportedSymbolName();
+ if (reexport_name)
+ {
+ ModuleSP reexport_module_sp;
+ ModuleSpec reexport_module_spec;
+ reexport_module_spec.GetPlatformFileSpec() = symbol->GetReExportedSymbolSharedLibrary();
+ if (reexport_module_spec.GetPlatformFileSpec())
+ {
+ reexport_module_sp = target.GetImages().FindFirstModule(reexport_module_spec);
+ if (!reexport_module_sp)
+ {
+ reexport_module_spec.GetPlatformFileSpec().GetDirectory().Clear();
+ reexport_module_sp = target.GetImages().FindFirstModule(reexport_module_spec);
+ }
+ }
+ return FindGlobalDataSymbol(target, symbol->GetReExportedSymbolName(), reexport_module_sp.get());
+ }
+ }
+ break;
+
case eSymbolTypeCode: // We already lookup functions elsewhere
case eSymbolTypeVariable:
case eSymbolTypeLocal:
@@ -1286,7 +1361,7 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
if (sc_list.GetSize())
{
- Symbol *generic_symbol = NULL;
+ Symbol *extern_symbol = NULL;
Symbol *non_extern_symbol = NULL;
for (uint32_t index = 0, num_indices = sc_list.GetSize();
@@ -1315,8 +1390,15 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
}
else if (sym_ctx.symbol)
{
+ if (sym_ctx.symbol->GetType() == eSymbolTypeReExported)
+ {
+ sym_ctx.symbol = sym_ctx.symbol->ResolveReExportedSymbol(*target);
+ if (sym_ctx.symbol == NULL)
+ continue;
+ }
+
if (sym_ctx.symbol->IsExternal())
- generic_symbol = sym_ctx.symbol;
+ extern_symbol = sym_ctx.symbol;
else
non_extern_symbol = sym_ctx.symbol;
}
@@ -1324,9 +1406,9 @@ ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
if (!context.m_found.function_with_type_info)
{
- if (generic_symbol)
+ if (extern_symbol)
{
- AddOneFunction (context, NULL, generic_symbol, current_id);
+ AddOneFunction (context, NULL, extern_symbol, current_id);
context.m_found.function = true;
}
else if (non_extern_symbol)
@@ -1418,7 +1500,6 @@ ClangExpressionDeclMap::GetVariableValue (VariableSP &var,
return false;
}
- // commented out because of <rdar://problem/11024417>
ASTContext *ast = var_type->GetClangASTContext().getASTContext();
if (!ast)
diff --git a/contrib/llvm/tools/lldb/source/Expression/ClangExpressionParser.cpp b/contrib/llvm/tools/lldb/source/Expression/ClangExpressionParser.cpp
index d026f2f..94c217e 100644
--- a/contrib/llvm/tools/lldb/source/Expression/ClangExpressionParser.cpp
+++ b/contrib/llvm/tools/lldb/source/Expression/ClangExpressionParser.cpp
@@ -55,10 +55,6 @@
#include "llvm/Support/PathV1.h"
#include "llvm/Support/TargetSelect.h"
-#if defined(__FreeBSD__)
-#define USE_STANDARD_JIT
-#endif
-
#if defined (USE_STANDARD_JIT)
#include "llvm/ExecutionEngine/JIT.h"
#else
@@ -122,7 +118,6 @@ static FrontendAction *CreateFrontendBaseAction(CompilerInstance &CI) {
case ASTDump: return new ASTDumpAction();
case ASTPrint: return new ASTPrintAction();
- case ASTDumpXML: return new ASTDumpXMLAction();
case ASTView: return new ASTViewAction();
case DumpRawTokens: return new DumpRawTokensAction();
case DumpTokens: return new DumpTokensAction();
@@ -198,8 +193,6 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
llvm::InitializeAllAsmPrinters();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllDisassemblers();
-
- llvm::DisablePrettyStackTrace = true;
}
} InitializeLLVM;
@@ -321,6 +314,8 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
// Set CodeGen options
m_compiler->getCodeGenOpts().EmitDeclMetadata = true;
m_compiler->getCodeGenOpts().InstrumentFunctions = false;
+ m_compiler->getCodeGenOpts().DisableFPElim = true;
+ m_compiler->getCodeGenOpts().OmitLeafFramePointer = false;
// Disable some warnings.
m_compiler->getDiagnostics().setDiagnosticGroupMapping("unused-value", clang::diag::MAP_IGNORE, SourceLocation());
diff --git a/contrib/llvm/tools/lldb/source/Expression/ClangFunction.cpp b/contrib/llvm/tools/lldb/source/Expression/ClangFunction.cpp
index 177138d..b37044d 100644
--- a/contrib/llvm/tools/lldb/source/Expression/ClangFunction.cpp
+++ b/contrib/llvm/tools/lldb/source/Expression/ClangFunction.cpp
@@ -80,7 +80,6 @@ ClangFunction::ClangFunction
m_function_ptr (&function),
m_function_addr (),
m_function_return_type (),
- m_clang_ast_context (ast_context),
m_wrapper_function_name ("__lldb_function_caller"),
m_wrapper_struct_name ("__lldb_caller_struct"),
m_wrapper_args_addrs (),
@@ -112,7 +111,7 @@ ClangFunction::CompileFunction (Stream &errors)
// FIXME: How does clang tell us there's no return value? We need to handle that case.
unsigned num_errors = 0;
- std::string return_type_str (m_function_return_type.GetTypeName());
+ std::string return_type_str (m_function_return_type.GetTypeName().AsCString(""));
// Cons up the function we're going to wrap our call in, then compile it...
// We declare the function "extern "C"" because the compiler might be in C++
@@ -163,18 +162,18 @@ ClangFunction::CompileFunction (Stream &errors)
if (trust_function)
{
- type_name = function_clang_type.GetFunctionArgumentTypeAtIndex(i).GetTypeName();
+ type_name = function_clang_type.GetFunctionArgumentTypeAtIndex(i).GetTypeName().AsCString("");
}
else
{
ClangASTType clang_qual_type = m_arg_values.GetValueAtIndex(i)->GetClangType ();
if (clang_qual_type)
{
- type_name = clang_qual_type.GetTypeName();
+ type_name = clang_qual_type.GetTypeName().AsCString("");
}
else
{
- errors.Printf("Could not determine type of input value %lu.", i);
+ errors.Printf("Could not determine type of input value %zu.", i);
return 1;
}
}
@@ -345,7 +344,7 @@ ClangFunction::WriteFunctionArguments (ExecutionContext &exe_ctx,
size_t num_args = arg_values.GetSize();
if (num_args != m_arg_values.GetSize())
{
- errors.Printf ("Wrong number of arguments - was: %lu should be: %lu", num_args, m_arg_values.GetSize());
+ errors.Printf ("Wrong number of arguments - was: %zu should be: %zu", num_args, m_arg_values.GetSize());
return false;
}
@@ -629,5 +628,7 @@ ClangFunction::ExecuteFunction(
clang::ASTConsumer *
ClangFunction::ASTTransformer (clang::ASTConsumer *passthrough)
{
- return new ASTStructExtractor(passthrough, m_wrapper_struct_name.c_str(), *this);
+ m_struct_extractor.reset(new ASTStructExtractor(passthrough, m_wrapper_struct_name.c_str(), *this));
+
+ return m_struct_extractor.get();
}
diff --git a/contrib/llvm/tools/lldb/source/Expression/ClangUserExpression.cpp b/contrib/llvm/tools/lldb/source/Expression/ClangUserExpression.cpp
index 7f09f6f..e4f2830 100644
--- a/contrib/llvm/tools/lldb/source/Expression/ClangUserExpression.cpp
+++ b/contrib/llvm/tools/lldb/source/Expression/ClangUserExpression.cpp
@@ -95,15 +95,9 @@ ClangUserExpression::~ClangUserExpression ()
clang::ASTConsumer *
ClangUserExpression::ASTTransformer (clang::ASTConsumer *passthrough)
-{
- ClangASTContext *clang_ast_context = m_target->GetScratchClangASTContext();
-
- if (!clang_ast_context)
- return NULL;
-
- if (!m_result_synthesizer.get())
- m_result_synthesizer.reset(new ASTResultSynthesizer(passthrough,
- *m_target));
+{
+ m_result_synthesizer.reset(new ASTResultSynthesizer(passthrough,
+ *m_target));
return m_result_synthesizer.get();
}
@@ -508,6 +502,9 @@ ClangUserExpression::Parse (Stream &error_stream,
if (!m_expr_decl_map->WillParse(exe_ctx, m_materializer_ap.get()))
{
error_stream.PutCString ("error: current process state is unsuitable for expression parsing\n");
+
+ m_expr_decl_map.reset(); // We are being careful here in the case of breakpoint conditions.
+
return false;
}
@@ -525,7 +522,7 @@ ClangUserExpression::Parse (Stream &error_stream,
{
error_stream.Printf ("error: %d errors parsing expression\n", num_errors);
- m_expr_decl_map->DidParse();
+ m_expr_decl_map.reset(); // We are being careful here in the case of breakpoint conditions.
return false;
}
@@ -540,6 +537,8 @@ ClangUserExpression::Parse (Stream &error_stream,
exe_ctx,
m_can_interpret,
execution_policy);
+
+ m_expr_decl_map.reset(); // Make this go away since we don't need any of its state after parsing. This also gets rid of any ClangASTImporter::Minions.
if (jit_error.Success())
{
@@ -785,12 +784,9 @@ ClangUserExpression::FinalizeJITExecution (Stream &error_stream,
ExecutionResults
ClangUserExpression::Execute (Stream &error_stream,
ExecutionContext &exe_ctx,
- bool unwind_on_error,
- bool ignore_breakpoints,
+ const EvaluateExpressionOptions& options,
ClangUserExpression::ClangUserExpressionSP &shared_ptr_to_me,
- lldb::ClangExpressionVariableSP &result,
- bool run_others,
- uint32_t timeout_usec)
+ lldb::ClangExpressionVariableSP &result)
{
// The expression log is quite verbose, and if you're just tracking the execution of the
// expression, it's quite convenient to have these logs come out with the STEP log as well.
@@ -856,9 +852,18 @@ ClangUserExpression::Execute (Stream &error_stream,
}
else
{
+ const uint32_t timeout_usec = options.GetTimeoutUsec();
+ const bool debug = options.GetDebug();
+ const bool unwind_on_error = debug ? false : options.DoesUnwindOnError();
+ const bool ignore_breakpoints = debug ? false : options.DoesIgnoreBreakpoints();
const bool stop_others = true;
- const bool try_all_threads = run_others;
-
+ const bool try_all_threads = options.GetRunOthers();
+ lldb::BreakpointSP debug_bkpt_sp;
+ if (debug)
+ {
+ // TODO: push this down into the thread plan and let the plan manage it
+ debug_bkpt_sp = exe_ctx.GetTargetRef().CreateBreakpoint(m_jit_start_addr, false, false);
+ }
Address wrapper_address (m_jit_start_addr);
lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression (exe_ctx.GetThreadRef(),
wrapper_address,
@@ -893,6 +898,11 @@ ClangUserExpression::Execute (Stream &error_stream,
timeout_usec,
error_stream);
+ if (debug_bkpt_sp)
+ {
+ exe_ctx.GetTargetRef().RemoveBreakpointByID(debug_bkpt_sp->GetID());
+ }
+
if (exe_ctx.GetProcessPtr())
exe_ctx.GetProcessPtr()->SetRunningUserExpression(false);
@@ -947,48 +957,17 @@ ClangUserExpression::Execute (Stream &error_stream,
ExecutionResults
ClangUserExpression::Evaluate (ExecutionContext &exe_ctx,
- lldb_private::ExecutionPolicy execution_policy,
- lldb::LanguageType language,
- ResultType desired_type,
- bool unwind_on_error,
- bool ignore_breakpoints,
+ const EvaluateExpressionOptions& options,
const char *expr_cstr,
const char *expr_prefix,
lldb::ValueObjectSP &result_valobj_sp,
- bool run_others,
- uint32_t timeout_usec)
-{
- Error error;
- return EvaluateWithError (exe_ctx,
- execution_policy,
- language,
- desired_type,
- unwind_on_error,
- ignore_breakpoints,
- expr_cstr,
- expr_prefix,
- result_valobj_sp,
- error,
- run_others,
- timeout_usec);
-}
-
-ExecutionResults
-ClangUserExpression::EvaluateWithError (ExecutionContext &exe_ctx,
- lldb_private::ExecutionPolicy execution_policy,
- lldb::LanguageType language,
- ResultType desired_type,
- bool unwind_on_error,
- bool ignore_breakpoints,
- const char *expr_cstr,
- const char *expr_prefix,
- lldb::ValueObjectSP &result_valobj_sp,
- Error &error,
- bool run_others,
- uint32_t timeout_usec)
+ Error &error)
{
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
+ lldb_private::ExecutionPolicy execution_policy = options.GetExecutionPolicy();
+ const lldb::LanguageType language = options.GetLanguage();
+ const ResultType desired_type = options.DoesCoerceToId() ? ClangUserExpression::eResultTypeId : ClangUserExpression::eResultTypeAny;
ExecutionResults execution_results = eExecutionSetupError;
Process *process = exe_ctx.GetProcessPtr();
@@ -1046,13 +1025,10 @@ ClangUserExpression::EvaluateWithError (ExecutionContext &exe_ctx,
log->Printf("== [ClangUserExpression::Evaluate] Executing expression ==");
execution_results = user_expression_sp->Execute (error_stream,
- exe_ctx,
- unwind_on_error,
- ignore_breakpoints,
- user_expression_sp,
- expr_result,
- run_others,
- timeout_usec);
+ exe_ctx,
+ options,
+ user_expression_sp,
+ expr_result);
if (execution_results != eExecutionCompleted)
{
diff --git a/contrib/llvm/tools/lldb/source/Expression/DWARFExpression.cpp b/contrib/llvm/tools/lldb/source/Expression/DWARFExpression.cpp
index e2ae19e..b36be8e 100644
--- a/contrib/llvm/tools/lldb/source/Expression/DWARFExpression.cpp
+++ b/contrib/llvm/tools/lldb/source/Expression/DWARFExpression.cpp
@@ -9,6 +9,10 @@
#include "lldb/Expression/DWARFExpression.h"
+// C Includes
+#include <inttypes.h>
+
+// C++ Includes
#include <vector>
#include "lldb/Core/DataEncoder.h"
@@ -28,20 +32,18 @@
#include "lldb/lldb-private-log.h"
-#include "lldb/Symbol/ClangASTType.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/Type.h"
-
#include "lldb/Target/ABI.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/StackID.h"
+#include "lldb/Target/Thread.h"
using namespace lldb;
using namespace lldb_private;
+// TODO- why is this also defined (in a better way) in DWARFDefines.cpp?
const char *
DW_OP_value_to_name (uint32_t val)
{
@@ -220,6 +222,7 @@ DW_OP_value_to_name (uint32_t val)
// DWARFExpression constructor
//----------------------------------------------------------------------
DWARFExpression::DWARFExpression() :
+ m_module_wp(),
m_data(),
m_reg_kind (eRegisterKindDWARF),
m_loclist_slide (LLDB_INVALID_ADDRESS)
@@ -227,6 +230,7 @@ DWARFExpression::DWARFExpression() :
}
DWARFExpression::DWARFExpression(const DWARFExpression& rhs) :
+ m_module_wp(rhs.m_module_wp),
m_data(rhs.m_data),
m_reg_kind (rhs.m_reg_kind),
m_loclist_slide(rhs.m_loclist_slide)
@@ -234,11 +238,14 @@ DWARFExpression::DWARFExpression(const DWARFExpression& rhs) :
}
-DWARFExpression::DWARFExpression(const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length) :
+DWARFExpression::DWARFExpression(lldb::ModuleSP module_sp, const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length) :
+ m_module_wp(),
m_data(data, data_offset, data_length),
m_reg_kind (eRegisterKindDWARF),
m_loclist_slide(LLDB_INVALID_ADDRESS)
{
+ if (module_sp)
+ m_module_wp = module_sp;
}
//----------------------------------------------------------------------
@@ -262,11 +269,12 @@ DWARFExpression::SetOpcodeData (const DataExtractor& data)
}
void
-DWARFExpression::CopyOpcodeData (const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length)
+DWARFExpression::CopyOpcodeData (lldb::ModuleSP module_sp, const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length)
{
const uint8_t *bytes = data.PeekData(data_offset, data_length);
if (bytes)
{
+ m_module_wp = module_sp;
m_data.SetData(DataBufferSP(new DataBufferHeap(bytes, data_length)));
m_data.SetByteOrder(data.GetByteOrder());
m_data.SetAddressByteSize(data.GetAddressByteSize());
@@ -274,8 +282,9 @@ DWARFExpression::CopyOpcodeData (const DataExtractor& data, lldb::offset_t data_
}
void
-DWARFExpression::SetOpcodeData (const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length)
+DWARFExpression::SetOpcodeData (lldb::ModuleSP module_sp, const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length)
{
+ m_module_wp = module_sp;
m_data.SetData(data, data_offset, data_length);
}
@@ -588,6 +597,9 @@ DWARFExpression::DumpLocation (Stream *s, lldb::offset_t offset, lldb::offset_t
// case DW_OP_APPLE_array_ref:
// s->PutCString("DW_OP_APPLE_array_ref");
// break;
+ case DW_OP_GNU_push_tls_address:
+ s->PutCString("DW_OP_GNU_push_tls_address"); // 0xe0
+ break;
case DW_OP_APPLE_uninit:
s->PutCString("DW_OP_APPLE_uninit"); // 0xF0
break;
@@ -919,7 +931,8 @@ GetOpcodeDataSize (const DataExtractor &data, const lldb::offset_t data_offset,
case DW_OP_form_tls_address: // 0x9b DWARF3
case DW_OP_call_frame_cfa: // 0x9c DWARF3
case DW_OP_stack_value: // 0x9f DWARF4
- return 0;
+ case DW_OP_GNU_push_tls_address: // 0xe0 GNU extension
+ return 0;
// Opcodes with a single 1 byte arguments
case DW_OP_const1u: // 0x08 1 1-byte constant
@@ -1221,6 +1234,8 @@ DWARFExpression::Evaluate
Error *error_ptr
) const
{
+ ModuleSP module_sp = m_module_wp.lock();
+
if (IsLocationList())
{
lldb::offset_t offset = 0;
@@ -1268,7 +1283,7 @@ DWARFExpression::Evaluate
if (length > 0 && lo_pc <= pc && pc < hi_pc)
{
- return DWARFExpression::Evaluate (exe_ctx, expr_locals, decl_map, reg_ctx, m_data, offset, length, m_reg_kind, initial_value_ptr, result, error_ptr);
+ return DWARFExpression::Evaluate (exe_ctx, expr_locals, decl_map, reg_ctx, module_sp, m_data, offset, length, m_reg_kind, initial_value_ptr, result, error_ptr);
}
offset += length;
}
@@ -1280,7 +1295,7 @@ DWARFExpression::Evaluate
}
// Not a location list, just a single expression.
- return DWARFExpression::Evaluate (exe_ctx, expr_locals, decl_map, reg_ctx, m_data, 0, m_data.GetByteSize(), m_reg_kind, initial_value_ptr, result, error_ptr);
+ return DWARFExpression::Evaluate (exe_ctx, expr_locals, decl_map, reg_ctx, module_sp, m_data, 0, m_data.GetByteSize(), m_reg_kind, initial_value_ptr, result, error_ptr);
}
@@ -1292,6 +1307,7 @@ DWARFExpression::Evaluate
ClangExpressionVariableList *expr_locals,
ClangExpressionDeclMap *decl_map,
RegisterContext *reg_ctx,
+ lldb::ModuleSP opcode_ctx,
const DataExtractor& opcodes,
const lldb::offset_t opcodes_offset,
const lldb::offset_t opcodes_length,
@@ -1347,7 +1363,7 @@ DWARFExpression::Evaluate
if (log && log->GetVerbose())
{
size_t count = stack.size();
- log->Printf("Stack before operation has %lu values:", count);
+ log->Printf("Stack before operation has %zu values:", count);
for (size_t i=0; i<count; ++i)
{
StreamString new_value;
@@ -2659,6 +2675,54 @@ DWARFExpression::Evaluate
return false;
}
break;
+
+ //----------------------------------------------------------------------
+ // OPCODE: DW_OP_GNU_push_tls_address
+ // OPERANDS: none
+ // DESCRIPTION: Pops a TLS offset from the stack, converts it to
+ // an absolute value, and pushes it back on.
+ //----------------------------------------------------------------------
+ case DW_OP_GNU_push_tls_address:
+ {
+ if (stack.size() < 1)
+ {
+ if (error_ptr)
+ error_ptr->SetErrorString("DW_OP_GNU_push_tls_address needs an argument.");
+ return false;
+ }
+
+ if (!exe_ctx || !opcode_ctx)
+ {
+ if (error_ptr)
+ error_ptr->SetErrorString("No context to evaluate TLS within.");
+ return false;
+ }
+
+ Thread *thread = exe_ctx->GetThreadPtr();
+ if (!thread)
+ {
+ if (error_ptr)
+ error_ptr->SetErrorString("No thread to evaluate TLS within.");
+ return false;
+ }
+
+ // Lookup the TLS block address for this thread and module.
+ addr_t tls_addr = thread->GetThreadLocalData (opcode_ctx);
+
+ if (tls_addr == LLDB_INVALID_ADDRESS)
+ {
+ if (error_ptr)
+ error_ptr->SetErrorString ("No TLS data currently exists for this thread.");
+ return false;
+ }
+
+ // Convert the TLS offset into the absolute address.
+ Scalar tmp = stack.back().ResolveValue(exe_ctx);
+ stack.back() = tmp + tls_addr;
+ stack.back().SetValueType (Value::eValueTypeLoadAddress);
+ }
+ break;
+
default:
if (log)
log->Printf("Unhandled opcode %s in DWARFExpression.", DW_OP_value_to_name(op));
@@ -2675,7 +2739,7 @@ DWARFExpression::Evaluate
else if (log && log->GetVerbose())
{
size_t count = stack.size();
- log->Printf("Stack after operation has %lu values:", count);
+ log->Printf("Stack after operation has %zu values:", count);
for (size_t i=0; i<count; ++i)
{
StreamString new_value;
diff --git a/contrib/llvm/tools/lldb/source/Expression/IRForTarget.cpp b/contrib/llvm/tools/lldb/source/Expression/IRForTarget.cpp
index dc27b65..792cc50 100644
--- a/contrib/llvm/tools/lldb/source/Expression/IRForTarget.cpp
+++ b/contrib/llvm/tools/lldb/source/Expression/IRForTarget.cpp
@@ -356,7 +356,7 @@ IRForTarget::ResolveFunctionPointers(llvm::Module &llvm_module)
if (value_ptr)
*value_ptr = value;
-
+
fun->replaceAllUsesWith(value);
}
@@ -2014,7 +2014,7 @@ IRForTarget::ReplaceStaticLiterals (llvm::BasicBlock &basic_block)
}
ss.flush();
- log->Printf("Found ConstantFP with size %lu and raw data %s", operand_data_size, s.c_str());
+ log->Printf("Found ConstantFP with size %zu and raw data %s", operand_data_size, s.c_str());
}
lldb_private::DataBufferHeap data(operand_data_size, 0);
@@ -2477,7 +2477,7 @@ IRForTarget::ReplaceVariables (Function &llvm_function)
}
if (log)
- log->Printf("Total structure [align %" PRId64 ", size %lu]", alignment, size);
+ log->Printf("Total structure [align %" PRId64 ", size %zu]", alignment, size);
return true;
}
diff --git a/contrib/llvm/tools/lldb/source/Expression/IRInterpreter.cpp b/contrib/llvm/tools/lldb/source/Expression/IRInterpreter.cpp
index dcbf584..71ef8d6 100644
--- a/contrib/llvm/tools/lldb/source/Expression/IRInterpreter.cpp
+++ b/contrib/llvm/tools/lldb/source/Expression/IRInterpreter.cpp
@@ -14,6 +14,7 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Expression/IRMemoryMap.h"
#include "lldb/Expression/IRInterpreter.h"
+#include "lldb/Host/Endian.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
@@ -321,13 +322,19 @@ public:
if (!ResolveConstantValue(resolved_value, constant))
return false;
- const uint64_t *raw_data = resolved_value.getRawData();
-
+ lldb_private::StreamString buffer (lldb_private::Stream::eBinary,
+ m_memory_map.GetAddressByteSize(),
+ m_memory_map.GetByteOrder());
+
size_t constant_size = m_target_data.getTypeStoreSize(constant->getType());
+ const uint64_t *raw_data = resolved_value.getRawData();
+
+ buffer.PutRawBytes(raw_data, constant_size, lldb::endian::InlHostByteOrder());
+
lldb_private::Error write_error;
- m_memory_map.WriteMemory(process_address, (uint8_t*)raw_data, constant_size, write_error);
+ m_memory_map.WriteMemory(process_address, (const uint8_t*)buffer.GetData(), constant_size, write_error);
return write_error.Success();
}
@@ -517,6 +524,7 @@ IRInterpreter::CanInterpret (llvm::Module &module,
case Instruction::SRem:
case Instruction::Store:
case Instruction::Sub:
+ case Instruction::Trunc:
case Instruction::UDiv:
case Instruction::URem:
case Instruction::Xor:
@@ -1162,6 +1170,42 @@ IRInterpreter::Interpret (llvm::Module &module,
}
}
break;
+ case Instruction::Trunc:
+ {
+ const TruncInst *trunc_inst = dyn_cast<TruncInst>(inst);
+
+ if (!trunc_inst)
+ {
+ if (log)
+ log->Printf("getOpcode() returns Trunc, but instruction is not a TruncInst");
+ error.SetErrorToGenericError();
+ error.SetErrorString(interpreter_internal_error);
+ return false;
+ }
+
+ Value *src_operand = trunc_inst->getOperand(0);
+
+ lldb_private::Scalar I;
+
+ if (!frame.EvaluateValue(I, src_operand, module))
+ {
+ if (log)
+ log->Printf("Couldn't evaluate %s", PrintValue(src_operand).c_str());
+ error.SetErrorToGenericError();
+ error.SetErrorString(bad_value_error);
+ return false;
+ }
+
+ frame.AssignValue(inst, I, module);
+
+ if (log)
+ {
+ log->Printf("Interpreted a Trunc");
+ log->Printf(" Src : %s", frame.SummarizeValue(src_operand).c_str());
+ log->Printf(" = : %s", frame.SummarizeValue(inst).c_str());
+ }
+ }
+ break;
case Instruction::Load:
{
const LoadInst *load_inst = dyn_cast<LoadInst>(inst);
diff --git a/contrib/llvm/tools/lldb/source/Expression/IRMemoryMap.cpp b/contrib/llvm/tools/lldb/source/Expression/IRMemoryMap.cpp
index ef362ba..53f74ae 100644
--- a/contrib/llvm/tools/lldb/source/Expression/IRMemoryMap.cpp
+++ b/contrib/llvm/tools/lldb/source/Expression/IRMemoryMap.cpp
@@ -74,15 +74,15 @@ IRMemoryMap::FindSpace (size_t size)
{
case 4:
{
- uint32_t random_data = random();
+ uint32_t random_data = rand();
candidate = random_data;
candidate &= ~0xfffull;
break;
}
case 8:
{
- uint32_t random_low = random();
- uint32_t random_high = random();
+ uint32_t random_low = rand();
+ uint32_t random_high = rand();
candidate = random_high;
candidate <<= 32ull;
candidate |= random_low;
diff --git a/contrib/llvm/tools/lldb/source/Expression/Materializer.cpp b/contrib/llvm/tools/lldb/source/Expression/Materializer.cpp
index 8a1900e..fb9522f 100644
--- a/contrib/llvm/tools/lldb/source/Expression/Materializer.cpp
+++ b/contrib/llvm/tools/lldb/source/Expression/Materializer.cpp
@@ -461,17 +461,11 @@ public:
}
else
{
- Error get_address_error;
- lldb::ValueObjectSP addr_of_valobj_sp = valobj_sp->AddressOf(get_address_error);
- if (get_address_error.Success())
+ lldb::addr_t addr_of_valobj = valobj_sp->GetAddressOf();
+ if (addr_of_valobj != LLDB_INVALID_ADDRESS)
{
- DataExtractor valobj_extractor;
- addr_of_valobj_sp->GetData(valobj_extractor);
- lldb::offset_t offset = 0;
- lldb::addr_t addr_of_valobj_addr = valobj_extractor.GetAddress(&offset);
-
Error write_error;
- map.WritePointerToMemory(load_addr, addr_of_valobj_addr, write_error);
+ map.WritePointerToMemory(load_addr, addr_of_valobj, write_error);
if (!write_error.Success())
{
@@ -839,7 +833,7 @@ public:
name,
address,
eAddressTypeLoad,
- ret->GetByteSize());
+ map.GetAddressByteSize());
}
ret->ValueUpdated();
OpenPOWER on IntegriCloud