summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Expression')
-rw-r--r--lldb/source/Expression/ClangExpression.cpp7
-rw-r--r--lldb/source/Expression/ClangFunction.cpp47
-rw-r--r--lldb/source/Expression/ClangStmtVisitor.cpp23
-rw-r--r--lldb/source/Expression/DWARFExpression.cpp3
-rw-r--r--lldb/source/Expression/Makefile14
5 files changed, 59 insertions, 35 deletions
diff --git a/lldb/source/Expression/ClangExpression.cpp b/lldb/source/Expression/ClangExpression.cpp
index 702c273db9f..2383faef054 100644
--- a/lldb/source/Expression/ClangExpression.cpp
+++ b/lldb/source/Expression/ClangExpression.cpp
@@ -195,9 +195,12 @@ static FrontendAction *CreateFrontendBaseAction(CompilerInstance &CI) {
ClangExpression::ClangExpression(const char *target_triple,
ClangExpressionDeclMap *decl_map) :
m_target_triple (),
- m_jit_mm_ptr (NULL),
+ m_decl_map (decl_map),
+ m_clang_ap (),
m_code_generator_ptr (NULL),
- m_decl_map (decl_map)
+ m_jit_mm_ptr (NULL),
+ m_execution_engine (),
+ m_jitted_functions ()
{
if (target_triple && target_triple[0])
m_target_triple = target_triple;
diff --git a/lldb/source/Expression/ClangFunction.cpp b/lldb/source/Expression/ClangFunction.cpp
index f833bab1320..3b775e5cb36 100644
--- a/lldb/source/Expression/ClangFunction.cpp
+++ b/lldb/source/Expression/ClangFunction.cpp
@@ -43,14 +43,19 @@ using namespace lldb_private;
//----------------------------------------------------------------------
ClangFunction::ClangFunction(const char *target_triple, ClangASTContext *ast_context, void *return_qualtype, const Address& functionAddress, const ValueList &arg_value_list) :
ClangExpression (target_triple, NULL),
- m_function_addr (functionAddress),
m_function_ptr (NULL),
- m_arg_values (arg_value_list),
- m_clang_ast_context (ast_context),
+ m_function_addr (functionAddress),
m_function_return_qual_type(return_qualtype),
+ m_clang_ast_context (ast_context),
m_wrapper_function_name ("__lldb_caller_function"),
m_wrapper_struct_name ("__lldb_caller_struct"),
+ m_wrapper_function_addr (),
+ m_wrapper_args_addrs (),
+ m_struct_layout (NULL),
+ m_arg_values (arg_value_list),
+ m_value_struct_size (0),
m_return_offset(0),
+ m_return_size (0),
m_compiled (false),
m_JITted (false)
{
@@ -59,12 +64,18 @@ ClangFunction::ClangFunction(const char *target_triple, ClangASTContext *ast_con
ClangFunction::ClangFunction(const char *target_triple, Function &function, ClangASTContext *ast_context, const ValueList &arg_value_list) :
ClangExpression (target_triple, NULL),
m_function_ptr (&function),
- m_arg_values (arg_value_list),
+ m_function_addr (),
+ m_function_return_qual_type (),
m_clang_ast_context (ast_context),
- m_function_return_qual_type (NULL),
m_wrapper_function_name ("__lldb_function_caller"),
m_wrapper_struct_name ("__lldb_caller_struct"),
- m_return_offset(0),
+ m_wrapper_function_addr (),
+ m_wrapper_args_addrs (),
+ m_struct_layout (NULL),
+ m_arg_values (arg_value_list),
+ m_value_struct_size (0),
+ m_return_offset (0),
+ m_return_size (0),
m_compiled (false),
m_JITted (false)
{
@@ -109,22 +120,24 @@ ClangFunction::CompileFunction (Stream &errors)
// to pull the defined arguments out of the function, then add the types from the
// arguments list for the variable arguments.
- size_t num_args = -1;
+ uint32_t num_args = UINT32_MAX;
bool trust_function = false;
// GetArgumentCount returns -1 for an unprototyped function.
if (m_function_ptr)
{
- num_args = m_function_ptr->GetArgumentCount();
- if (num_args != -1)
+ int num_func_args = m_function_ptr->GetArgumentCount();
+ if (num_func_args >= 0)
trust_function = true;
+ else
+ num_args = num_func_args;
}
- if (num_args == -1)
+ if (num_args == UINT32_MAX)
num_args = m_arg_values.GetSize();
std::string args_buffer; // This one stores the definition of all the args in "struct caller".
std::string args_list_buffer; // This one stores the argument list called from the structure.
- for (int i = 0; i < num_args; i++)
+ for (size_t i = 0; i < num_args; i++)
{
const char *type_string;
std::string type_stdstr;
@@ -157,7 +170,7 @@ ClangFunction::CompileFunction (Stream &errors)
char arg_buf[32];
args_buffer.append (" ");
args_buffer.append (type_string);
- snprintf(arg_buf, 31, "arg_%d", i);
+ snprintf(arg_buf, 31, "arg_%zd", i);
args_buffer.push_back (' ');
args_buffer.append (arg_buf);
args_buffer.append (";\n");
@@ -253,8 +266,8 @@ ClangFunction::WriteFunctionWrapper (ExecutionContext &exc_context, Stream &erro
}
// Next get the call address for the function:
- m_wrapper_fun_addr = GetFunctionAddress (m_wrapper_function_name.c_str());
- if (m_wrapper_fun_addr == LLDB_INVALID_ADDRESS)
+ m_wrapper_function_addr = GetFunctionAddress (m_wrapper_function_name.c_str());
+ if (m_wrapper_function_addr == LLDB_INVALID_ADDRESS)
return false;
return true;
@@ -322,7 +335,7 @@ ClangFunction::WriteFunctionArguments (ExecutionContext &exc_context, lldb::addr
return false;
}
- for (int i = 0; i < num_args; i++)
+ for (size_t i = 0; i < num_args; i++)
{
// FIXME: We should sanity check sizes.
@@ -366,7 +379,7 @@ ClangFunction::InsertFunction (ExecutionContext &exc_context, lldb::addr_t &args
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP);
if (log)
- log->Printf ("Call Address: 0x%llx Struct Address: 0x%llx.\n", m_wrapper_fun_addr, args_addr_ref);
+ log->Printf ("Call Address: 0x%llx Struct Address: 0x%llx.\n", m_wrapper_function_addr, args_addr_ref);
return true;
}
@@ -386,7 +399,7 @@ ClangFunction::GetThreadPlanToCallFunction (ExecutionContext &exc_context, lldb:
// Okay, now run the function:
- Address wrapper_address (NULL, m_wrapper_fun_addr);
+ Address wrapper_address (NULL, m_wrapper_function_addr);
ThreadPlan *new_plan = new ThreadPlanCallFunction (*exc_context.thread,
wrapper_address,
args_addr,
diff --git a/lldb/source/Expression/ClangStmtVisitor.cpp b/lldb/source/Expression/ClangStmtVisitor.cpp
index b3aecebaeac..cfe525068a5 100644
--- a/lldb/source/Expression/ClangStmtVisitor.cpp
+++ b/lldb/source/Expression/ClangStmtVisitor.cpp
@@ -37,6 +37,9 @@ GetScalarTypeForClangType (clang::ASTContext &ast_context, clang::QualType clang
switch (clang_type->getTypeClass())
{
+ default:
+ break;
+
case clang::Type::FunctionNoProto:
case clang::Type::FunctionProto:
break;
@@ -135,8 +138,8 @@ lldb_private::ClangStmtVisitor::ClangStmtVisitor
lldb_private::StreamString &strm
) :
m_ast_context (ast_context),
- m_variable_list (variable_list),
m_decl_map (decl_map),
+ m_variable_list (variable_list),
m_stream (strm)
{
}
@@ -477,22 +480,10 @@ lldb_private::ClangStmtVisitor::VisitStringLiteral (clang::StringLiteral *Str)
bool is_wide = Str->isWide();
size_t new_length = byte_length + (is_wide ? 1 : 2);
+
+ std::string null_terminated_string (Str->getStrData(), byte_length);
- uint8_t null_terminated_string[new_length];
-
- memcpy(&null_terminated_string[0], Str->getStrData(), byte_length);
-
- if(is_wide)
- {
- null_terminated_string[byte_length] = '\0';
- null_terminated_string[byte_length + 1] = '\0';
- }
- else
- {
- null_terminated_string[byte_length] = '\0';
- }
-
- Value *val = new Value(null_terminated_string, new_length);
+ Value *val = new Value((uint8_t*)null_terminated_string.c_str(), new_length);
val->SetContext(Value::eContextTypeOpaqueClangQualType, Str->getType().getAsOpaquePtr());
uint32_t val_idx = m_variable_list.AppendValue(val);
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index 3873766a07b..839cf2ef592 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -303,6 +303,9 @@ DWARFExpression::DumpLocation (Stream *s, uint32_t offset, uint32_t length, lldb
switch (level)
{
+ default:
+ break;
+
case lldb::eDescriptionLevelBrief:
if (offset > start_offset)
s->PutChar(' ');
diff --git a/lldb/source/Expression/Makefile b/lldb/source/Expression/Makefile
new file mode 100644
index 00000000000..fa4404f1813
--- /dev/null
+++ b/lldb/source/Expression/Makefile
@@ -0,0 +1,14 @@
+##===- source/Expression/Makefile --------------------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LLDB_LEVEL := ../..
+LIBRARYNAME := lldbExpression
+BUILD_ARCHIVE = 1
+
+include $(LLDB_LEVEL)/Makefile
OpenPOWER on IntegriCloud