[Lldb-commits] [lldb] [lldb] Unify the way we get the Target in CommandObject (PR #101208)
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Tue Jul 30 10:48:17 PDT 2024
================
@@ -754,23 +754,29 @@ const char *CommandObject::GetArgumentDescriptionAsCString(
return g_argument_table[arg_type].help_text;
}
-Target &CommandObject::GetDummyTarget() {
+Target &CommandObject::GetTarget(bool dummy) {
+ // Always return the dummy target if explicitly requested.
+ if (dummy)
+ return m_interpreter.GetDebugger().GetDummyTarget();
+
+ // Prefer the frozen execution context in the command object.
+ if (Target *target = m_exe_ctx.GetTargetPtr())
+ return *target;
+
+ // Fallback to the command interpreter's execution context in case we get
+ // called after DoExecute has finished. For example, when doing multi-line
+ // expression that uses an input reader or breakpoint callbacks.
+ if (Target *target = m_interpreter.GetExecutionContext().GetTargetPtr())
+ return *target;
+
+ // Finally, if we have no other target, get the selected target.
+ if (TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget())
+ return *target_sp;
+
+ // We only have the dummy target.
return m_interpreter.GetDebugger().GetDummyTarget();
}
-Target &CommandObject::GetSelectedOrDummyTarget(bool prefer_dummy) {
- return m_interpreter.GetDebugger().GetSelectedOrDummyTarget(prefer_dummy);
-}
-
-Target &CommandObject::GetSelectedTarget() {
- assert(m_flags.AnySet(eCommandRequiresTarget | eCommandProcessMustBePaused |
----------------
bulbazord wrote:
Do you think this assertion would still be useful to have?
https://github.com/llvm/llvm-project/pull/101208
More information about the lldb-commits
mailing list