Made lldb_private::ArchSpec contain much more than just an architecture. It

now, in addition to cpu type/subtype and architecture flavor, contains:
- byte order (big endian, little endian)
- address size in bytes
- llvm::Triple for true target triple support and for more powerful plug-in
  selection.

llvm-svn: 125602
This commit is contained in:
Greg Clayton 2011-02-15 21:59:32 +00:00
parent 41febc658b
commit 514487e806
59 changed files with 697 additions and 577 deletions

View File

@ -13,6 +13,7 @@
#if defined(__cplusplus)
#include "lldb/lldb-private.h"
#include "llvm/ADT/Triple.h"
namespace lldb_private {
@ -40,6 +41,9 @@ public:
eCPU_ppc64,
eCPU_sparc
};
static void
Initialize();
//------------------------------------------------------------------
/// Default constructor.
@ -140,6 +144,11 @@ public:
uint32_t
GetAddressByteSize () const;
void
SetAddressByteSize (uint32_t byte_size)
{
m_addr_byte_size = byte_size;
}
CPU
GetGenericCPUType () const;
@ -262,11 +271,42 @@ public:
/// @param[in] subtype The new CPU subtype
//------------------------------------------------------------------
void
SetMachOArch (uint32_t cpu, uint32_t sub)
SetMachOArch (uint32_t cpu, uint32_t sub);
//------------------------------------------------------------------
/// Returns the byte order for the architecture specification.
///
/// @return The endian enumeration for the current endianness of
/// the architecture specification
//------------------------------------------------------------------
lldb::ByteOrder
GetByteOrder () const
{
m_type = lldb::eArchTypeMachO;
m_cpu = cpu;
m_sub = sub;
return m_byte_order;
}
void
SetByteOrder (lldb::ByteOrder b)
{
m_byte_order = b;
}
llvm::Triple &
GetTriple ()
{
return m_triple;
}
const llvm::Triple &
GetTriple () const
{
return m_triple;
}
void
SetTriple (const llvm::Triple &triple)
{
m_triple = triple;
}
void
@ -301,6 +341,17 @@ protected:
// m_type => eArchTypeMachO eArchTypeELF
uint32_t m_cpu; // cpu type ELF header e_machine
uint32_t m_sub; // cpu subtype nothing
llvm::Triple m_triple;
lldb::ByteOrder m_byte_order;
uint32_t m_addr_byte_size;
private:
void
MachOArchUpdated (size_t macho_idx = SIZE_T_MAX);
void
ELFArchUpdated (size_t idx = SIZE_T_MAX);
};

View File

@ -81,7 +81,7 @@ class EmulateInstruction :
public:
static EmulateInstruction*
FindPlugin (const ConstString &triple, const char *plugin_name);
FindPlugin (const ArchSpec &arch, const char *plugin_name);
enum ContextType
{
@ -403,7 +403,7 @@ public:
}
virtual bool
SetTargetTriple (const ConstString &triple) = 0;
SetTargetTriple (const ArchSpec &arch) = 0;
virtual bool
ReadInstruction () = 0;

View File

@ -11,6 +11,7 @@
#define liblldb_ClangExpressionParser_h_
#include "lldb/lldb-include.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/ClangForward.h"
#include "lldb/Core/Error.h"
@ -40,19 +41,15 @@ public:
///
/// Initializes class variabes.
///
/// @param[in] target_triple
/// The LLVM-friendly target triple for use in initializing the
/// compiler.
///
/// @param[in process
/// If non-NULL, the process to customize the expression for
/// (e.g., by tuning Objective-C runtime support). May be NULL.
/// @param[in] exe_scope,
/// If non-NULL, an execution context scope that can help to
/// correctly create an expression with a valid process for
/// optional tuning Objective-C runtime support. Can be NULL.
///
/// @param[in] expr
/// The expression to be parsed.
//------------------------------------------------------------------
ClangExpressionParser (const char *target_triple,
Process *process,
ClangExpressionParser (ExecutionContextScope *exe_scope,
ClangExpression &expr);
//------------------------------------------------------------------
@ -181,7 +178,6 @@ private:
ClangExpression &m_expr; ///< The expression to be parsed
std::string m_target_triple; ///< The target triple used to initialize LLVM
std::auto_ptr<clang::FileManager> m_file_manager; ///< The Clang file manager object used by the compiler
std::auto_ptr<clang::CompilerInstance> m_compiler; ///< The Clang compiler used to parse expressions into IR
std::auto_ptr<clang::Builtin::Context> m_builtin_context; ///< Context for Clang built-ins

View File

@ -18,6 +18,7 @@
// Project includes
#include "lldb/Core/ClangForward.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Expression/ClangExpression.h"
@ -69,9 +70,9 @@ public:
//------------------------------------------------------------------
/// Constructor
///
/// @param[in] target_triple
/// The LLVM-style target triple for the target in which the
/// function is to be executed.
/// @param[in] exe_scope
/// An execution context scope that gets us a target and/or
/// process (possibly neither.).
///
/// @param[in] function_ptr
/// The default function to be called. Can be overridden using
@ -84,17 +85,17 @@ public:
/// The default values to use when calling this function. Can
/// be overridden using WriteFunctionArguments().
//------------------------------------------------------------------
ClangFunction(const char *target_triple,
Function &function_ptr,
ClangASTContext *ast_context,
const ValueList &arg_value_list);
ClangFunction (ExecutionContextScope *exe_scope,
Function &function_ptr,
ClangASTContext *ast_context,
const ValueList &arg_value_list);
//------------------------------------------------------------------
/// Constructor
///
/// @param[in] target_triple
/// The LLVM-style target triple for the target in which the
/// function is to be executed.
/// @param[in] exe_scope
/// An execution context scope that gets us a target and/or
/// process (possibly neither.).
///
/// @param[in] ast_context
/// The AST context to evaluate argument types in.
@ -110,11 +111,11 @@ public:
/// The default values to use when calling this function. Can
/// be overridden using WriteFunctionArguments().
//------------------------------------------------------------------
ClangFunction(const char *target_triple,
ClangASTContext *ast_context,
void *return_qualtype,
const Address& function_address,
const ValueList &arg_value_list);
ClangFunction (ExecutionContextScope *exe_scope,
ClangASTContext *ast_context,
void *return_qualtype,
const Address& function_address,
const ValueList &arg_value_list);
//------------------------------------------------------------------
/// Destructor
@ -613,7 +614,7 @@ private:
Address m_function_addr; ///< If we don't have the FunctionSP, we at least need the address & return type.
void *m_function_return_qual_type; ///< The opaque clang qual type for the function return type.
ClangASTContext *m_clang_ast_context; ///< This is the clang_ast_context that we're getting types from the and value, and the function return the function pointer is NULL.
std::string m_target_triple; ///< The target triple to compile the wrapper function for.
ArchSpec m_arch; ///< The target triple to compile the wrapper function for.
std::string m_wrapper_function_name; ///< The name of the wrapper function.
std::string m_wrapper_function_text; ///< The contents of the wrapper function.

View File

@ -97,14 +97,21 @@ public:
GetByteOrder ();
//------------------------------------------------------------------
/// Gets the host kernel architecture.
/// Gets the host architecture.
///
/// @return
/// A const architecture object that represents the host kernel
/// A const architecture object that represents the host
/// architecture.
//------------------------------------------------------------------
enum SystemDefaultArchitecture
{
eSystemDefaultArchitecture, // The overall default architecture that applications will run on this host
eSystemDefaultArchitecture32, // If this host supports 32 bit programs, return the default 32 bit arch
eSystemDefaultArchitecture64 // If this host supports 64 bit programs, return the default 64 bit arch
};
static const ArchSpec &
GetArchitecture ();
GetArchitecture (SystemDefaultArchitecture arch_kind = eSystemDefaultArchitecture);
//------------------------------------------------------------------
/// Gets the host vendor string.

View File

@ -104,6 +104,9 @@ public:
void
SetTargetTriple (const char *target_triple);
void
SetArchitecture (const ArchSpec &arch);
bool
HasExternalSource ();

View File

@ -238,7 +238,7 @@ public:
/// false otherwise.
//------------------------------------------------------------------
virtual bool
GetTargetTriple(ConstString &target_triple) = 0;
GetArchitecture (ArchSpec &arch) = 0;
//------------------------------------------------------------------
/// Gets the section list for the currently selected architecture

View File

@ -47,7 +47,7 @@ public:
Value &value) const = 0;
static ABI*
FindPlugin (const ConstString &triple);
FindPlugin (const ArchSpec &arch);
protected:
//------------------------------------------------------------------
// Classes that inherit from ABI can see and modify these

View File

@ -417,6 +417,7 @@ public:
void
UpdateInstanceName ();
//------------------------------------------------------------------
/// Construct with a shared pointer to a target, and the Process listener.
//------------------------------------------------------------------
@ -474,6 +475,12 @@ public:
int signo, // Zero for no signal
int status); // Exit value of process if signal is zero
lldb::ByteOrder
GetByteOrder () const;
uint32_t
GetAddressByteSize () const;
//------------------------------------------------------------------
/// Check if a plug-in instance can debug the file in \a module.
///
@ -649,15 +656,6 @@ public:
virtual ArchSpec
GetArchSpecForExistingProcess (const char *process_name);
uint32_t
GetAddressByteSize();
void
SetAddressByteSize (uint32_t addr_byte_size)
{
m_addr_byte_size = addr_byte_size;
}
//------------------------------------------------------------------
/// Get the image information address for the current process.
///
@ -821,8 +819,10 @@ public:
Signal (int signal);
virtual UnixSignals &
GetUnixSignals ();
GetUnixSignals ()
{
return m_unix_signals;
}
//==================================================================
// Plug-in Process Control Overrides
@ -1179,7 +1179,10 @@ public:
/// module.
//------------------------------------------------------------------
Target &
GetTarget ();
GetTarget ()
{
return m_target;
}
//------------------------------------------------------------------
/// Get the const target object pointer for this module.
@ -1189,7 +1192,11 @@ public:
/// module.
//------------------------------------------------------------------
const Target &
GetTarget () const;
GetTarget () const
{
return m_target;
}
//------------------------------------------------------------------
/// Get accessor for the current process state.
@ -1652,10 +1659,16 @@ public:
UpdateThreadListIfNeeded () = 0;
ThreadList &
GetThreadList ();
GetThreadList ()
{
return m_thread_list;
}
const ThreadList &
GetThreadList () const;
GetThreadList () const
{
return m_thread_list;
}
uint32_t
GetNextThreadIndexID ();
@ -1739,30 +1752,6 @@ protected:
ShouldBroadcastEvent (Event *event_ptr);
public:
//------------------------------------------------------------------
/// Gets the byte order for this process.
///
/// @return
/// A valid ByteOrder enumeration, or eByteOrderInvalid.
//------------------------------------------------------------------
lldb::ByteOrder
GetByteOrder () const
{
return m_byte_order;
}
void
SetByteOrder (lldb::ByteOrder byte_order)
{
m_byte_order = byte_order;
}
const ConstString &
GetTargetTriple ()
{
return m_target_triple;
}
const ABI *
GetABI ();
@ -1807,16 +1796,28 @@ public:
// lldb::ExecutionContextScope pure virtual functions
//------------------------------------------------------------------
virtual Target *
CalculateTarget ();
CalculateTarget ()
{
return &m_target;
}
virtual Process *
CalculateProcess ();
CalculateProcess ()
{
return this;
}
virtual Thread *
CalculateThread ();
CalculateThread ()
{
return NULL;
}
virtual StackFrame *
CalculateStackFrame ();
CalculateStackFrame ()
{
return NULL;
}
virtual void
CalculateExecutionContext (ExecutionContext &exe_ctx);
@ -1941,9 +1942,6 @@ protected:
///< to insert in the target.
std::auto_ptr<DynamicCheckerFunctions> m_dynamic_checkers_ap; ///< The functions used by the expression parser to validate data that expressions use.
UnixSignals m_unix_signals; /// This is the current signal set for this process.
ConstString m_target_triple;
lldb::ByteOrder m_byte_order; /// The byte order of the process. Should be set in DidLaunch/DidAttach.
uint32_t m_addr_byte_size; /// The size in bytes of an address/pointer for the inferior process. Should be set in DidLaunch/DidAttach.
lldb::ABISP m_abi_sp;
lldb::InputReaderSP m_process_input_reader;
lldb_private::Communication m_stdio_communication;

View File

@ -365,10 +365,28 @@ public:
/// A list of Module objects in a module list.
//------------------------------------------------------------------
ModuleList&
GetImages ();
GetImages ()
{
return m_images;
}
ArchSpec
GetArchitecture () const;
const ModuleList&
GetImages () const
{
return m_images;
}
ArchSpec &
GetArchitecture ()
{
return m_arch_spec;
}
const ArchSpec &
GetArchitecture () const
{
return m_arch_spec;
}
//------------------------------------------------------------------
/// Set the architecture for this target.
@ -397,9 +415,6 @@ public:
return m_debugger;
}
bool
GetTargetTriple (ConstString &target_triple);
size_t
ReadMemoryFromFileCache (const Address& addr,
void *dst,
@ -505,7 +520,6 @@ protected:
// we can correctly tear down everything that we need to, so the only
// class that knows about the process lifespan is this target class.
lldb::ProcessSP m_process_sp;
ConstString m_triple; ///< The target triple ("x86_64-apple-darwin10")
lldb::SearchFilterSP m_search_filter_sp;
PathMappingList m_image_search_paths;
std::auto_ptr<ClangASTContext> m_scratch_ast_context_ap;

View File

@ -16,13 +16,13 @@
namespace lldb_private
{
typedef ABI* (*ABICreateInstance) (const ConstString &triple);
typedef ABI* (*ABICreateInstance) (const ArchSpec &arch);
typedef Disassembler* (*DisassemblerCreateInstance) (const ArchSpec &arch);
typedef DynamicLoader* (*DynamicLoaderCreateInstance) (Process* process);
typedef ObjectContainer* (*ObjectContainerCreateInstance) (Module* module, lldb::DataBufferSP& dataSP, const FileSpec *file, lldb::addr_t offset, lldb::addr_t length);
typedef ObjectFile* (*ObjectFileCreateInstance) (Module* module, lldb::DataBufferSP& dataSP, const FileSpec* file, lldb::addr_t offset, lldb::addr_t length);
typedef LogChannel* (*LogChannelCreateInstance) ();
typedef EmulateInstruction * (*EmulateInstructionCreateInstance) (const ConstString &triple);
typedef EmulateInstruction * (*EmulateInstructionCreateInstance) (const ArchSpec &arch);
typedef LanguageRuntime *(*LanguageRuntimeCreateInstance) (Process *process, lldb::LanguageType language);
typedef Process* (*ProcessCreateInstance) (Target &target, Listener &listener);
typedef SymbolFile* (*SymbolFileCreateInstance) (ObjectFile* obj_file);

View File

@ -31,6 +31,10 @@
<CommandLineArguments>
<CommandLineArgument
argument = "/Volumes/work/gclayton/Documents/src/attach/a.out"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "-a i386 /Volumes/work/gclayton/Documents/src/lldb/test/macosx/universal/testit"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
@ -89,6 +93,10 @@
argument = "/Volumes/work/gclayton/Documents/src/attach/a.out"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "-a i386 /Volumes/work/gclayton/Documents/src/lldb/test/macosx/universal/testit"
isEnabled = "NO">
</CommandLineArgument>
</CommandLineArguments>
<EnvironmentVariables>
<EnvironmentVariable
@ -144,6 +152,10 @@
<CommandLineArguments>
<CommandLineArgument
argument = "/Volumes/work/gclayton/Documents/src/attach/a.out"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "-a i386 /Volumes/work/gclayton/Documents/src/lldb/test/macosx/universal/testit"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>

View File

@ -371,7 +371,7 @@ SBProcess::GetAddressByteSize () const
{
uint32_t size = 0;
if (m_opaque_sp)
size = m_opaque_sp->GetAddressByteSize();
size = m_opaque_sp->GetTarget().GetArchitecture().GetAddressByteSize();
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)

View File

@ -342,7 +342,7 @@ DumpSymbolContextList (CommandInterpreter &interpreter, Stream &strm, SymbolCont
int addr_size = sizeof (addr_t);
Process *process = interpreter.GetDebugger().GetExecutionContext().process;
if (process)
addr_size = process->GetAddressByteSize();
addr_size = process->GetTarget().GetArchitecture().GetAddressByteSize();
if (vm_addr != LLDB_INVALID_ADDRESS)
strm.Address (vm_addr, addr_size);
else

View File

@ -260,7 +260,7 @@ public:
if (item_byte_size == 0)
{
if (m_options.m_format == eFormatPointer)
item_byte_size = process->GetAddressByteSize();
item_byte_size = process->GetTarget().GetArchitecture().GetAddressByteSize();
else
item_byte_size = 1;
}
@ -334,7 +334,9 @@ public:
result.AppendWarningWithFormat("Not all bytes (%u/%u) were able to be read from 0x%llx.\n", bytes_read, total_byte_size, addr);
result.SetStatus(eReturnStatusSuccessFinishResult);
DataExtractor data(data_sp, process->GetByteOrder(), process->GetAddressByteSize());
DataExtractor data (data_sp,
process->GetTarget().GetArchitecture().GetByteOrder(),
process->GetTarget().GetArchitecture().GetAddressByteSize());
StreamFile outfile_stream;
Stream *output_stream = NULL;
@ -616,8 +618,8 @@ public:
}
StreamString buffer (Stream::eBinary,
process->GetAddressByteSize(),
process->GetByteOrder());
process->GetTarget().GetArchitecture().GetAddressByteSize(),
process->GetTarget().GetArchitecture().GetByteOrder());
size_t item_byte_size = m_options.m_byte_size;

View File

@ -328,6 +328,10 @@ public:
if (synchronous_execution)
{
state = process->WaitForProcessToStop (NULL);
if (!StateIsStoppedState(state));
{
result.AppendErrorWithFormat ("Process isn't stopped: %s", StateAsCString(state));
}
result.SetDidChangeProcessState (true);
result.SetStatus (eReturnStatusSuccessFinishResult);
}
@ -336,9 +340,24 @@ public:
result.SetStatus (eReturnStatusSuccessContinuingNoResult);
}
}
else
{
result.AppendErrorWithFormat ("Process resume at entry point failed: %s", error.AsCString());
result.SetStatus (eReturnStatusFailed);
}
}
else
{
result.AppendErrorWithFormat ("Initial process state wasn't stopped: %s", StateAsCString(state));
result.SetStatus (eReturnStatusFailed);
}
}
}
else
{
result.AppendErrorWithFormat ("Process launch failed: %s", error.AsCString());
result.SetStatus (eReturnStatusFailed);
}
return result.Succeeded();
}

View File

@ -42,11 +42,11 @@ GetByteOrderAndAddressSize (ExecutionContextScope *exe_scope, const Address &add
if (exe_scope == NULL)
return false;
Process *process = exe_scope->CalculateProcess();
if (process)
Target *target = exe_scope->CalculateTarget();
if (target)
{
byte_order = process->GetByteOrder();
addr_size = process->GetAddressByteSize();
byte_order = target->GetArchitecture().GetByteOrder();
addr_size = target->GetArchitecture().GetAddressByteSize();
}
if (byte_order == eByteOrderInvalid || addr_size == 0)
@ -54,7 +54,7 @@ GetByteOrderAndAddressSize (ExecutionContextScope *exe_scope, const Address &add
Module *module = address.GetModule();
if (module)
{
byte_order = module->GetArchitecture().GetDefaultEndian();
byte_order = module->GetArchitecture().GetByteOrder();
addr_size = module->GetArchitecture().GetAddressByteSize();
}
}
@ -313,7 +313,7 @@ Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, Dum
if (addr_size == UINT32_MAX)
{
if (process)
addr_size = process->GetAddressByteSize ();
addr_size = target->GetArchitecture().GetAddressByteSize ();
else
addr_size = sizeof(addr_t);
}
@ -387,8 +387,8 @@ Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, Dum
uint32_t pointer_size = 4;
Module *module = GetModule();
if (process)
pointer_size = process->GetAddressByteSize();
if (target)
pointer_size = target->GetArchitecture().GetAddressByteSize();
else if (module)
pointer_size = module->GetArchitecture().GetAddressByteSize();

View File

@ -143,8 +143,8 @@ AddressRange::Dump(Stream *s, Target *target, Address::DumpStyle style, Address:
{
addr_t vmaddr = LLDB_INVALID_ADDRESS;
int addr_size = sizeof (addr_t);
if (target && target->GetProcessSP())
addr_size = target->GetProcessSP()->GetAddressByteSize ();
if (target)
addr_size = target->GetArchitecture().GetAddressByteSize ();
bool show_module = false;
switch (style)

View File

@ -15,6 +15,8 @@
#include "llvm/Support/ELF.h"
#include "llvm/Support/MachO.h"
#include "lldb/Host/Endian.h"
#include "lldb/Host/Host.h"
using namespace lldb;
using namespace lldb_private;
@ -28,6 +30,8 @@ using namespace lldb_private;
//----------------------------------------------------------------------
struct ArchDefinition
{
ByteOrder byte_order;
uint32_t addr_byte_size;
uint32_t cpu;
uint32_t sub;
const char *name;
@ -52,54 +56,36 @@ static const char *g_arch_type_strings[] =
//----------------------------------------------------------------------
static ArchDefinition g_mach_arch_defs[] =
{
{ CPU_ANY, CPU_ANY , "all" },
{ llvm::MachO::CPUTypeARM, CPU_ANY , "arm" },
{ llvm::MachO::CPUTypeARM, 0 , "arm" },
{ llvm::MachO::CPUTypeARM, 5 , "armv4" },
{ llvm::MachO::CPUTypeARM, 6 , "armv6" },
{ llvm::MachO::CPUTypeARM, 7 , "armv5" },
{ llvm::MachO::CPUTypeARM, 8 , "xscale" },
{ llvm::MachO::CPUTypeARM, 9 , "armv7" },
{ llvm::MachO::CPUTypePowerPC, CPU_ANY , "ppc" },
{ llvm::MachO::CPUTypePowerPC, 0 , "ppc" },
{ llvm::MachO::CPUTypePowerPC, 1 , "ppc601" },
{ llvm::MachO::CPUTypePowerPC, 2 , "ppc602" },
{ llvm::MachO::CPUTypePowerPC, 3 , "ppc603" },
{ llvm::MachO::CPUTypePowerPC, 4 , "ppc603e" },
{ llvm::MachO::CPUTypePowerPC, 5 , "ppc603ev" },
{ llvm::MachO::CPUTypePowerPC, 6 , "ppc604" },
{ llvm::MachO::CPUTypePowerPC, 7 , "ppc604e" },
{ llvm::MachO::CPUTypePowerPC, 8 , "ppc620" },
{ llvm::MachO::CPUTypePowerPC, 9 , "ppc750" },
{ llvm::MachO::CPUTypePowerPC, 10 , "ppc7400" },
{ llvm::MachO::CPUTypePowerPC, 11 , "ppc7450" },
{ llvm::MachO::CPUTypePowerPC, 100 , "ppc970" },
{ llvm::MachO::CPUTypePowerPC64, 0 , "ppc64" },
{ llvm::MachO::CPUTypePowerPC64, 100 , "ppc970-64" },
{ llvm::MachO::CPUTypeI386, 3 , "i386" },
{ llvm::MachO::CPUTypeI386, 4 , "i486" },
{ llvm::MachO::CPUTypeI386, 0x84 , "i486sx" },
{ llvm::MachO::CPUTypeI386, CPU_ANY , "i386" },
{ llvm::MachO::CPUTypeX86_64, 3 , "x86_64" },
{ llvm::MachO::CPUTypeX86_64, CPU_ANY , "x86_64" },
// TODO: when we get a platform that knows more about the host OS we should
// let it call some accessor funcitons to set the default system arch for
// the default, 32 and 64 bit cases instead of hard coding it in this
// table.
#if defined (__i386__) || defined(__x86_64__)
{ llvm::MachO::CPUTypeX86_64, 3 , LLDB_ARCH_DEFAULT },
{ llvm::MachO::CPUTypeI386, 3 , LLDB_ARCH_DEFAULT_32BIT },
{ llvm::MachO::CPUTypeX86_64, 3 , LLDB_ARCH_DEFAULT_64BIT },
#elif defined (__arm__)
{ llvm::MachO::CPUTypeARM, 6 , LLDB_ARCH_DEFAULT },
{ llvm::MachO::CPUTypeARM, 6 , LLDB_ARCH_DEFAULT_32BIT },
#elif defined (__powerpc__) || defined (__ppc__) || defined (__ppc64__)
{ llvm::MachO::CPUTypePowerPC, 10 , LLDB_ARCH_DEFAULT },
{ llvm::MachO::CPUTypePowerPC, 10 , LLDB_ARCH_DEFAULT_32BIT },
{ llvm::MachO::CPUTypePowerPC64, 100 , LLDB_ARCH_DEFAULT_64BIT },
#endif
{ eByteOrderInvalid, 0, CPU_ANY, CPU_ANY , "all" },
{ eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, CPU_ANY , "arm" },
{ eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, 0 , "arm" },
{ eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, 5 , "armv4" },
{ eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, 6 , "armv6" },
{ eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, 7 , "armv5" },
{ eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, 8 , "xscale" },
{ eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, 9 , "armv7" },
{ eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, CPU_ANY , "ppc" },
{ eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 0 , "ppc" },
{ eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 1 , "ppc601" },
{ eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 2 , "ppc602" },
{ eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 3 , "ppc603" },
{ eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 4 , "ppc603e" },
{ eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 5 , "ppc603ev" },
{ eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 6 , "ppc604" },
{ eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 7 , "ppc604e" },
{ eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 8 , "ppc620" },
{ eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 9 , "ppc750" },
{ eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 10 , "ppc7400" },
{ eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 11 , "ppc7450" },
{ eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 100 , "ppc970" },
{ eByteOrderBig, 8, llvm::MachO::CPUTypePowerPC64, 0 , "ppc64" },
{ eByteOrderBig, 8, llvm::MachO::CPUTypePowerPC64, 100 , "ppc970-64" },
{ eByteOrderLittle, 4, llvm::MachO::CPUTypeI386, 3 , "i386" },
{ eByteOrderLittle, 4, llvm::MachO::CPUTypeI386, 4 , "i486" },
{ eByteOrderLittle, 4, llvm::MachO::CPUTypeI386, 0x84 , "i486sx" },
{ eByteOrderLittle, 4, llvm::MachO::CPUTypeI386, CPU_ANY , "i386" },
{ eByteOrderLittle, 8, llvm::MachO::CPUTypeX86_64, 3 , "x86_64" },
{ eByteOrderLittle, 8, llvm::MachO::CPUTypeX86_64, CPU_ANY , "x86_64" },
};
//----------------------------------------------------------------------
@ -118,33 +104,20 @@ const size_t k_num_mach_arch_defs = sizeof(g_mach_arch_defs)/sizeof(ArchDefiniti
//----------------------------------------------------------------------
static ArchDefinition g_elf_arch_defs[] =
{
{ llvm::ELF::EM_M32 , 0, "m32" }, // AT&T WE 32100
{ llvm::ELF::EM_SPARC , 0, "sparc" }, // AT&T WE 32100
{ llvm::ELF::EM_386 , 0, "i386" }, // Intel 80386
{ llvm::ELF::EM_68K , 0, "68k" }, // Motorola 68000
{ llvm::ELF::EM_88K , 0, "88k" }, // Motorola 88000
{ llvm::ELF::EM_486 , 0, "i486" }, // Intel 486 (deprecated)
{ llvm::ELF::EM_860 , 0, "860" }, // Intel 80860
{ llvm::ELF::EM_MIPS , 0, "rs3000" }, // MIPS RS3000
{ llvm::ELF::EM_PPC , 0, "ppc" }, // PowerPC
{ 21 , 0, "ppc64" }, // PowerPC64
{ llvm::ELF::EM_ARM , 0, "arm" }, // ARM
{ llvm::ELF::EM_ALPHA , 0, "alpha" }, // DEC Alpha
{ llvm::ELF::EM_SPARCV9, 0, "sparc9" }, // SPARC V9
{ llvm::ELF::EM_X86_64 , 0, "x86_64" }, // AMD64
#if defined (__i386__) || defined(__x86_64__)
{ llvm::ELF::EM_X86_64 , 0, LLDB_ARCH_DEFAULT },
{ llvm::ELF::EM_386 , 0, LLDB_ARCH_DEFAULT_32BIT },
{ llvm::ELF::EM_X86_64 , 0, LLDB_ARCH_DEFAULT_64BIT },
#elif defined (__arm__)
{ llvm::ELF::EM_ARM , 0, LLDB_ARCH_DEFAULT },
{ llvm::ELF::EM_ARM , 0, LLDB_ARCH_DEFAULT_32BIT },
#elif defined (__powerpc__) || defined (__ppc__) || defined (__ppc64__)
{ llvm::ELF::EM_PPC , 0, LLDB_ARCH_DEFAULT },
{ llvm::ELF::EM_PPC , 0, LLDB_ARCH_DEFAULT_32BIT },
{ llvm::ELF::EM_PPC64 , 0, LLDB_ARCH_DEFAULT_64BIT },
#endif
{ eByteOrderInvalid, 0, llvm::ELF::EM_M32 , 0, "m32" }, // AT&T WE 32100
{ eByteOrderBig, 4, llvm::ELF::EM_SPARC , 0, "sparc" }, // Sparc
{ eByteOrderLittle, 4, llvm::ELF::EM_386 , 0, "i386" }, // Intel 80386
{ eByteOrderBig, 4, llvm::ELF::EM_68K , 0, "68k" }, // Motorola 68000
{ eByteOrderBig, 4, llvm::ELF::EM_88K , 0, "88k" }, // Motorola 88000
{ eByteOrderLittle, 4, llvm::ELF::EM_486 , 0, "i486" }, // Intel 486 (deprecated)
{ eByteOrderLittle, 4, llvm::ELF::EM_860 , 0, "860" }, // Intel 80860
{ eByteOrderBig, 4, llvm::ELF::EM_MIPS , 0, "rs3000" }, // MIPS RS3000
{ eByteOrderBig, 4, llvm::ELF::EM_PPC , 0, "ppc" }, // PowerPC
{ eByteOrderBig, 8, 21 , 0, "ppc64" }, // PowerPC64
{ eByteOrderLittle, 4, llvm::ELF::EM_ARM , 0, "arm" }, // ARM
{ eByteOrderLittle, 4, llvm::ELF::EM_ALPHA , 0, "alpha" }, // DEC Alpha
{ eByteOrderLittle, 4, llvm::ELF::EM_SPARCV9, 0, "sparc9" }, // SPARC V9
{ eByteOrderLittle, 8, llvm::ELF::EM_X86_64 , 0, "x86_64" }, // AMD64
};
//----------------------------------------------------------------------
@ -158,7 +131,10 @@ const size_t k_num_elf_arch_defs = sizeof(g_elf_arch_defs)/sizeof(ArchDefinition
ArchSpec::ArchSpec() :
m_type (eArchTypeMachO), // Use the most complete arch definition which will always be translatable to any other ArchitectureType values
m_cpu (LLDB_INVALID_CPUTYPE),
m_sub (0)
m_sub (0),
m_triple (),
m_byte_order (lldb::endian::InlHostByteOrder()),
m_addr_byte_size (0)
{
}
@ -169,31 +145,38 @@ ArchSpec::ArchSpec() :
ArchSpec::ArchSpec (lldb::ArchitectureType arch_type, uint32_t cpu, uint32_t sub) :
m_type (arch_type),
m_cpu (cpu),
m_sub (sub)
m_sub (sub),
m_triple (),
m_byte_order (lldb::endian::InlHostByteOrder()),
m_addr_byte_size (0)
{
if (m_type == eArchTypeMachO)
MachOArchUpdated ();
}
//----------------------------------------------------------------------
// Constructor that initializes the object with supplied
// architecture name. There are also predefined values in
// Defines.h:
// liblldb_ARCH_DEFAULT
// LLDB_ARCH_DEFAULT
// The arch the current system defaults to when a program is
// launched without any extra attributes or settings.
//
// liblldb_ARCH_DEFAULT_32BIT
// LLDB_ARCH_DEFAULT_32BIT
// The 32 bit arch the current system defaults to (if any)
//
// liblldb_ARCH_DEFAULT_32BIT
// LLDB_ARCH_DEFAULT_32BIT
// The 64 bit arch the current system defaults to (if any)
//----------------------------------------------------------------------
ArchSpec::ArchSpec (const char *arch_name) :
m_type (eArchTypeMachO), // Use the most complete arch definition which will always be translatable to any other ArchitectureType values
m_cpu (LLDB_INVALID_CPUTYPE),
m_sub (0)
m_sub (0),
m_triple (),
m_byte_order (lldb::endian::InlHostByteOrder()),
m_addr_byte_size (0)
{
if (arch_name)
SetArch (arch_name);
SetArch (arch_name);
}
//----------------------------------------------------------------------
@ -214,6 +197,9 @@ ArchSpec::operator= (const ArchSpec& rhs)
m_type = rhs.m_type;
m_cpu = rhs.m_cpu;
m_sub = rhs.m_sub;
m_triple = rhs.m_triple;
m_byte_order = rhs.m_byte_order;
m_addr_byte_size = rhs.m_addr_byte_size;
}
return *this;
}
@ -294,6 +280,9 @@ ArchSpec::Clear()
m_type = eArchTypeInvalid;
m_cpu = LLDB_INVALID_CPUTYPE;
m_sub = 0;
m_triple = llvm::Triple();
m_byte_order = lldb::endian::InlHostByteOrder();
m_addr_byte_size = 0;
}
@ -1605,6 +1594,9 @@ ArchSpec::IsValid() const
uint32_t
ArchSpec::GetAddressByteSize() const
{
if (m_addr_byte_size > 0)
return m_addr_byte_size;
switch (m_type)
{
case kNumArchTypes:
@ -1639,7 +1631,6 @@ ArchSpec::GetAddressByteSize() const
}
break;
}
return 0;
}
@ -1667,6 +1658,105 @@ ArchSpec::SetArchFromTargetTriple (const char *target_triple)
}
return SetArch (target_triple);
}
void
ArchSpec::SetMachOArch (uint32_t cpu, uint32_t sub)
{
m_type = lldb::eArchTypeMachO;
m_cpu = cpu;
m_sub = sub;
MachOArchUpdated ();
}
void
ArchSpec::MachOArchUpdated (size_t idx)
{
// m_type, m_cpu, and m_sub have been updated, fixup everything else
if (idx >= k_num_mach_arch_defs)
{
for (size_t i=0; i<k_num_mach_arch_defs; i++)
{
if (m_cpu == g_mach_arch_defs[i].cpu)
{
if (m_sub == CPU_ANY || m_sub == LLDB_INVALID_CPUTYPE)
{
if (m_sub == g_mach_arch_defs[i].sub)
{
idx = i;
break;
}
}
else if ((m_sub & 0x00ffffff) == g_mach_arch_defs[i].sub)
{
idx = i;
break;
}
}
}
}
if (idx < k_num_mach_arch_defs)
{
m_byte_order = g_mach_arch_defs[idx].byte_order;
m_addr_byte_size = g_mach_arch_defs[idx].addr_byte_size;
char triple_cstr[1024];
int triple_cstr_len = ::snprintf (triple_cstr,
sizeof(triple_cstr),
"%s-apple-darwin",
g_mach_arch_defs[idx].name);
std::string triple_sstr (llvm::Triple::normalize (llvm::StringRef (triple_cstr, triple_cstr_len)));
llvm::StringRef triple_sref (triple_sstr.c_str(), triple_sstr.size());
llvm::Triple triple (triple_sref);
m_triple = triple;
}
else
{
assert (!"Unknown mach-o architecture");
m_byte_order = lldb::endian::InlHostByteOrder();
// We weren't able to find our CPU type in out known list of mach architectures...
if (GetCPUType() & llvm::MachO::CPUArchABI64)
m_addr_byte_size = 8;
else
m_addr_byte_size = 4;
m_triple = llvm::Triple();
}
}
void
ArchSpec::ELFArchUpdated (size_t idx)
{
if (idx >= k_num_elf_arch_defs)
{
for (size_t i=0; i<k_num_elf_arch_defs; i++)
{
if (g_elf_arch_defs[i].cpu == m_cpu)
{
idx = i;
break;
}
}
}
if (idx < k_num_elf_arch_defs)
{
m_byte_order = g_elf_arch_defs[idx].byte_order;
m_addr_byte_size = g_elf_arch_defs[idx].addr_byte_size;
char triple_cstr[1024];
int triple_cstr_len = ::snprintf (triple_cstr,
sizeof(triple_cstr),
"%s-unknown-unknown",
g_elf_arch_defs[idx].name);
std::string triple_sstr (llvm::Triple::normalize (llvm::StringRef (triple_cstr, triple_cstr_len)));
llvm::StringRef triple_sref (triple_sstr.c_str(), triple_sstr.size());
llvm::Triple triple (triple_sref);
m_triple = triple;
}
else
{
assert (!"Unknown ELF architecture");
m_byte_order = lldb::endian::InlHostByteOrder();
m_addr_byte_size = sizeof(void *);
m_triple = llvm::Triple();
}
}
//----------------------------------------------------------------------
// Change the CPU type and subtype given an architecture name.
@ -1676,8 +1766,22 @@ ArchSpec::SetArch (const char *arch_name)
{
if (arch_name && arch_name[0] != '\0')
{
size_t i;
// All system default architecture string values start with LLDB_ARCH_DEFAULT
if (::strncmp (arch_name, LLDB_ARCH_DEFAULT, strlen(LLDB_ARCH_DEFAULT)) == 0)
{
// Special case for the current host default architectures...
if (::strcmp (arch_name, LLDB_ARCH_DEFAULT_32BIT) == 0)
*this = Host::GetArchitecture (Host::eSystemDefaultArchitecture32);
else if (::strcmp (arch_name, LLDB_ARCH_DEFAULT_64BIT) == 0)
*this = Host::GetArchitecture (Host::eSystemDefaultArchitecture64);
else
*this = Host::GetArchitecture (Host::eSystemDefaultArchitecture);
return IsValid();
}
size_t i;
switch (m_type)
{
case eArchTypeInvalid:
@ -1689,6 +1793,7 @@ ArchSpec::SetArch (const char *arch_name)
m_type = eArchTypeMachO;
m_cpu = g_mach_arch_defs[i].cpu;
m_sub = g_mach_arch_defs[i].sub;
MachOArchUpdated (i);
return true;
}
}
@ -1701,6 +1806,7 @@ ArchSpec::SetArch (const char *arch_name)
{
m_cpu = g_elf_arch_defs[i].cpu;
m_sub = g_elf_arch_defs[i].sub;
ELFArchUpdated (i);
return true;
}
}
@ -1731,6 +1837,7 @@ ArchSpec::SetArch (const char *arch_name)
if (m_type != eArchTypeInvalid)
{
m_type = eArchTypeMachO;
char *end = NULL;
m_cpu = ::strtoul (str, &end, 0);
if (str != end)
@ -1744,6 +1851,7 @@ ArchSpec::SetArch (const char *arch_name)
m_sub = strtoul(str, &end, 0);
if (*end == '\0')
{
MachOArchUpdated ();
// We consumed the entire string and got a cpu type and subtype
return true;
}
@ -1760,6 +1868,9 @@ ArchSpec::SetArch (const char *arch_name)
if (m_cpu == g_mach_arch_defs[i].cpu)
{
m_sub = g_mach_arch_defs[i].sub;
m_byte_order = g_mach_arch_defs[i].byte_order;
m_addr_byte_size = g_mach_arch_defs[i].addr_byte_size;
MachOArchUpdated (i);
return true;
}
}
@ -1767,8 +1878,8 @@ ArchSpec::SetArch (const char *arch_name)
// Default the cpu subtype to zero when we don't have a matching
// cpu type in our architecture defs structure (g_mach_arch_defs).
m_sub = 0;
MachOArchUpdated ();
return true;
}
}
}
@ -1781,17 +1892,17 @@ ArchSpec::GetDefaultEndian () const
{
switch (GetGenericCPUType ())
{
case eCPU_ppc:
case eCPU_ppc64:
return eByteOrderBig;
case eCPU_arm:
case eCPU_i386:
case eCPU_x86_64:
return eByteOrderLittle;
default:
break;
case eCPU_ppc:
case eCPU_ppc64:
return eByteOrderBig;
case eCPU_arm:
case eCPU_i386:
case eCPU_x86_64:
return eByteOrderLittle;
default:
break;
}
return eByteOrderInvalid;
}

View File

@ -1208,9 +1208,7 @@ Debugger::FormatPrompt
if (vaddr != LLDB_INVALID_ADDRESS)
{
int addr_width = 0;
if (exe_ctx && exe_ctx->process)
addr_width = exe_ctx->process->GetAddressByteSize() * 2;
int addr_width = target->GetArchitecture().GetAddressByteSize() * 2;
if (addr_width == 0)
addr_width = 16;
s.Printf("0x%*.*llx", addr_width, addr_width, vaddr);

View File

@ -436,16 +436,8 @@ Disassembler::ParseInstructions
heap_buffer->SetByteSize (bytes_read);
data.SetData(data_sp);
if (exe_ctx->process)
{
data.SetByteOrder(exe_ctx->process->GetByteOrder());
data.SetAddressByteSize(exe_ctx->process->GetAddressByteSize());
}
else
{
data.SetByteOrder(target->GetArchitecture().GetDefaultEndian());
data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize());
}
data.SetByteOrder(target->GetArchitecture().GetByteOrder());
data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize());
return DecodeInstructions (range.GetBaseAddress(), data, 0, UINT32_MAX);
}

View File

@ -17,7 +17,7 @@ using namespace lldb;
using namespace lldb_private;
EmulateInstruction*
EmulateInstruction::FindPlugin (const ConstString &triple, const char *plugin_name)
EmulateInstruction::FindPlugin (const ArchSpec &arch, const char *plugin_name)
{
EmulateInstructionCreateInstance create_callback = NULL;
if (plugin_name)
@ -25,7 +25,7 @@ EmulateInstruction::FindPlugin (const ConstString &triple, const char *plugin_na
create_callback = PluginManager::GetEmulateInstructionCreateCallbackForPluginName (plugin_name);
if (create_callback)
{
std::auto_ptr<EmulateInstruction> instance_ap(create_callback(triple));
std::auto_ptr<EmulateInstruction> instance_ap(create_callback(arch));
if (instance_ap.get())
return instance_ap.release();
}
@ -34,7 +34,7 @@ EmulateInstruction::FindPlugin (const ConstString &triple, const char *plugin_na
{
for (uint32_t idx = 0; (create_callback = PluginManager::GetEmulateInstructionCreateCallbackAtIndex(idx)) != NULL; ++idx)
{
std::auto_ptr<EmulateInstruction> instance_ap(create_callback(triple));
std::auto_ptr<EmulateInstruction> instance_ap(create_callback(arch));
if (instance_ap.get())
return instance_ap.release();
}

View File

@ -102,11 +102,11 @@ Module::GetClangASTContext ()
if (m_did_init_ast == false)
{
ObjectFile * objfile = GetObjectFile();
ConstString target_triple;
if (objfile && objfile->GetTargetTriple(target_triple))
ArchSpec object_arch;
if (objfile && objfile->GetArchitecture(object_arch))
{
m_did_init_ast = true;
m_ast.SetTargetTriple (target_triple.AsCString());
m_ast.SetArchitecture (object_arch);
}
}
return m_ast;

View File

@ -25,6 +25,7 @@
#include "lldb/Symbol/Variable.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
@ -542,8 +543,8 @@ Value::GetValueAsData (ExecutionContext *exe_ctx, clang::ASTContext *ast_context
{
address = m_value.ULongLong(LLDB_INVALID_ADDRESS);
address_type = eAddressTypeLoad;
data.SetByteOrder(exe_ctx->process->GetByteOrder());
data.SetAddressByteSize(exe_ctx->process->GetAddressByteSize());
data.SetByteOrder(exe_ctx->process->GetTarget().GetArchitecture().GetByteOrder());
data.SetAddressByteSize(exe_ctx->process->GetTarget().GetArchitecture().GetAddressByteSize());
}
break;
@ -570,8 +571,8 @@ Value::GetValueAsData (ExecutionContext *exe_ctx, clang::ASTContext *ast_context
if (address != LLDB_INVALID_ADDRESS)
{
address_type = eAddressTypeLoad;
data.SetByteOrder(exe_ctx->process->GetByteOrder());
data.SetAddressByteSize(exe_ctx->process->GetAddressByteSize());
data.SetByteOrder(exe_ctx->target->GetArchitecture().GetByteOrder());
data.SetAddressByteSize(exe_ctx->target->GetArchitecture().GetAddressByteSize());
}
else
{

View File

@ -104,10 +104,10 @@ ValueObjectVariable::UpdateValue (ExecutionContextScope *exe_scope)
lldb::addr_t loclist_base_load_addr = LLDB_INVALID_ADDRESS;
ExecutionContext exe_ctx (exe_scope);
if (exe_ctx.process)
if (exe_ctx.target)
{
m_data.SetByteOrder(exe_ctx.process->GetByteOrder());
m_data.SetAddressByteSize(exe_ctx.process->GetAddressByteSize());
m_data.SetByteOrder(exe_ctx.target->GetArchitecture().GetByteOrder());
m_data.SetAddressByteSize(exe_ctx.target->GetArchitecture().GetAddressByteSize());
}
if (expr.IsLocationList())

View File

@ -178,11 +178,9 @@ static FrontendAction *CreateFrontendAction(CompilerInstance &CI) {
// Implementation of ClangExpressionParser
//===----------------------------------------------------------------------===//
ClangExpressionParser::ClangExpressionParser(const char *target_triple,
Process *process,
ClangExpression &expr) :
m_expr(expr),
m_target_triple (),
ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
ClangExpression &expr) :
m_expr (expr),
m_compiler (),
m_code_generator (NULL),
m_execution_engine (),
@ -195,12 +193,7 @@ ClangExpressionParser::ClangExpressionParser(const char *target_triple,
llvm::InitializeAllAsmPrinters();
}
} InitializeLLVM;
if (target_triple && target_triple[0])
m_target_triple = target_triple;
else
m_target_triple = llvm::sys::getHostTriple();
// 1. Create a new compiler instance.
m_compiler.reset(new CompilerInstance());
m_compiler->setLLVMContext(new LLVMContext());
@ -215,6 +208,10 @@ ClangExpressionParser::ClangExpressionParser(const char *target_triple,
m_compiler->getLangOpts().ObjC1 = true;
m_compiler->getLangOpts().ObjC2 = true;
Process *process = NULL;
if (exe_scope)
process = exe_scope->CalculateProcess();
if (process)
{
if (process->GetObjCLanguageRuntime())
@ -239,7 +236,19 @@ ClangExpressionParser::ClangExpressionParser(const char *target_triple,
m_compiler->getDiagnosticOpts().Warnings.push_back("no-unused-value");
// Set the target triple.
m_compiler->getTargetOpts().Triple = m_target_triple;
Target *target = NULL;
if (exe_scope)
target = exe_scope->CalculateTarget();
// TODO: figure out what to really do when we don't have a valid target.
// Sometimes this will be ok to just use the host target triple (when we
// evaluate say "2+3", but other expressions like breakpoint conditions
// and other things that _are_ target specific really shouldn't just be
// using the host triple. This needs to be fixed in a better way.
if (target && target->GetArchitecture().IsValid())
m_compiler->getTargetOpts().Triple = target->GetArchitecture().GetTriple().str();
else
m_compiler->getTargetOpts().Triple = llvm::sys::getHostTriple();
// 3. Set up various important bits of infrastructure.
m_compiler->createDiagnostics(0, 0);

View File

@ -17,6 +17,7 @@
#include "clang/CodeGen/ModuleBuilder.h"
#include "clang/Frontend/CompilerInstance.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/Module.h"
@ -36,6 +37,7 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/ThreadPlanCallFunction.h"
@ -48,13 +50,13 @@ using namespace lldb_private;
//----------------------------------------------------------------------
ClangFunction::ClangFunction
(
const char *target_triple,
ExecutionContextScope *exe_scope,
ClangASTContext *ast_context,
void *return_qualtype,
const Address& functionAddress,
const ValueList &arg_value_list
) :
m_target_triple (target_triple),
m_arch (),
m_function_ptr (NULL),
m_function_addr (functionAddress),
m_function_return_qual_type(return_qualtype),
@ -66,16 +68,22 @@ ClangFunction::ClangFunction
m_compiled (false),
m_JITted (false)
{
if (exe_scope)
{
Target *target = exe_scope->CalculateTarget();
if (target)
m_arch = target->GetArchitecture();
}
}
ClangFunction::ClangFunction
(
const char *target_triple,
ExecutionContextScope *exe_scope,
Function &function,
ClangASTContext *ast_context,
const ValueList &arg_value_list
) :
m_target_triple (target_triple),
m_arch (),
m_function_ptr (&function),
m_function_addr (),
m_function_return_qual_type (),
@ -87,6 +95,13 @@ ClangFunction::ClangFunction
m_compiled (false),
m_JITted (false)
{
if (exe_scope)
{
Target *target = exe_scope->CalculateTarget();
if (target)
m_arch = target->GetArchitecture();
}
m_function_addr = m_function_ptr->GetAddressRange().GetBaseAddress();
m_function_return_qual_type = m_function_ptr->GetReturnType().GetClangType();
}
@ -212,7 +227,7 @@ ClangFunction::CompileFunction (Stream &errors)
// Okay, now compile this expression
m_parser.reset(new ClangExpressionParser(m_target_triple.c_str(), NULL, *this));
m_parser.reset(new ClangExpressionParser(NULL, *this));
num_errors = m_parser->Parse (errors);

View File

@ -234,19 +234,6 @@ ClangUserExpression::Parse (Stream &error_stream,
return false;
}
ConstString target_triple;
target->GetTargetTriple (target_triple);
if (!target_triple)
target_triple = Host::GetTargetTriple ();
if (!target_triple)
{
error_stream.PutCString ("error: invalid target triple\n");
return false;
}
//////////////////////////
// Parse the expression
//
@ -257,7 +244,7 @@ ClangUserExpression::Parse (Stream &error_stream,
m_expr_decl_map->WillParse(exe_ctx);
ClangExpressionParser parser(target_triple.GetCString(), exe_ctx.process, *this);
ClangExpressionParser parser(exe_ctx.process, *this);
unsigned num_errors = parser.Parse (error_stream);

View File

@ -81,20 +81,7 @@ ClangUtilityFunction::Install (Stream &error_stream,
error_stream.PutCString ("error: invalid target\n");
return false;
}
ConstString target_triple;
target->GetTargetTriple (target_triple);
if (!target_triple)
target_triple = Host::GetTargetTriple ();
if (!target_triple)
{
error_stream.PutCString ("error: invalid target triple\n");
return false;
}
//////////////////////////
// Parse the expression
//
@ -105,7 +92,7 @@ ClangUtilityFunction::Install (Stream &error_stream,
m_expr_decl_map->WillParse(exe_ctx);
ClangExpressionParser parser(target_triple.GetCString(), exe_ctx.process, *this);
ClangExpressionParser parser(exe_ctx.GetBestExecutionContextScope(), *this);
unsigned num_errors = parser.Parse (error_stream);

View File

@ -222,38 +222,122 @@ Host::GetPageSize()
}
const ArchSpec &
Host::GetArchitecture ()
Host::GetArchitecture (SystemDefaultArchitecture arch_kind)
{
static ArchSpec g_host_arch;
if (!g_host_arch.IsValid())
{
static bool g_supports_32 = false;
static bool g_supports_64 = false;
static ArchSpec g_host_arch_32;
static ArchSpec g_host_arch_64;
#if defined (__APPLE__)
// Apple is different in that it can support both 32 and 64 bit executables
// in the same operating system running concurrently. Here we detect the
// correct host architectures for both 32 and 64 bit including if 64 bit
// executables are supported on the system.
if (g_supports_32 == false && g_supports_64 == false)
{
// All apple systems support 32 bit execution.
g_supports_32 = true;
uint32_t cputype, cpusubtype;
uint32_t is_64_bit_capable;
uint32_t is_64_bit_capable = false;
size_t len = sizeof(cputype);
ArchSpec host_arch;
// These will tell us about the kernel architecture, which even on a 64
// bit machine can be 32 bit...
if (::sysctlbyname("hw.cputype", &cputype, &len, NULL, 0) == 0)
{
len = sizeof(cpusubtype);
if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) == 0)
g_host_arch.SetMachOArch (cputype, cpusubtype);
len = sizeof (cpusubtype);
if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) != 0)
cpusubtype = CPU_TYPE_ANY;
len = sizeof (is_64_bit_capable);
if (::sysctlbyname("hw.cpu64bit_capable", &is_64_bit_capable, &len, NULL, 0) == 0)
{
if (is_64_bit_capable)
g_supports_64 = true;
}
if (is_64_bit_capable)
{
if (cputype & CPU_ARCH_ABI64)
{
if (cputype == CPU_TYPE_I386 && cpusubtype == CPU_SUBTYPE_486)
// We have a 64 bit kernel on a 64 bit system
g_host_arch_32.SetMachOArch (CPU_TYPE_I386, CPU_SUBTYPE_386);
g_host_arch_64.SetMachOArch (cputype, cpusubtype);
}
else
{
// We have a 32 bit kernel on a 64 bit system
g_host_arch_32.SetMachOArch (cputype, cpusubtype);
#if defined (__i386__) || defined (__x86_64__)
if (cpusubtype == CPU_SUBTYPE_486)
cpusubtype = CPU_SUBTYPE_I386_ALL;
#endif
cputype |= CPU_ARCH_ABI64;
g_host_arch_64.SetMachOArch (cputype, cpusubtype);
}
}
else
{
g_host_arch_32.SetMachOArch (cputype, cpusubtype);
g_host_arch_64.Clear();
}
}
#elif defined (__linux__)
g_host_arch.SetElfArch(7u, 144u);
}
#else // #if defined (__APPLE__)
if (g_supports_32 == false && g_supports_64 == false)
{
#if defined (__x86_64__)
g_host_arch_64.SetArch ("x86_64");
g_supports_32 = false;
g_supports_64 = true;
#elif defined (__i386__)
g_host_arch.SetArch ("i386");
g_supports_32 = true;
g_supports_64 = false;
#elif defined (__arm__)
g_host_arch.SetArch ("arm");
g_supports_32 = true;
g_supports_64 = false;
#elif defined (__ppc64__)
g_host_arch.SetArch ("ppc64");
g_supports_32 = false;
g_supports_64 = true;
#elif defined (__powerpc__) || defined (__ppc__)
g_host_arch.SetArch ("ppc");
g_supports_32 = true;
g_supports_64 = false;
#else
#error undefined architecture, define your architecture here
#endif
}
return g_host_arch;
#endif // #else for #if defined (__APPLE__)
if (arch_kind == eSystemDefaultArchitecture32)
return g_host_arch_32;
else if (arch_kind == eSystemDefaultArchitecture64)
return g_host_arch_64;
if (g_supports_64)
return g_host_arch_64;
return g_host_arch_32;
}
const ConstString &

View File

@ -41,15 +41,12 @@ ABIMacOSX_i386::GetRedZoneSize () const
// Static Functions
//------------------------------------------------------------------
lldb_private::ABI *
ABIMacOSX_i386::CreateInstance (const ConstString &triple)
ABIMacOSX_i386::CreateInstance (const ArchSpec &arch)
{
llvm::StringRef tripleStr(triple.GetCString());
llvm::Triple llvmTriple(tripleStr);
if (llvmTriple.getArch() != llvm::Triple::x86)
return NULL;
return new ABIMacOSX_i386;
if (arch.GetTriple().getArch() == llvm::Triple::x86)
return new ABIMacOSX_i386;
return NULL;
}
bool

View File

@ -63,7 +63,7 @@ namespace lldb_private {
Terminate();
static lldb_private::ABI *
CreateInstance (const ConstString &triple);
CreateInstance (const ArchSpec &arch);
//------------------------------------------------------------------
// PluginInterface protocol

View File

@ -42,15 +42,11 @@ ABISysV_x86_64::GetRedZoneSize () const
// Static Functions
//------------------------------------------------------------------
lldb_private::ABI *
ABISysV_x86_64::CreateInstance (const ConstString &triple)
ABISysV_x86_64::CreateInstance (const ArchSpec &arch)
{
llvm::StringRef tripleStr(triple.GetCString());
llvm::Triple llvmTriple(tripleStr);
if (llvmTriple.getArch() != llvm::Triple::x86_64)
return NULL;
return new ABISysV_x86_64;
if (arch.GetTriple().getArch() == llvm::Triple::x86_64)
return new ABISysV_x86_64;
return NULL;
}
bool
@ -227,7 +223,9 @@ static bool ReadIntegerArgument(Scalar &scalar,
uint8_t arg_data[sizeof(arg_contents)];
Error error;
thread.GetProcess().ReadMemory(current_stack_argument, arg_data, sizeof(arg_contents), error);
DataExtractor arg_data_extractor(arg_data, sizeof(arg_contents), thread.GetProcess().GetByteOrder(), thread.GetProcess().GetAddressByteSize());
DataExtractor arg_data_extractor (arg_data, sizeof(arg_contents),
thread.GetProcess().GetTarget().GetArchitecture().GetByteOrder(),
thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize());
uint32_t offset = 0;
arg_contents = arg_data_extractor.GetMaxU64(&offset, bit_width / 8);
if (!offset)

View File

@ -62,7 +62,7 @@ public:
Terminate();
static lldb_private::ABI *
CreateInstance (const ConstString &triple);
CreateInstance (const ArchSpec &arch);
//------------------------------------------------------------------
// PluginInterface protocol

View File

@ -424,7 +424,7 @@ DynamicLoaderMacOSXDYLD::ReadAllImageInfosStructure ()
m_dyld_all_image_infos.Clear();
if (m_dyld_all_image_infos_addr != LLDB_INVALID_ADDRESS)
{
ByteOrder byte_order = m_process->GetByteOrder();
ByteOrder byte_order = m_process->GetTarget().GetArchitecture().GetByteOrder();
uint32_t addr_size = 4;
if (m_dyld_all_image_infos_addr > UINT32_MAX)
addr_size = 8;

View File

@ -10,6 +10,7 @@
#include <stdlib.h>
#include "EmulateInstructionARM.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/ConstString.h"
#include "Plugins/Process/Utility/ARMDefines.h"
@ -3620,38 +3621,22 @@ EmulateInstructionARM::GetThumbOpcodeForInstruction (const uint32_t opcode)
}
bool
EmulateInstructionARM::SetTargetTriple (const ConstString &triple)
EmulateInstructionARM::SetArchitecture (const ArchSpec &arch)
{
m_arm_isa = 0;
const char *triple_cstr = triple.GetCString();
if (triple_cstr)
const char *arch_cstr = arch.AsCString ();
if (arch_cstr)
{
const char *dash = ::strchr (triple_cstr, '-');
if (dash)
{
std::string arch (triple_cstr, dash);
const char *arch_cstr = arch.c_str();
if (strcasecmp(arch_cstr, "armv4t") == 0)
m_arm_isa = ARMv4T;
else if (strcasecmp(arch_cstr, "armv4") == 0)
m_arm_isa = ARMv4;
else if (strcasecmp(arch_cstr, "armv5tej") == 0)
m_arm_isa = ARMv5TEJ;
else if (strcasecmp(arch_cstr, "armv5te") == 0)
m_arm_isa = ARMv5TE;
else if (strcasecmp(arch_cstr, "armv5t") == 0)
m_arm_isa = ARMv5T;
else if (strcasecmp(arch_cstr, "armv6k") == 0)
m_arm_isa = ARMv6K;
else if (strcasecmp(arch_cstr, "armv6") == 0)
m_arm_isa = ARMv6;
else if (strcasecmp(arch_cstr, "armv6t2") == 0)
m_arm_isa = ARMv6T2;
else if (strcasecmp(arch_cstr, "armv7") == 0)
m_arm_isa = ARMv7;
else if (strcasecmp(arch_cstr, "armv8") == 0)
m_arm_isa = ARMv8;
}
if (0 == ::strcasecmp(arch_cstr, "armv4t")) m_arm_isa = ARMv4T;
else if (0 == ::strcasecmp(arch_cstr, "armv4")) m_arm_isa = ARMv4;
else if (0 == ::strcasecmp(arch_cstr, "armv5tej")) m_arm_isa = ARMv5TEJ;
else if (0 == ::strcasecmp(arch_cstr, "armv5te")) m_arm_isa = ARMv5TE;
else if (0 == ::strcasecmp(arch_cstr, "armv5t")) m_arm_isa = ARMv5T;
else if (0 == ::strcasecmp(arch_cstr, "armv6k")) m_arm_isa = ARMv6K;
else if (0 == ::strcasecmp(arch_cstr, "armv6")) m_arm_isa = ARMv6;
else if (0 == ::strcasecmp(arch_cstr, "armv6t2")) m_arm_isa = ARMv6T2;
else if (0 == ::strcasecmp(arch_cstr, "armv7")) m_arm_isa = ARMv7;
else if (0 == ::strcasecmp(arch_cstr, "armv8")) m_arm_isa = ARMv8;
}
return m_arm_isa != 0;
}

View File

@ -131,7 +131,7 @@ public:
virtual bool
SetTargetTriple (const ConstString &triple);
SetArchitecture (const ArchSpec &arch);
virtual bool
ReadInstruction ();

View File

@ -104,7 +104,6 @@ AppleObjCRuntime::GetObjectDescription (Stream &str, Value &value, ExecutionCont
arg_value_list.PushValue(value);
// This is the return value:
const char *target_triple = exe_ctx.process->GetTargetTriple().GetCString();
ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext();
void *return_qualtype = ast_context->GetCStringType(true);
@ -112,7 +111,12 @@ AppleObjCRuntime::GetObjectDescription (Stream &str, Value &value, ExecutionCont
ret.SetContext(Value::eContextTypeClangType, return_qualtype);
// Now we're ready to call the function:
ClangFunction func(target_triple, ast_context, return_qualtype, *function_address, arg_value_list);
ClangFunction func (exe_ctx.GetBestExecutionContextScope(),
ast_context,
return_qualtype,
*function_address,
arg_value_list);
StreamString error_stream;
lldb::addr_t wrapper_struct_addr = LLDB_INVALID_ADDRESS;

View File

@ -819,11 +819,11 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan (Thread &thread, bool sto
// Next make the runner function for our implementation utility function.
if (!m_impl_function.get())
{
m_impl_function.reset(new ClangFunction(process->GetTargetTriple().GetCString(),
clang_ast_context,
clang_void_ptr_type,
impl_code_address,
dispatch_values));
m_impl_function.reset(new ClangFunction (&thread,
clang_ast_context,
clang_void_ptr_type,
impl_code_address,
dispatch_values));
errors.Clear();
unsigned num_errors = m_impl_function->CompileFunction(errors);

View File

@ -1043,40 +1043,28 @@ ObjectFileELF::DumpDependentModules(lldb_private::Stream *s)
}
bool
ObjectFileELF::GetTargetTriple(ConstString &target_triple)
ObjectFileELF::GetArchitecture (ArchSpec &arch)
{
static ConstString g_target_triple;
if (g_target_triple)
{
target_triple = g_target_triple;
return true;
}
std::string triple;
switch (m_header.e_machine)
{
default:
assert(false && "Unexpected machine type.");
break;
case EM_SPARC: triple.assign("sparc-"); break;
case EM_386: triple.assign("i386-"); break;
case EM_68K: triple.assign("68k-"); break;
case EM_88K: triple.assign("88k-"); break;
case EM_860: triple.assign("i860-"); break;
case EM_MIPS: triple.assign("mips-"); break;
case EM_PPC: triple.assign("powerpc-"); break;
case EM_PPC64: triple.assign("powerpc64-"); break;
case EM_ARM: triple.assign("arm-"); break;
case EM_X86_64: triple.assign("x86_64-"); break;
case EM_SPARC: arch.GetTriple().setArchName("sparc"); break;
case EM_386: arch.GetTriple().setArchName("i386"); break;
case EM_68K: arch.GetTriple().setArchName("68k"); break;
case EM_88K: arch.GetTriple().setArchName("88k"); break;
case EM_860: arch.GetTriple().setArchName("i860"); break;
case EM_MIPS: arch.GetTriple().setArchName("mips"); break;
case EM_PPC: arch.GetTriple().setArchName("powerpc"); break;
case EM_PPC64: arch.GetTriple().setArchName("powerpc64"); break;
case EM_ARM: arch.GetTriple().setArchName("arm"); break;
case EM_X86_64: arch.GetTriple().setArchName("x86_64"); break;
}
// TODO: determine if there is a vendor in the ELF? Default to "linux" for now
triple += "linux-";
arch.GetTriple().setOSName ("linux");
// TODO: determine if there is an OS in the ELF? Default to "gnu" for now
triple += "gnu";
g_target_triple.SetCString(triple.c_str());
target_triple = g_target_triple;
arch.GetTriple().setVendorName("gnu");
return true;
}

View File

@ -105,7 +105,7 @@ public:
Dump(lldb_private::Stream *s);
virtual bool
GetTargetTriple(lldb_private::ConstString &target_triple);
GetArchitecture (lldb_private::ArchSpec &arch);
virtual bool
GetUUID(lldb_private::UUID* uuid);

View File

@ -1436,15 +1436,11 @@ ObjectFileMachO::GetDependentModules (FileSpecList& files)
}
bool
ObjectFileMachO::GetTargetTriple (ConstString &target_triple)
ObjectFileMachO::GetArchitecture (ArchSpec &arch)
{
lldb_private::Mutex::Locker locker(m_mutex);
std::string triple(GetModule()->GetArchitecture().AsCString());
triple += "-apple-darwin";
target_triple.SetCString(triple.c_str());
if (target_triple)
return true;
return false;
arch.SetMachOArch(m_header.cputype, m_header.cpusubtype);
return true;
}

View File

@ -83,7 +83,7 @@ public:
Dump (lldb_private::Stream *s);
virtual bool
GetTargetTriple (lldb_private::ConstString &target_triple);
GetArchitecture (lldb_private::ArchSpec &arch);
virtual bool
GetUUID (lldb_private::UUID* uuid);

View File

@ -443,39 +443,10 @@ ProcessMacOSX::DidLaunchOrAttach ()
Module * exe_module = GetTarget().GetExecutableModule ().get();
assert (exe_module);
m_arch_spec = exe_module->GetArchitecture();
assert (m_arch_spec.IsValid());
ObjectFile *exe_objfile = exe_module->GetObjectFile();
assert (exe_objfile);
m_byte_order = exe_objfile->GetByteOrder();
assert (m_byte_order != eByteOrderInvalid);
// Install a signal handler so we can catch when our child process
// dies and set the exit status correctly.
m_monitor_thread = Host::StartMonitoringChildProcess (Process::SetProcessExitStatus, NULL, GetID(), false);
if (m_arch_spec == ArchSpec("arm"))
{
// On ARM we want the actual target triple of the OS to get the
// most capable ARM slice for the process. Since this plug-in is
// only used for doing native debugging this will work.
m_target_triple = Host::GetTargetTriple();
}
else
{
// We want the arch of the process, and the vendor and OS from the
// host OS.
StreamString triple;
triple.Printf("%s-%s-%s",
m_arch_spec.AsCString(),
Host::GetVendorString().AsCString("apple"),
Host::GetOSString().AsCString("darwin"));
m_target_triple.SetCString(triple.GetString().c_str());
}
}
}
@ -883,12 +854,6 @@ ProcessMacOSX::DoDestroy ()
return error;
}
ByteOrder
ProcessMacOSX::GetByteOrder () const
{
return m_byte_order;
}
//------------------------------------------------------------------
// Process Queries
//------------------------------------------------------------------

View File

@ -222,9 +222,6 @@ public:
virtual lldb_private::Error
DisableWatchpoint (lldb_private::WatchpointLocation *wp_loc);
virtual lldb::ByteOrder
GetByteOrder () const;
virtual lldb_private::DynamicLoader *
GetDynamicLoader ();

View File

@ -107,7 +107,9 @@ ThreadMacOSX::GetDispatchQueueName()
uint8_t memory_buffer[8];
addr_t dispatch_queue_offsets_addr = LLDB_INVALID_ADDRESS;
DataExtractor data(memory_buffer, sizeof(memory_buffer), m_process.GetByteOrder(), m_process.GetAddressByteSize());
DataExtractor data (memory_buffer, sizeof(memory_buffer),
m_process.GetTarget().GetArchitecture().GetByteOrder(),
m_process.GetTarget().GetArchitecture().GetAddressByteSize());
static ConstString g_dispatch_queue_offsets_symbol_name ("dispatch_queue_offsets");
const Symbol *dispatch_queue_offsets_symbol = NULL;
ModuleSP module_sp(m_process.GetTarget().GetImages().FindFirstModuleForFileSpec (FileSpec("libSystem.B.dylib", false)));
@ -477,6 +479,8 @@ ThreadMacOSX::ThreadWillResume (StateType resume_state)
case eStateStepping:
Resume();
break;
default:
break;
}
m_context->ThreadWillResume();
}

View File

@ -13,6 +13,7 @@
// C Includes
// C++ Includes
// Other libraries and framework includes
#include "llvm/ADT/Triple.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Core/ConnectionFileDescriptor.h"
#include "lldb/Core/Log.h"

View File

@ -638,7 +638,7 @@ ProcessGDBRemote::DidLaunchOrAttach ()
BuildDynamicRegisterInfo (false);
m_byte_order = m_gdb_comm.GetByteOrder();
m_target.GetArchitecture().SetByteOrder (m_gdb_comm.GetByteOrder());
StreamString strm;
@ -656,33 +656,16 @@ ProcessGDBRemote::DidLaunchOrAttach ()
// defacto architecture in this case.
if (gdb_remote_arch == ArchSpec ("arm") &&
vendor != NULL &&
strcmp(vendor, "apple") == 0)
vendor && ::strcmp(vendor, "apple") == 0)
{
GetTarget().SetArchitecture (gdb_remote_arch);
target_arch = gdb_remote_arch;
}
if (!target_arch.IsValid())
target_arch = gdb_remote_arch;
if (target_arch.IsValid())
{
if (vendor == NULL)
vendor = Host::GetVendorString().AsCString("apple");
if (os_type == NULL)
os_type = Host::GetOSString().AsCString("darwin");
strm.Printf ("%s-%s-%s", target_arch.AsCString(), vendor, os_type);
std::transform (strm.GetString().begin(),
strm.GetString().end(),
strm.GetString().begin(),
::tolower);
m_target_triple.SetCString(strm.GetString().c_str());
}
if (vendor)
m_target.GetArchitecture().GetTriple().setVendorName(vendor);
if (os_type)
m_target.GetArchitecture().GetTriple().setOSName(os_type);
}
}
@ -2557,7 +2540,10 @@ ProcessGDBRemote::GetDispatchQueueNameForThread
}
uint8_t memory_buffer[8];
DataExtractor data(memory_buffer, sizeof(memory_buffer), GetByteOrder(), GetAddressByteSize());
DataExtractor data (memory_buffer,
sizeof(memory_buffer),
m_target.GetArchitecture().GetByteOrder(),
m_target.GetArchitecture().GetAddressByteSize());
// Excerpt from src/queue_private.h
struct dispatch_queue_offsets_s

View File

@ -54,6 +54,7 @@
#include <assert.h>
#endif
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/dwarf.h"
#include "lldb/Core/Flags.h"
#include "lldb/Core/Log.h"
@ -395,6 +396,13 @@ ClangASTContext::SetTargetTriple (const char *target_triple)
m_target_triple.assign(target_triple);
}
void
ClangASTContext::SetArchitecture (const ArchSpec &arch)
{
Clear();
m_target_triple.assign(arch.GetTriple().str());
}
bool
ClangASTContext::HasExternalSource ()
{

View File

@ -25,6 +25,7 @@
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
@ -355,7 +356,8 @@ Type::DumpValueInMemory
if (address != LLDB_INVALID_ADDRESS)
{
DataExtractor data;
data.SetByteOrder (exe_ctx->process->GetByteOrder());
if (exe_ctx->target)
data.SetByteOrder (exe_ctx->target->GetArchitecture().GetByteOrder());
if (ReadFromMemory (exe_ctx, address, address_type, data))
{
DumpValue(exe_ctx, s, data, 0, show_types, show_summary, verbose);

View File

@ -58,12 +58,11 @@ UnwindTable::Initialize ()
}
ArchSpec arch;
ConstString str;
m_object_file.GetTargetTriple (str);
arch.SetArchFromTargetTriple (str.GetCString());
m_assembly_profiler = UnwindAssemblyProfiler::FindPlugin (arch);
m_initialized = true;
if (m_object_file.GetArchitecture (arch))
{
m_assembly_profiler = UnwindAssemblyProfiler::FindPlugin (arch);
m_initialized = true;
}
}
UnwindTable::~UnwindTable ()

View File

@ -14,7 +14,7 @@ using namespace lldb;
using namespace lldb_private;
ABI*
ABI::FindPlugin (const ConstString &triple)
ABI::FindPlugin (const ArchSpec &arch)
{
std::auto_ptr<ABI> abi_ap;
ABICreateInstance create_callback;
@ -23,7 +23,7 @@ ABI::FindPlugin (const ConstString &triple)
(create_callback = PluginManager::GetABICreateCallbackAtIndex(idx)) != NULL;
++idx)
{
abi_ap.reset (create_callback(triple));
abi_ap.reset (create_callback(arch));
if (abi_ap.get())
return abi_ap.release();

View File

@ -229,9 +229,6 @@ Process::Process(Target &target, Listener &listener) :
m_breakpoint_site_list (),
m_dynamic_checkers_ap (),
m_unix_signals (),
m_target_triple (),
m_byte_order (lldb::endian::InlHostByteOrder()),
m_addr_byte_size (0),
m_abi_sp (),
m_process_input_reader (),
m_stdio_communication ("process.stdio"),
@ -857,15 +854,8 @@ Process::GetDynamicLoader()
const ABI *
Process::GetABI()
{
ConstString& triple = m_target_triple;
if (triple.IsEmpty())
return NULL;
if (m_abi_sp.get() == NULL)
{
m_abi_sp.reset(ABI::FindPlugin(triple));
}
m_abi_sp.reset(ABI::FindPlugin(m_target.GetArchitecture()));
return m_abi_sp.get();
}
@ -1317,7 +1307,10 @@ Process::ReadUnsignedInteger (lldb::addr_t vm_addr, size_t integer_byte_size, Er
else
{
uint8_t tmp[sizeof(uint64_t)];
DataExtractor data (tmp, integer_byte_size, GetByteOrder(), GetAddressByteSize());
DataExtractor data (tmp,
integer_byte_size,
m_target.GetArchitecture().GetByteOrder(),
m_target.GetArchitecture().GetAddressByteSize());
if (ReadMemory (vm_addr, tmp, integer_byte_size, error) == integer_byte_size)
{
uint32_t offset = 0;
@ -1509,7 +1502,6 @@ Process::Launch
)
{
Error error;
m_target_triple.Clear();
m_abi_sp.reset();
m_process_input_reader.reset();
@ -1666,7 +1658,6 @@ Error
Process::Attach (lldb::pid_t attach_pid)
{
m_target_triple.Clear();
m_abi_sp.reset();
m_process_input_reader.reset();
@ -1710,7 +1701,6 @@ Process::Attach (lldb::pid_t attach_pid)
Error
Process::Attach (const char *process_name, bool wait_for_launch)
{
m_target_triple.Clear();
m_abi_sp.reset();
m_process_input_reader.reset();
@ -1756,7 +1746,6 @@ Process::Attach (const char *process_name, bool wait_for_launch)
Error
Process::ConnectRemote (const char *remote_url)
{
m_target_triple.Clear();
m_abi_sp.reset();
m_process_input_reader.reset();
@ -1975,32 +1964,19 @@ Process::Signal (int signal)
return error;
}
UnixSignals &
Process::GetUnixSignals ()
lldb::ByteOrder
Process::GetByteOrder () const
{
return m_unix_signals;
}
Target &
Process::GetTarget ()
{
return m_target;
}
const Target &
Process::GetTarget () const
{
return m_target;
return m_target.GetArchitecture().GetByteOrder();
}
uint32_t
Process::GetAddressByteSize()
Process::GetAddressByteSize () const
{
if (m_addr_byte_size == 0)
return m_target.GetArchitecture().GetAddressByteSize();
return m_addr_byte_size;
return m_target.GetArchitecture().GetAddressByteSize();
}
bool
Process::ShouldBroadcastEvent (Event *event_ptr)
{
@ -2111,22 +2087,6 @@ Process::ShouldBroadcastEvent (Event *event_ptr)
return return_value;
}
//------------------------------------------------------------------
// Thread Queries
//------------------------------------------------------------------
ThreadList &
Process::GetThreadList ()
{
return m_thread_list;
}
const ThreadList &
Process::GetThreadList () const
{
return m_thread_list;
}
bool
Process::StartPrivateStateThread ()
@ -2517,30 +2477,6 @@ Process::ProcessEventData::SetUpdateStateOnRemoval (Event *event_ptr)
return false;
}
Target *
Process::CalculateTarget ()
{
return &m_target;
}
Process *
Process::CalculateProcess ()
{
return this;
}
Thread *
Process::CalculateThread ()
{
return NULL;
}
StackFrame *
Process::CalculateStackFrame ()
{
return NULL;
}
void
Process::CalculateExecutionContext (ExecutionContext &exe_ctx)
{

View File

@ -910,7 +910,7 @@ StackFrame::Dump (Stream *strm, bool show_frame_index, bool show_fullpaths)
if (show_frame_index)
strm->Printf("frame #%u: ", m_frame_index);
strm->Printf("0x%0*llx ", m_thread.GetProcess().GetAddressByteSize() * 2, GetFrameCodeAddress().GetLoadAddress(&m_thread.GetProcess().GetTarget()));
strm->Printf("0x%0*llx ", m_thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize() * 2, GetFrameCodeAddress().GetLoadAddress(&m_thread.GetProcess().GetTarget()));
GetSymbolContext(eSymbolContextEverything);
const bool show_module = true;
const bool show_inline = true;

View File

@ -45,7 +45,6 @@ Target::Target(Debugger &debugger) :
m_breakpoint_list (false),
m_internal_breakpoint_list (true),
m_process_sp(),
m_triple(),
m_search_filter_sp(),
m_image_search_paths (ImageSearchPathsChanged, this),
m_scratch_ast_context_ap (NULL),
@ -447,10 +446,9 @@ Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files)
}
// Now see if we know the target triple, and if so, create our scratch AST context:
ConstString target_triple;
if (GetTargetTriple(target_triple))
if (m_arch_spec.IsValid())
{
m_scratch_ast_context_ap.reset (new ClangASTContext(target_triple.GetCString()));
m_scratch_ast_context_ap.reset (new ClangASTContext(m_arch_spec.GetTriple().str().c_str()));
}
}
@ -458,18 +456,6 @@ Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files)
}
ModuleList&
Target::GetImages ()
{
return m_images;
}
ArchSpec
Target::GetArchitecture () const
{
return m_arch_spec;
}
bool
Target::SetArchitecture (const ArchSpec &arch_spec)
{
@ -492,7 +478,6 @@ Target::SetArchitecture (const ArchSpec &arch_spec)
ModuleSP executable_sp = GetExecutableModule ();
m_images.Clear();
m_scratch_ast_context_ap.reset();
m_triple.Clear();
// Need to do something about unsetting breakpoints.
if (executable_sp)
@ -524,31 +509,6 @@ Target::SetArchitecture (const ArchSpec &arch_spec)
}
}
bool
Target::GetTargetTriple(ConstString &triple)
{
triple.Clear();
if (m_triple)
{
triple = m_triple;
}
else
{
Module *exe_module = GetExecutableModule().get();
if (exe_module)
{
ObjectFile *objfile = exe_module->GetObjectFile();
if (objfile)
{
objfile->GetTargetTriple(m_triple);
triple = m_triple;
}
}
}
return !triple.IsEmpty();
}
void
Target::ModuleAdded (ModuleSP &module_sp)
{

View File

@ -21,6 +21,7 @@
#include "lldb/Symbol/Function.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanStepOut.h"
#include "lldb/Target/ThreadPlanStepThrough.h"
@ -75,7 +76,8 @@ ThreadPlanStepInRange::ShouldStop (Event *event_ptr)
if (log)
{
StreamString s;
s.Address (m_thread.GetRegisterContext()->GetPC(), m_thread.GetProcess().GetAddressByteSize());
s.Address (m_thread.GetRegisterContext()->GetPC(),
m_thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize());
log->Printf("ThreadPlanStepInRange reached %s.", s.GetData());
}

View File

@ -123,10 +123,10 @@ ThreadPlanStepInstruction::ShouldStop (Event *event_ptr)
StreamString s;
s.PutCString ("Stepped in to: ");
addr_t stop_addr = m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
s.Address (stop_addr, m_thread.GetProcess().GetAddressByteSize());
s.Address (stop_addr, m_thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize());
s.PutCString (" stepping out to: ");
addr_t return_addr = return_frame->GetRegisterContext()->GetPC();
s.Address (return_addr, m_thread.GetProcess().GetAddressByteSize());
s.Address (return_addr, m_thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize());
log->Printf("%s.", s.GetData());
}
m_thread.QueueThreadPlanForStepOut(false, NULL, true, m_stop_other_threads, eVoteNo, eVoteNoOpinion, 0);

View File

@ -19,6 +19,7 @@
#include "lldb/Core/Stream.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanStepOut.h"
#include "lldb/Target/ThreadPlanStepThrough.h"
@ -69,7 +70,8 @@ ThreadPlanStepOverRange::ShouldStop (Event *event_ptr)
if (log)
{
StreamString s;
s.Address (m_thread.GetRegisterContext()->GetPC(), m_thread.GetProcess().GetAddressByteSize());
s.Address (m_thread.GetRegisterContext()->GetPC(),
m_thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize());
log->Printf("ThreadPlanStepOverRange reached %s.", s.GetData());
}

View File

@ -3270,7 +3270,10 @@ RNBRemote::HandlePacket_qHostInfo (const char *p)
strm << "endian:pdp;";
#endif
strm << "ptrsize:" << std::dec << sizeof(void *) << ';';
if (promoted_to_64)
strm << "ptrsize:8;";
else
strm << "ptrsize:" << std::dec << sizeof(void *) << ';';
return SendPacket (strm.str());
}