<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 5, 2016, at 5:05 PM, Jim Ingham <<a href="mailto:jingham@apple.com" class="">jingham@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Is it ever right for a Command to add a subcommand from a different CommandInterpreter?  If it is not (and I am pretty sure it isn't) then this check should be done in LoadSubCommand, where you would check the to-be-added command's interpreter against the added-to's interpreter.  This would immediately catch this error if anybody makes it in the future.  Probably good to do this in AddCommand for the interpreter as well.<br class=""><br class="">Jim<br class=""><br class=""><blockquote type="cite" class="">On Feb 5, 2016, at 5:02 PM, Enrico Granata <<a href="mailto:egranata@apple.com" class="">egranata@apple.com</a>> wrote:<br class=""><br class=""><blockquote type="cite" class=""><br class="">On Feb 5, 2016, at 4:57 PM, Jim Ingham <<a href="mailto:jingham@apple.com" class="">jingham@apple.com</a>> wrote:<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Feb 5, 2016, at 4:43 PM, Enrico Granata via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org" class="">lldb-commits@lists.llvm.org</a>> wrote:<br class=""><br class="">Modified: lldb/trunk/source/Target/LanguageRuntime.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/LanguageRuntime.cpp?rev=259964&r1=259963&r2=259964&view=diff" class="">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/LanguageRuntime.cpp?rev=259964&r1=259963&r2=259964&view=diff</a><br class="">==============================================================================<br class="">--- lldb/trunk/source/Target/LanguageRuntime.cpp (original)<br class="">+++ lldb/trunk/source/Target/LanguageRuntime.cpp Fri Feb  5 18:43:07 2016<br class="">@@ -336,6 +336,10 @@ LanguageRuntime::InitializeCommands (Com<br class="">           CommandObjectSP command = command_callback(parent->GetCommandInterpreter());<br class="">           if (command)<br class="">           {<br class="">+                // the CommandObject vended by a Language plugin cannot be created once and cached because<br class="">+                // we may create multiple debuggers and need one instance of the command each - the implementing function<br class="">+                // is meant to create a new instance of the command each time it is invoked<br class="">+                assert(&command->GetCommandInterpreter() == &parent->GetCommandInterpreter() && "language plugin returned command for a mismatched CommandInterpreter");<br class=""></blockquote><br class="">Should CommandObject::LoadSubCommand do this check?<br class=""><br class=""><blockquote type="cite" class="">               parent->LoadSubCommand(command->GetCommandName(), command);<br class="">           }<br class="">       }<br class=""></blockquote><br class="">Jim<br class=""><br class=""></blockquote><br class="">You mean the assert? The point of the assert is that the language plugin was creating a command once and caching it and then returning the cached version to a different debugger<br class="">Hence I am doing the check specifically for those commands.<br class=""><br class="">But maybe I am missing what you’re trying to suggest here.<br class=""><br class="">Thanks,<br class="">- Enrico<br class="">📩 egranata@.com ☎️ 27683<br class=""></blockquote><br class=""></div></div></blockquote></div><br class=""><div class="">Aha! Yeah, now I see what you’re saying. And, yes, you do make a good point. I can move the assert there alright.</div><div class="">
<div class="" style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class="Apple-interchange-newline">Thanks,</div><div class="" style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><i class="">- Enrico</i><br class="">📩 egranata@<font color="#ff2600" class=""></font>.com ☎️ 27683</div>
</div>
<br class=""></body></html>