2010-06-09 00:52:24 +08:00
|
|
|
//===-- ClangExpressionDeclMap.cpp -----------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/Expression/ClangExpressionDeclMap.h"
|
|
|
|
|
|
|
|
// C Includes
|
|
|
|
// C++ Includes
|
|
|
|
// Other libraries and framework includes
|
|
|
|
// Project includes
|
2010-09-23 11:01:22 +08:00
|
|
|
#include "clang/AST/DeclarationName.h"
|
2010-11-02 07:22:47 +08:00
|
|
|
#include "clang/AST/Decl.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/lldb-private.h"
|
|
|
|
#include "lldb/Core/Address.h"
|
2010-07-16 08:09:46 +08:00
|
|
|
#include "lldb/Core/Error.h"
|
2010-06-23 08:47:48 +08:00
|
|
|
#include "lldb/Core/Log.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/Module.h"
|
2011-05-10 04:18:18 +08:00
|
|
|
#include "lldb/Core/RegisterValue.h"
|
2010-12-16 11:17:46 +08:00
|
|
|
#include "lldb/Core/ValueObjectConstResult.h"
|
2011-02-02 07:43:26 +08:00
|
|
|
#include "lldb/Expression/ASTDumper.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Expression/ClangASTSource.h"
|
2010-08-11 11:57:18 +08:00
|
|
|
#include "lldb/Expression/ClangPersistentVariables.h"
|
2011-02-01 09:31:41 +08:00
|
|
|
#include "lldb/Host/Endian.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Symbol/ClangASTContext.h"
|
2010-11-13 11:52:47 +08:00
|
|
|
#include "lldb/Symbol/ClangNamespaceDecl.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Symbol/CompileUnit.h"
|
|
|
|
#include "lldb/Symbol/Function.h"
|
|
|
|
#include "lldb/Symbol/ObjectFile.h"
|
|
|
|
#include "lldb/Symbol/SymbolContext.h"
|
2011-10-12 08:12:34 +08:00
|
|
|
#include "lldb/Symbol/SymbolVendor.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Symbol/Type.h"
|
|
|
|
#include "lldb/Symbol/TypeList.h"
|
|
|
|
#include "lldb/Symbol/Variable.h"
|
|
|
|
#include "lldb/Symbol/VariableList.h"
|
2010-07-21 07:31:16 +08:00
|
|
|
#include "lldb/Target/ExecutionContext.h"
|
2010-07-16 08:09:46 +08:00
|
|
|
#include "lldb/Target/Process.h"
|
2010-10-06 04:18:48 +08:00
|
|
|
#include "lldb/Target/RegisterContext.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/StackFrame.h"
|
2010-07-21 07:31:16 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2010-12-07 09:56:02 +08:00
|
|
|
#include "lldb/Target/Thread.h"
|
2010-11-02 07:22:47 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
Just like functions can have a basename and a mangled/demangled name, variable
can too. So now the lldb_private::Variable class has support for this.
Variables now have support for having a basename ("i"), and a mangled name
("_ZN12_GLOBAL__N_11iE"), and a demangled name ("(anonymous namespace)::i").
Nowwhen searching for a variable by name, users might enter the fully qualified
name, or just the basename. So new test functions were added to the Variable
and Mangled classes as:
bool NameMatches (const ConstString &name);
bool NameMatches (const RegularExpression ®ex);
I also modified "ClangExpressionDeclMap::FindVariableInScope" to also search
for global variables that are not in the current file scope by first starting
with the current module, then moving on to all modules.
Fixed an issue in the DWARF parser that could cause a varaible to get parsed
more than once. Now, once we have parsed a VariableSP for a DIE, we cache
the result even if a variable wasn't made so we don't do any re-parsing. Some
DW_TAG_variable DIEs don't have locations, or are missing vital info that
stops a debugger from being able to display anything for it, we parse a NULL
variable shared pointer for these DIEs so we don't keep trying to reparse it.
llvm-svn: 119085
2010-11-15 06:13:40 +08:00
|
|
|
using namespace lldb;
|
2010-06-09 00:52:24 +08:00
|
|
|
using namespace lldb_private;
|
|
|
|
using namespace clang;
|
|
|
|
|
2011-01-13 16:53:35 +08:00
|
|
|
ClangExpressionDeclMap::ClangExpressionDeclMap (bool keep_result_in_memory) :
|
2010-10-16 06:48:33 +08:00
|
|
|
m_found_entities (),
|
|
|
|
m_struct_members (),
|
2011-04-12 03:41:40 +08:00
|
|
|
m_keep_result_in_memory (keep_result_in_memory),
|
2010-12-03 09:38:59 +08:00
|
|
|
m_parser_vars (),
|
2011-04-12 03:41:40 +08:00
|
|
|
m_struct_vars ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-03 09:38:59 +08:00
|
|
|
EnableStructVars();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ClangExpressionDeclMap::~ClangExpressionDeclMap()
|
2010-12-03 09:38:59 +08:00
|
|
|
{
|
2011-10-13 06:20:02 +08:00
|
|
|
// Note: The model is now that the parser's AST context and all associated
|
|
|
|
// data does not vanish until the expression has been executed. This means
|
|
|
|
// that valuable lookup data (like namespaces) doesn't vanish, but
|
|
|
|
|
|
|
|
DidParse();
|
2010-12-03 09:38:59 +08:00
|
|
|
DidDematerialize();
|
|
|
|
DisableStructVars();
|
|
|
|
}
|
|
|
|
|
2011-08-02 02:18:33 +08:00
|
|
|
bool
|
2010-12-14 10:59:59 +08:00
|
|
|
ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx)
|
2010-08-24 07:09:38 +08:00
|
|
|
{
|
2010-12-03 09:38:59 +08:00
|
|
|
EnableParserVars();
|
|
|
|
m_parser_vars->m_exe_ctx = &exe_ctx;
|
2011-09-22 12:58:26 +08:00
|
|
|
|
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
if (exe_ctx.GetFramePtr())
|
|
|
|
m_parser_vars->m_sym_ctx = exe_ctx.GetFramePtr()->GetSymbolContext(lldb::eSymbolContextEverything);
|
|
|
|
else if (exe_ctx.GetThreadPtr())
|
|
|
|
m_parser_vars->m_sym_ctx = exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(0)->GetSymbolContext(lldb::eSymbolContextEverything);
|
|
|
|
else if (exe_ctx.GetProcessPtr())
|
2011-09-17 16:33:22 +08:00
|
|
|
{
|
|
|
|
m_parser_vars->m_sym_ctx.Clear();
|
2011-09-22 12:58:26 +08:00
|
|
|
m_parser_vars->m_sym_ctx.target_sp = exe_ctx.GetTargetSP();
|
2011-09-17 16:33:22 +08:00
|
|
|
}
|
2011-09-22 12:58:26 +08:00
|
|
|
else if (target)
|
2011-09-17 16:33:22 +08:00
|
|
|
{
|
|
|
|
m_parser_vars->m_sym_ctx.Clear();
|
2011-09-22 12:58:26 +08:00
|
|
|
m_parser_vars->m_sym_ctx.target_sp = exe_ctx.GetTargetSP();
|
2011-09-17 16:33:22 +08:00
|
|
|
}
|
2011-09-16 02:41:04 +08:00
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
if (target)
|
|
|
|
{
|
|
|
|
m_parser_vars->m_persistent_vars = &target->GetPersistentVariables();
|
2011-08-02 02:18:33 +08:00
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
if (!target->GetScratchClangASTContext())
|
|
|
|
return false;
|
|
|
|
}
|
2011-08-02 02:18:33 +08:00
|
|
|
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
m_parser_vars->m_target_info = GetTargetInfo();
|
|
|
|
|
2011-08-02 02:18:33 +08:00
|
|
|
return true;
|
2010-12-03 09:38:59 +08:00
|
|
|
}
|
2010-10-26 08:31:56 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
void
|
|
|
|
ClangExpressionDeclMap::DidParse()
|
2010-12-03 09:38:59 +08:00
|
|
|
{
|
|
|
|
if (m_parser_vars.get())
|
|
|
|
{
|
2010-12-14 10:59:59 +08:00
|
|
|
for (size_t entity_index = 0, num_entities = m_found_entities.GetSize();
|
2010-12-03 09:38:59 +08:00
|
|
|
entity_index < num_entities;
|
|
|
|
++entity_index)
|
|
|
|
{
|
2010-12-14 10:59:59 +08:00
|
|
|
ClangExpressionVariableSP var_sp(m_found_entities.GetVariableAtIndex(entity_index));
|
|
|
|
if (var_sp &&
|
|
|
|
var_sp->m_parser_vars.get() &&
|
|
|
|
var_sp->m_parser_vars->m_lldb_value)
|
|
|
|
delete var_sp->m_parser_vars->m_lldb_value;
|
2010-12-03 09:38:59 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
var_sp->DisableParserVars();
|
2010-12-03 09:38:59 +08:00
|
|
|
}
|
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
for (size_t pvar_index = 0, num_pvars = m_parser_vars->m_persistent_vars->GetSize();
|
2010-12-03 09:38:59 +08:00
|
|
|
pvar_index < num_pvars;
|
|
|
|
++pvar_index)
|
|
|
|
{
|
2010-12-14 10:59:59 +08:00
|
|
|
ClangExpressionVariableSP pvar_sp(m_parser_vars->m_persistent_vars->GetVariableAtIndex(pvar_index));
|
|
|
|
if (pvar_sp)
|
|
|
|
pvar_sp->DisableParserVars();
|
2010-12-03 09:38:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
DisableParserVars();
|
2010-10-08 09:58:41 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-07-14 05:41:46 +08:00
|
|
|
// Interface for IRForTarget
|
|
|
|
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
ClangExpressionDeclMap::TargetInfo
|
|
|
|
ClangExpressionDeclMap::GetTargetInfo()
|
|
|
|
{
|
|
|
|
assert (m_parser_vars.get());
|
|
|
|
|
|
|
|
TargetInfo ret;
|
|
|
|
|
|
|
|
ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx;
|
2011-09-22 12:58:26 +08:00
|
|
|
if (exe_ctx)
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
{
|
2011-09-22 12:58:26 +08:00
|
|
|
Process *process = exe_ctx->GetProcessPtr();
|
|
|
|
if (process)
|
|
|
|
{
|
|
|
|
ret.byte_order = process->GetByteOrder();
|
|
|
|
ret.address_byte_size = process->GetAddressByteSize();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Target *target = exe_ctx->GetTargetPtr();
|
|
|
|
if (target)
|
|
|
|
{
|
|
|
|
ret.byte_order = target->GetArchitecture().GetByteOrder();
|
|
|
|
ret.address_byte_size = target->GetArchitecture().GetAddressByteSize();
|
|
|
|
}
|
|
|
|
}
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-10-16 06:48:33 +08:00
|
|
|
const ConstString &
|
|
|
|
ClangExpressionDeclMap::GetPersistentResultName ()
|
2010-08-12 09:56:52 +08:00
|
|
|
{
|
2010-12-03 09:38:59 +08:00
|
|
|
assert (m_struct_vars.get());
|
|
|
|
assert (m_parser_vars.get());
|
|
|
|
if (!m_struct_vars->m_result_name)
|
2010-12-14 10:59:59 +08:00
|
|
|
{
|
|
|
|
Target *target = m_parser_vars->GetTarget();
|
|
|
|
assert (target);
|
|
|
|
m_struct_vars->m_result_name = target->GetPersistentVariables().GetNextPersistentVariableName();
|
|
|
|
}
|
2010-12-03 09:38:59 +08:00
|
|
|
return m_struct_vars->m_result_name;
|
2010-08-12 09:56:52 +08:00
|
|
|
}
|
|
|
|
|
2010-12-16 11:17:46 +08:00
|
|
|
lldb::ClangExpressionVariableSP
|
|
|
|
ClangExpressionDeclMap::BuildIntegerVariable (const ConstString &name,
|
|
|
|
lldb_private::TypeFromParser type,
|
|
|
|
const llvm::APInt& value)
|
|
|
|
{
|
|
|
|
assert (m_parser_vars.get());
|
2011-08-02 02:18:33 +08:00
|
|
|
|
2011-03-31 08:19:25 +08:00
|
|
|
ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx;
|
2011-09-22 12:58:26 +08:00
|
|
|
if (exe_ctx == NULL)
|
|
|
|
return lldb::ClangExpressionVariableSP();
|
|
|
|
Target *target = exe_ctx->GetTargetPtr();
|
|
|
|
|
|
|
|
ASTContext *context(target->GetScratchClangASTContext()->getASTContext());
|
2010-12-16 11:17:46 +08:00
|
|
|
|
|
|
|
TypeFromUser user_type(ClangASTContext::CopyType(context,
|
|
|
|
type.GetASTContext(),
|
|
|
|
type.GetOpaqueQualType()),
|
|
|
|
context);
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
|
2011-03-31 08:19:25 +08:00
|
|
|
if (!m_parser_vars->m_persistent_vars->CreatePersistentVariable (exe_ctx->GetBestExecutionContextScope (),
|
|
|
|
name,
|
2011-01-04 10:41:41 +08:00
|
|
|
user_type,
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
m_parser_vars->m_target_info.byte_order,
|
|
|
|
m_parser_vars->m_target_info.address_byte_size))
|
2011-01-04 10:41:41 +08:00
|
|
|
return lldb::ClangExpressionVariableSP();
|
|
|
|
|
|
|
|
ClangExpressionVariableSP pvar_sp (m_parser_vars->m_persistent_vars->GetVariable(name));
|
|
|
|
|
|
|
|
if (!pvar_sp)
|
|
|
|
return lldb::ClangExpressionVariableSP();
|
2010-12-16 11:17:46 +08:00
|
|
|
|
2011-01-04 10:41:41 +08:00
|
|
|
uint8_t *pvar_data = pvar_sp->GetValueBytes();
|
|
|
|
if (pvar_data == NULL)
|
|
|
|
return lldb::ClangExpressionVariableSP();
|
2010-12-16 11:17:46 +08:00
|
|
|
|
|
|
|
uint64_t value64 = value.getLimitedValue();
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
|
2010-12-16 11:17:46 +08:00
|
|
|
size_t num_val_bytes = sizeof(value64);
|
2011-01-04 10:41:41 +08:00
|
|
|
size_t num_data_bytes = pvar_sp->GetByteSize();
|
2010-12-16 11:17:46 +08:00
|
|
|
|
|
|
|
size_t num_bytes = num_val_bytes;
|
|
|
|
if (num_bytes > num_data_bytes)
|
|
|
|
num_bytes = num_data_bytes;
|
|
|
|
|
2011-07-20 03:48:13 +08:00
|
|
|
for (size_t byte_idx = 0;
|
2010-12-16 11:17:46 +08:00
|
|
|
byte_idx < num_bytes;
|
|
|
|
++byte_idx)
|
|
|
|
{
|
|
|
|
uint64_t shift = byte_idx * 8;
|
|
|
|
uint64_t mask = 0xffll << shift;
|
|
|
|
uint8_t cur_byte = (uint8_t)((value64 & mask) >> shift);
|
|
|
|
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
switch (m_parser_vars->m_target_info.byte_order)
|
2010-12-16 11:17:46 +08:00
|
|
|
{
|
2011-01-04 10:41:41 +08:00
|
|
|
case eByteOrderBig:
|
|
|
|
// High Low
|
|
|
|
// Original: |AABBCCDDEEFFGGHH|
|
|
|
|
// Target: |EEFFGGHH|
|
|
|
|
|
|
|
|
pvar_data[num_data_bytes - (1 + byte_idx)] = cur_byte;
|
|
|
|
break;
|
|
|
|
case eByteOrderLittle:
|
|
|
|
// Target: |HHGGFFEE|
|
|
|
|
pvar_data[byte_idx] = cur_byte;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return lldb::ClangExpressionVariableSP();
|
2010-12-16 11:17:46 +08:00
|
|
|
}
|
|
|
|
}
|
2011-01-13 16:53:35 +08:00
|
|
|
|
|
|
|
pvar_sp->m_flags |= ClangExpressionVariable::EVIsFreezeDried;
|
2011-05-07 09:06:41 +08:00
|
|
|
pvar_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
|
|
|
|
pvar_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
|
2011-01-04 10:41:41 +08:00
|
|
|
|
|
|
|
return pvar_sp;
|
2010-12-16 11:17:46 +08:00
|
|
|
}
|
|
|
|
|
2011-05-07 09:06:41 +08:00
|
|
|
lldb::ClangExpressionVariableSP
|
|
|
|
ClangExpressionDeclMap::BuildCastVariable (const ConstString &name,
|
2011-07-30 10:42:06 +08:00
|
|
|
VarDecl *decl,
|
2011-05-07 09:06:41 +08:00
|
|
|
lldb_private::TypeFromParser type)
|
|
|
|
{
|
|
|
|
assert (m_parser_vars.get());
|
|
|
|
|
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
|
|
|
|
|
|
|
ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx;
|
2011-09-22 12:58:26 +08:00
|
|
|
if (exe_ctx == NULL)
|
|
|
|
return lldb::ClangExpressionVariableSP();
|
|
|
|
Target *target = exe_ctx->GetTargetPtr();
|
|
|
|
if (target == NULL)
|
|
|
|
return lldb::ClangExpressionVariableSP();
|
|
|
|
|
|
|
|
ASTContext *context(target->GetScratchClangASTContext()->getASTContext());
|
2011-05-07 09:06:41 +08:00
|
|
|
|
|
|
|
ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(decl));
|
|
|
|
|
|
|
|
if (!var_sp)
|
|
|
|
var_sp = m_parser_vars->m_persistent_vars->GetVariable(decl);
|
|
|
|
|
|
|
|
if (!var_sp)
|
|
|
|
return ClangExpressionVariableSP();
|
|
|
|
|
|
|
|
TypeFromUser user_type(ClangASTContext::CopyType(context,
|
|
|
|
type.GetASTContext(),
|
|
|
|
type.GetOpaqueQualType()),
|
|
|
|
context);
|
|
|
|
|
|
|
|
TypeFromUser var_type = var_sp->GetTypeFromUser();
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
StackFrame *frame = exe_ctx->GetFramePtr();
|
|
|
|
if (frame == NULL)
|
|
|
|
return lldb::ClangExpressionVariableSP();
|
|
|
|
|
|
|
|
VariableSP var = FindVariableInScope (*frame, var_sp->GetName(), &var_type);
|
2011-05-07 09:06:41 +08:00
|
|
|
|
|
|
|
if (!var)
|
|
|
|
return lldb::ClangExpressionVariableSP(); // but we should handle this; it may be a persistent variable
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
ValueObjectSP var_valobj = frame->GetValueObjectForFrameVariable(var, lldb::eNoDynamicValues);
|
2011-05-07 09:06:41 +08:00
|
|
|
|
|
|
|
if (!var_valobj)
|
|
|
|
return lldb::ClangExpressionVariableSP();
|
|
|
|
|
|
|
|
ValueObjectSP var_casted_valobj = var_valobj->CastPointerType(name.GetCString(), user_type);
|
|
|
|
|
|
|
|
if (!var_casted_valobj)
|
|
|
|
return lldb::ClangExpressionVariableSP();
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
StreamString my_stream_string;
|
|
|
|
|
|
|
|
ClangASTType::DumpTypeDescription (var_type.GetASTContext(),
|
|
|
|
var_type.GetOpaqueQualType(),
|
|
|
|
&my_stream_string);
|
|
|
|
|
|
|
|
|
|
|
|
log->Printf("Building cast variable to type: %s", my_stream_string.GetString().c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
ClangExpressionVariableSP pvar_sp = m_parser_vars->m_persistent_vars->CreatePersistentVariable (var_casted_valobj);
|
|
|
|
|
|
|
|
if (!pvar_sp)
|
|
|
|
return lldb::ClangExpressionVariableSP();
|
|
|
|
|
|
|
|
if (pvar_sp != m_parser_vars->m_persistent_vars->GetVariable(name))
|
|
|
|
return lldb::ClangExpressionVariableSP();
|
|
|
|
|
|
|
|
pvar_sp->m_flags |= ClangExpressionVariable::EVIsFreezeDried;
|
|
|
|
pvar_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
|
|
|
|
pvar_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
|
|
|
|
|
|
|
|
return pvar_sp;
|
|
|
|
}
|
|
|
|
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
bool
|
|
|
|
ClangExpressionDeclMap::ResultIsReference (const ConstString &name)
|
|
|
|
{
|
|
|
|
ClangExpressionVariableSP pvar_sp = m_parser_vars->m_persistent_vars->GetVariable(name);
|
|
|
|
|
|
|
|
return (pvar_sp->m_flags & ClangExpressionVariable::EVIsProgramReference);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ClangExpressionDeclMap::CompleteResultVariable (lldb::ClangExpressionVariableSP &valobj,
|
|
|
|
lldb_private::Value &value,
|
|
|
|
const ConstString &name,
|
2011-09-22 08:41:11 +08:00
|
|
|
lldb_private::TypeFromParser type,
|
|
|
|
bool transient)
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
{
|
|
|
|
assert (m_parser_vars.get());
|
|
|
|
|
|
|
|
ClangExpressionVariableSP pvar_sp = m_parser_vars->m_persistent_vars->GetVariable(name);
|
|
|
|
|
|
|
|
if (!pvar_sp)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (pvar_sp->m_flags & ClangExpressionVariable::EVIsProgramReference &&
|
2011-09-22 08:41:11 +08:00
|
|
|
!pvar_sp->m_live_sp &&
|
|
|
|
!transient)
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
{
|
|
|
|
// The reference comes from the program. We need to set up a live SP for it.
|
|
|
|
|
|
|
|
pvar_sp->m_live_sp = ValueObjectConstResult::Create(m_parser_vars->m_exe_ctx->GetBestExecutionContextScope(),
|
|
|
|
pvar_sp->GetTypeFromUser().GetASTContext(),
|
|
|
|
pvar_sp->GetTypeFromUser().GetOpaqueQualType(),
|
|
|
|
pvar_sp->GetName(),
|
|
|
|
value.GetScalar().ULongLong(),
|
|
|
|
value.GetValueAddressType(),
|
|
|
|
pvar_sp->GetByteSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pvar_sp->m_flags & ClangExpressionVariable::EVNeedsFreezeDry)
|
|
|
|
{
|
|
|
|
pvar_sp->ValueUpdated();
|
|
|
|
|
|
|
|
const size_t pvar_byte_size = pvar_sp->GetByteSize();
|
|
|
|
uint8_t *pvar_data = pvar_sp->GetValueBytes();
|
|
|
|
|
|
|
|
if (!ReadTarget(pvar_data, value, pvar_byte_size))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
pvar_sp->m_flags &= ~(ClangExpressionVariable::EVNeedsFreezeDry);
|
|
|
|
}
|
|
|
|
|
|
|
|
valobj = pvar_sp;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-11 11:57:18 +08:00
|
|
|
bool
|
2010-10-16 06:48:33 +08:00
|
|
|
ClangExpressionDeclMap::AddPersistentVariable
|
|
|
|
(
|
2011-07-30 10:42:06 +08:00
|
|
|
const NamedDecl *decl,
|
2010-10-16 06:48:33 +08:00
|
|
|
const ConstString &name,
|
2011-01-13 16:53:35 +08:00
|
|
|
TypeFromParser parser_type,
|
|
|
|
bool is_result,
|
|
|
|
bool is_lvalue
|
2010-10-16 06:48:33 +08:00
|
|
|
)
|
2010-08-11 11:57:18 +08:00
|
|
|
{
|
2010-12-03 09:38:59 +08:00
|
|
|
assert (m_parser_vars.get());
|
|
|
|
|
2011-01-13 16:53:35 +08:00
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
2011-03-31 08:19:25 +08:00
|
|
|
ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx;
|
2011-09-22 12:58:26 +08:00
|
|
|
if (exe_ctx == NULL)
|
|
|
|
return false;
|
|
|
|
Target *target = exe_ctx->GetTargetPtr();
|
|
|
|
if (target == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ASTContext *context(target->GetScratchClangASTContext()->getASTContext());
|
2010-08-11 11:57:18 +08:00
|
|
|
|
|
|
|
TypeFromUser user_type(ClangASTContext::CopyType(context,
|
2010-08-12 09:56:52 +08:00
|
|
|
parser_type.GetASTContext(),
|
|
|
|
parser_type.GetOpaqueQualType()),
|
2011-01-14 05:23:32 +08:00
|
|
|
context);
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
|
|
|
|
if (!m_parser_vars->m_target_info.IsValid())
|
|
|
|
return false;
|
2010-08-11 11:57:18 +08:00
|
|
|
|
2011-03-31 08:19:25 +08:00
|
|
|
if (!m_parser_vars->m_persistent_vars->CreatePersistentVariable (exe_ctx->GetBestExecutionContextScope (),
|
|
|
|
name,
|
2010-12-14 10:59:59 +08:00
|
|
|
user_type,
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
m_parser_vars->m_target_info.byte_order,
|
|
|
|
m_parser_vars->m_target_info.address_byte_size))
|
2010-08-24 07:09:38 +08:00
|
|
|
return false;
|
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
ClangExpressionVariableSP var_sp (m_parser_vars->m_persistent_vars->GetVariable(name));
|
2010-08-24 07:09:38 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
if (!var_sp)
|
2010-08-24 07:09:38 +08:00
|
|
|
return false;
|
|
|
|
|
2011-01-13 16:53:35 +08:00
|
|
|
if (is_result)
|
|
|
|
var_sp->m_flags |= ClangExpressionVariable::EVNeedsFreezeDry;
|
|
|
|
else
|
|
|
|
var_sp->m_flags |= ClangExpressionVariable::EVKeepInTarget; // explicitly-declared persistent variables should persist
|
|
|
|
|
|
|
|
if (is_lvalue)
|
|
|
|
{
|
|
|
|
var_sp->m_flags |= ClangExpressionVariable::EVIsProgramReference;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
|
|
|
|
var_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
log->Printf("Created persistent variable with flags 0x%hx", var_sp->m_flags);
|
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
var_sp->EnableParserVars();
|
2010-08-24 07:09:38 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
var_sp->m_parser_vars->m_named_decl = decl;
|
|
|
|
var_sp->m_parser_vars->m_parser_type = parser_type;
|
2010-08-24 07:09:38 +08:00
|
|
|
|
|
|
|
return true;
|
2010-08-11 11:57:18 +08:00
|
|
|
}
|
|
|
|
|
2010-07-14 05:41:46 +08:00
|
|
|
bool
|
2010-10-16 06:48:33 +08:00
|
|
|
ClangExpressionDeclMap::AddValueToStruct
|
|
|
|
(
|
2011-07-30 10:42:06 +08:00
|
|
|
const NamedDecl *decl,
|
2010-10-16 06:48:33 +08:00
|
|
|
const ConstString &name,
|
|
|
|
llvm::Value *value,
|
|
|
|
size_t size,
|
|
|
|
off_t alignment
|
|
|
|
)
|
2010-07-14 05:41:46 +08:00
|
|
|
{
|
2010-12-03 09:38:59 +08:00
|
|
|
assert (m_struct_vars.get());
|
|
|
|
assert (m_parser_vars.get());
|
|
|
|
|
2010-11-06 09:53:30 +08:00
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
2010-08-31 06:17:16 +08:00
|
|
|
|
2010-12-03 09:38:59 +08:00
|
|
|
m_struct_vars->m_struct_laid_out = false;
|
2010-07-14 05:41:46 +08:00
|
|
|
|
2010-08-24 07:09:38 +08:00
|
|
|
if (m_struct_members.GetVariable(decl))
|
|
|
|
return true;
|
2010-07-14 05:41:46 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(decl));
|
2010-08-24 07:09:38 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
if (!var_sp)
|
|
|
|
var_sp = m_parser_vars->m_persistent_vars->GetVariable(decl);
|
2010-08-24 07:09:38 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
if (!var_sp)
|
2010-08-24 07:09:38 +08:00
|
|
|
return false;
|
|
|
|
|
2010-08-31 06:17:16 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("Adding value for decl %p [%s - %s] to the structure",
|
|
|
|
decl,
|
2010-10-16 06:48:33 +08:00
|
|
|
name.GetCString(),
|
2010-12-14 10:59:59 +08:00
|
|
|
var_sp->GetName().GetCString());
|
2010-08-31 06:17:16 +08:00
|
|
|
|
2010-08-24 07:09:38 +08:00
|
|
|
// We know entity->m_parser_vars is valid because we used a parser variable
|
|
|
|
// to find it
|
2010-12-14 10:59:59 +08:00
|
|
|
var_sp->m_parser_vars->m_llvm_value = value;
|
2010-07-14 05:41:46 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
var_sp->EnableJITVars();
|
|
|
|
var_sp->m_jit_vars->m_alignment = alignment;
|
|
|
|
var_sp->m_jit_vars->m_size = size;
|
2010-07-14 05:41:46 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
m_struct_members.AddVariable(var_sp);
|
2010-07-14 05:41:46 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ClangExpressionDeclMap::DoStructLayout ()
|
|
|
|
{
|
2010-12-03 09:38:59 +08:00
|
|
|
assert (m_struct_vars.get());
|
|
|
|
|
|
|
|
if (m_struct_vars->m_struct_laid_out)
|
2010-07-14 05:41:46 +08:00
|
|
|
return true;
|
|
|
|
|
|
|
|
off_t cursor = 0;
|
|
|
|
|
2010-12-03 09:38:59 +08:00
|
|
|
m_struct_vars->m_struct_alignment = 0;
|
|
|
|
m_struct_vars->m_struct_size = 0;
|
2010-07-14 05:41:46 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
for (size_t member_index = 0, num_members = m_struct_members.GetSize();
|
2010-08-24 07:09:38 +08:00
|
|
|
member_index < num_members;
|
|
|
|
++member_index)
|
2010-07-14 05:41:46 +08:00
|
|
|
{
|
2010-12-14 10:59:59 +08:00
|
|
|
ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(member_index));
|
|
|
|
if (!member_sp)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!member_sp->m_jit_vars.get())
|
2010-08-24 07:09:38 +08:00
|
|
|
return false;
|
2010-07-14 05:41:46 +08:00
|
|
|
|
2010-08-24 07:09:38 +08:00
|
|
|
if (member_index == 0)
|
2010-12-14 10:59:59 +08:00
|
|
|
m_struct_vars->m_struct_alignment = member_sp->m_jit_vars->m_alignment;
|
2010-07-14 05:41:46 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
if (cursor % member_sp->m_jit_vars->m_alignment)
|
|
|
|
cursor += (member_sp->m_jit_vars->m_alignment - (cursor % member_sp->m_jit_vars->m_alignment));
|
2010-08-24 07:09:38 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
member_sp->m_jit_vars->m_offset = cursor;
|
|
|
|
cursor += member_sp->m_jit_vars->m_size;
|
2010-07-14 05:41:46 +08:00
|
|
|
}
|
|
|
|
|
2010-12-03 09:38:59 +08:00
|
|
|
m_struct_vars->m_struct_size = cursor;
|
2010-07-14 05:41:46 +08:00
|
|
|
|
2010-12-03 09:38:59 +08:00
|
|
|
m_struct_vars->m_struct_laid_out = true;
|
2010-07-14 05:41:46 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-10-16 06:48:33 +08:00
|
|
|
bool ClangExpressionDeclMap::GetStructInfo
|
|
|
|
(
|
|
|
|
uint32_t &num_elements,
|
|
|
|
size_t &size,
|
|
|
|
off_t &alignment
|
|
|
|
)
|
2010-07-14 05:41:46 +08:00
|
|
|
{
|
2010-12-03 09:38:59 +08:00
|
|
|
assert (m_struct_vars.get());
|
|
|
|
|
|
|
|
if (!m_struct_vars->m_struct_laid_out)
|
2010-07-14 05:41:46 +08:00
|
|
|
return false;
|
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
num_elements = m_struct_members.GetSize();
|
2010-12-03 09:38:59 +08:00
|
|
|
size = m_struct_vars->m_struct_size;
|
|
|
|
alignment = m_struct_vars->m_struct_alignment;
|
2010-07-14 05:41:46 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-10-16 06:48:33 +08:00
|
|
|
ClangExpressionDeclMap::GetStructElement
|
|
|
|
(
|
2011-07-30 10:42:06 +08:00
|
|
|
const NamedDecl *&decl,
|
2010-10-16 06:48:33 +08:00
|
|
|
llvm::Value *&value,
|
|
|
|
off_t &offset,
|
|
|
|
ConstString &name,
|
|
|
|
uint32_t index
|
|
|
|
)
|
2010-07-14 05:41:46 +08:00
|
|
|
{
|
2010-12-03 09:38:59 +08:00
|
|
|
assert (m_struct_vars.get());
|
|
|
|
|
|
|
|
if (!m_struct_vars->m_struct_laid_out)
|
2010-07-14 05:41:46 +08:00
|
|
|
return false;
|
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
if (index >= m_struct_members.GetSize())
|
2010-07-14 05:41:46 +08:00
|
|
|
return false;
|
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(index));
|
2010-08-24 07:09:38 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
if (!member_sp ||
|
|
|
|
!member_sp->m_parser_vars.get() ||
|
|
|
|
!member_sp->m_jit_vars.get())
|
2010-08-24 07:09:38 +08:00
|
|
|
return false;
|
2010-07-14 05:41:46 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
decl = member_sp->m_parser_vars->m_named_decl;
|
|
|
|
value = member_sp->m_parser_vars->m_llvm_value;
|
|
|
|
offset = member_sp->m_jit_vars->m_offset;
|
|
|
|
name = member_sp->GetName();
|
2010-08-24 07:09:38 +08:00
|
|
|
|
2010-07-14 05:41:46 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-28 05:39:39 +08:00
|
|
|
bool
|
2010-10-16 06:48:33 +08:00
|
|
|
ClangExpressionDeclMap::GetFunctionInfo
|
|
|
|
(
|
2011-07-30 10:42:06 +08:00
|
|
|
const NamedDecl *decl,
|
2010-10-16 06:48:33 +08:00
|
|
|
llvm::Value**& value,
|
|
|
|
uint64_t &ptr
|
|
|
|
)
|
2010-07-27 10:07:53 +08:00
|
|
|
{
|
2010-12-14 10:59:59 +08:00
|
|
|
ClangExpressionVariableSP entity_sp(m_found_entities.GetVariable(decl));
|
2010-08-24 07:09:38 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
if (!entity_sp)
|
2010-08-24 07:09:38 +08:00
|
|
|
return false;
|
2010-07-27 10:07:53 +08:00
|
|
|
|
2010-08-24 07:09:38 +08:00
|
|
|
// We know m_parser_vars is valid since we searched for the variable by
|
|
|
|
// its NamedDecl
|
2010-07-27 10:07:53 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
value = &entity_sp->m_parser_vars->m_llvm_value;
|
|
|
|
ptr = entity_sp->m_parser_vars->m_lldb_value->GetScalar().ULongLong();
|
2010-08-24 07:09:38 +08:00
|
|
|
|
|
|
|
return true;
|
2010-07-27 10:07:53 +08:00
|
|
|
}
|
|
|
|
|
2011-08-17 02:09:29 +08:00
|
|
|
static void
|
|
|
|
FindCodeSymbolInContext
|
|
|
|
(
|
|
|
|
const ConstString &name,
|
|
|
|
SymbolContext &sym_ctx,
|
|
|
|
SymbolContextList &sc_list
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (sym_ctx.module_sp)
|
2011-10-14 00:49:47 +08:00
|
|
|
sym_ctx.module_sp->FindSymbolsWithNameAndType(name, eSymbolTypeCode, sc_list);
|
2011-08-17 02:09:29 +08:00
|
|
|
|
|
|
|
if (!sc_list.GetSize())
|
|
|
|
sym_ctx.target_sp->GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeCode, sc_list);
|
|
|
|
}
|
|
|
|
|
2010-07-31 09:32:05 +08:00
|
|
|
bool
|
2010-10-16 06:48:33 +08:00
|
|
|
ClangExpressionDeclMap::GetFunctionAddress
|
|
|
|
(
|
|
|
|
const ConstString &name,
|
2011-05-19 06:01:49 +08:00
|
|
|
uint64_t &func_addr
|
2010-10-16 06:48:33 +08:00
|
|
|
)
|
2010-07-31 09:32:05 +08:00
|
|
|
{
|
2010-12-03 09:38:59 +08:00
|
|
|
assert (m_parser_vars.get());
|
|
|
|
|
2011-05-14 02:27:02 +08:00
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
2011-09-22 12:58:26 +08:00
|
|
|
ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx;
|
|
|
|
if (exe_ctx == NULL)
|
|
|
|
return false;
|
|
|
|
Target *target = exe_ctx->GetTargetPtr();
|
2010-07-31 09:32:05 +08:00
|
|
|
// Back out in all cases where we're not fully initialized
|
2011-09-22 12:58:26 +08:00
|
|
|
if (target == NULL)
|
2010-12-07 09:56:02 +08:00
|
|
|
return false;
|
|
|
|
if (!m_parser_vars->m_sym_ctx.target_sp)
|
2010-07-31 09:32:05 +08:00
|
|
|
return false;
|
|
|
|
|
2010-11-10 07:46:37 +08:00
|
|
|
SymbolContextList sc_list;
|
2010-07-31 09:32:05 +08:00
|
|
|
|
2011-08-17 02:09:29 +08:00
|
|
|
FindCodeSymbolInContext(name, m_parser_vars->m_sym_ctx, sc_list);
|
|
|
|
|
2010-11-10 07:46:37 +08:00
|
|
|
if (!sc_list.GetSize())
|
2011-05-14 02:27:02 +08:00
|
|
|
{
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
Mangled mangled(name.GetCString(), true);
|
|
|
|
|
|
|
|
ConstString demangled_name = mangled.GetDemangledName();
|
|
|
|
|
|
|
|
if (strlen(demangled_name.GetCString()))
|
|
|
|
{
|
|
|
|
std::string const_name_scratch(demangled_name.GetCString());
|
|
|
|
|
|
|
|
const_name_scratch.append(" const");
|
|
|
|
|
|
|
|
ConstString const_name(const_name_scratch.c_str());
|
|
|
|
|
2011-08-17 02:09:29 +08:00
|
|
|
FindCodeSymbolInContext(name, m_parser_vars->m_sym_ctx, sc_list);
|
2011-05-14 02:27:02 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
log->Printf("Found %d results with const name %s", sc_list.GetSize(), const_name.GetCString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!sc_list.GetSize())
|
2010-07-31 09:32:05 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
SymbolContext sym_ctx;
|
2010-11-10 07:46:37 +08:00
|
|
|
sc_list.GetContextAtIndex(0, sym_ctx);
|
2010-07-31 09:32:05 +08:00
|
|
|
|
2011-05-19 06:01:49 +08:00
|
|
|
const Address *func_so_addr = NULL;
|
2010-07-31 09:32:05 +08:00
|
|
|
|
|
|
|
if (sym_ctx.function)
|
2011-05-19 06:01:49 +08:00
|
|
|
func_so_addr = &sym_ctx.function->GetAddressRange().GetBaseAddress();
|
2010-07-31 09:32:05 +08:00
|
|
|
else if (sym_ctx.symbol)
|
2011-05-19 06:01:49 +08:00
|
|
|
func_so_addr = &sym_ctx.symbol->GetAddressRangeRef().GetBaseAddress();
|
2010-07-31 09:32:05 +08:00
|
|
|
else
|
|
|
|
return false;
|
|
|
|
|
2011-07-08 07:05:43 +08:00
|
|
|
if (!func_so_addr || !func_so_addr->IsValid())
|
|
|
|
return false;
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
func_addr = func_so_addr->GetCallableLoadAddress (target);
|
2011-05-19 06:01:49 +08:00
|
|
|
|
2010-07-31 09:32:05 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-06-23 12:25:29 +08:00
|
|
|
addr_t
|
|
|
|
ClangExpressionDeclMap::GetSymbolAddress (Target &target, const ConstString &name)
|
2011-01-18 07:42:46 +08:00
|
|
|
{
|
|
|
|
SymbolContextList sc_list;
|
|
|
|
|
2011-05-08 10:21:26 +08:00
|
|
|
target.GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeAny, sc_list);
|
2011-01-18 07:42:46 +08:00
|
|
|
|
2011-06-23 12:25:29 +08:00
|
|
|
const uint32_t num_matches = sc_list.GetSize();
|
|
|
|
addr_t symbol_load_addr = LLDB_INVALID_ADDRESS;
|
|
|
|
|
|
|
|
for (uint32_t i=0; i<num_matches && symbol_load_addr == LLDB_INVALID_ADDRESS; i++)
|
|
|
|
{
|
|
|
|
SymbolContext sym_ctx;
|
|
|
|
sc_list.GetContextAtIndex(i, sym_ctx);
|
2011-01-18 07:42:46 +08:00
|
|
|
|
2011-06-23 12:25:29 +08:00
|
|
|
const Address *sym_address = &sym_ctx.symbol->GetAddressRangeRef().GetBaseAddress();
|
2011-07-08 07:05:43 +08:00
|
|
|
|
|
|
|
if (!sym_address || !sym_address->IsValid())
|
|
|
|
return LLDB_INVALID_ADDRESS;
|
|
|
|
|
2011-06-23 12:25:29 +08:00
|
|
|
if (sym_address)
|
|
|
|
{
|
|
|
|
switch (sym_ctx.symbol->GetType())
|
|
|
|
{
|
|
|
|
case eSymbolTypeCode:
|
|
|
|
case eSymbolTypeTrampoline:
|
|
|
|
symbol_load_addr = sym_address->GetCallableLoadAddress (&target);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eSymbolTypeData:
|
|
|
|
case eSymbolTypeRuntime:
|
|
|
|
case eSymbolTypeVariable:
|
|
|
|
case eSymbolTypeLocal:
|
|
|
|
case eSymbolTypeParam:
|
|
|
|
case eSymbolTypeInvalid:
|
|
|
|
case eSymbolTypeAbsolute:
|
|
|
|
case eSymbolTypeExtern:
|
|
|
|
case eSymbolTypeException:
|
|
|
|
case eSymbolTypeSourceFile:
|
|
|
|
case eSymbolTypeHeaderFile:
|
|
|
|
case eSymbolTypeObjectFile:
|
|
|
|
case eSymbolTypeCommonBlock:
|
|
|
|
case eSymbolTypeBlock:
|
|
|
|
case eSymbolTypeVariableType:
|
|
|
|
case eSymbolTypeLineEntry:
|
|
|
|
case eSymbolTypeLineHeader:
|
|
|
|
case eSymbolTypeScopeBegin:
|
|
|
|
case eSymbolTypeScopeEnd:
|
|
|
|
case eSymbolTypeAdditional:
|
|
|
|
case eSymbolTypeCompiler:
|
|
|
|
case eSymbolTypeInstrumentation:
|
|
|
|
case eSymbolTypeUndefined:
|
|
|
|
symbol_load_addr = sym_address->GetLoadAddress (&target);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-18 07:42:46 +08:00
|
|
|
|
2011-06-23 12:25:29 +08:00
|
|
|
return symbol_load_addr;
|
2011-01-18 07:42:46 +08:00
|
|
|
}
|
|
|
|
|
2011-06-23 12:25:29 +08:00
|
|
|
addr_t
|
|
|
|
ClangExpressionDeclMap::GetSymbolAddress (const ConstString &name)
|
2011-05-08 10:21:26 +08:00
|
|
|
{
|
|
|
|
assert (m_parser_vars.get());
|
|
|
|
|
|
|
|
if (!m_parser_vars->m_exe_ctx ||
|
2011-09-22 12:58:26 +08:00
|
|
|
!m_parser_vars->m_exe_ctx->GetTargetPtr())
|
2011-05-08 10:21:26 +08:00
|
|
|
return false;
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
return GetSymbolAddress(m_parser_vars->m_exe_ctx->GetTargetRef(), name);
|
2011-05-08 10:21:26 +08:00
|
|
|
}
|
|
|
|
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
// Interface for IRInterpreter
|
|
|
|
|
|
|
|
bool
|
|
|
|
ClangExpressionDeclMap::WriteTarget (lldb_private::Value &value,
|
|
|
|
const uint8_t *data,
|
|
|
|
size_t length)
|
|
|
|
{
|
|
|
|
assert (m_parser_vars.get());
|
|
|
|
|
|
|
|
ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx;
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
Process *process = exe_ctx->GetProcessPtr();
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
if (value.GetContextType() == Value::eContextTypeRegisterInfo)
|
|
|
|
{
|
2011-09-22 12:58:26 +08:00
|
|
|
if (!process)
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
RegisterContext *reg_ctx = exe_ctx->GetRegisterContext();
|
|
|
|
RegisterInfo *reg_info = value.GetRegisterInfo();
|
|
|
|
|
|
|
|
if (!reg_ctx)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
lldb_private::RegisterValue reg_value;
|
|
|
|
Error err;
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
if (!reg_value.SetFromMemoryData (reg_info, data, length, process->GetByteOrder(), err))
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return reg_ctx->WriteRegister(reg_info, reg_value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (value.GetValueType())
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
case Value::eValueTypeFileAddress:
|
|
|
|
{
|
2011-09-22 12:58:26 +08:00
|
|
|
if (!process)
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
return false;
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
Target *target = exe_ctx->GetTargetPtr();
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
Address file_addr;
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
if (!target->GetImages().ResolveFileAddress((lldb::addr_t)value.GetScalar().ULongLong(), file_addr))
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
return false;
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
lldb::addr_t load_addr = file_addr.GetLoadAddress(target);
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
|
|
|
|
Error err;
|
2011-09-22 12:58:26 +08:00
|
|
|
process->WriteMemory(load_addr, data, length, err);
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
|
|
|
|
return err.Success();
|
|
|
|
}
|
|
|
|
case Value::eValueTypeLoadAddress:
|
|
|
|
{
|
2011-09-22 12:58:26 +08:00
|
|
|
if (!process)
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
Error err;
|
2011-09-22 12:58:26 +08:00
|
|
|
process->WriteMemory((lldb::addr_t)value.GetScalar().ULongLong(), data, length, err);
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
|
|
|
|
return err.Success();
|
|
|
|
}
|
|
|
|
case Value::eValueTypeHostAddress:
|
|
|
|
memcpy ((void *)value.GetScalar().ULongLong(), data, length);
|
|
|
|
return true;
|
|
|
|
case Value::eValueTypeScalar:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ClangExpressionDeclMap::ReadTarget (uint8_t *data,
|
|
|
|
lldb_private::Value &value,
|
|
|
|
size_t length)
|
|
|
|
{
|
|
|
|
assert (m_parser_vars.get());
|
|
|
|
|
|
|
|
ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx;
|
2011-09-22 12:58:26 +08:00
|
|
|
|
|
|
|
Process *process = exe_ctx->GetProcessPtr();
|
|
|
|
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
if (value.GetContextType() == Value::eContextTypeRegisterInfo)
|
|
|
|
{
|
2011-09-22 12:58:26 +08:00
|
|
|
if (!process)
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
RegisterContext *reg_ctx = exe_ctx->GetRegisterContext();
|
|
|
|
RegisterInfo *reg_info = value.GetRegisterInfo();
|
|
|
|
|
|
|
|
if (!reg_ctx)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
lldb_private::RegisterValue reg_value;
|
|
|
|
Error err;
|
|
|
|
|
|
|
|
if (!reg_ctx->ReadRegister(reg_info, reg_value))
|
|
|
|
return false;
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
return reg_value.GetAsMemoryData(reg_info, data, length, process->GetByteOrder(), err);
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (value.GetValueType())
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
case Value::eValueTypeFileAddress:
|
|
|
|
{
|
2011-09-22 12:58:26 +08:00
|
|
|
Target *target = exe_ctx->GetTargetPtr();
|
|
|
|
if (target == NULL)
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
Address file_addr;
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
if (!target->GetImages().ResolveFileAddress((lldb::addr_t)value.GetScalar().ULongLong(), file_addr))
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
Error err;
|
2011-09-22 12:58:26 +08:00
|
|
|
target->ReadMemory(file_addr, true, data, length, err);
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
|
|
|
|
return err.Success();
|
|
|
|
}
|
|
|
|
case Value::eValueTypeLoadAddress:
|
|
|
|
{
|
2011-09-22 12:58:26 +08:00
|
|
|
if (!process)
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
Error err;
|
2011-09-22 12:58:26 +08:00
|
|
|
process->ReadMemory((lldb::addr_t)value.GetScalar().ULongLong(), data, length, err);
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
|
|
|
|
return err.Success();
|
|
|
|
}
|
|
|
|
case Value::eValueTypeHostAddress:
|
|
|
|
memcpy (data, (const void *)value.GetScalar().ULongLong(), length);
|
|
|
|
return true;
|
|
|
|
case Value::eValueTypeScalar:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb_private::Value
|
|
|
|
ClangExpressionDeclMap::LookupDecl (clang::NamedDecl *decl)
|
|
|
|
{
|
|
|
|
assert (m_parser_vars.get());
|
|
|
|
|
|
|
|
ExecutionContext exe_ctx = *m_parser_vars->m_exe_ctx;
|
|
|
|
|
|
|
|
ClangExpressionVariableSP expr_var_sp (m_found_entities.GetVariable(decl));
|
|
|
|
ClangExpressionVariableSP persistent_var_sp (m_parser_vars->m_persistent_vars->GetVariable(decl));
|
|
|
|
|
|
|
|
if (expr_var_sp)
|
|
|
|
{
|
2011-10-13 08:09:20 +08:00
|
|
|
if (!expr_var_sp->m_parser_vars.get() || !expr_var_sp->m_parser_vars->m_lldb_var)
|
2011-10-13 06:20:02 +08:00
|
|
|
return Value();
|
|
|
|
|
2011-10-13 08:09:20 +08:00
|
|
|
return *GetVariableValue(exe_ctx, expr_var_sp->m_parser_vars->m_lldb_var, NULL);
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
}
|
|
|
|
else if (persistent_var_sp)
|
|
|
|
{
|
2011-09-22 08:41:11 +08:00
|
|
|
if ((persistent_var_sp->m_flags & ClangExpressionVariable::EVIsProgramReference ||
|
|
|
|
persistent_var_sp->m_flags & ClangExpressionVariable::EVIsLLDBAllocated) &&
|
|
|
|
persistent_var_sp->m_live_sp)
|
|
|
|
{
|
|
|
|
return persistent_var_sp->m_live_sp->GetValue();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lldb_private::Value ret;
|
|
|
|
ret.SetValueType(Value::eValueTypeHostAddress);
|
|
|
|
ret.SetContext(Value::eContextTypeInvalid, NULL);
|
|
|
|
ret.GetScalar() = (lldb::addr_t)persistent_var_sp->GetValueBytes();
|
|
|
|
return ret;
|
|
|
|
}
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return Value();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-16 08:09:46 +08:00
|
|
|
// Interface for CommandObjectExpression
|
2010-07-21 07:31:16 +08:00
|
|
|
|
|
|
|
bool
|
2010-10-16 06:48:33 +08:00
|
|
|
ClangExpressionDeclMap::Materialize
|
|
|
|
(
|
2010-12-03 09:38:59 +08:00
|
|
|
ExecutionContext &exe_ctx,
|
2010-10-16 06:48:33 +08:00
|
|
|
lldb::addr_t &struct_address,
|
|
|
|
Error &err
|
|
|
|
)
|
2010-07-21 07:31:16 +08:00
|
|
|
{
|
2010-12-03 09:38:59 +08:00
|
|
|
EnableMaterialVars();
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
m_material_vars->m_process = exe_ctx.GetProcessPtr();
|
2010-12-03 09:38:59 +08:00
|
|
|
|
2011-05-10 06:04:36 +08:00
|
|
|
bool result = DoMaterialize(false /* dematerialize */,
|
|
|
|
exe_ctx,
|
|
|
|
LLDB_INVALID_ADDRESS /* top of stack frame */,
|
|
|
|
LLDB_INVALID_ADDRESS /* bottom of stack frame */,
|
|
|
|
NULL, /* result SP */
|
|
|
|
err);
|
2010-07-21 07:31:16 +08:00
|
|
|
|
|
|
|
if (result)
|
2010-12-03 09:38:59 +08:00
|
|
|
struct_address = m_material_vars->m_materialized_location;
|
2010-07-21 07:31:16 +08:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
bool
|
2010-10-16 06:48:33 +08:00
|
|
|
ClangExpressionDeclMap::GetObjectPointer
|
|
|
|
(
|
|
|
|
lldb::addr_t &object_ptr,
|
2010-12-14 06:46:15 +08:00
|
|
|
ConstString &object_name,
|
2010-12-03 09:38:59 +08:00
|
|
|
ExecutionContext &exe_ctx,
|
2010-12-14 08:42:36 +08:00
|
|
|
Error &err,
|
|
|
|
bool suppress_type_check
|
2010-10-16 06:48:33 +08:00
|
|
|
)
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
{
|
2010-12-03 09:38:59 +08:00
|
|
|
assert (m_struct_vars.get());
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
StackFrame *frame = exe_ctx.GetFramePtr();
|
|
|
|
|
|
|
|
if (frame == NULL || process == NULL || target == NULL)
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
{
|
|
|
|
err.SetErrorString("Couldn't load 'this' because the context is incomplete");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-12-03 09:38:59 +08:00
|
|
|
if (!m_struct_vars->m_object_pointer_type.GetOpaqueQualType())
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
{
|
|
|
|
err.SetErrorString("Couldn't load 'this' because its type is unknown");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
VariableSP object_ptr_var = FindVariableInScope (*frame,
|
2011-05-07 09:06:41 +08:00
|
|
|
object_name,
|
|
|
|
(suppress_type_check ? NULL : &m_struct_vars->m_object_pointer_type));
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
|
|
|
|
if (!object_ptr_var)
|
|
|
|
{
|
2010-12-14 06:46:15 +08:00
|
|
|
err.SetErrorStringWithFormat("Couldn't find '%s' with appropriate type in scope", object_name.GetCString());
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-12-03 09:38:59 +08:00
|
|
|
std::auto_ptr<lldb_private::Value> location_value(GetVariableValue(exe_ctx,
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
object_ptr_var,
|
2010-12-03 09:38:59 +08:00
|
|
|
NULL));
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
|
|
|
|
if (!location_value.get())
|
|
|
|
{
|
2010-12-14 06:46:15 +08:00
|
|
|
err.SetErrorStringWithFormat("Couldn't get the location for '%s'", object_name.GetCString());
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-03-04 08:23:47 +08:00
|
|
|
switch (location_value->GetValueType())
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
{
|
2011-03-04 08:23:47 +08:00
|
|
|
default:
|
|
|
|
err.SetErrorStringWithFormat("'%s' is not in memory; LLDB must be extended to handle registers", object_name.GetCString());
|
|
|
|
return false;
|
|
|
|
case Value::eValueTypeLoadAddress:
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
{
|
2011-03-04 08:23:47 +08:00
|
|
|
lldb::addr_t value_addr = location_value->GetScalar().ULongLong();
|
2011-09-22 12:58:26 +08:00
|
|
|
uint32_t address_byte_size = target->GetArchitecture().GetAddressByteSize();
|
2011-03-04 08:23:47 +08:00
|
|
|
|
|
|
|
if (ClangASTType::GetClangTypeBitWidth(m_struct_vars->m_object_pointer_type.GetASTContext(),
|
|
|
|
m_struct_vars->m_object_pointer_type.GetOpaqueQualType()) != address_byte_size * 8)
|
|
|
|
{
|
|
|
|
err.SetErrorStringWithFormat("'%s' is not of an expected pointer size", object_name.GetCString());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Error read_error;
|
2011-09-22 12:58:26 +08:00
|
|
|
object_ptr = process->ReadPointerFromMemory (value_addr, read_error);
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
if (read_error.Fail() || object_ptr == LLDB_INVALID_ADDRESS)
|
2011-03-04 08:23:47 +08:00
|
|
|
{
|
|
|
|
err.SetErrorStringWithFormat("Coldn't read '%s' from the target: %s", object_name.GetCString(), read_error.AsCString());
|
|
|
|
return false;
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
}
|
2011-03-04 08:23:47 +08:00
|
|
|
return true;
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
}
|
2011-03-04 08:23:47 +08:00
|
|
|
case Value::eValueTypeScalar:
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
{
|
2011-03-04 08:23:47 +08:00
|
|
|
if (location_value->GetContextType() != Value::eContextTypeRegisterInfo)
|
|
|
|
{
|
|
|
|
StreamString ss;
|
|
|
|
location_value->Dump(&ss);
|
|
|
|
|
|
|
|
err.SetErrorStringWithFormat("%s is a scalar of unhandled type: %s", object_name.GetCString(), ss.GetString().c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-10 04:18:18 +08:00
|
|
|
RegisterInfo *reg_info = location_value->GetRegisterInfo();
|
2011-03-04 08:23:47 +08:00
|
|
|
|
2011-05-10 04:18:18 +08:00
|
|
|
if (!reg_info)
|
2011-03-04 08:23:47 +08:00
|
|
|
{
|
|
|
|
err.SetErrorStringWithFormat("Couldn't get the register information for %s", object_name.GetCString());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-10 04:18:18 +08:00
|
|
|
RegisterContext *reg_ctx = exe_ctx.GetRegisterContext();
|
2011-03-04 08:23:47 +08:00
|
|
|
|
2011-05-10 04:18:18 +08:00
|
|
|
if (!reg_ctx)
|
2011-03-04 08:23:47 +08:00
|
|
|
{
|
2011-05-10 04:18:18 +08:00
|
|
|
err.SetErrorStringWithFormat("Couldn't read register context to read %s from %s", object_name.GetCString(), reg_info->name);
|
2011-03-04 08:23:47 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-10 04:18:18 +08:00
|
|
|
uint32_t register_number = reg_info->kinds[lldb::eRegisterKindLLDB];
|
2011-03-04 08:23:47 +08:00
|
|
|
|
2011-05-10 04:18:18 +08:00
|
|
|
object_ptr = reg_ctx->ReadRegisterAsUnsigned(register_number, 0x0);
|
2011-03-04 08:23:47 +08:00
|
|
|
|
|
|
|
return true;
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-21 07:31:16 +08:00
|
|
|
bool
|
2010-10-16 06:48:33 +08:00
|
|
|
ClangExpressionDeclMap::Dematerialize
|
|
|
|
(
|
2010-12-03 09:38:59 +08:00
|
|
|
ExecutionContext &exe_ctx,
|
2010-12-14 10:59:59 +08:00
|
|
|
ClangExpressionVariableSP &result_sp,
|
2011-05-10 06:04:36 +08:00
|
|
|
lldb::addr_t stack_frame_top,
|
|
|
|
lldb::addr_t stack_frame_bottom,
|
2010-10-16 06:48:33 +08:00
|
|
|
Error &err
|
|
|
|
)
|
2010-07-21 07:31:16 +08:00
|
|
|
{
|
2011-05-10 06:04:36 +08:00
|
|
|
return DoMaterialize(true, exe_ctx, stack_frame_top, stack_frame_bottom, &result_sp, err);
|
2010-12-03 09:38:59 +08:00
|
|
|
|
|
|
|
DidDematerialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ClangExpressionDeclMap::DidDematerialize()
|
|
|
|
{
|
|
|
|
if (m_material_vars.get())
|
|
|
|
{
|
|
|
|
if (m_material_vars->m_materialized_location)
|
|
|
|
{
|
|
|
|
//#define SINGLE_STEP_EXPRESSIONS
|
|
|
|
|
|
|
|
#ifndef SINGLE_STEP_EXPRESSIONS
|
|
|
|
m_material_vars->m_process->DeallocateMemory(m_material_vars->m_materialized_location);
|
|
|
|
#endif
|
|
|
|
m_material_vars->m_materialized_location = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DisableMaterialVars();
|
|
|
|
}
|
2010-07-21 07:31:16 +08:00
|
|
|
}
|
|
|
|
|
2010-07-24 06:19:18 +08:00
|
|
|
bool
|
2010-10-16 06:48:33 +08:00
|
|
|
ClangExpressionDeclMap::DumpMaterializedStruct
|
|
|
|
(
|
2010-12-03 09:38:59 +08:00
|
|
|
ExecutionContext &exe_ctx,
|
2010-10-16 06:48:33 +08:00
|
|
|
Stream &s,
|
|
|
|
Error &err
|
|
|
|
)
|
2010-07-24 06:19:18 +08:00
|
|
|
{
|
2010-12-03 09:38:59 +08:00
|
|
|
assert (m_struct_vars.get());
|
|
|
|
assert (m_material_vars.get());
|
|
|
|
|
|
|
|
if (!m_struct_vars->m_struct_laid_out)
|
2010-07-24 06:19:18 +08:00
|
|
|
{
|
|
|
|
err.SetErrorString("Structure hasn't been laid out yet");
|
|
|
|
return false;
|
|
|
|
}
|
2011-09-22 12:58:26 +08:00
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
|
|
|
|
if (!process)
|
2010-07-24 06:19:18 +08:00
|
|
|
{
|
|
|
|
err.SetErrorString("Couldn't find the process");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
if (!target)
|
2010-07-24 06:19:18 +08:00
|
|
|
{
|
|
|
|
err.SetErrorString("Couldn't find the target");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-12-07 18:00:20 +08:00
|
|
|
if (!m_material_vars->m_materialized_location)
|
|
|
|
{
|
|
|
|
err.SetErrorString("No materialized location");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
lldb::DataBufferSP data_sp(new DataBufferHeap(m_struct_vars->m_struct_size, 0));
|
2010-07-24 06:19:18 +08:00
|
|
|
|
|
|
|
Error error;
|
2011-09-22 12:58:26 +08:00
|
|
|
if (process->ReadMemory (m_material_vars->m_materialized_location,
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
data_sp->GetBytes(),
|
|
|
|
data_sp->GetByteSize(), error) != data_sp->GetByteSize())
|
2010-07-24 06:19:18 +08:00
|
|
|
{
|
|
|
|
err.SetErrorStringWithFormat ("Couldn't read struct from the target: %s", error.AsCString());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
DataExtractor extractor(data_sp, process->GetByteOrder(), target->GetArchitecture().GetAddressByteSize());
|
2010-07-24 06:19:18 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
for (size_t member_idx = 0, num_members = m_struct_members.GetSize();
|
|
|
|
member_idx < num_members;
|
|
|
|
++member_idx)
|
2010-07-24 06:19:18 +08:00
|
|
|
{
|
2010-12-14 10:59:59 +08:00
|
|
|
ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(member_idx));
|
2010-07-24 06:19:18 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
if (!member_sp)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
s.Printf("[%s]\n", member_sp->GetName().GetCString());
|
2010-08-24 07:09:38 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
if (!member_sp->m_jit_vars.get())
|
2010-08-24 07:09:38 +08:00
|
|
|
return false;
|
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
extractor.Dump (&s, // stream
|
|
|
|
member_sp->m_jit_vars->m_offset, // offset
|
|
|
|
lldb::eFormatBytesWithASCII, // format
|
|
|
|
1, // byte size of individual entries
|
|
|
|
member_sp->m_jit_vars->m_size, // number of entries
|
|
|
|
16, // entries per line
|
|
|
|
m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset, // address to print
|
|
|
|
0, // bit size (bitfields only; 0 means ignore)
|
|
|
|
0); // bit alignment (bitfields only; 0 means ignore)
|
2010-07-24 06:19:18 +08:00
|
|
|
|
|
|
|
s.PutChar('\n');
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-21 07:31:16 +08:00
|
|
|
bool
|
2010-10-16 06:48:33 +08:00
|
|
|
ClangExpressionDeclMap::DoMaterialize
|
|
|
|
(
|
|
|
|
bool dematerialize,
|
2010-12-03 09:38:59 +08:00
|
|
|
ExecutionContext &exe_ctx,
|
2011-05-10 06:04:36 +08:00
|
|
|
lldb::addr_t stack_frame_top,
|
|
|
|
lldb::addr_t stack_frame_bottom,
|
2010-12-14 10:59:59 +08:00
|
|
|
lldb::ClangExpressionVariableSP *result_sp_ptr,
|
2010-10-16 06:48:33 +08:00
|
|
|
Error &err
|
|
|
|
)
|
2010-07-16 08:09:46 +08:00
|
|
|
{
|
2010-12-14 10:59:59 +08:00
|
|
|
if (result_sp_ptr)
|
|
|
|
result_sp_ptr->reset();
|
|
|
|
|
2010-12-03 09:38:59 +08:00
|
|
|
assert (m_struct_vars.get());
|
|
|
|
|
2010-11-06 09:53:30 +08:00
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
2010-08-12 09:56:52 +08:00
|
|
|
|
2010-12-03 09:38:59 +08:00
|
|
|
if (!m_struct_vars->m_struct_laid_out)
|
2010-07-16 08:09:46 +08:00
|
|
|
{
|
|
|
|
err.SetErrorString("Structure hasn't been laid out yet");
|
2011-09-13 12:03:52 +08:00
|
|
|
return false;
|
2010-07-16 08:09:46 +08:00
|
|
|
}
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
StackFrame *frame = exe_ctx.GetFramePtr();
|
|
|
|
if (!frame)
|
2010-07-24 09:37:44 +08:00
|
|
|
{
|
|
|
|
err.SetErrorString("Received null execution frame");
|
2011-09-13 12:03:52 +08:00
|
|
|
return false;
|
2010-07-24 09:37:44 +08:00
|
|
|
}
|
2011-09-22 12:58:26 +08:00
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
2010-07-24 09:37:44 +08:00
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
ClangPersistentVariables &persistent_vars = target->GetPersistentVariables();
|
2010-12-03 09:38:59 +08:00
|
|
|
|
|
|
|
if (!m_struct_vars->m_struct_size)
|
2010-09-14 05:34:21 +08:00
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->PutCString("Not bothering to allocate a struct because no arguments are needed");
|
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
m_material_vars->m_allocated_area = NULL;
|
2010-09-14 05:34:21 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
const SymbolContext &sym_ctx(frame->GetSymbolContext(lldb::eSymbolContextEverything));
|
2010-07-16 08:09:46 +08:00
|
|
|
|
2010-07-21 07:31:16 +08:00
|
|
|
if (!dematerialize)
|
|
|
|
{
|
2011-09-22 12:58:26 +08:00
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
2010-12-03 09:38:59 +08:00
|
|
|
if (m_material_vars->m_materialized_location)
|
2010-07-21 07:31:16 +08:00
|
|
|
{
|
2011-09-22 12:58:26 +08:00
|
|
|
process->DeallocateMemory(m_material_vars->m_materialized_location);
|
2010-12-03 09:38:59 +08:00
|
|
|
m_material_vars->m_materialized_location = 0;
|
2010-07-21 07:31:16 +08:00
|
|
|
}
|
2010-07-16 08:09:46 +08:00
|
|
|
|
2010-10-08 09:58:41 +08:00
|
|
|
if (log)
|
|
|
|
log->PutCString("Allocating memory for materialized argument struct");
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
lldb::addr_t mem = process->AllocateMemory(m_struct_vars->m_struct_alignment + m_struct_vars->m_struct_size,
|
2010-12-03 09:38:59 +08:00
|
|
|
lldb::ePermissionsReadable | lldb::ePermissionsWritable,
|
|
|
|
err);
|
2010-07-21 07:31:16 +08:00
|
|
|
|
|
|
|
if (mem == LLDB_INVALID_ADDRESS)
|
|
|
|
return false;
|
|
|
|
|
2010-12-03 09:38:59 +08:00
|
|
|
m_material_vars->m_allocated_area = mem;
|
2010-07-21 07:31:16 +08:00
|
|
|
}
|
2010-07-16 08:09:46 +08:00
|
|
|
|
2010-12-03 09:38:59 +08:00
|
|
|
m_material_vars->m_materialized_location = m_material_vars->m_allocated_area;
|
2010-07-16 08:09:46 +08:00
|
|
|
|
2010-12-03 09:38:59 +08:00
|
|
|
if (m_material_vars->m_materialized_location % m_struct_vars->m_struct_alignment)
|
|
|
|
m_material_vars->m_materialized_location += (m_struct_vars->m_struct_alignment - (m_material_vars->m_materialized_location % m_struct_vars->m_struct_alignment));
|
2010-07-16 08:09:46 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
for (uint64_t member_index = 0, num_members = m_struct_members.GetSize();
|
2010-08-24 07:09:38 +08:00
|
|
|
member_index < num_members;
|
|
|
|
++member_index)
|
2010-07-16 08:09:46 +08:00
|
|
|
{
|
2010-12-14 10:59:59 +08:00
|
|
|
ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(member_index));
|
2010-12-01 09:29:06 +08:00
|
|
|
|
2011-01-10 05:07:35 +08:00
|
|
|
if (m_found_entities.ContainsVariable (member_sp))
|
2010-07-17 08:43:37 +08:00
|
|
|
{
|
2011-01-10 05:07:35 +08:00
|
|
|
RegisterInfo *reg_info = member_sp->GetRegisterInfo ();
|
2010-12-14 10:59:59 +08:00
|
|
|
if (reg_info)
|
2010-11-30 08:27:43 +08:00
|
|
|
{
|
|
|
|
// This is a register variable
|
|
|
|
|
2010-12-03 09:38:59 +08:00
|
|
|
RegisterContext *reg_ctx = exe_ctx.GetRegisterContext();
|
2010-11-30 08:27:43 +08:00
|
|
|
|
|
|
|
if (!reg_ctx)
|
|
|
|
return false;
|
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
if (!DoMaterializeOneRegister (dematerialize,
|
|
|
|
exe_ctx,
|
|
|
|
*reg_ctx,
|
|
|
|
*reg_info,
|
|
|
|
m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset,
|
|
|
|
err))
|
2010-11-30 08:27:43 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-12-14 10:59:59 +08:00
|
|
|
if (!member_sp->m_jit_vars.get())
|
2010-11-30 08:27:43 +08:00
|
|
|
return false;
|
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
if (!DoMaterializeOneVariable (dematerialize,
|
|
|
|
exe_ctx,
|
2011-01-13 16:53:35 +08:00
|
|
|
sym_ctx,
|
|
|
|
member_sp,
|
2010-12-14 10:59:59 +08:00
|
|
|
m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset,
|
|
|
|
err))
|
2010-11-30 08:27:43 +08:00
|
|
|
return false;
|
|
|
|
}
|
2010-08-24 07:09:38 +08:00
|
|
|
}
|
2011-01-10 05:07:35 +08:00
|
|
|
else
|
2010-08-24 07:09:38 +08:00
|
|
|
{
|
2011-01-10 05:07:35 +08:00
|
|
|
// No need to look for presistent variables if the name doesn't start
|
|
|
|
// with with a '$' character...
|
|
|
|
if (member_sp->GetName().AsCString ("!")[0] == '$' && persistent_vars.ContainsVariable(member_sp))
|
2010-08-31 06:17:16 +08:00
|
|
|
{
|
2011-01-13 16:53:35 +08:00
|
|
|
|
2011-01-10 05:07:35 +08:00
|
|
|
if (member_sp->GetName() == m_struct_vars->m_result_name)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->PutCString("Found result member in the struct");
|
2011-01-13 16:53:35 +08:00
|
|
|
|
2011-01-10 05:07:35 +08:00
|
|
|
if (result_sp_ptr)
|
|
|
|
*result_sp_ptr = member_sp;
|
2011-01-13 16:53:35 +08:00
|
|
|
|
2011-01-10 05:07:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!DoMaterializeOnePersistentVariable (dematerialize,
|
2011-01-13 16:53:35 +08:00
|
|
|
exe_ctx,
|
2011-01-10 05:07:35 +08:00
|
|
|
member_sp,
|
2011-05-10 06:04:36 +08:00
|
|
|
m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset,
|
|
|
|
stack_frame_top,
|
|
|
|
stack_frame_bottom,
|
2011-01-10 05:07:35 +08:00
|
|
|
err))
|
|
|
|
return false;
|
2010-07-21 07:31:16 +08:00
|
|
|
}
|
2011-01-10 05:07:35 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
err.SetErrorStringWithFormat("Unexpected variable %s", member_sp->GetName().GetCString());
|
2010-08-24 07:09:38 +08:00
|
|
|
return false;
|
2011-01-10 05:07:35 +08:00
|
|
|
}
|
2010-08-24 07:09:38 +08:00
|
|
|
}
|
2010-07-16 08:09:46 +08:00
|
|
|
}
|
|
|
|
|
2010-07-21 07:31:16 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-11 11:57:18 +08:00
|
|
|
bool
|
2010-10-16 06:48:33 +08:00
|
|
|
ClangExpressionDeclMap::DoMaterializeOnePersistentVariable
|
|
|
|
(
|
|
|
|
bool dematerialize,
|
|
|
|
ExecutionContext &exe_ctx,
|
2010-12-14 10:59:59 +08:00
|
|
|
ClangExpressionVariableSP &var_sp,
|
2010-10-16 06:48:33 +08:00
|
|
|
lldb::addr_t addr,
|
2011-05-10 06:04:36 +08:00
|
|
|
lldb::addr_t stack_frame_top,
|
|
|
|
lldb::addr_t stack_frame_bottom,
|
2010-10-16 06:48:33 +08:00
|
|
|
Error &err
|
|
|
|
)
|
2010-12-03 09:38:59 +08:00
|
|
|
{
|
2011-01-13 16:53:35 +08:00
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
if (!var_sp)
|
2010-08-11 11:57:18 +08:00
|
|
|
{
|
2010-12-14 10:59:59 +08:00
|
|
|
err.SetErrorString("Invalid persistent variable");
|
2010-08-11 11:57:18 +08:00
|
|
|
return LLDB_INVALID_ADDRESS;
|
|
|
|
}
|
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
const size_t pvar_byte_size = var_sp->GetByteSize();
|
2010-08-20 09:02:30 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
uint8_t *pvar_data = var_sp->GetValueBytes();
|
|
|
|
if (pvar_data == NULL)
|
2010-08-20 09:02:30 +08:00
|
|
|
return false;
|
|
|
|
|
2010-08-11 11:57:18 +08:00
|
|
|
Error error;
|
2011-09-22 12:58:26 +08:00
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
|
2011-01-13 16:53:35 +08:00
|
|
|
lldb::addr_t mem; // The address of a spare memory area used to hold the persistent variable.
|
|
|
|
|
2010-08-11 11:57:18 +08:00
|
|
|
if (dematerialize)
|
|
|
|
{
|
2011-01-13 16:53:35 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("Dematerializing persistent variable with flags 0x%hx", var_sp->m_flags);
|
|
|
|
|
|
|
|
if ((var_sp->m_flags & ClangExpressionVariable::EVIsLLDBAllocated) ||
|
|
|
|
(var_sp->m_flags & ClangExpressionVariable::EVIsProgramReference))
|
|
|
|
{
|
|
|
|
// Get the location of the target out of the struct.
|
|
|
|
|
|
|
|
Error read_error;
|
2011-09-22 12:58:26 +08:00
|
|
|
mem = process->ReadPointerFromMemory (addr, read_error);
|
2011-01-13 16:53:35 +08:00
|
|
|
|
|
|
|
if (mem == LLDB_INVALID_ADDRESS)
|
|
|
|
{
|
|
|
|
err.SetErrorStringWithFormat("Couldn't read address of %s from struct: %s", var_sp->GetName().GetCString(), error.AsCString());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (var_sp->m_flags & ClangExpressionVariable::EVIsProgramReference &&
|
|
|
|
!var_sp->m_live_sp)
|
|
|
|
{
|
|
|
|
// If the reference comes from the program, then the ClangExpressionVariable's
|
|
|
|
// live variable data hasn't been set up yet. Do this now.
|
|
|
|
|
2011-04-23 07:53:53 +08:00
|
|
|
var_sp->m_live_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope (),
|
|
|
|
var_sp->GetTypeFromUser().GetASTContext(),
|
|
|
|
var_sp->GetTypeFromUser().GetOpaqueQualType(),
|
|
|
|
var_sp->GetName(),
|
|
|
|
mem,
|
|
|
|
eAddressTypeLoad,
|
|
|
|
pvar_byte_size);
|
2011-01-13 16:53:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!var_sp->m_live_sp)
|
|
|
|
{
|
|
|
|
err.SetErrorStringWithFormat("Couldn't find the memory area used to store %s", var_sp->GetName().GetCString());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-03-25 05:19:54 +08:00
|
|
|
if (var_sp->m_live_sp->GetValue().GetValueAddressType() != eAddressTypeLoad)
|
2011-01-13 16:53:35 +08:00
|
|
|
{
|
|
|
|
err.SetErrorStringWithFormat("The address of the memory area for %s is in an incorrect format", var_sp->GetName().GetCString());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-01-14 05:23:32 +08:00
|
|
|
if (var_sp->m_flags & ClangExpressionVariable::EVNeedsFreezeDry ||
|
|
|
|
var_sp->m_flags & ClangExpressionVariable::EVKeepInTarget)
|
2011-01-13 16:53:35 +08:00
|
|
|
{
|
|
|
|
mem = var_sp->m_live_sp->GetValue().GetScalar().ULongLong();
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
log->Printf("Dematerializing %s from 0x%llx", var_sp->GetName().GetCString(), (uint64_t)mem);
|
|
|
|
|
|
|
|
// Read the contents of the spare memory area
|
2011-05-10 06:04:36 +08:00
|
|
|
|
2011-01-13 16:53:35 +08:00
|
|
|
var_sp->ValueUpdated ();
|
2011-09-22 12:58:26 +08:00
|
|
|
if (process->ReadMemory (mem, pvar_data, pvar_byte_size, error) != pvar_byte_size)
|
2011-01-13 16:53:35 +08:00
|
|
|
{
|
|
|
|
err.SetErrorStringWithFormat ("Couldn't read a composite type from the target: %s", error.AsCString());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-10 06:04:36 +08:00
|
|
|
if (stack_frame_top != LLDB_INVALID_ADDRESS &&
|
|
|
|
stack_frame_bottom != LLDB_INVALID_ADDRESS &&
|
|
|
|
mem >= stack_frame_bottom &&
|
|
|
|
mem <= stack_frame_top)
|
|
|
|
{
|
|
|
|
// If the variable is resident in the stack frame created by the expression,
|
|
|
|
// then it cannot be relied upon to stay around. We treat it as needing
|
|
|
|
// reallocation.
|
|
|
|
|
|
|
|
var_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
|
|
|
|
var_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
|
|
|
|
var_sp->m_flags &= ~ClangExpressionVariable::EVIsProgramReference;
|
|
|
|
}
|
|
|
|
|
2011-01-13 16:53:35 +08:00
|
|
|
var_sp->m_flags &= ~ClangExpressionVariable::EVNeedsFreezeDry;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (var_sp->m_flags & ClangExpressionVariable::EVNeedsAllocation &&
|
|
|
|
!(var_sp->m_flags & ClangExpressionVariable::EVKeepInTarget))
|
|
|
|
{
|
|
|
|
if (m_keep_result_in_memory)
|
|
|
|
{
|
|
|
|
var_sp->m_flags |= ClangExpressionVariable::EVKeepInTarget;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-22 12:58:26 +08:00
|
|
|
Error deallocate_error = process->DeallocateMemory(mem);
|
2011-01-13 16:53:35 +08:00
|
|
|
|
|
|
|
if (!err.Success())
|
|
|
|
{
|
|
|
|
err.SetErrorStringWithFormat ("Couldn't deallocate memory for %s: %s", var_sp->GetName().GetCString(), deallocate_error.AsCString());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2010-08-11 11:57:18 +08:00
|
|
|
{
|
2011-01-13 16:53:35 +08:00
|
|
|
err.SetErrorStringWithFormat("Persistent variables without separate allocations are not currently supported.");
|
2010-08-11 11:57:18 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-13 16:53:35 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("Materializing persistent variable with flags 0x%hx", var_sp->m_flags);
|
|
|
|
|
|
|
|
if (var_sp->m_flags & ClangExpressionVariable::EVNeedsAllocation)
|
|
|
|
{
|
|
|
|
// Allocate a spare memory area to store the persistent variable's contents.
|
|
|
|
|
|
|
|
Error allocate_error;
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
mem = process->AllocateMemory(pvar_byte_size,
|
2011-01-13 16:53:35 +08:00
|
|
|
lldb::ePermissionsReadable | lldb::ePermissionsWritable,
|
|
|
|
allocate_error);
|
|
|
|
|
|
|
|
if (mem == LLDB_INVALID_ADDRESS)
|
|
|
|
{
|
|
|
|
err.SetErrorStringWithFormat("Couldn't allocate a memory area to store %s: %s", var_sp->GetName().GetCString(), allocate_error.AsCString());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
log->Printf("Allocated %s (0x%llx) sucessfully", var_sp->GetName().GetCString(), mem);
|
|
|
|
|
|
|
|
// Put the location of the spare memory into the live data of the ValueObject.
|
|
|
|
|
2011-04-23 07:53:53 +08:00
|
|
|
var_sp->m_live_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
|
|
|
|
var_sp->GetTypeFromUser().GetASTContext(),
|
|
|
|
var_sp->GetTypeFromUser().GetOpaqueQualType(),
|
|
|
|
var_sp->GetName(),
|
|
|
|
mem,
|
|
|
|
eAddressTypeLoad,
|
|
|
|
pvar_byte_size);
|
2011-01-13 16:53:35 +08:00
|
|
|
|
|
|
|
// Clear the flag if the variable will never be deallocated.
|
|
|
|
|
|
|
|
if (var_sp->m_flags & ClangExpressionVariable::EVKeepInTarget)
|
|
|
|
var_sp->m_flags &= ~ClangExpressionVariable::EVNeedsAllocation;
|
|
|
|
|
|
|
|
// Write the contents of the variable to the area.
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
if (process->WriteMemory (mem, pvar_data, pvar_byte_size, error) != pvar_byte_size)
|
2011-01-13 16:53:35 +08:00
|
|
|
{
|
|
|
|
err.SetErrorStringWithFormat ("Couldn't write a composite type to the target: %s", error.AsCString());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((var_sp->m_flags & ClangExpressionVariable::EVIsProgramReference && var_sp->m_live_sp) ||
|
|
|
|
var_sp->m_flags & ClangExpressionVariable::EVIsLLDBAllocated)
|
|
|
|
{
|
|
|
|
// Now write the location of the area into the struct.
|
|
|
|
Error write_error;
|
2011-09-22 12:58:26 +08:00
|
|
|
if (!process->WriteScalarToMemory (addr,
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
var_sp->m_live_sp->GetValue().GetScalar(),
|
2011-09-22 12:58:26 +08:00
|
|
|
process->GetAddressByteSize(),
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
write_error))
|
2011-01-13 16:53:35 +08:00
|
|
|
{
|
|
|
|
err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", var_sp->GetName().GetCString(), write_error.AsCString());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (log)
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
log->Printf("Materialized %s into 0x%llx", var_sp->GetName().GetCString(), var_sp->m_live_sp->GetValue().GetScalar().ULongLong());
|
2011-01-13 16:53:35 +08:00
|
|
|
}
|
2011-05-07 09:06:41 +08:00
|
|
|
else if (!(var_sp->m_flags & ClangExpressionVariable::EVIsProgramReference))
|
2010-08-11 11:57:18 +08:00
|
|
|
{
|
2011-01-13 16:53:35 +08:00
|
|
|
err.SetErrorStringWithFormat("Persistent variables without separate allocations are not currently supported.");
|
2010-08-11 11:57:18 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-21 07:31:16 +08:00
|
|
|
bool
|
2010-10-16 06:48:33 +08:00
|
|
|
ClangExpressionDeclMap::DoMaterializeOneVariable
|
|
|
|
(
|
|
|
|
bool dematerialize,
|
|
|
|
ExecutionContext &exe_ctx,
|
|
|
|
const SymbolContext &sym_ctx,
|
2011-01-13 16:53:35 +08:00
|
|
|
ClangExpressionVariableSP &expr_var,
|
2010-10-16 06:48:33 +08:00
|
|
|
lldb::addr_t addr,
|
|
|
|
Error &err
|
|
|
|
)
|
2010-07-21 07:31:16 +08:00
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
2011-09-22 12:58:26 +08:00
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
StackFrame *frame = exe_ctx.GetFramePtr();
|
|
|
|
|
2011-10-13 06:20:02 +08:00
|
|
|
if (!frame || !process || !target || !m_parser_vars.get() || !expr_var->m_parser_vars.get())
|
2010-09-15 05:59:34 +08:00
|
|
|
return false;
|
|
|
|
|
2011-01-13 16:53:35 +08:00
|
|
|
// Vital information about the value
|
|
|
|
|
|
|
|
const ConstString &name(expr_var->GetName());
|
|
|
|
TypeFromUser type(expr_var->GetTypeFromUser());
|
|
|
|
|
2011-10-13 08:09:20 +08:00
|
|
|
VariableSP &var(expr_var->m_parser_vars->m_lldb_var);
|
|
|
|
lldb_private::Symbol *sym(expr_var->m_parser_vars->m_lldb_sym);
|
2010-07-21 07:31:16 +08:00
|
|
|
|
2011-05-08 10:21:26 +08:00
|
|
|
std::auto_ptr<lldb_private::Value> location_value;
|
2011-10-13 08:09:20 +08:00
|
|
|
|
2011-05-08 10:21:26 +08:00
|
|
|
if (var)
|
|
|
|
{
|
|
|
|
location_value.reset(GetVariableValue(exe_ctx,
|
|
|
|
var,
|
|
|
|
NULL));
|
|
|
|
}
|
|
|
|
else if (sym)
|
2011-10-13 08:09:20 +08:00
|
|
|
{
|
2011-09-22 12:58:26 +08:00
|
|
|
addr_t location_load_addr = GetSymbolAddress(*target, name);
|
2011-05-08 10:21:26 +08:00
|
|
|
|
2011-06-23 12:25:29 +08:00
|
|
|
if (location_load_addr == LLDB_INVALID_ADDRESS)
|
2011-05-08 10:21:26 +08:00
|
|
|
{
|
|
|
|
if (log)
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
err.SetErrorStringWithFormat ("Couldn't find value for global symbol %s",
|
|
|
|
name.GetCString());
|
2011-05-08 10:21:26 +08:00
|
|
|
}
|
|
|
|
|
2011-10-13 08:09:20 +08:00
|
|
|
location_value.reset(new Value);
|
|
|
|
|
2011-05-08 10:21:26 +08:00
|
|
|
location_value->SetValueType(Value::eValueTypeLoadAddress);
|
|
|
|
location_value->GetScalar() = location_load_addr;
|
|
|
|
}
|
|
|
|
else
|
2010-07-21 07:31:16 +08:00
|
|
|
{
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
err.SetErrorStringWithFormat ("Couldn't find %s with appropriate type",
|
|
|
|
name.GetCString());
|
2010-07-21 07:31:16 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-07-23 08:16:21 +08:00
|
|
|
if (log)
|
2011-05-13 07:54:16 +08:00
|
|
|
{
|
|
|
|
StreamString my_stream_string;
|
|
|
|
|
|
|
|
ClangASTType::DumpTypeDescription (type.GetASTContext(),
|
|
|
|
type.GetOpaqueQualType(),
|
|
|
|
&my_stream_string);
|
|
|
|
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
log->Printf ("%s %s with type %s",
|
|
|
|
dematerialize ? "Dematerializing" : "Materializing",
|
|
|
|
name.GetCString(),
|
|
|
|
my_stream_string.GetString().c_str());
|
2011-05-13 07:54:16 +08:00
|
|
|
}
|
2010-07-21 07:31:16 +08:00
|
|
|
|
|
|
|
if (!location_value.get())
|
|
|
|
{
|
2010-10-16 06:48:33 +08:00
|
|
|
err.SetErrorStringWithFormat("Couldn't get value for %s", name.GetCString());
|
2010-07-21 07:31:16 +08:00
|
|
|
return false;
|
|
|
|
}
|
2010-10-06 04:18:48 +08:00
|
|
|
|
|
|
|
// The size of the type contained in addr
|
2010-07-21 07:31:16 +08:00
|
|
|
|
2011-01-13 16:53:35 +08:00
|
|
|
size_t value_bit_size = ClangASTType::GetClangTypeBitWidth(type.GetASTContext(), type.GetOpaqueQualType());
|
|
|
|
size_t value_byte_size = value_bit_size % 8 ? ((value_bit_size + 8) / 8) : (value_bit_size / 8);
|
2010-10-06 04:18:48 +08:00
|
|
|
|
|
|
|
Value::ValueType value_type = location_value->GetValueType();
|
|
|
|
|
|
|
|
switch (value_type)
|
2010-07-21 07:31:16 +08:00
|
|
|
{
|
2010-10-06 04:18:48 +08:00
|
|
|
default:
|
2010-07-21 07:31:16 +08:00
|
|
|
{
|
2010-10-06 04:18:48 +08:00
|
|
|
StreamString ss;
|
|
|
|
|
|
|
|
location_value->Dump(&ss);
|
|
|
|
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
err.SetErrorStringWithFormat ("%s has a value of unhandled type: %s",
|
|
|
|
name.GetCString(),
|
|
|
|
ss.GetString().c_str());
|
2010-10-06 04:18:48 +08:00
|
|
|
return false;
|
2010-07-21 07:31:16 +08:00
|
|
|
}
|
2010-10-06 04:18:48 +08:00
|
|
|
break;
|
|
|
|
case Value::eValueTypeLoadAddress:
|
2010-07-21 07:31:16 +08:00
|
|
|
{
|
2011-01-13 16:53:35 +08:00
|
|
|
if (!dematerialize)
|
2010-10-06 04:18:48 +08:00
|
|
|
{
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
Error write_error;
|
2011-01-13 16:53:35 +08:00
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
if (!process->WriteScalarToMemory (addr,
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
location_value->GetScalar(),
|
2011-09-22 12:58:26 +08:00
|
|
|
process->GetAddressByteSize(),
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
write_error))
|
2011-01-13 16:53:35 +08:00
|
|
|
{
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s",
|
|
|
|
name.GetCString(),
|
|
|
|
write_error.AsCString());
|
2011-01-13 16:53:35 +08:00
|
|
|
return false;
|
|
|
|
}
|
2010-10-06 04:18:48 +08:00
|
|
|
}
|
2010-07-21 07:31:16 +08:00
|
|
|
}
|
2010-10-06 04:18:48 +08:00
|
|
|
break;
|
|
|
|
case Value::eValueTypeScalar:
|
2010-07-21 07:31:16 +08:00
|
|
|
{
|
2010-11-13 11:52:47 +08:00
|
|
|
if (location_value->GetContextType() != Value::eContextTypeRegisterInfo)
|
2010-10-06 04:18:48 +08:00
|
|
|
{
|
|
|
|
StreamString ss;
|
|
|
|
location_value->Dump(&ss);
|
|
|
|
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
err.SetErrorStringWithFormat ("%s is a scalar of unhandled type: %s",
|
|
|
|
name.GetCString(),
|
|
|
|
ss.GetString().c_str());
|
2010-10-06 04:18:48 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-10 04:18:18 +08:00
|
|
|
RegisterInfo *reg_info = location_value->GetRegisterInfo();
|
2010-10-06 04:18:48 +08:00
|
|
|
|
2011-05-10 04:18:18 +08:00
|
|
|
if (!reg_info)
|
2010-10-06 04:18:48 +08:00
|
|
|
{
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
err.SetErrorStringWithFormat ("Couldn't get the register information for %s",
|
|
|
|
name.GetCString());
|
2010-10-06 04:18:48 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-10 04:18:18 +08:00
|
|
|
RegisterValue reg_value;
|
|
|
|
|
|
|
|
RegisterContext *reg_ctx = exe_ctx.GetRegisterContext();
|
|
|
|
|
|
|
|
if (!reg_ctx)
|
2010-10-06 04:18:48 +08:00
|
|
|
{
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
err.SetErrorStringWithFormat ("Couldn't read register context to read %s from %s",
|
|
|
|
name.GetCString(),
|
|
|
|
reg_info->name);
|
2010-10-06 04:18:48 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-10 04:18:18 +08:00
|
|
|
uint32_t register_byte_size = reg_info->byte_size;
|
2010-10-06 04:18:48 +08:00
|
|
|
|
|
|
|
if (dematerialize)
|
|
|
|
{
|
2011-01-13 16:53:35 +08:00
|
|
|
// Get the location of the spare memory area out of the variable's live data.
|
|
|
|
|
|
|
|
if (!expr_var->m_live_sp)
|
|
|
|
{
|
|
|
|
err.SetErrorStringWithFormat("Couldn't find the memory area used to store %s", name.GetCString());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-03-25 05:19:54 +08:00
|
|
|
if (expr_var->m_live_sp->GetValue().GetValueAddressType() != eAddressTypeLoad)
|
2011-01-13 16:53:35 +08:00
|
|
|
{
|
|
|
|
err.SetErrorStringWithFormat("The address of the memory area for %s is in an incorrect format", name.GetCString());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
Scalar ®_addr = expr_var->m_live_sp->GetValue().GetScalar();
|
2010-10-06 04:18:48 +08:00
|
|
|
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
err = reg_ctx->ReadRegisterValueFromMemory (reg_info,
|
|
|
|
reg_addr.ULongLong(),
|
|
|
|
value_byte_size,
|
|
|
|
reg_value);
|
2011-05-10 04:18:18 +08:00
|
|
|
if (err.Fail())
|
2010-10-06 04:18:48 +08:00
|
|
|
return false;
|
2011-05-10 04:18:18 +08:00
|
|
|
|
|
|
|
if (!reg_ctx->WriteRegister (reg_info, reg_value))
|
2010-10-06 04:18:48 +08:00
|
|
|
{
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
err.SetErrorStringWithFormat ("Couldn't write %s to register %s",
|
|
|
|
name.GetCString(),
|
|
|
|
reg_info->name);
|
2010-10-06 04:18:48 +08:00
|
|
|
return false;
|
|
|
|
}
|
2011-01-13 16:53:35 +08:00
|
|
|
|
|
|
|
// Deallocate the spare area and clear the variable's live data.
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
Error deallocate_error = process->DeallocateMemory(reg_addr.ULongLong());
|
2011-01-13 16:53:35 +08:00
|
|
|
|
|
|
|
if (!deallocate_error.Success())
|
|
|
|
{
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
err.SetErrorStringWithFormat ("Couldn't deallocate spare memory area for %s: %s",
|
|
|
|
name.GetCString(),
|
|
|
|
deallocate_error.AsCString());
|
2011-01-13 16:53:35 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
expr_var->m_live_sp.reset();
|
2010-10-06 04:18:48 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-13 16:53:35 +08:00
|
|
|
// Allocate a spare memory area to place the register's contents into. This memory area will be pointed to by the slot in the
|
|
|
|
// struct.
|
|
|
|
|
|
|
|
Error allocate_error;
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
Scalar reg_addr (process->AllocateMemory (value_byte_size,
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
lldb::ePermissionsReadable | lldb::ePermissionsWritable,
|
|
|
|
allocate_error));
|
2011-01-13 16:53:35 +08:00
|
|
|
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
if (reg_addr.ULongLong() == LLDB_INVALID_ADDRESS)
|
2011-01-13 16:53:35 +08:00
|
|
|
{
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
err.SetErrorStringWithFormat ("Couldn't allocate a memory area to store %s: %s",
|
|
|
|
name.GetCString(),
|
|
|
|
allocate_error.AsCString());
|
2011-01-13 16:53:35 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Put the location of the spare memory into the live data of the ValueObject.
|
|
|
|
|
2011-04-23 07:53:53 +08:00
|
|
|
expr_var->m_live_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
|
|
|
|
type.GetASTContext(),
|
|
|
|
type.GetOpaqueQualType(),
|
|
|
|
name,
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
reg_addr.ULongLong(),
|
2011-04-23 07:53:53 +08:00
|
|
|
eAddressTypeLoad,
|
|
|
|
value_byte_size);
|
2011-01-13 16:53:35 +08:00
|
|
|
|
|
|
|
// Now write the location of the area into the struct.
|
|
|
|
|
|
|
|
Error write_error;
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
if (!process->WriteScalarToMemory (addr,
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
reg_addr,
|
2011-09-22 12:58:26 +08:00
|
|
|
process->GetAddressByteSize(),
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
write_error))
|
2011-01-13 16:53:35 +08:00
|
|
|
{
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s",
|
|
|
|
name.GetCString(),
|
|
|
|
write_error.AsCString());
|
2011-01-13 16:53:35 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value_byte_size > register_byte_size)
|
2010-10-06 04:18:48 +08:00
|
|
|
{
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
err.SetErrorStringWithFormat ("%s is too big to store in %s",
|
|
|
|
name.GetCString(),
|
|
|
|
reg_info->name);
|
2010-10-06 04:18:48 +08:00
|
|
|
return false;
|
|
|
|
}
|
2011-05-10 04:18:18 +08:00
|
|
|
|
|
|
|
RegisterValue reg_value;
|
|
|
|
|
|
|
|
if (!reg_ctx->ReadRegister (reg_info, reg_value))
|
2010-10-06 04:18:48 +08:00
|
|
|
{
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
err.SetErrorStringWithFormat ("Couldn't read %s from %s",
|
|
|
|
name.GetCString(),
|
|
|
|
reg_info->name);
|
2010-10-06 04:18:48 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
2011-05-23 06:46:53 +08:00
|
|
|
err = reg_ctx->WriteRegisterValueToMemory (reg_info,
|
|
|
|
reg_addr.ULongLong(),
|
|
|
|
value_byte_size,
|
|
|
|
reg_value);
|
2011-05-10 04:18:18 +08:00
|
|
|
if (err.Fail())
|
2010-10-06 04:18:48 +08:00
|
|
|
return false;
|
|
|
|
}
|
2010-07-21 07:31:16 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2010-07-16 08:09:46 +08:00
|
|
|
}
|
|
|
|
|
2010-11-30 08:27:43 +08:00
|
|
|
bool
|
|
|
|
ClangExpressionDeclMap::DoMaterializeOneRegister
|
|
|
|
(
|
|
|
|
bool dematerialize,
|
|
|
|
ExecutionContext &exe_ctx,
|
|
|
|
RegisterContext ®_ctx,
|
2011-03-25 05:19:54 +08:00
|
|
|
const RegisterInfo ®_info,
|
2010-11-30 08:27:43 +08:00
|
|
|
lldb::addr_t addr,
|
|
|
|
Error &err
|
|
|
|
)
|
|
|
|
{
|
|
|
|
uint32_t register_byte_size = reg_info.byte_size;
|
2011-05-10 04:18:18 +08:00
|
|
|
RegisterValue reg_value;
|
2010-11-30 08:27:43 +08:00
|
|
|
if (dematerialize)
|
|
|
|
{
|
2011-05-10 04:18:18 +08:00
|
|
|
Error read_error (reg_ctx.ReadRegisterValueFromMemory(®_info, addr, register_byte_size, reg_value));
|
|
|
|
if (read_error.Fail())
|
2010-11-30 08:27:43 +08:00
|
|
|
{
|
2011-01-26 07:55:37 +08:00
|
|
|
err.SetErrorStringWithFormat ("Couldn't read %s from the target: %s", reg_info.name, read_error.AsCString());
|
2010-11-30 08:27:43 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-10 04:18:18 +08:00
|
|
|
if (!reg_ctx.WriteRegister (®_info, reg_value))
|
2010-11-30 08:27:43 +08:00
|
|
|
{
|
2011-05-10 04:18:18 +08:00
|
|
|
err.SetErrorStringWithFormat("Couldn't write register %s (dematerialize)", reg_info.name);
|
2010-11-30 08:27:43 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
2011-05-10 04:18:18 +08:00
|
|
|
if (!reg_ctx.ReadRegister(®_info, reg_value))
|
2010-11-30 08:27:43 +08:00
|
|
|
{
|
2011-05-10 04:18:18 +08:00
|
|
|
err.SetErrorStringWithFormat("Couldn't read %s (materialize)", reg_info.name);
|
2010-11-30 08:27:43 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-10 04:18:18 +08:00
|
|
|
Error write_error (reg_ctx.WriteRegisterValueToMemory(®_info, addr, register_byte_size, reg_value));
|
|
|
|
if (write_error.Fail())
|
2010-11-30 08:27:43 +08:00
|
|
|
{
|
2011-09-20 08:26:08 +08:00
|
|
|
err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", reg_info.name, write_error.AsCString());
|
2010-11-30 08:27:43 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-05-07 09:06:41 +08:00
|
|
|
lldb::VariableSP
|
2010-10-16 06:48:33 +08:00
|
|
|
ClangExpressionDeclMap::FindVariableInScope
|
|
|
|
(
|
|
|
|
StackFrame &frame,
|
|
|
|
const ConstString &name,
|
|
|
|
TypeFromUser *type
|
|
|
|
)
|
2010-12-03 09:38:59 +08:00
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
2010-09-15 05:59:34 +08:00
|
|
|
|
2011-08-06 08:28:14 +08:00
|
|
|
ValueObjectSP valobj;
|
|
|
|
VariableSP var_sp;
|
|
|
|
Error err;
|
|
|
|
|
|
|
|
valobj = frame.GetValueForVariableExpressionPath(name.GetCString(),
|
|
|
|
eNoDynamicValues,
|
|
|
|
StackFrame::eExpressionPathOptionCheckPtrVsMember,
|
|
|
|
var_sp,
|
|
|
|
err);
|
Just like functions can have a basename and a mangled/demangled name, variable
can too. So now the lldb_private::Variable class has support for this.
Variables now have support for having a basename ("i"), and a mangled name
("_ZN12_GLOBAL__N_11iE"), and a demangled name ("(anonymous namespace)::i").
Nowwhen searching for a variable by name, users might enter the fully qualified
name, or just the basename. So new test functions were added to the Variable
and Mangled classes as:
bool NameMatches (const ConstString &name);
bool NameMatches (const RegularExpression ®ex);
I also modified "ClangExpressionDeclMap::FindVariableInScope" to also search
for global variables that are not in the current file scope by first starting
with the current module, then moving on to all modules.
Fixed an issue in the DWARF parser that could cause a varaible to get parsed
more than once. Now, once we have parsed a VariableSP for a DIE, we cache
the result even if a variable wasn't made so we don't do any re-parsing. Some
DW_TAG_variable DIEs don't have locations, or are missing vital info that
stops a debugger from being able to display anything for it, we parse a NULL
variable shared pointer for these DIEs so we don't keep trying to reparse it.
llvm-svn: 119085
2010-11-15 06:13:40 +08:00
|
|
|
|
2011-08-06 08:28:14 +08:00
|
|
|
if (!err.Success() ||
|
|
|
|
!var_sp ||
|
2011-07-08 07:05:43 +08:00
|
|
|
!var_sp->IsInScope(&frame) ||
|
|
|
|
!var_sp->LocationIsValidForFrame (&frame))
|
|
|
|
return lldb::VariableSP();
|
Just like functions can have a basename and a mangled/demangled name, variable
can too. So now the lldb_private::Variable class has support for this.
Variables now have support for having a basename ("i"), and a mangled name
("_ZN12_GLOBAL__N_11iE"), and a demangled name ("(anonymous namespace)::i").
Nowwhen searching for a variable by name, users might enter the fully qualified
name, or just the basename. So new test functions were added to the Variable
and Mangled classes as:
bool NameMatches (const ConstString &name);
bool NameMatches (const RegularExpression ®ex);
I also modified "ClangExpressionDeclMap::FindVariableInScope" to also search
for global variables that are not in the current file scope by first starting
with the current module, then moving on to all modules.
Fixed an issue in the DWARF parser that could cause a varaible to get parsed
more than once. Now, once we have parsed a VariableSP for a DIE, we cache
the result even if a variable wasn't made so we don't do any re-parsing. Some
DW_TAG_variable DIEs don't have locations, or are missing vital info that
stops a debugger from being able to display anything for it, we parse a NULL
variable shared pointer for these DIEs so we don't keep trying to reparse it.
llvm-svn: 119085
2010-11-15 06:13:40 +08:00
|
|
|
|
|
|
|
if (var_sp && type)
|
|
|
|
{
|
|
|
|
if (type->GetASTContext() == var_sp->GetType()->GetClangAST())
|
|
|
|
{
|
2011-02-17 07:00:21 +08:00
|
|
|
if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var_sp->GetType()->GetClangFullType()))
|
2011-05-07 09:06:41 +08:00
|
|
|
return lldb::VariableSP();
|
Just like functions can have a basename and a mangled/demangled name, variable
can too. So now the lldb_private::Variable class has support for this.
Variables now have support for having a basename ("i"), and a mangled name
("_ZN12_GLOBAL__N_11iE"), and a demangled name ("(anonymous namespace)::i").
Nowwhen searching for a variable by name, users might enter the fully qualified
name, or just the basename. So new test functions were added to the Variable
and Mangled classes as:
bool NameMatches (const ConstString &name);
bool NameMatches (const RegularExpression ®ex);
I also modified "ClangExpressionDeclMap::FindVariableInScope" to also search
for global variables that are not in the current file scope by first starting
with the current module, then moving on to all modules.
Fixed an issue in the DWARF parser that could cause a varaible to get parsed
more than once. Now, once we have parsed a VariableSP for a DIE, we cache
the result even if a variable wasn't made so we don't do any re-parsing. Some
DW_TAG_variable DIEs don't have locations, or are missing vital info that
stops a debugger from being able to display anything for it, we parse a NULL
variable shared pointer for these DIEs so we don't keep trying to reparse it.
llvm-svn: 119085
2010-11-15 06:13:40 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->PutCString("Skipping a candidate variable because of different AST contexts");
|
2011-05-07 09:06:41 +08:00
|
|
|
return lldb::VariableSP();
|
Just like functions can have a basename and a mangled/demangled name, variable
can too. So now the lldb_private::Variable class has support for this.
Variables now have support for having a basename ("i"), and a mangled name
("_ZN12_GLOBAL__N_11iE"), and a demangled name ("(anonymous namespace)::i").
Nowwhen searching for a variable by name, users might enter the fully qualified
name, or just the basename. So new test functions were added to the Variable
and Mangled classes as:
bool NameMatches (const ConstString &name);
bool NameMatches (const RegularExpression ®ex);
I also modified "ClangExpressionDeclMap::FindVariableInScope" to also search
for global variables that are not in the current file scope by first starting
with the current module, then moving on to all modules.
Fixed an issue in the DWARF parser that could cause a varaible to get parsed
more than once. Now, once we have parsed a VariableSP for a DIE, we cache
the result even if a variable wasn't made so we don't do any re-parsing. Some
DW_TAG_variable DIEs don't have locations, or are missing vital info that
stops a debugger from being able to display anything for it, we parse a NULL
variable shared pointer for these DIEs so we don't keep trying to reparse it.
llvm-svn: 119085
2010-11-15 06:13:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-07 09:06:41 +08:00
|
|
|
return var_sp;
|
2010-09-15 05:59:34 +08:00
|
|
|
}
|
2010-07-17 08:43:37 +08:00
|
|
|
|
2011-05-08 10:21:26 +08:00
|
|
|
Symbol *
|
|
|
|
ClangExpressionDeclMap::FindGlobalDataSymbol
|
|
|
|
(
|
|
|
|
Target &target,
|
2011-10-14 00:49:47 +08:00
|
|
|
const ConstString &name
|
2011-05-08 10:21:26 +08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
SymbolContextList sc_list;
|
|
|
|
|
2011-10-14 00:49:47 +08:00
|
|
|
target.GetImages().FindSymbolsWithNameAndType(name,
|
|
|
|
eSymbolTypeData,
|
|
|
|
sc_list);
|
2011-05-08 10:21:26 +08:00
|
|
|
|
|
|
|
if (sc_list.GetSize())
|
|
|
|
{
|
|
|
|
SymbolContext sym_ctx;
|
|
|
|
sc_list.GetContextAtIndex(0, sym_ctx);
|
|
|
|
|
|
|
|
return sym_ctx.symbol;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
lldb::VariableSP
|
|
|
|
ClangExpressionDeclMap::FindGlobalVariable
|
|
|
|
(
|
|
|
|
Target &target,
|
2011-10-13 00:59:31 +08:00
|
|
|
ModuleSP &module,
|
|
|
|
const ConstString &name,
|
|
|
|
ClangNamespaceDecl *namespace_decl,
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
TypeFromUser *type
|
|
|
|
)
|
|
|
|
{
|
|
|
|
VariableList vars;
|
|
|
|
|
2011-10-13 00:59:31 +08:00
|
|
|
if (module && namespace_decl)
|
|
|
|
module->FindGlobalVariables (name, namespace_decl, true, -1, vars);
|
|
|
|
else
|
|
|
|
target.GetImages().FindGlobalVariables(name, true, -1, vars);
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
|
|
|
|
if (vars.GetSize())
|
|
|
|
{
|
|
|
|
if (type)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < vars.GetSize(); ++i)
|
|
|
|
{
|
|
|
|
VariableSP var_sp = vars.GetVariableAtIndex(i);
|
|
|
|
|
|
|
|
if (type->GetASTContext() == var_sp->GetType()->GetClangAST())
|
|
|
|
{
|
|
|
|
if (ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var_sp->GetType()->GetClangFullType()))
|
|
|
|
return var_sp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return vars.GetVariableAtIndex(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return VariableSP();
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
// Interface for ClangASTSource
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
|
2011-10-12 08:12:34 +08:00
|
|
|
void
|
|
|
|
ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context, const ConstString &name)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-12-03 09:38:59 +08:00
|
|
|
if (m_parser_vars->m_ignore_lookups)
|
2010-11-20 04:20:02 +08:00
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Ignoring a query during an import");
|
|
|
|
return;
|
|
|
|
}
|
2011-06-25 08:44:06 +08:00
|
|
|
|
2011-10-12 08:12:34 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
if (!context.m_decl_context)
|
|
|
|
log->Printf("FindExternalVisibleDecls for '%s' in a NULL DeclContext", name.GetCString());
|
|
|
|
else if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context.m_decl_context))
|
|
|
|
log->Printf("FindExternalVisibleDecls for '%s' in '%s'", name.GetCString(), context_named_decl->getNameAsString().c_str());
|
|
|
|
else
|
|
|
|
log->Printf("FindExternalVisibleDecls for '%s' in a '%s'", name.GetCString(), context.m_decl_context->getDeclKindName());
|
|
|
|
}
|
2011-10-14 05:08:11 +08:00
|
|
|
|
|
|
|
context.m_namespace_map.reset(new ClangASTImporter::NamespaceMap);
|
2011-10-12 08:12:34 +08:00
|
|
|
|
|
|
|
if (const NamespaceDecl *namespace_context = dyn_cast<NamespaceDecl>(context.m_decl_context))
|
|
|
|
{
|
|
|
|
ClangASTImporter::NamespaceMapSP namespace_map = m_parser_vars->m_ast_importer->GetNamespaceMap(namespace_context);
|
2011-10-14 05:08:11 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
log->Printf("Inspecting namespace map %p (%d entries)", namespace_map.get(), (int)namespace_map->size());
|
|
|
|
|
2011-10-12 08:12:34 +08:00
|
|
|
for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(), e = namespace_map->end();
|
|
|
|
i != e;
|
|
|
|
++i)
|
|
|
|
{
|
|
|
|
if (log)
|
2011-10-14 05:08:11 +08:00
|
|
|
log->Printf(" Searching namespace %s in module %s",
|
2011-10-12 08:12:34 +08:00
|
|
|
i->second.GetNamespaceDecl()->getNameAsString().c_str(),
|
|
|
|
i->first->GetFileSpec().GetFilename().GetCString());
|
|
|
|
|
2011-10-14 05:50:33 +08:00
|
|
|
FindExternalVisibleDecls(context,
|
|
|
|
i->first,
|
|
|
|
i->second,
|
|
|
|
name);
|
2011-10-12 08:12:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!isa<TranslationUnitDecl>(context.m_decl_context))
|
|
|
|
{
|
|
|
|
// we shouldn't be getting FindExternalVisibleDecls calls for these
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ClangNamespaceDecl namespace_decl;
|
|
|
|
|
|
|
|
if (log)
|
2011-10-13 00:59:31 +08:00
|
|
|
log->Printf(" Searching the root namespace");
|
2011-10-12 08:12:34 +08:00
|
|
|
|
|
|
|
FindExternalVisibleDecls(context,
|
|
|
|
lldb::ModuleSP(),
|
|
|
|
namespace_decl,
|
|
|
|
name);
|
|
|
|
}
|
2011-10-14 05:08:11 +08:00
|
|
|
|
|
|
|
if (!context.m_namespace_map->empty())
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Registering namespace map %p (%d entries)", context.m_namespace_map.get(), (int)context.m_namespace_map->size());
|
|
|
|
|
|
|
|
NamespaceDecl *clang_namespace_decl = AddNamespace(context, context.m_namespace_map);
|
|
|
|
|
|
|
|
if (clang_namespace_decl)
|
|
|
|
clang_namespace_decl->setHasExternalVisibleStorage();
|
|
|
|
}
|
2011-10-12 08:12:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ClangExpressionDeclMap::FindExternalVisibleDecls (NameSearchContext &context,
|
2011-10-13 02:44:30 +08:00
|
|
|
lldb::ModuleSP module_sp,
|
2011-10-12 09:39:28 +08:00
|
|
|
ClangNamespaceDecl &namespace_decl,
|
2011-10-12 08:12:34 +08:00
|
|
|
const ConstString &name)
|
|
|
|
{
|
|
|
|
assert (m_struct_vars.get());
|
|
|
|
assert (m_parser_vars.get());
|
|
|
|
|
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
2011-06-25 08:44:06 +08:00
|
|
|
|
2010-11-10 07:46:37 +08:00
|
|
|
SymbolContextList sc_list;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
Just like functions can have a basename and a mangled/demangled name, variable
can too. So now the lldb_private::Variable class has support for this.
Variables now have support for having a basename ("i"), and a mangled name
("_ZN12_GLOBAL__N_11iE"), and a demangled name ("(anonymous namespace)::i").
Nowwhen searching for a variable by name, users might enter the fully qualified
name, or just the basename. So new test functions were added to the Variable
and Mangled classes as:
bool NameMatches (const ConstString &name);
bool NameMatches (const RegularExpression ®ex);
I also modified "ClangExpressionDeclMap::FindVariableInScope" to also search
for global variables that are not in the current file scope by first starting
with the current module, then moving on to all modules.
Fixed an issue in the DWARF parser that could cause a varaible to get parsed
more than once. Now, once we have parsed a VariableSP for a DIE, we cache
the result even if a variable wasn't made so we don't do any re-parsing. Some
DW_TAG_variable DIEs don't have locations, or are missing vital info that
stops a debugger from being able to display anything for it, we parse a NULL
variable shared pointer for these DIEs so we don't keep trying to reparse it.
llvm-svn: 119085
2010-11-15 06:13:40 +08:00
|
|
|
const char *name_unique_cstr = name.GetCString();
|
|
|
|
|
|
|
|
if (name_unique_cstr == NULL)
|
|
|
|
return;
|
|
|
|
|
2010-10-16 06:48:33 +08:00
|
|
|
// Only look for functions by name out in our symbols if the function
|
|
|
|
// doesn't start with our phony prefix of '$'
|
2011-09-22 12:58:26 +08:00
|
|
|
Target *target = m_parser_vars->m_exe_ctx->GetTargetPtr();
|
|
|
|
StackFrame *frame = m_parser_vars->m_exe_ctx->GetFramePtr();
|
2011-10-12 09:39:28 +08:00
|
|
|
if (name_unique_cstr[0] == '$' && !namespace_decl)
|
2010-10-06 08:10:07 +08:00
|
|
|
{
|
2010-11-09 12:42:43 +08:00
|
|
|
static ConstString g_lldb_class_name ("$__lldb_class");
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
|
2010-11-09 12:42:43 +08:00
|
|
|
if (name == g_lldb_class_name)
|
|
|
|
{
|
|
|
|
// Clang is looking for the type of "this"
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
if (!frame)
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
return;
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
VariableList *vars = frame->GetVariableList(false);
|
2010-11-09 12:42:43 +08:00
|
|
|
|
|
|
|
if (!vars)
|
|
|
|
return;
|
|
|
|
|
|
|
|
lldb::VariableSP this_var = vars->FindVariable(ConstString("this"));
|
|
|
|
|
2011-07-07 02:55:08 +08:00
|
|
|
if (!this_var ||
|
2011-09-22 12:58:26 +08:00
|
|
|
!this_var->IsInScope(frame) ||
|
|
|
|
!this_var->LocationIsValidForFrame (frame))
|
2010-11-09 12:42:43 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
Type *this_type = this_var->GetType();
|
|
|
|
|
|
|
|
if (!this_type)
|
|
|
|
return;
|
|
|
|
|
2010-11-16 10:10:54 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
log->PutCString ("Type for \"this\" is: ");
|
|
|
|
StreamString strm;
|
|
|
|
this_type->Dump(&strm, true);
|
|
|
|
log->PutCString (strm.GetData());
|
|
|
|
}
|
2011-10-12 09:39:28 +08:00
|
|
|
|
2011-02-17 07:00:21 +08:00
|
|
|
TypeFromUser this_user_type(this_type->GetClangFullType(),
|
2010-11-09 12:42:43 +08:00
|
|
|
this_type->GetClangAST());
|
|
|
|
|
2010-12-03 09:38:59 +08:00
|
|
|
m_struct_vars->m_object_pointer_type = this_user_type;
|
2010-11-09 12:42:43 +08:00
|
|
|
|
2011-07-08 08:39:14 +08:00
|
|
|
void *pointer_target_type = NULL;
|
2010-11-09 12:42:43 +08:00
|
|
|
|
|
|
|
if (!ClangASTContext::IsPointerType(this_user_type.GetOpaqueQualType(),
|
|
|
|
&pointer_target_type))
|
|
|
|
return;
|
|
|
|
|
2011-08-06 07:43:37 +08:00
|
|
|
clang::QualType pointer_target_qual_type = QualType::getFromOpaquePtr(pointer_target_type);
|
|
|
|
|
|
|
|
if (pointer_target_qual_type.isConstQualified())
|
|
|
|
pointer_target_qual_type.removeLocalConst();
|
|
|
|
|
|
|
|
TypeFromUser class_user_type(pointer_target_qual_type.getAsOpaquePtr(),
|
2010-11-09 12:42:43 +08:00
|
|
|
this_type->GetClangAST());
|
2011-10-12 09:39:28 +08:00
|
|
|
|
2010-12-14 06:46:15 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
StreamString type_stream;
|
|
|
|
class_user_type.DumpTypeCode(&type_stream);
|
|
|
|
type_stream.Flush();
|
|
|
|
log->Printf("Adding type for $__lldb_class: %s", type_stream.GetString().c_str());
|
|
|
|
}
|
|
|
|
|
2010-11-09 12:42:43 +08:00
|
|
|
AddOneType(context, class_user_type, true);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-12-14 06:46:15 +08:00
|
|
|
static ConstString g_lldb_objc_class_name ("$__lldb_objc_class");
|
|
|
|
if (name == g_lldb_objc_class_name)
|
|
|
|
{
|
|
|
|
// Clang is looking for the type of "*self"
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
if (!frame)
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
return;
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
VariableList *vars = frame->GetVariableList(false);
|
2011-10-12 09:39:28 +08:00
|
|
|
|
2010-12-14 06:46:15 +08:00
|
|
|
if (!vars)
|
|
|
|
return;
|
2011-10-12 09:39:28 +08:00
|
|
|
|
2010-12-14 06:46:15 +08:00
|
|
|
lldb::VariableSP self_var = vars->FindVariable(ConstString("self"));
|
2011-10-12 09:39:28 +08:00
|
|
|
|
2011-07-07 02:55:08 +08:00
|
|
|
if (!self_var ||
|
2011-09-22 12:58:26 +08:00
|
|
|
!self_var->IsInScope(frame) ||
|
|
|
|
!self_var->LocationIsValidForFrame (frame))
|
2010-12-14 06:46:15 +08:00
|
|
|
return;
|
2011-10-12 09:39:28 +08:00
|
|
|
|
2010-12-14 06:46:15 +08:00
|
|
|
Type *self_type = self_var->GetType();
|
|
|
|
|
|
|
|
if (!self_type)
|
|
|
|
return;
|
2011-10-12 09:39:28 +08:00
|
|
|
|
2011-02-17 07:00:21 +08:00
|
|
|
TypeFromUser self_user_type(self_type->GetClangFullType(),
|
2010-12-14 06:46:15 +08:00
|
|
|
self_type->GetClangAST());
|
|
|
|
|
|
|
|
m_struct_vars->m_object_pointer_type = self_user_type;
|
2011-10-12 09:39:28 +08:00
|
|
|
|
2011-07-08 08:39:14 +08:00
|
|
|
void *pointer_target_type = NULL;
|
2011-10-12 09:39:28 +08:00
|
|
|
|
2010-12-14 06:46:15 +08:00
|
|
|
if (!ClangASTContext::IsPointerType(self_user_type.GetOpaqueQualType(),
|
2011-07-09 02:34:32 +08:00
|
|
|
&pointer_target_type)
|
2011-07-09 02:27:39 +08:00
|
|
|
|| pointer_target_type == NULL)
|
2010-12-14 06:46:15 +08:00
|
|
|
return;
|
2011-10-12 09:39:28 +08:00
|
|
|
|
2010-12-14 06:46:15 +08:00
|
|
|
TypeFromUser class_user_type(pointer_target_type,
|
|
|
|
self_type->GetClangAST());
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
StreamString type_stream;
|
|
|
|
class_user_type.DumpTypeCode(&type_stream);
|
|
|
|
type_stream.Flush();
|
|
|
|
log->Printf("Adding type for $__lldb_objc_class: %s", type_stream.GetString().c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
AddOneType(context, class_user_type, false);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2011-10-08 07:18:13 +08:00
|
|
|
|
|
|
|
// any other $__lldb names should be weeded out now
|
|
|
|
if (!::strncmp(name_unique_cstr, "$__lldb", sizeof("$__lldb") - 1))
|
|
|
|
return;
|
2011-10-12 09:39:28 +08:00
|
|
|
|
2011-08-24 05:20:51 +08:00
|
|
|
do
|
|
|
|
{
|
2011-09-22 12:58:26 +08:00
|
|
|
if (!target)
|
2011-08-24 05:20:51 +08:00
|
|
|
break;
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
ClangASTContext *scratch_clang_ast_context = target->GetScratchClangASTContext();
|
2011-08-24 05:20:51 +08:00
|
|
|
|
|
|
|
if (!scratch_clang_ast_context)
|
|
|
|
break;
|
|
|
|
|
|
|
|
ASTContext *scratch_ast_context = scratch_clang_ast_context->getASTContext();
|
|
|
|
|
|
|
|
if (!scratch_ast_context)
|
|
|
|
break;
|
|
|
|
|
|
|
|
TypeDecl *ptype_type_decl = m_parser_vars->m_persistent_vars->GetPersistentType(name);
|
2011-10-12 09:39:28 +08:00
|
|
|
|
2011-08-24 05:20:51 +08:00
|
|
|
if (!ptype_type_decl)
|
|
|
|
break;
|
|
|
|
|
|
|
|
Decl *parser_ptype_decl = ClangASTContext::CopyDecl(context.GetASTContext(), scratch_ast_context, ptype_type_decl);
|
|
|
|
|
|
|
|
if (!parser_ptype_decl)
|
|
|
|
break;
|
|
|
|
|
|
|
|
TypeDecl *parser_ptype_type_decl = dyn_cast<TypeDecl>(parser_ptype_decl);
|
|
|
|
|
|
|
|
if (!parser_ptype_type_decl)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
log->Printf("Found persistent type %s", name.GetCString());
|
|
|
|
|
|
|
|
context.AddNamedDecl(parser_ptype_type_decl);
|
|
|
|
} while (0);
|
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
ClangExpressionVariableSP pvar_sp(m_parser_vars->m_persistent_vars->GetVariable(name));
|
2011-10-12 09:39:28 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
if (pvar_sp)
|
2010-11-30 08:27:43 +08:00
|
|
|
{
|
2010-12-14 10:59:59 +08:00
|
|
|
AddOneVariable(context, pvar_sp);
|
2010-11-30 08:27:43 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *reg_name(&name.GetCString()[1]);
|
|
|
|
|
2010-12-03 09:38:59 +08:00
|
|
|
if (m_parser_vars->m_exe_ctx->GetRegisterContext())
|
2010-11-30 08:27:43 +08:00
|
|
|
{
|
2011-03-25 05:19:54 +08:00
|
|
|
const RegisterInfo *reg_info(m_parser_vars->m_exe_ctx->GetRegisterContext()->GetRegisterInfoByName(reg_name));
|
2010-11-30 08:27:43 +08:00
|
|
|
|
|
|
|
if (reg_info)
|
|
|
|
AddOneRegister(context, reg_info);
|
|
|
|
}
|
2010-10-16 06:48:33 +08:00
|
|
|
}
|
2011-10-12 09:39:28 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ValueObjectSP valobj;
|
|
|
|
VariableSP var;
|
|
|
|
Error err;
|
|
|
|
|
|
|
|
if (frame && !namespace_decl)
|
|
|
|
{
|
|
|
|
valobj = frame->GetValueForVariableExpressionPath(name_unique_cstr,
|
|
|
|
eNoDynamicValues,
|
|
|
|
StackFrame::eExpressionPathOptionCheckPtrVsMember,
|
|
|
|
var,
|
|
|
|
err);
|
|
|
|
|
|
|
|
// If we found a variable in scope, no need to pull up function names
|
|
|
|
if (err.Success() && var != NULL)
|
|
|
|
{
|
|
|
|
AddOneVariable(context, var);
|
2011-10-13 04:29:25 +08:00
|
|
|
context.m_found.variable = true;
|
2011-10-12 09:39:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (target)
|
|
|
|
{
|
2011-10-13 00:59:31 +08:00
|
|
|
var = FindGlobalVariable (*target,
|
2011-10-13 02:44:30 +08:00
|
|
|
module_sp,
|
2011-10-13 00:59:31 +08:00
|
|
|
name,
|
|
|
|
&namespace_decl,
|
2011-10-12 09:39:28 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (var)
|
|
|
|
{
|
|
|
|
AddOneVariable(context, var);
|
2011-10-13 04:29:25 +08:00
|
|
|
context.m_found.variable = true;
|
2011-10-12 09:39:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-13 04:29:25 +08:00
|
|
|
if (!context.m_found.variable)
|
2011-10-12 09:39:28 +08:00
|
|
|
{
|
|
|
|
const bool include_symbols = true;
|
|
|
|
const bool append = false;
|
2011-10-13 01:38:09 +08:00
|
|
|
|
2011-10-13 02:44:30 +08:00
|
|
|
if (namespace_decl && module_sp)
|
2011-10-13 01:38:09 +08:00
|
|
|
{
|
2011-10-13 02:44:30 +08:00
|
|
|
module_sp->FindFunctions(name,
|
|
|
|
&namespace_decl,
|
|
|
|
eFunctionNameTypeBase,
|
|
|
|
include_symbols,
|
|
|
|
append,
|
|
|
|
sc_list);
|
2011-10-13 01:38:09 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
target->GetImages().FindFunctions(name,
|
|
|
|
eFunctionNameTypeBase,
|
|
|
|
include_symbols,
|
|
|
|
append,
|
|
|
|
sc_list);
|
|
|
|
}
|
|
|
|
|
2011-10-12 09:39:28 +08:00
|
|
|
if (sc_list.GetSize())
|
|
|
|
{
|
|
|
|
Symbol *generic_symbol = NULL;
|
|
|
|
Symbol *non_extern_symbol = NULL;
|
|
|
|
|
|
|
|
for (uint32_t index = 0, num_indices = sc_list.GetSize();
|
|
|
|
index < num_indices;
|
|
|
|
++index)
|
|
|
|
{
|
|
|
|
SymbolContext sym_ctx;
|
|
|
|
sc_list.GetContextAtIndex(index, sym_ctx);
|
|
|
|
|
|
|
|
if (sym_ctx.function)
|
|
|
|
{
|
|
|
|
// TODO only do this if it's a C function; C++ functions may be
|
|
|
|
// overloaded
|
2011-10-13 04:29:25 +08:00
|
|
|
if (!context.m_found.function_with_type_info)
|
2011-10-12 09:39:28 +08:00
|
|
|
AddOneFunction(context, sym_ctx.function, NULL);
|
2011-10-13 04:29:25 +08:00
|
|
|
context.m_found.function_with_type_info = true;
|
|
|
|
context.m_found.function = true;
|
2011-10-12 09:39:28 +08:00
|
|
|
}
|
|
|
|
else if (sym_ctx.symbol)
|
|
|
|
{
|
|
|
|
if (sym_ctx.symbol->IsExternal())
|
|
|
|
generic_symbol = sym_ctx.symbol;
|
|
|
|
else
|
|
|
|
non_extern_symbol = sym_ctx.symbol;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-13 04:29:25 +08:00
|
|
|
if (!context.m_found.function_with_type_info)
|
2011-10-12 09:39:28 +08:00
|
|
|
{
|
|
|
|
if (generic_symbol)
|
|
|
|
{
|
|
|
|
AddOneFunction (context, NULL, generic_symbol);
|
2011-10-13 04:29:25 +08:00
|
|
|
context.m_found.function = true;
|
2011-10-12 09:39:28 +08:00
|
|
|
}
|
|
|
|
else if (non_extern_symbol)
|
|
|
|
{
|
|
|
|
AddOneFunction (context, NULL, non_extern_symbol);
|
2011-10-13 04:29:25 +08:00
|
|
|
context.m_found.function = true;
|
2011-10-12 09:39:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-13 04:29:25 +08:00
|
|
|
if (!context.m_found.variable)
|
2011-10-12 09:39:28 +08:00
|
|
|
{
|
2011-10-13 04:29:25 +08:00
|
|
|
// We couldn't find a non-symbol variable for this. Now we'll hunt for a generic
|
2011-10-12 09:39:28 +08:00
|
|
|
// data symbol, and -- if it is found -- treat it as a variable.
|
|
|
|
|
2011-10-14 00:49:47 +08:00
|
|
|
Symbol *data_symbol = FindGlobalDataSymbol(*target, name);
|
2011-10-12 09:39:28 +08:00
|
|
|
|
|
|
|
if (data_symbol)
|
|
|
|
{
|
|
|
|
AddOneGenericVariable(context, *data_symbol);
|
2011-10-13 04:29:25 +08:00
|
|
|
context.m_found.variable = true;
|
2011-10-12 09:39:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-14 05:08:11 +08:00
|
|
|
if (module_sp && namespace_decl)
|
2011-10-12 09:39:28 +08:00
|
|
|
{
|
2011-10-14 05:08:11 +08:00
|
|
|
ClangNamespaceDecl found_namespace_decl;
|
2011-10-12 09:39:28 +08:00
|
|
|
|
2011-10-14 05:08:11 +08:00
|
|
|
SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor();
|
2011-10-12 09:39:28 +08:00
|
|
|
|
2011-10-14 05:08:11 +08:00
|
|
|
if (symbol_vendor)
|
2011-10-12 09:39:28 +08:00
|
|
|
{
|
2011-10-14 05:08:11 +08:00
|
|
|
SymbolContext null_sc;
|
2011-10-12 09:39:28 +08:00
|
|
|
|
2011-10-14 05:08:11 +08:00
|
|
|
found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &namespace_decl);
|
|
|
|
|
|
|
|
if (found_namespace_decl)
|
|
|
|
{
|
|
|
|
context.m_namespace_map->push_back(std::pair<ModuleSP, ClangNamespaceDecl>(module_sp, found_namespace_decl));
|
2011-10-12 09:39:28 +08:00
|
|
|
|
2011-10-14 05:08:11 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("Found namespace %s in module %s",
|
|
|
|
name.GetCString(),
|
|
|
|
module_sp->GetFileSpec().GetFilename().GetCString());
|
2011-10-12 09:39:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-10-14 05:08:11 +08:00
|
|
|
else
|
2011-10-12 09:39:28 +08:00
|
|
|
{
|
2011-10-14 05:08:11 +08:00
|
|
|
ModuleList &images = m_parser_vars->m_sym_ctx.target_sp->GetImages();
|
|
|
|
|
|
|
|
for (uint32_t i = 0, e = images.GetSize();
|
|
|
|
i != e;
|
|
|
|
++i)
|
|
|
|
{
|
|
|
|
ModuleSP image = images.GetModuleAtIndex(i);
|
|
|
|
|
|
|
|
if (!image)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ClangNamespaceDecl found_namespace_decl;
|
|
|
|
|
|
|
|
SymbolVendor *symbol_vendor = image->GetSymbolVendor();
|
|
|
|
|
|
|
|
if (!symbol_vendor)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
SymbolContext null_sc;
|
|
|
|
|
|
|
|
found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &namespace_decl);
|
|
|
|
|
|
|
|
if (found_namespace_decl)
|
|
|
|
{
|
|
|
|
context.m_namespace_map->push_back(std::pair<ModuleSP, ClangNamespaceDecl>(image, found_namespace_decl));
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
log->Printf("Found namespace %s in module %s",
|
|
|
|
name.GetCString(),
|
|
|
|
image->GetFileSpec().GetFilename().GetCString());
|
|
|
|
}
|
|
|
|
}
|
2011-10-12 09:39:28 +08:00
|
|
|
}
|
|
|
|
}
|
2010-08-11 11:57:18 +08:00
|
|
|
|
2011-10-13 02:44:30 +08:00
|
|
|
TypeList types;
|
|
|
|
SymbolContext null_sc;
|
|
|
|
|
|
|
|
if (module_sp && namespace_decl)
|
|
|
|
module_sp->FindTypes(null_sc, name, &namespace_decl, true, 1, types);
|
|
|
|
else
|
|
|
|
target->GetImages().FindTypes (null_sc, name, true, 1, types);
|
|
|
|
|
|
|
|
if (types.GetSize())
|
2010-11-20 04:20:02 +08:00
|
|
|
{
|
2011-10-13 02:44:30 +08:00
|
|
|
TypeSP type_sp = types.GetTypeAtIndex(0);
|
|
|
|
|
2010-11-20 04:20:02 +08:00
|
|
|
if (log)
|
2010-09-28 07:54:58 +08:00
|
|
|
{
|
2011-10-13 02:44:30 +08:00
|
|
|
log->Printf("Matching type found for \"%s\": ", name.GetCString());
|
2010-11-20 04:20:02 +08:00
|
|
|
StreamString strm;
|
|
|
|
type_sp->Dump(&strm, true);
|
|
|
|
log->PutCString (strm.GetData());
|
|
|
|
}
|
2010-11-16 10:10:54 +08:00
|
|
|
|
2011-10-13 02:44:30 +08:00
|
|
|
TypeFromUser user_type(type_sp->GetClangFullType(),
|
|
|
|
type_sp->GetClangAST());
|
2010-09-28 07:54:58 +08:00
|
|
|
|
2010-11-20 04:20:02 +08:00
|
|
|
AddOneType(context, user_type, false);
|
2010-09-28 07:54:58 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2011-06-25 08:44:06 +08:00
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
clang::ExternalLoadResult
|
|
|
|
ClangExpressionDeclMap::FindExternalLexicalDecls (const DeclContext *decl_context,
|
|
|
|
bool (*predicate)(Decl::Kind),
|
|
|
|
llvm::SmallVectorImpl<Decl*> &decls)
|
2011-06-25 08:44:06 +08:00
|
|
|
{
|
2011-07-30 10:42:06 +08:00
|
|
|
assert (m_parser_vars.get());
|
|
|
|
|
2011-06-25 08:44:06 +08:00
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
2011-07-30 10:42:06 +08:00
|
|
|
|
|
|
|
const Decl *context_decl = dyn_cast<Decl>(decl_context);
|
|
|
|
|
|
|
|
if (!context_decl)
|
|
|
|
return ELR_Failure;
|
|
|
|
|
|
|
|
ASTContext *ast_context = &context_decl->getASTContext();
|
|
|
|
|
|
|
|
if (log)
|
2011-10-12 08:12:34 +08:00
|
|
|
{
|
|
|
|
if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context_decl))
|
|
|
|
log->Printf("FindExternalLexicalDecls in '%s' (a %s) with %s predicate",
|
|
|
|
context_named_decl->getNameAsString().c_str(),
|
|
|
|
context_decl->getDeclKindName(),
|
|
|
|
(predicate ? "non-null" : "null"));
|
|
|
|
else if(context_decl)
|
|
|
|
log->Printf("FindExternalLexicalDecls in a %s with %s predicate",
|
|
|
|
context_decl->getDeclKindName(),
|
|
|
|
(predicate ? "non-null" : "null"));
|
|
|
|
else
|
|
|
|
log->Printf("FindExternalLexicalDecls in a NULL context with %s predicate",
|
|
|
|
(predicate ? "non-null" : "null"));
|
|
|
|
}
|
2011-07-30 10:42:06 +08:00
|
|
|
|
|
|
|
Decl *original_decl = NULL;
|
|
|
|
ASTContext *original_ctx = NULL;
|
|
|
|
|
|
|
|
ClangASTImporter *ast_importer = m_parser_vars->GetASTImporter(ast_context);
|
|
|
|
|
|
|
|
if (!ast_importer)
|
|
|
|
return ELR_Failure;
|
|
|
|
|
|
|
|
if (!ast_importer->ResolveDeclOrigin(context_decl, &original_decl, &original_ctx))
|
|
|
|
return ELR_Failure;
|
|
|
|
|
2011-06-25 08:44:06 +08:00
|
|
|
if (log)
|
|
|
|
{
|
2011-07-30 10:42:06 +08:00
|
|
|
std::string decl_print_string;
|
|
|
|
llvm::raw_string_ostream decl_print_stream(decl_print_string);
|
|
|
|
original_decl->print(decl_print_stream);
|
|
|
|
decl_print_stream.flush();
|
|
|
|
log->Printf("Original decl:\n%s", decl_print_string.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TagDecl *original_tag_decl = dyn_cast<TagDecl>(original_decl))
|
|
|
|
{
|
|
|
|
ExternalASTSource *external_source = original_ctx->getExternalSource();
|
2010-07-17 08:43:37 +08:00
|
|
|
|
2011-08-12 07:56:13 +08:00
|
|
|
if (external_source)
|
|
|
|
external_source->CompleteType (original_tag_decl);
|
2011-06-25 08:44:06 +08:00
|
|
|
}
|
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
DeclContext *original_decl_context = dyn_cast<DeclContext>(original_decl);
|
2011-06-25 08:44:06 +08:00
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
if (!original_decl_context)
|
|
|
|
return ELR_Failure;
|
2011-06-25 08:44:06 +08:00
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
for (TagDecl::decl_iterator iter = original_decl_context->decls_begin();
|
|
|
|
iter != original_decl_context->decls_end();
|
|
|
|
++iter)
|
2011-06-25 08:44:06 +08:00
|
|
|
{
|
2011-07-30 10:42:06 +08:00
|
|
|
Decl *decl = *iter;
|
2011-06-25 08:44:06 +08:00
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
if (!predicate || predicate(decl->getKind()))
|
2011-06-25 08:44:06 +08:00
|
|
|
{
|
2011-07-30 10:42:06 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
std::string decl_print_string;
|
|
|
|
llvm::raw_string_ostream decl_print_stream(decl_print_string);
|
|
|
|
decl->print(decl_print_stream);
|
|
|
|
decl_print_stream.flush();
|
|
|
|
log->Printf(" Adding lexical decl %s", decl_print_string.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
Decl *copied_decl = ast_importer->CopyDecl(original_ctx, decl);
|
2011-06-25 08:44:06 +08:00
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
decls.push_back(copied_decl);
|
2011-06-25 08:44:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
return ELR_AlreadyLoaded;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ClangExpressionDeclMap::CompleteTagDecl (TagDecl *tag_decl)
|
|
|
|
{
|
|
|
|
assert (m_parser_vars.get());
|
|
|
|
|
|
|
|
m_parser_vars->GetASTImporter(&tag_decl->getASTContext())->CompleteTagDecl (tag_decl);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ClangExpressionDeclMap::CompleteObjCInterfaceDecl (clang::ObjCInterfaceDecl *interface_decl)
|
|
|
|
{
|
|
|
|
assert (m_parser_vars.get());
|
|
|
|
|
|
|
|
m_parser_vars->GetASTImporter(&interface_decl->getASTContext())->CompleteObjCInterfaceDecl (interface_decl);
|
2011-06-25 08:44:06 +08:00
|
|
|
}
|
|
|
|
|
2010-07-17 08:43:37 +08:00
|
|
|
Value *
|
2010-10-16 06:48:33 +08:00
|
|
|
ClangExpressionDeclMap::GetVariableValue
|
|
|
|
(
|
|
|
|
ExecutionContext &exe_ctx,
|
2011-10-13 08:09:20 +08:00
|
|
|
VariableSP &var,
|
2011-07-30 10:42:06 +08:00
|
|
|
ASTContext *parser_ast_context,
|
2010-10-16 06:48:33 +08:00
|
|
|
TypeFromUser *user_type,
|
|
|
|
TypeFromParser *parser_type
|
|
|
|
)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
2010-06-23 08:47:48 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
Type *var_type = var->GetType();
|
|
|
|
|
|
|
|
if (!var_type)
|
|
|
|
{
|
2010-07-16 08:09:46 +08:00
|
|
|
if (log)
|
|
|
|
log->PutCString("Skipped a definition because it has no type");
|
2010-07-17 08:43:37 +08:00
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-02-17 07:00:21 +08:00
|
|
|
clang_type_t var_opaque_type = var_type->GetClangFullType();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
if (!var_opaque_type)
|
|
|
|
{
|
2010-07-16 08:09:46 +08:00
|
|
|
if (log)
|
|
|
|
log->PutCString("Skipped a definition because it has no Clang type");
|
2010-07-17 08:43:37 +08:00
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
ASTContext *ast = var_type->GetClangASTContext().getASTContext();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
if (!ast)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-07-16 08:09:46 +08:00
|
|
|
if (log)
|
|
|
|
log->PutCString("There is no AST context for the current execution context");
|
2010-07-17 08:43:37 +08:00
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-07-17 08:43:37 +08:00
|
|
|
DWARFExpression &var_location_expr = var->LocationExpression();
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
std::auto_ptr<Value> var_location(new Value);
|
|
|
|
|
2010-09-14 10:20:48 +08:00
|
|
|
lldb::addr_t loclist_base_load_addr = LLDB_INVALID_ADDRESS;
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
|
2010-09-14 10:20:48 +08:00
|
|
|
if (var_location_expr.IsLocationList())
|
|
|
|
{
|
|
|
|
SymbolContext var_sc;
|
|
|
|
var->CalculateSymbolContext (&var_sc);
|
2011-09-22 12:58:26 +08:00
|
|
|
loclist_base_load_addr = var_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (target);
|
2010-09-14 10:20:48 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
Error err;
|
|
|
|
|
2011-01-26 07:55:37 +08:00
|
|
|
if (!var_location_expr.Evaluate(&exe_ctx, ast, NULL, NULL, NULL, loclist_base_load_addr, NULL, *var_location.get(), &err))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-07-16 08:09:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("Error evaluating location: %s", err.AsCString());
|
2010-07-17 08:43:37 +08:00
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
|
2011-07-08 08:39:14 +08:00
|
|
|
void *type_to_use = NULL;
|
2010-07-17 08:43:37 +08:00
|
|
|
|
2010-07-21 07:31:16 +08:00
|
|
|
if (parser_ast_context)
|
|
|
|
{
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
type_to_use = GuardedCopyType(parser_ast_context, ast, var_opaque_type);
|
2010-07-21 07:31:16 +08:00
|
|
|
|
2010-11-20 10:19:29 +08:00
|
|
|
if (!type_to_use)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't copy a variable's type into the parser's AST context");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-07-21 07:31:16 +08:00
|
|
|
if (parser_type)
|
|
|
|
*parser_type = TypeFromParser(type_to_use, parser_ast_context);
|
|
|
|
}
|
2010-07-17 08:43:37 +08:00
|
|
|
else
|
|
|
|
type_to_use = var_opaque_type;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
if (var_location.get()->GetContextType() == Value::eContextTypeInvalid)
|
2010-11-13 11:52:47 +08:00
|
|
|
var_location.get()->SetContext(Value::eContextTypeClangType, type_to_use);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
if (var_location.get()->GetValueType() == Value::eValueTypeFileAddress)
|
|
|
|
{
|
|
|
|
SymbolContext var_sc;
|
|
|
|
var->CalculateSymbolContext(&var_sc);
|
2010-07-17 08:43:37 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (!var_sc.module_sp)
|
2010-07-17 08:43:37 +08:00
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
ObjectFile *object_file = var_sc.module_sp->GetObjectFile();
|
|
|
|
|
|
|
|
if (!object_file)
|
2010-07-17 08:43:37 +08:00
|
|
|
return NULL;
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
Address so_addr(var_location->GetScalar().ULongLong(), object_file->GetSectionList());
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
lldb::addr_t load_addr = so_addr.GetLoadAddress(target);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
if (load_addr != LLDB_INVALID_ADDRESS)
|
|
|
|
{
|
|
|
|
var_location->GetScalar() = load_addr;
|
|
|
|
var_location->SetValueType(Value::eValueTypeLoadAddress);
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-07-21 07:31:16 +08:00
|
|
|
if (user_type)
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
*user_type = TypeFromUser(var_opaque_type, ast);
|
2010-07-17 08:43:37 +08:00
|
|
|
|
|
|
|
return var_location.release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-05-07 09:06:41 +08:00
|
|
|
ClangExpressionDeclMap::AddOneVariable (NameSearchContext &context, VariableSP var)
|
2010-07-17 08:43:37 +08:00
|
|
|
{
|
2010-12-03 09:38:59 +08:00
|
|
|
assert (m_parser_vars.get());
|
|
|
|
|
2010-11-06 09:53:30 +08:00
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
|
2010-07-21 07:31:16 +08:00
|
|
|
TypeFromUser ut;
|
|
|
|
TypeFromParser pt;
|
2010-07-17 08:43:37 +08:00
|
|
|
|
2010-12-03 09:38:59 +08:00
|
|
|
Value *var_location = GetVariableValue (*m_parser_vars->m_exe_ctx,
|
2010-10-16 06:48:33 +08:00
|
|
|
var,
|
|
|
|
context.GetASTContext(),
|
|
|
|
&ut,
|
|
|
|
&pt);
|
2010-07-17 08:43:37 +08:00
|
|
|
|
2010-11-20 10:19:29 +08:00
|
|
|
if (!var_location)
|
|
|
|
return;
|
|
|
|
|
2011-01-13 16:53:35 +08:00
|
|
|
NamedDecl *var_decl = context.AddVarDecl(ClangASTContext::CreateLValueReferenceType(pt.GetASTContext(), pt.GetOpaqueQualType()));
|
2010-10-16 06:48:33 +08:00
|
|
|
std::string decl_name(context.m_decl_name.getAsString());
|
2010-12-14 10:59:59 +08:00
|
|
|
ConstString entity_name(decl_name.c_str());
|
2011-03-31 08:19:25 +08:00
|
|
|
ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx->GetBestExecutionContextScope (),
|
|
|
|
entity_name,
|
2010-12-14 10:59:59 +08:00
|
|
|
ut,
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
m_parser_vars->m_target_info.byte_order,
|
|
|
|
m_parser_vars->m_target_info.address_byte_size));
|
2010-12-14 10:59:59 +08:00
|
|
|
assert (entity.get());
|
|
|
|
entity->EnableParserVars();
|
|
|
|
entity->m_parser_vars->m_parser_type = pt;
|
|
|
|
entity->m_parser_vars->m_named_decl = var_decl;
|
|
|
|
entity->m_parser_vars->m_llvm_value = NULL;
|
|
|
|
entity->m_parser_vars->m_lldb_value = var_location;
|
2011-05-07 09:06:41 +08:00
|
|
|
entity->m_parser_vars->m_lldb_var = var;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-07-16 08:09:46 +08:00
|
|
|
if (log)
|
2010-10-16 06:48:33 +08:00
|
|
|
{
|
2010-11-02 07:22:47 +08:00
|
|
|
std::string var_decl_print_string;
|
|
|
|
llvm::raw_string_ostream var_decl_print_stream(var_decl_print_string);
|
|
|
|
var_decl->print(var_decl_print_stream);
|
|
|
|
var_decl_print_stream.flush();
|
|
|
|
|
|
|
|
log->Printf("Found variable %s, returned %s", decl_name.c_str(), var_decl_print_string.c_str());
|
2011-02-02 07:43:26 +08:00
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
//if (log->GetVerbose())
|
|
|
|
//{
|
|
|
|
// StreamString var_decl_dump_string;
|
|
|
|
// ASTDumper::DumpDecl(var_decl_dump_string, var_decl);
|
|
|
|
// log->Printf("%s\n", var_decl_dump_string.GetData());
|
|
|
|
//}
|
2010-10-16 06:48:33 +08:00
|
|
|
}
|
2010-06-23 07:46:24 +08:00
|
|
|
}
|
|
|
|
|
2010-08-11 11:57:18 +08:00
|
|
|
void
|
|
|
|
ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
|
2010-12-14 10:59:59 +08:00
|
|
|
ClangExpressionVariableSP &pvar_sp)
|
2010-08-11 11:57:18 +08:00
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
2010-08-31 06:17:16 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
TypeFromUser user_type (pvar_sp->GetTypeFromUser());
|
2010-08-11 11:57:18 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
TypeFromParser parser_type (GuardedCopyType(context.GetASTContext(),
|
|
|
|
user_type.GetASTContext(),
|
|
|
|
user_type.GetOpaqueQualType()),
|
|
|
|
context.GetASTContext());
|
2010-08-11 11:57:18 +08:00
|
|
|
|
2011-01-13 16:53:35 +08:00
|
|
|
NamedDecl *var_decl = context.AddVarDecl(ClangASTContext::CreateLValueReferenceType(parser_type.GetASTContext(), parser_type.GetOpaqueQualType()));
|
2010-08-24 07:09:38 +08:00
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
pvar_sp->EnableParserVars();
|
|
|
|
pvar_sp->m_parser_vars->m_parser_type = parser_type;
|
|
|
|
pvar_sp->m_parser_vars->m_named_decl = var_decl;
|
|
|
|
pvar_sp->m_parser_vars->m_llvm_value = NULL;
|
|
|
|
pvar_sp->m_parser_vars->m_lldb_value = NULL;
|
2010-08-31 06:17:16 +08:00
|
|
|
|
|
|
|
if (log)
|
2010-11-02 07:22:47 +08:00
|
|
|
{
|
|
|
|
std::string var_decl_print_string;
|
|
|
|
llvm::raw_string_ostream var_decl_print_stream(var_decl_print_string);
|
|
|
|
var_decl->print(var_decl_print_stream);
|
|
|
|
var_decl_print_stream.flush();
|
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
log->Printf("Added pvar %s, returned %s", pvar_sp->GetName().GetCString(), var_decl_print_string.c_str());
|
2010-11-02 07:22:47 +08:00
|
|
|
}
|
2010-08-11 11:57:18 +08:00
|
|
|
}
|
|
|
|
|
2011-05-08 10:21:26 +08:00
|
|
|
void
|
|
|
|
ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
|
|
|
|
Symbol &symbol)
|
|
|
|
{
|
|
|
|
assert(m_parser_vars.get());
|
|
|
|
|
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
Target *target = m_parser_vars->m_exe_ctx->GetTargetPtr();
|
|
|
|
|
|
|
|
if (target == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ASTContext *scratch_ast_context = target->GetScratchClangASTContext()->getASTContext();
|
2011-05-08 10:21:26 +08:00
|
|
|
|
2011-05-13 07:54:16 +08:00
|
|
|
TypeFromUser user_type (ClangASTContext::CreateLValueReferenceType(scratch_ast_context, ClangASTContext::GetVoidPtrType(scratch_ast_context, true)),
|
2011-05-08 10:21:26 +08:00
|
|
|
scratch_ast_context);
|
|
|
|
|
2011-05-13 07:54:16 +08:00
|
|
|
TypeFromParser parser_type (ClangASTContext::CreateLValueReferenceType(scratch_ast_context, ClangASTContext::GetVoidPtrType(context.GetASTContext(), true)),
|
2011-05-08 10:21:26 +08:00
|
|
|
context.GetASTContext());
|
|
|
|
|
2011-05-13 07:54:16 +08:00
|
|
|
NamedDecl *var_decl = context.AddVarDecl(parser_type.GetOpaqueQualType());
|
2011-05-08 10:21:26 +08:00
|
|
|
|
|
|
|
std::string decl_name(context.m_decl_name.getAsString());
|
|
|
|
ConstString entity_name(decl_name.c_str());
|
|
|
|
ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx->GetBestExecutionContextScope (),
|
|
|
|
entity_name,
|
|
|
|
user_type,
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
m_parser_vars->m_target_info.byte_order,
|
|
|
|
m_parser_vars->m_target_info.address_byte_size));
|
2011-05-08 10:21:26 +08:00
|
|
|
assert (entity.get());
|
|
|
|
|
|
|
|
std::auto_ptr<Value> symbol_location(new Value);
|
|
|
|
|
|
|
|
AddressRange &symbol_range = symbol.GetAddressRangeRef();
|
|
|
|
Address &symbol_address = symbol_range.GetBaseAddress();
|
2011-09-22 12:58:26 +08:00
|
|
|
lldb::addr_t symbol_load_addr = symbol_address.GetLoadAddress(target);
|
2011-05-08 10:21:26 +08:00
|
|
|
|
|
|
|
symbol_location->SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType());
|
|
|
|
symbol_location->GetScalar() = symbol_load_addr;
|
|
|
|
symbol_location->SetValueType(Value::eValueTypeLoadAddress);
|
|
|
|
|
2011-05-13 07:54:16 +08:00
|
|
|
entity->EnableParserVars();
|
2011-05-08 10:21:26 +08:00
|
|
|
entity->m_parser_vars->m_parser_type = parser_type;
|
|
|
|
entity->m_parser_vars->m_named_decl = var_decl;
|
|
|
|
entity->m_parser_vars->m_llvm_value = NULL;
|
|
|
|
entity->m_parser_vars->m_lldb_value = symbol_location.release();
|
|
|
|
entity->m_parser_vars->m_lldb_sym = &symbol;
|
2011-05-13 07:54:16 +08:00
|
|
|
//entity->m_flags |= ClangExpressionVariable::EVUnknownType;
|
2011-05-08 10:21:26 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
std::string var_decl_print_string;
|
|
|
|
llvm::raw_string_ostream var_decl_print_stream(var_decl_print_string);
|
|
|
|
var_decl->print(var_decl_print_stream);
|
|
|
|
var_decl_print_stream.flush();
|
|
|
|
|
|
|
|
log->Printf("Found variable %s, returned %s", decl_name.c_str(), var_decl_print_string.c_str());
|
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
//if (log->GetVerbose())
|
|
|
|
//{
|
|
|
|
// StreamString var_decl_dump_string;
|
|
|
|
// ASTDumper::DumpDecl(var_decl_dump_string, var_decl);
|
|
|
|
// log->Printf("%s\n", var_decl_dump_string.GetData());
|
|
|
|
//}
|
2011-05-08 10:21:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-13 07:54:16 +08:00
|
|
|
bool
|
|
|
|
ClangExpressionDeclMap::ResolveUnknownTypes()
|
|
|
|
{
|
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
2011-09-22 12:58:26 +08:00
|
|
|
Target *target = m_parser_vars->m_exe_ctx->GetTargetPtr();
|
|
|
|
|
|
|
|
ASTContext *scratch_ast_context = target->GetScratchClangASTContext()->getASTContext();
|
2011-05-13 07:54:16 +08:00
|
|
|
|
|
|
|
for (size_t index = 0, num_entities = m_found_entities.GetSize();
|
|
|
|
index < num_entities;
|
|
|
|
++index)
|
|
|
|
{
|
|
|
|
ClangExpressionVariableSP entity = m_found_entities.GetVariableAtIndex(index);
|
|
|
|
|
|
|
|
if (entity->m_flags & ClangExpressionVariable::EVUnknownType)
|
|
|
|
{
|
|
|
|
const NamedDecl *named_decl = entity->m_parser_vars->m_named_decl;
|
|
|
|
const VarDecl *var_decl = dyn_cast<VarDecl>(named_decl);
|
|
|
|
|
|
|
|
if (!var_decl)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Entity of unknown type does not have a VarDecl");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
std::string var_decl_print_string;
|
|
|
|
llvm::raw_string_ostream var_decl_print_stream(var_decl_print_string);
|
|
|
|
var_decl->print(var_decl_print_stream);
|
|
|
|
var_decl_print_stream.flush();
|
|
|
|
|
|
|
|
log->Printf("Variable of unknown type now has Decl %s", var_decl_print_string.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
QualType var_type = var_decl->getType();
|
|
|
|
TypeFromParser parser_type(var_type.getAsOpaquePtr(), &var_decl->getASTContext());
|
|
|
|
|
|
|
|
lldb::clang_type_t copied_type = ClangASTContext::CopyType(scratch_ast_context, &var_decl->getASTContext(), var_type.getAsOpaquePtr());
|
|
|
|
|
|
|
|
TypeFromUser user_type(copied_type, scratch_ast_context);
|
|
|
|
|
|
|
|
entity->m_parser_vars->m_lldb_value->SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType());
|
|
|
|
entity->m_parser_vars->m_parser_type = parser_type;
|
|
|
|
|
|
|
|
entity->SetClangAST(user_type.GetASTContext());
|
|
|
|
entity->SetClangType(user_type.GetOpaqueQualType());
|
|
|
|
|
|
|
|
entity->m_flags &= ~(ClangExpressionVariable::EVUnknownType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-30 08:27:43 +08:00
|
|
|
void
|
2010-12-14 10:59:59 +08:00
|
|
|
ClangExpressionDeclMap::AddOneRegister (NameSearchContext &context,
|
|
|
|
const RegisterInfo *reg_info)
|
2010-11-30 08:27:43 +08:00
|
|
|
{
|
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
|
|
|
|
|
|
|
void *ast_type = ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(context.GetASTContext(),
|
|
|
|
reg_info->encoding,
|
|
|
|
reg_info->byte_size * 8);
|
|
|
|
|
|
|
|
if (!ast_type)
|
|
|
|
{
|
2011-08-10 06:52:27 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("Tried to add a type for %s, but couldn't get one", context.m_decl_name.getAsString().c_str());
|
2010-11-30 08:27:43 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-12-14 10:59:59 +08:00
|
|
|
TypeFromParser parser_type (ast_type,
|
|
|
|
context.GetASTContext());
|
2010-11-30 08:27:43 +08:00
|
|
|
|
|
|
|
NamedDecl *var_decl = context.AddVarDecl(parser_type.GetOpaqueQualType());
|
|
|
|
|
2011-03-31 08:19:25 +08:00
|
|
|
ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx->GetBestExecutionContextScope(),
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
m_parser_vars->m_target_info.byte_order,
|
|
|
|
m_parser_vars->m_target_info.address_byte_size));
|
2010-12-14 10:59:59 +08:00
|
|
|
assert (entity.get());
|
2010-11-30 08:27:43 +08:00
|
|
|
std::string decl_name(context.m_decl_name.getAsString());
|
2010-12-14 10:59:59 +08:00
|
|
|
entity->SetName (ConstString (decl_name.c_str()));
|
|
|
|
entity->SetRegisterInfo (reg_info);
|
|
|
|
entity->EnableParserVars();
|
|
|
|
entity->m_parser_vars->m_parser_type = parser_type;
|
|
|
|
entity->m_parser_vars->m_named_decl = var_decl;
|
|
|
|
entity->m_parser_vars->m_llvm_value = NULL;
|
|
|
|
entity->m_parser_vars->m_lldb_value = NULL;
|
2010-11-30 08:27:43 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
std::string var_decl_print_string;
|
|
|
|
llvm::raw_string_ostream var_decl_print_stream(var_decl_print_string);
|
|
|
|
var_decl->print(var_decl_print_stream);
|
|
|
|
var_decl_print_stream.flush();
|
|
|
|
|
|
|
|
log->Printf("Added register %s, returned %s", context.m_decl_name.getAsString().c_str(), var_decl_print_string.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
NamespaceDecl *
|
2011-10-12 08:12:34 +08:00
|
|
|
ClangExpressionDeclMap::AddNamespace (NameSearchContext &context, ClangASTImporter::NamespaceMapSP &namespace_decls)
|
2010-11-13 11:52:47 +08:00
|
|
|
{
|
2011-10-12 08:12:34 +08:00
|
|
|
if (namespace_decls.empty())
|
|
|
|
return NULL;
|
|
|
|
|
2010-11-13 11:52:47 +08:00
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
|
|
|
|
2011-06-25 08:44:06 +08:00
|
|
|
assert (m_parser_vars.get());
|
|
|
|
|
2011-10-12 08:12:34 +08:00
|
|
|
const ClangNamespaceDecl &namespace_decl = namespace_decls->begin()->second;
|
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
Decl *copied_decl = m_parser_vars->GetASTImporter(context.GetASTContext())->CopyDecl(namespace_decl.GetASTContext(),
|
2011-10-12 08:12:34 +08:00
|
|
|
namespace_decl.GetNamespaceDecl());
|
|
|
|
|
|
|
|
NamespaceDecl *copied_namespace_decl = dyn_cast<NamespaceDecl>(copied_decl);
|
|
|
|
|
|
|
|
m_parser_vars->GetASTImporter(context.GetASTContext())->RegisterNamespaceMap(copied_namespace_decl, namespace_decls);
|
|
|
|
|
2011-07-30 10:42:06 +08:00
|
|
|
return dyn_cast<NamespaceDecl>(copied_decl);
|
2010-11-13 11:52:47 +08:00
|
|
|
}
|
|
|
|
|
2010-06-23 07:46:24 +08:00
|
|
|
void
|
2011-05-19 06:01:49 +08:00
|
|
|
ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context,
|
|
|
|
Function* fun,
|
|
|
|
Symbol* symbol)
|
2010-06-23 07:46:24 +08:00
|
|
|
{
|
2010-12-03 09:38:59 +08:00
|
|
|
assert (m_parser_vars.get());
|
|
|
|
|
2010-11-06 09:53:30 +08:00
|
|
|
lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
2010-06-23 07:46:24 +08:00
|
|
|
|
2011-07-08 08:39:14 +08:00
|
|
|
NamedDecl *fun_decl = NULL;
|
2010-07-27 08:55:47 +08:00
|
|
|
std::auto_ptr<Value> fun_location(new Value);
|
2011-07-08 08:39:14 +08:00
|
|
|
const Address *fun_address = NULL;
|
2010-06-23 07:46:24 +08:00
|
|
|
|
2010-07-27 08:55:47 +08:00
|
|
|
// only valid for Functions, not for Symbols
|
|
|
|
void *fun_opaque_type = NULL;
|
2011-07-30 10:42:06 +08:00
|
|
|
ASTContext *fun_ast_context = NULL;
|
2010-06-23 07:46:24 +08:00
|
|
|
|
2010-07-27 08:55:47 +08:00
|
|
|
if (fun)
|
|
|
|
{
|
|
|
|
Type *fun_type = fun->GetType();
|
|
|
|
|
|
|
|
if (!fun_type)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->PutCString("Skipped a function because it has no type");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-02-17 07:00:21 +08:00
|
|
|
fun_opaque_type = fun_type->GetClangFullType();
|
2010-07-27 08:55:47 +08:00
|
|
|
|
|
|
|
if (!fun_opaque_type)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->PutCString("Skipped a function because it has no Clang type");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fun_address = &fun->GetAddressRange().GetBaseAddress();
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
fun_ast_context = fun_type->GetClangASTContext().getASTContext();
|
2010-11-20 04:20:02 +08:00
|
|
|
void *copied_type = GuardedCopyType(context.GetASTContext(), fun_ast_context, fun_opaque_type);
|
2010-07-27 08:55:47 +08:00
|
|
|
|
|
|
|
fun_decl = context.AddFunDecl(copied_type);
|
|
|
|
}
|
|
|
|
else if (symbol)
|
|
|
|
{
|
|
|
|
fun_address = &symbol->GetAddressRangeRef().GetBaseAddress();
|
|
|
|
|
|
|
|
fun_decl = context.AddGenericFunDecl();
|
|
|
|
}
|
|
|
|
else
|
2010-06-23 07:46:24 +08:00
|
|
|
{
|
2010-07-16 08:09:46 +08:00
|
|
|
if (log)
|
2010-07-27 08:55:47 +08:00
|
|
|
log->PutCString("AddOneFunction called with no function and no symbol");
|
2010-06-23 07:46:24 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
Target *target = m_parser_vars->m_exe_ctx->GetTargetPtr();
|
|
|
|
|
|
|
|
lldb::addr_t load_addr = fun_address->GetCallableLoadAddress(target);
|
2010-06-23 07:46:24 +08:00
|
|
|
fun_location->SetValueType(Value::eValueTypeLoadAddress);
|
|
|
|
fun_location->GetScalar() = load_addr;
|
|
|
|
|
2011-03-31 08:19:25 +08:00
|
|
|
ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx->GetBestExecutionContextScope (),
|
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process.
This allows expressions to run in situations where the
target cannot run -- e.g., to perform calculations based
on type information, or to inspect a binary's static
data.
This modification touches the following files:
lldb-private-enumerations.h
Introduce a new enum specifying the policy for
processing an expression. Some expressions should
always be JITted, for example if they are functions
that will be used over and over again. Some
expressions should always be interpreted, for
example if the target is unsafe to run. For most,
it is acceptable to JIT them, but interpretation
is preferable when possible.
Target.[h,cpp]
Have EvaluateExpression now accept the new enum.
ClangExpressionDeclMap.[cpp,h]
Add support for the IR interpreter and also make
the ClangExpressionDeclMap more robust in the
absence of a process.
ClangFunction.[cpp,h]
Add support for the new enum.
IRInterpreter.[cpp,h]
New implementation.
ClangUserExpression.[cpp,h]
Add support for the new enum, and for running
expressions in the absence of a process.
ClangExpression.h
Remove references to the old DWARF-based method
of evaluating expressions, because it has been
superseded for now.
ClangUtilityFunction.[cpp,h]
Add support for the new enum.
ClangExpressionParser.[cpp,h]
Add support for the new enum, remove references
to DWARF, and add support for checking whether
the expression could be evaluated statically.
IRForTarget.[h,cpp]
Add support for the new enum, and add utility
functions to support the interpreter.
IRToDWARF.cpp
Removed
CommandObjectExpression.cpp
Remove references to the obsolete -i option.
Process.cpp
Modify calls to ClangUserExpression::Evaluate
to pass the correct enum (for dlopen/dlclose)
SBValue.cpp
Add support for the new enum.
SBFrame.cpp
Add support for he new enum.
BreakpointOptions.cpp
Add support for the new enum.
llvm-svn: 139772
2011-09-15 10:13:07 +08:00
|
|
|
m_parser_vars->m_target_info.byte_order,
|
|
|
|
m_parser_vars->m_target_info.address_byte_size));
|
2010-12-14 10:59:59 +08:00
|
|
|
assert (entity.get());
|
2010-10-16 06:48:33 +08:00
|
|
|
std::string decl_name(context.m_decl_name.getAsString());
|
2010-12-14 10:59:59 +08:00
|
|
|
entity->SetName(ConstString(decl_name.c_str()));
|
|
|
|
entity->SetClangType (fun_opaque_type);
|
|
|
|
entity->SetClangAST (fun_ast_context);
|
|
|
|
|
|
|
|
entity->EnableParserVars();
|
|
|
|
entity->m_parser_vars->m_named_decl = fun_decl;
|
|
|
|
entity->m_parser_vars->m_llvm_value = NULL;
|
|
|
|
entity->m_parser_vars->m_lldb_value = fun_location.release();
|
2010-08-24 07:09:38 +08:00
|
|
|
|
2010-07-16 08:09:46 +08:00
|
|
|
if (log)
|
2010-10-16 06:48:33 +08:00
|
|
|
{
|
2010-11-02 07:22:47 +08:00
|
|
|
std::string fun_decl_print_string;
|
|
|
|
llvm::raw_string_ostream fun_decl_print_stream(fun_decl_print_string);
|
|
|
|
fun_decl->print(fun_decl_print_stream);
|
|
|
|
fun_decl_print_stream.flush();
|
|
|
|
|
|
|
|
log->Printf("Found %s function %s, returned %s", (fun ? "specific" : "generic"), decl_name.c_str(), fun_decl_print_string.c_str());
|
2010-10-16 06:48:33 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-08-04 09:02:13 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
ClangExpressionDeclMap::AddOneType(NameSearchContext &context,
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
TypeFromUser &ut,
|
|
|
|
bool add_method)
|
2010-08-04 09:02:13 +08:00
|
|
|
{
|
2011-07-30 10:42:06 +08:00
|
|
|
ASTContext *parser_ast_context = context.GetASTContext();
|
|
|
|
ASTContext *user_ast_context = ut.GetASTContext();
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
|
2010-11-20 04:20:02 +08:00
|
|
|
void *copied_type = GuardedCopyType(parser_ast_context, user_ast_context, ut.GetOpaqueQualType());
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
|
|
|
|
TypeFromParser parser_type(copied_type, parser_ast_context);
|
2010-08-04 09:02:13 +08:00
|
|
|
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
if (add_method && ClangASTContext::IsAggregateType(copied_type))
|
|
|
|
{
|
|
|
|
void *args[1];
|
|
|
|
|
|
|
|
args[0] = ClangASTContext::GetVoidPtrType(parser_ast_context, false);
|
|
|
|
|
|
|
|
void *method_type = ClangASTContext::CreateFunctionType (parser_ast_context,
|
|
|
|
ClangASTContext::GetBuiltInType_void(parser_ast_context),
|
|
|
|
args,
|
|
|
|
1,
|
|
|
|
false,
|
|
|
|
ClangASTContext::GetTypeQualifiers(copied_type));
|
2010-10-01 10:31:07 +08:00
|
|
|
|
2010-09-24 13:15:53 +08:00
|
|
|
const bool is_virtual = false;
|
|
|
|
const bool is_static = false;
|
|
|
|
const bool is_inline = false;
|
2010-10-01 10:31:07 +08:00
|
|
|
const bool is_explicit = false;
|
|
|
|
|
2010-09-24 13:15:53 +08:00
|
|
|
ClangASTContext::AddMethodToCXXRecordType (parser_ast_context,
|
|
|
|
copied_type,
|
2010-10-16 06:48:33 +08:00
|
|
|
"$__lldb_expr",
|
2010-09-24 13:15:53 +08:00
|
|
|
method_type,
|
|
|
|
lldb::eAccessPublic,
|
|
|
|
is_virtual,
|
|
|
|
is_static,
|
2010-10-01 10:31:07 +08:00
|
|
|
is_inline,
|
|
|
|
is_explicit);
|
Removed the hacky "#define this ___clang_this" handler
for C++ classes. Replaced it with a less hacky approach:
- If an expression is defined in the context of a
method of class A, then that expression is wrapped as
___clang_class::___clang_expr(void*) { ... }
instead of ___clang_expr(void*) { ... }.
- ___clang_class is resolved as the type of the target
of the "this" pointer in the method the expression
is defined in.
- When reporting the type of ___clang_class, a method
with the signature ___clang_expr(void*) is added to
that class, so that Clang doesn't complain about a
method being defined without a corresponding
declaration.
- Whenever the expression gets called, "this" gets
looked up, type-checked, and then passed in as the
first argument.
This required the following changes:
- The ABIs were changed to support passing of the "this"
pointer as part of trivial calls.
- ThreadPlanCallFunction and ClangFunction were changed
to support passing of an optional "this" pointer.
- ClangUserExpression was extended to perform the
wrapping described above.
- ClangASTSource was changed to revert the changes
required by the hack.
- ClangExpressionParser, IRForTarget, and
ClangExpressionDeclMap were changed to handle
different manglings of ___clang_expr flexibly. This
meant no longer searching for a function called
___clang_expr, but rather looking for a function whose
name *contains* ___clang_expr.
- ClangExpressionParser and ClangExpressionDeclMap now
remember whether "this" is required, and know how to
look it up as necessary.
A few inheritance bugs remain, and I'm trying to resolve
these. But it is now possible to use "this" as well as
refer implicitly to member variables, when in the proper
context.
llvm-svn: 114384
2010-09-21 08:44:12 +08:00
|
|
|
}
|
2010-08-04 09:02:13 +08:00
|
|
|
|
|
|
|
context.AddTypeDecl(copied_type);
|
|
|
|
}
|
2010-11-20 04:20:02 +08:00
|
|
|
|
|
|
|
void *
|
|
|
|
ClangExpressionDeclMap::GuardedCopyType (ASTContext *dest_context,
|
|
|
|
ASTContext *source_context,
|
|
|
|
void *clang_type)
|
|
|
|
{
|
2010-12-03 09:38:59 +08:00
|
|
|
assert (m_parser_vars.get());
|
|
|
|
|
|
|
|
m_parser_vars->m_ignore_lookups = true;
|
2010-11-20 04:20:02 +08:00
|
|
|
|
2011-06-25 08:44:06 +08:00
|
|
|
lldb_private::ClangASTImporter *importer = m_parser_vars->GetASTImporter(dest_context);
|
|
|
|
|
|
|
|
QualType ret_qual_type = importer->CopyType (source_context,
|
|
|
|
QualType::getFromOpaquePtr(clang_type));
|
|
|
|
|
|
|
|
void *ret = ret_qual_type.getAsOpaquePtr();
|
2010-11-20 04:20:02 +08:00
|
|
|
|
2010-12-03 09:38:59 +08:00
|
|
|
m_parser_vars->m_ignore_lookups = false;
|
2010-11-20 04:20:02 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|