Files
clang-p2996/lldb/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp
Greg Clayton e996fd30be LLDB now has "Platform" plug-ins. Platform plug-ins are plug-ins that provide
an interface to a local or remote debugging platform. By default each host OS
that supports LLDB should be registering a "default" platform that will be
used unless a new platform is selected. Platforms are responsible for things
such as:
- getting process information by name or by processs ID
- finding platform files. This is useful for remote debugging where there is 
  an SDK with files that might already or need to be cached for debug access.
- getting a list of platform supported architectures in the exact order they
  should be selected. This helps the native x86 platform on MacOSX select the
  correct x86_64/i386 slice from universal binaries.
- Connect to remote platforms for remote debugging
- Resolving an executable including finding an executable inside platform
  specific bundles (macosx uses .app bundles that contain files) and also
  selecting the appropriate slice of universal files for a given platform.

So by default there is always a local platform, but remote platforms can be
connected to. I will soon be adding a new "platform" command that will support
the following commands:
(lldb) platform connect --name machine1 macosx connect://host:port
Connected to "machine1" platform.
(lldb) platform disconnect macosx

This allows LLDB to be well setup to do remote debugging and also once 
connected process listing and finding for things like:
(lldb) process attach --name x<TAB>

The currently selected platform plug-in can now auto complete any available
processes that start with "x". The responsibilities for the platform plug-in
will soon grow and expand.

llvm-svn: 127286
2011-03-08 22:40:15 +00:00

149 lines
3.7 KiB
C++

//===-- ArchVolatileRegs-x86.cpp --------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "ArchVolatileRegs-x86.h"
#include "llvm/Support/MachO.h"
#include "lldb/lldb-private.h"
#include "lldb/Utility/ArchVolatileRegs.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/RegisterContext.h"
#include <set>
using namespace lldb;
using namespace lldb_private;
bool
ArchVolatileRegs_x86::RegisterIsVolatile (Thread& thread, uint32_t regnum)
{
initialize_regset (thread);
if (m_non_volatile_regs.find (regnum) == m_non_volatile_regs.end())
return true;
else
return false;
}
lldb_private::ArchVolatileRegs *
ArchVolatileRegs_x86::CreateInstance (const lldb_private::ArchSpec &arch)
{
llvm::Triple::ArchType cpu = arch.GetMachine ();
if (cpu == llvm::Triple::x86 || cpu == llvm::Triple::x86_64)
return new ArchVolatileRegs_x86 (cpu);
return NULL;
}
ArchVolatileRegs_x86::ArchVolatileRegs_x86(llvm::Triple::ArchType cpu) :
lldb_private::ArchVolatileRegs(),
m_cpu(cpu),
m_non_volatile_regs()
{
}
void
ArchVolatileRegs_x86::initialize_regset(Thread& thread)
{
if (m_non_volatile_regs.size() > 0)
return;
RegisterContext *reg_ctx = thread.GetRegisterContext().get();
const RegisterInfo *ri;
const char *x86_64_regnames[] = { "rbx",
"rsp",
"rbp",
"r12",
"r13",
"r14",
"r15",
"rip" };
const char *i386_regnames[] = { "ebx",
"ebp",
"esi",
"edi",
"esp",
"eip" };
const char **names;
int namecount;
if (m_cpu == llvm::Triple::x86_64)
{
names = x86_64_regnames;
namecount = sizeof (x86_64_regnames) / sizeof (char *);
}
else
{
assert (m_cpu == llvm::Triple::x86);
names = i386_regnames;
namecount = sizeof (i386_regnames) / sizeof (char *);
}
for (int i = 0; i < namecount; i++)
{
ri = reg_ctx->GetRegisterInfoByName (names[i]);
if (ri)
m_non_volatile_regs.insert (ri->kinds[eRegisterKindLLDB]);
}
}
//------------------------------------------------------------------
// PluginInterface protocol in ArchVolatileRegs_x86
//------------------------------------------------------------------
const char *
ArchVolatileRegs_x86::GetPluginName()
{
return "ArchVolatileRegs_x86";
}
const char *
ArchVolatileRegs_x86::GetShortPluginName()
{
return "archvolatileregs.x86";
}
uint32_t
ArchVolatileRegs_x86::GetPluginVersion()
{
return 1;
}
void
ArchVolatileRegs_x86::Initialize()
{
PluginManager::RegisterPlugin (GetPluginNameStatic(),
GetPluginDescriptionStatic(),
CreateInstance);
}
void
ArchVolatileRegs_x86::Terminate()
{
PluginManager::UnregisterPlugin (CreateInstance);
}
const char *
ArchVolatileRegs_x86::GetPluginNameStatic()
{
return "ArchVolatileRegs_x86";
}
const char *
ArchVolatileRegs_x86::GetPluginDescriptionStatic()
{
return "i386 and x86_64 architecture volatile register information.";
}