forked from OSchip/llvm-project
Add language command and LanguageRuntime plugin changes to allow vending of command objects.
Differential Revision: http://reviews.llvm.org/D9402 llvm-svn: 236443
This commit is contained in:
parent
b61f06c9c2
commit
c9c55a26bd
|
@ -137,7 +137,8 @@ public:
|
||||||
static bool
|
static bool
|
||||||
RegisterPlugin (const ConstString &name,
|
RegisterPlugin (const ConstString &name,
|
||||||
const char *description,
|
const char *description,
|
||||||
LanguageRuntimeCreateInstance create_callback);
|
LanguageRuntimeCreateInstance create_callback,
|
||||||
|
LanguageRuntimeGetCommandObject command_callback = nullptr);
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
UnregisterPlugin (LanguageRuntimeCreateInstance create_callback);
|
UnregisterPlugin (LanguageRuntimeCreateInstance create_callback);
|
||||||
|
@ -145,6 +146,9 @@ public:
|
||||||
static LanguageRuntimeCreateInstance
|
static LanguageRuntimeCreateInstance
|
||||||
GetLanguageRuntimeCreateCallbackAtIndex (uint32_t idx);
|
GetLanguageRuntimeCreateCallbackAtIndex (uint32_t idx);
|
||||||
|
|
||||||
|
static LanguageRuntimeGetCommandObject
|
||||||
|
GetLanguageRuntimeGetCommandObjectAtIndex (uint32_t idx);
|
||||||
|
|
||||||
static LanguageRuntimeCreateInstance
|
static LanguageRuntimeCreateInstance
|
||||||
GetLanguageRuntimeCreateCallbackForPluginName (const ConstString &name);
|
GetLanguageRuntimeCreateCallbackForPluginName (const ConstString &name);
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,9 @@ public:
|
||||||
|
|
||||||
static LanguageRuntime*
|
static LanguageRuntime*
|
||||||
FindPlugin (Process *process, lldb::LanguageType language);
|
FindPlugin (Process *process, lldb::LanguageType language);
|
||||||
|
|
||||||
|
static void
|
||||||
|
InitializeCommands (CommandObject* parent);
|
||||||
|
|
||||||
virtual lldb::LanguageType
|
virtual lldb::LanguageType
|
||||||
GetLanguageType () const = 0;
|
GetLanguageType () const = 0;
|
||||||
|
|
|
@ -29,6 +29,7 @@ namespace lldb_private
|
||||||
typedef EmulateInstruction * (*EmulateInstructionCreateInstance) (const ArchSpec &arch, InstructionType inst_type);
|
typedef EmulateInstruction * (*EmulateInstructionCreateInstance) (const ArchSpec &arch, InstructionType inst_type);
|
||||||
typedef OperatingSystem* (*OperatingSystemCreateInstance) (Process *process, bool force);
|
typedef OperatingSystem* (*OperatingSystemCreateInstance) (Process *process, bool force);
|
||||||
typedef LanguageRuntime *(*LanguageRuntimeCreateInstance) (Process *process, lldb::LanguageType language);
|
typedef LanguageRuntime *(*LanguageRuntimeCreateInstance) (Process *process, lldb::LanguageType language);
|
||||||
|
typedef lldb::CommandObjectSP (*LanguageRuntimeGetCommandObject) (CommandInterpreter& interpreter);
|
||||||
typedef SystemRuntime *(*SystemRuntimeCreateInstance) (Process *process);
|
typedef SystemRuntime *(*SystemRuntimeCreateInstance) (Process *process);
|
||||||
typedef lldb::PlatformSP (*PlatformCreateInstance) (bool force, const ArchSpec *arch);
|
typedef lldb::PlatformSP (*PlatformCreateInstance) (bool force, const ArchSpec *arch);
|
||||||
typedef lldb::ProcessSP (*ProcessCreateInstance) (Target &target, Listener &listener, const FileSpec *crash_file_path);
|
typedef lldb::ProcessSP (*ProcessCreateInstance) (Target &target, Listener &listener, const FileSpec *crash_file_path);
|
||||||
|
|
|
@ -29,4 +29,5 @@ add_lldb_library(lldbCommands
|
||||||
CommandObjectVersion.cpp
|
CommandObjectVersion.cpp
|
||||||
CommandObjectWatchpoint.cpp
|
CommandObjectWatchpoint.cpp
|
||||||
CommandObjectWatchpointCommand.cpp
|
CommandObjectWatchpointCommand.cpp
|
||||||
|
CommandObjectLanguage.cpp
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
//===-- CommandObjectLanguage.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/lldb-python.h"
|
||||||
|
|
||||||
|
#include "CommandObjectLanguage.h"
|
||||||
|
|
||||||
|
#include "lldb/Host/Host.h"
|
||||||
|
|
||||||
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
||||||
|
#include "lldb/Interpreter/CommandReturnObject.h"
|
||||||
|
|
||||||
|
#include "lldb/Target/LanguageRuntime.h"
|
||||||
|
|
||||||
|
using namespace lldb;
|
||||||
|
using namespace lldb_private;
|
||||||
|
|
||||||
|
CommandObjectLanguage::CommandObjectLanguage (CommandInterpreter &interpreter) :
|
||||||
|
CommandObjectMultiword (interpreter,
|
||||||
|
"language",
|
||||||
|
"A set of commands for managing language-specific functionality.'.",
|
||||||
|
"language <language-name> <subcommand> [<subcommand-options>]"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//Let the LanguageRuntime populates this command with subcommands
|
||||||
|
LanguageRuntime::InitializeCommands(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CommandObjectLanguage::GenerateHelpText (Stream &output_stream) {
|
||||||
|
CommandObjectMultiword::GenerateHelpText(output_stream);
|
||||||
|
|
||||||
|
output_stream << "\nlanguage name can be one of the following:\n";
|
||||||
|
|
||||||
|
LanguageRuntime::PrintAllLanguages(output_stream, " ", "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandObjectLanguage::~CommandObjectLanguage ()
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
//===-- CommandObjectLanguage.h ---------------------------------*- C++ -*-===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open Source
|
||||||
|
// License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef liblldb_CommandObjectLanguage_h_
|
||||||
|
#define liblldb_CommandObjectLanguage_h_
|
||||||
|
|
||||||
|
// C Includes
|
||||||
|
// C++ Includes
|
||||||
|
|
||||||
|
|
||||||
|
// Other libraries and framework includes
|
||||||
|
// Project includes
|
||||||
|
|
||||||
|
#include "lldb/lldb-types.h"
|
||||||
|
#include "lldb/Interpreter/CommandObjectMultiword.h"
|
||||||
|
|
||||||
|
namespace lldb_private {
|
||||||
|
class CommandObjectLanguage : public CommandObjectMultiword
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CommandObjectLanguage (CommandInterpreter &interpreter);
|
||||||
|
|
||||||
|
virtual
|
||||||
|
~CommandObjectLanguage ();
|
||||||
|
|
||||||
|
virtual void
|
||||||
|
GenerateHelpText (Stream &output_stream);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool
|
||||||
|
DoExecute (Args& command, CommandReturnObject &result);
|
||||||
|
};
|
||||||
|
} // namespace lldb_private
|
||||||
|
|
||||||
|
#endif // liblldb_CommandObjectLanguage_h_
|
|
@ -885,6 +885,7 @@ struct LanguageRuntimeInstance
|
||||||
ConstString name;
|
ConstString name;
|
||||||
std::string description;
|
std::string description;
|
||||||
LanguageRuntimeCreateInstance create_callback;
|
LanguageRuntimeCreateInstance create_callback;
|
||||||
|
LanguageRuntimeGetCommandObject command_callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<LanguageRuntimeInstance> LanguageRuntimeInstances;
|
typedef std::vector<LanguageRuntimeInstance> LanguageRuntimeInstances;
|
||||||
|
@ -908,7 +909,8 @@ PluginManager::RegisterPlugin
|
||||||
(
|
(
|
||||||
const ConstString &name,
|
const ConstString &name,
|
||||||
const char *description,
|
const char *description,
|
||||||
LanguageRuntimeCreateInstance create_callback
|
LanguageRuntimeCreateInstance create_callback,
|
||||||
|
LanguageRuntimeGetCommandObject command_callback
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (create_callback)
|
if (create_callback)
|
||||||
|
@ -919,6 +921,7 @@ PluginManager::RegisterPlugin
|
||||||
if (description && description[0])
|
if (description && description[0])
|
||||||
instance.description = description;
|
instance.description = description;
|
||||||
instance.create_callback = create_callback;
|
instance.create_callback = create_callback;
|
||||||
|
instance.command_callback = command_callback;
|
||||||
Mutex::Locker locker (GetLanguageRuntimeMutex ());
|
Mutex::Locker locker (GetLanguageRuntimeMutex ());
|
||||||
GetLanguageRuntimeInstances ().push_back (instance);
|
GetLanguageRuntimeInstances ().push_back (instance);
|
||||||
}
|
}
|
||||||
|
@ -956,6 +959,16 @@ PluginManager::GetLanguageRuntimeCreateCallbackAtIndex (uint32_t idx)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LanguageRuntimeGetCommandObject
|
||||||
|
PluginManager::GetLanguageRuntimeGetCommandObjectAtIndex (uint32_t idx)
|
||||||
|
{
|
||||||
|
Mutex::Locker locker (GetLanguageRuntimeMutex ());
|
||||||
|
LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances ();
|
||||||
|
if (idx < instances.size())
|
||||||
|
return instances[idx].command_callback;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
LanguageRuntimeCreateInstance
|
LanguageRuntimeCreateInstance
|
||||||
PluginManager::GetLanguageRuntimeCreateCallbackForPluginName (const ConstString &name)
|
PluginManager::GetLanguageRuntimeCreateCallbackForPluginName (const ConstString &name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "../Commands/CommandObjectType.h"
|
#include "../Commands/CommandObjectType.h"
|
||||||
#include "../Commands/CommandObjectVersion.h"
|
#include "../Commands/CommandObjectVersion.h"
|
||||||
#include "../Commands/CommandObjectWatchpoint.h"
|
#include "../Commands/CommandObjectWatchpoint.h"
|
||||||
|
#include "../Commands/CommandObjectLanguage.h"
|
||||||
|
|
||||||
|
|
||||||
#include "lldb/Core/Debugger.h"
|
#include "lldb/Core/Debugger.h"
|
||||||
|
@ -443,6 +444,7 @@ CommandInterpreter::LoadCommandDictionary ()
|
||||||
m_command_dict["type"] = CommandObjectSP (new CommandObjectType (*this));
|
m_command_dict["type"] = CommandObjectSP (new CommandObjectType (*this));
|
||||||
m_command_dict["version"] = CommandObjectSP (new CommandObjectVersion (*this));
|
m_command_dict["version"] = CommandObjectSP (new CommandObjectVersion (*this));
|
||||||
m_command_dict["watchpoint"]= CommandObjectSP (new CommandObjectMultiwordWatchpoint (*this));
|
m_command_dict["watchpoint"]= CommandObjectSP (new CommandObjectMultiwordWatchpoint (*this));
|
||||||
|
m_command_dict["language"] = CommandObjectSP (new CommandObjectLanguage(*this));
|
||||||
|
|
||||||
const char *break_regexes[][2] = {{"^(.*[^[:space:]])[[:space:]]*:[[:space:]]*([[:digit:]]+)[[:space:]]*$", "breakpoint set --file '%1' --line %2"},
|
const char *break_regexes[][2] = {{"^(.*[^[:space:]])[[:space:]]*:[[:space:]]*([[:digit:]]+)[[:space:]]*$", "breakpoint set --file '%1' --line %2"},
|
||||||
{"^/([^/]+)/$", "breakpoint set --source-pattern-regexp '%1'"},
|
{"^/([^/]+)/$", "breakpoint set --source-pattern-regexp '%1'"},
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "lldb/Target/Target.h"
|
#include "lldb/Target/Target.h"
|
||||||
#include "lldb/Core/PluginManager.h"
|
#include "lldb/Core/PluginManager.h"
|
||||||
#include "lldb/Core/SearchFilter.h"
|
#include "lldb/Core/SearchFilter.h"
|
||||||
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
||||||
|
|
||||||
using namespace lldb;
|
using namespace lldb;
|
||||||
using namespace lldb_private;
|
using namespace lldb_private;
|
||||||
|
@ -418,6 +419,33 @@ LanguageRuntime::LanguageIsCPlusPlus (LanguageType language)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LanguageRuntime::InitializeCommands (CommandObject* parent)
|
||||||
|
{
|
||||||
|
if (!parent)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!parent->IsMultiwordObject())
|
||||||
|
return;
|
||||||
|
|
||||||
|
LanguageRuntimeCreateInstance create_callback;
|
||||||
|
|
||||||
|
for (uint32_t idx = 0;
|
||||||
|
(create_callback = PluginManager::GetLanguageRuntimeCreateCallbackAtIndex(idx)) != nullptr;
|
||||||
|
++idx)
|
||||||
|
{
|
||||||
|
if (LanguageRuntimeGetCommandObject command_callback =
|
||||||
|
PluginManager::GetLanguageRuntimeGetCommandObjectAtIndex(idx))
|
||||||
|
{
|
||||||
|
CommandObjectSP command = command_callback(parent->GetCommandInterpreter());
|
||||||
|
if (command)
|
||||||
|
{
|
||||||
|
parent->LoadSubCommand(command->GetCommandName(), command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lldb::SearchFilterSP
|
lldb::SearchFilterSP
|
||||||
LanguageRuntime::CreateExceptionSearchFilter ()
|
LanguageRuntime::CreateExceptionSearchFilter ()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue