[Lldb-commits] [PATCH] D22863: Improve code of loading plugins that provide cmnds
Abhishek via lldb-commits
lldb-commits at lists.llvm.org
Thu Jul 28 03:48:07 PDT 2016
abhishek.aggarwal updated this revision to Diff 65903.
abhishek.aggarwal added a comment.
New patch according to review feedback
- Added another variant of AddCommand API with syntax as an additional argument
https://reviews.llvm.org/D22863
Files:
include/lldb/API/SBCommandInterpreter.h
source/API/SBCommandInterpreter.cpp
Index: source/API/SBCommandInterpreter.cpp
===================================================================
--- source/API/SBCommandInterpreter.cpp
+++ source/API/SBCommandInterpreter.cpp
@@ -153,7 +153,7 @@
sb_return.Release();
return ret;
}
- lldb::SBCommandPluginInterface* m_backend;
+ std::shared_ptr<lldb::SBCommandPluginInterface> m_backend;
};
SBCommandInterpreter::SBCommandInterpreter (CommandInterpreter *interpreter) :
@@ -605,6 +605,17 @@
return lldb::SBCommand();
}
+lldb::SBCommand
+SBCommandInterpreter::AddCommand (const char* name, lldb::SBCommandPluginInterface* impl, const char* help, const char* syntax)
+{
+ lldb::CommandObjectSP new_command_sp;
+ new_command_sp.reset(new CommandPluginInterfaceImplementation(*m_opaque_ptr,name, impl, help, syntax));
+
+ if (new_command_sp && m_opaque_ptr->AddUserCommand(name, new_command_sp, true))
+ return lldb::SBCommand(new_command_sp);
+ return lldb::SBCommand();
+}
+
SBCommand::SBCommand() = default;
SBCommand::SBCommand (lldb::CommandObjectSP cmd_sp) : m_opaque_sp (cmd_sp)
@@ -677,6 +688,21 @@
return lldb::SBCommand();
}
+lldb::SBCommand
+SBCommand::AddCommand (const char* name, lldb::SBCommandPluginInterface *impl, const char* help, const char* syntax)
+{
+ if (!IsValid ())
+ return lldb::SBCommand();
+ if (!m_opaque_sp->IsMultiwordObject())
+ return lldb::SBCommand();
+ lldb::CommandObjectSP new_command_sp;
+ new_command_sp.reset(new CommandPluginInterfaceImplementation(m_opaque_sp->GetCommandInterpreter(),name,impl,help, syntax));
+ if (new_command_sp && m_opaque_sp->LoadSubCommand(name,new_command_sp))
+ return lldb::SBCommand(new_command_sp);
+ return lldb::SBCommand();
+}
+
+
uint32_t
SBCommand::GetFlags ()
{
Index: include/lldb/API/SBCommandInterpreter.h
===================================================================
--- include/lldb/API/SBCommandInterpreter.h
+++ include/lldb/API/SBCommandInterpreter.h
@@ -141,6 +141,9 @@
lldb::SBCommand
AddCommand (const char* name, lldb::SBCommandPluginInterface *impl, const char* help);
+ lldb::SBCommand
+ AddCommand (const char* name, lldb::SBCommandPluginInterface *impl, const char* help, const char* syntax);
+
void
SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result);
@@ -308,6 +311,9 @@
lldb::SBCommand
AddCommand(const char* name, lldb::SBCommandPluginInterface* impl, const char* help = nullptr);
+ lldb::SBCommand
+ AddCommand(const char* name, lldb::SBCommandPluginInterface* impl, const char* help, const char* syntax);
+
private:
friend class SBDebugger;
friend class SBCommandInterpreter;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22863.65903.patch
Type: text/x-patch
Size: 2736 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160728/ce98498c/attachment.bin>
More information about the lldb-commits
mailing list