diff options
| author | Enrico Granata <egranata@apple.com> | 2016-02-06 01:36:07 +0000 |
|---|---|---|
| committer | Enrico Granata <egranata@apple.com> | 2016-02-06 01:36:07 +0000 |
| commit | 41571781c01723a64a0d2fa3e82b1b7f3f2c28dc (patch) | |
| tree | 77748f328d2f3aa97ff5dac3d46cab10769f59b2 | |
| parent | 23919372d1db1dba80e8c4697e0a0922e830fc3a (diff) | |
| download | bcm5719-llvm-41571781c01723a64a0d2fa3e82b1b7f3f2c28dc.tar.gz bcm5719-llvm-41571781c01723a64a0d2fa3e82b1b7f3f2c28dc.zip | |
Per Jim's suggestion, move checks that we're not mixing and matching Debuggers and Commands deeper in the bowels of LLDB
NFC
llvm-svn: 259972
| -rw-r--r-- | lldb/source/Commands/CommandObjectMultiword.cpp | 3 | ||||
| -rw-r--r-- | lldb/source/Interpreter/CommandInterpreter.cpp | 10 | ||||
| -rw-r--r-- | lldb/source/Target/LanguageRuntime.cpp | 1 |
3 files changed, 12 insertions, 2 deletions
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp index 206f3b6fb7d..ed70551ef37 100644 --- a/lldb/source/Commands/CommandObjectMultiword.cpp +++ b/lldb/source/Commands/CommandObjectMultiword.cpp @@ -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; diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index fd88f0d6b4b..bab12462489 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -874,6 +874,9 @@ CommandInterpreter::GetCommandSP (const char *cmd_cstr, bool include_aliases, bo 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::string 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.empty()) { - const char* name_cstr = name.c_str(); // do not allow replacement of internal commands @@ -1110,6 +1115,9 @@ CommandInterpreter::UserCommandExists (const char *cmd) 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; } diff --git a/lldb/source/Target/LanguageRuntime.cpp b/lldb/source/Target/LanguageRuntime.cpp index 7f386162d16..d247994621f 100644 --- a/lldb/source/Target/LanguageRuntime.cpp +++ b/lldb/source/Target/LanguageRuntime.cpp @@ -339,7 +339,6 @@ LanguageRuntime::InitializeCommands (CommandObject* parent) // 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); } } |

