Fix a problem where the stop-hook command 'frame variable g_val' produces nothing
when newly created threads were subsequently stopped due to breakpoint hit.
The stop-hook mechanism delegates to CommandInterpreter::HandleCommands() to
execuet the commands. Make sure the execution context is switched only once
at the beginning of HandleCommands() only and don't update the context while looping
on each individual command to be executed.
rdar://problem/10228156
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@141144 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Interpreter/CommandInterpreter.cpp b/source/Interpreter/CommandInterpreter.cpp
index b3b1d30..26d3b82 100644
--- a/source/Interpreter/CommandInterpreter.cpp
+++ b/source/Interpreter/CommandInterpreter.cpp
@@ -952,7 +952,8 @@
bool add_to_history,
CommandReturnObject &result,
ExecutionContext *override_context,
- bool repeat_on_empty_command)
+ bool repeat_on_empty_command,
+ bool no_context_switching)
{
@@ -975,7 +976,8 @@
Timer scoped_timer (__PRETTY_FUNCTION__, "Handling command: %s.", command_line);
- UpdateExecutionContext (override_context);
+ if (!no_context_switching)
+ UpdateExecutionContext (override_context);
bool empty_command = false;
bool comment_command = false;
@@ -1911,7 +1913,12 @@
}
CommandReturnObject tmp_result;
- bool success = HandleCommand(cmd, false, tmp_result, NULL);
+ // If override_context is not NULL, pass no_context_switching = true for
+ // HandleCommand() since we updated our context already.
+ bool success = HandleCommand(cmd, false, tmp_result,
+ NULL, /* override_context */
+ true, /* repeat_on_empty_command */
+ override_context != NULL /* no_context_switching */);
if (print_results)
{