[Lldb-commits] [lldb] r259972 - Per Jim's suggestion, move checks that we're not mixing and matching Debuggers and Commands deeper in the bowels of LLDB
Enrico Granata via lldb-commits
lldb-commits at lists.llvm.org
Fri Feb 5 17:36:08 PST 2016
Author: enrico
Date: Fri Feb 5 19:36:07 2016
New Revision: 259972
URL: http://llvm.org/viewvc/llvm-project?rev=259972&view=rev
Log:
Per Jim's suggestion, move checks that we're not mixing and matching Debuggers and Commands deeper in the bowels of LLDB
NFC
Modified:
lldb/trunk/source/Commands/CommandObjectMultiword.cpp
lldb/trunk/source/Interpreter/CommandInterpreter.cpp
lldb/trunk/source/Target/LanguageRuntime.cpp
Modified: lldb/trunk/source/Commands/CommandObjectMultiword.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMultiword.cpp?rev=259972&r1=259971&r2=259972&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectMultiword.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMultiword.cpp Fri Feb 5 19:36:07 2016
@@ -92,6 +92,9 @@ CommandObjectMultiword::LoadSubCommand
const CommandObjectSP& cmd_obj
)
{
+ if (cmd_obj.get())
+ assert((&GetCommandInterpreter() == &cmd_obj->GetCommandInterpreter()) && "tried to add a CommandObject from a different interpreter");
+
CommandMap::iterator pos;
bool success = true;
Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=259972&r1=259971&r2=259972&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Fri Feb 5 19:36:07 2016
@@ -874,6 +874,9 @@ CommandInterpreter::GetCommandSP (const
bool
CommandInterpreter::AddCommand (const char *name, const lldb::CommandObjectSP &cmd_sp, bool can_replace)
{
+ if (cmd_sp.get())
+ assert((this == &cmd_sp->GetCommandInterpreter()) && "tried to add a CommandObject from a different interpreter");
+
if (name && name[0])
{
std::string name_sstr(name);
@@ -893,9 +896,11 @@ CommandInterpreter::AddUserCommand (std:
const lldb::CommandObjectSP &cmd_sp,
bool can_replace)
{
+ if (cmd_sp.get())
+ assert((this == &cmd_sp->GetCommandInterpreter()) && "tried to add a CommandObject from a different interpreter");
+
if (!name.empty())
{
-
const char* name_cstr = name.c_str();
// do not allow replacement of internal commands
@@ -1110,6 +1115,9 @@ CommandInterpreter::UserCommandExists (c
void
CommandInterpreter::AddAlias (const char *alias_name, CommandObjectSP& command_obj_sp)
{
+ if (command_obj_sp.get())
+ assert((this == &command_obj_sp->GetCommandInterpreter()) && "tried to add a CommandObject from a different interpreter");
+
command_obj_sp->SetIsAlias (true);
m_alias_dict[alias_name] = command_obj_sp;
}
Modified: lldb/trunk/source/Target/LanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/LanguageRuntime.cpp?rev=259972&r1=259971&r2=259972&view=diff
==============================================================================
--- lldb/trunk/source/Target/LanguageRuntime.cpp (original)
+++ lldb/trunk/source/Target/LanguageRuntime.cpp Fri Feb 5 19:36:07 2016
@@ -339,7 +339,6 @@ LanguageRuntime::InitializeCommands (Com
// the CommandObject vended by a Language plugin cannot be created once and cached because
// we may create multiple debuggers and need one instance of the command each - the implementing function
// is meant to create a new instance of the command each time it is invoked
- assert(&command->GetCommandInterpreter() == &parent->GetCommandInterpreter() && "language plugin returned command for a mismatched CommandInterpreter");
parent->LoadSubCommand(command->GetCommandName(), command);
}
}
More information about the lldb-commits
mailing list