mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 13:35:38 +08:00
plug-ins are add on plug-ins for the lldb_private::Process class that can add thread contexts that are read from memory. It is common in kernels to have a lot of threads that are not currently executing on any cores (JTAG debugging also follows this sort of thing) and are context switched out whose state is stored in memory data structures. Clients can now subclass the OperatingSystem plug-ins and then make sure their Create functions correcltly only enable themselves when the right binary/target triple are being debugged. The operating system plug-ins get a chance to attach themselves to processes just after launching or attaching and are given a lldb_private::Process object pointer which can be inspected to see if the main executable, target triple, or any shared libraries match a case where the OS plug-in should be used. Currently the OS plug-ins can create new threads, define the register contexts for these threads (which can all be different if desired), and populate and manage the thread info (stop reason, registers in the register context) as the debug session goes on. llvm-svn: 138228
100 lines
2.5 KiB
C++
100 lines
2.5 KiB
C++
//===-- ABI.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/Target/ABI.h"
|
|
#include "lldb/Core/PluginManager.h"
|
|
|
|
using namespace lldb;
|
|
using namespace lldb_private;
|
|
|
|
ABISP
|
|
ABI::FindPlugin (const ArchSpec &arch)
|
|
{
|
|
ABISP abi_sp;
|
|
ABICreateInstance create_callback;
|
|
|
|
for (uint32_t idx = 0;
|
|
(create_callback = PluginManager::GetABICreateCallbackAtIndex(idx)) != NULL;
|
|
++idx)
|
|
{
|
|
abi_sp = create_callback(arch);
|
|
|
|
if (abi_sp)
|
|
return abi_sp;
|
|
}
|
|
abi_sp.reset();
|
|
return abi_sp;
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
// Constructor
|
|
//----------------------------------------------------------------------
|
|
ABI::ABI()
|
|
{
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
// Destructor
|
|
//----------------------------------------------------------------------
|
|
ABI::~ABI()
|
|
{
|
|
}
|
|
|
|
|
|
bool
|
|
ABI::GetRegisterInfoByName (const ConstString &name, RegisterInfo &info)
|
|
{
|
|
uint32_t count = 0;
|
|
const RegisterInfo *register_info_array = GetRegisterInfoArray (count);
|
|
if (register_info_array)
|
|
{
|
|
const char *unique_name_cstr = name.GetCString();
|
|
uint32_t i;
|
|
for (i=0; i<count; ++i)
|
|
{
|
|
if (register_info_array[i].name == unique_name_cstr)
|
|
{
|
|
info = register_info_array[i];
|
|
return true;
|
|
}
|
|
}
|
|
for (i=0; i<count; ++i)
|
|
{
|
|
if (register_info_array[i].alt_name == unique_name_cstr)
|
|
{
|
|
info = register_info_array[i];
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool
|
|
ABI::GetRegisterInfoByKind (RegisterKind reg_kind, uint32_t reg_num, RegisterInfo &info)
|
|
{
|
|
if (reg_kind < eRegisterKindGCC || reg_kind >= kNumRegisterKinds)
|
|
return false;
|
|
|
|
uint32_t count = 0;
|
|
const RegisterInfo *register_info_array = GetRegisterInfoArray (count);
|
|
if (register_info_array)
|
|
{
|
|
for (uint32_t i=0; i<count; ++i)
|
|
{
|
|
if (register_info_array[i].kinds[reg_kind] == reg_num)
|
|
{
|
|
info = register_info_array[i];
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|