/* This command is needed to be sure that we are actually starting the inferior
 * We need it so that we know when to call continuedebugging in the DBE
 *
 * When we had continuedebugging in the command loop, the problem was that whenever
 * we evaluated an expression, there was a pretty good chance that the event loop
 * thread would call "ContinueDebugging" even though it should not happen since we are
 * still evaluating expressions
 * */
void hsail_set_continue_dispatch(void)
{
  gdb_assert(is_hsail_linux_initialized());
  gdb_assert(hsail_is_focus_device());

  hsail_enqueue_continue_dispatch_packet();

}
bool is_hsail_step(void)
{
  /* true if the focus thread is the debug thread */
  bool is_hsail_thread_focus_thread = hsail_infcmd_is_focus_thread_dispach_thread();

  /* currently only consider if hsail device is focused.
     TODO: check if the current frame is hsail code, etc.
  */


  /* We handle each known case of is_hsail_step individually by && all
   * required checks together to make it more cleaner
   * */

  /* GPU Stepping: Case#1
     Check if we are focused on the debug thread, we can step into
     GPU execution from here.
     Single step on the CPU happens when the debug thread is not the focus
  */
  if (  hsail_is_focus_device() &&
        is_hsail_thread_focus_thread &&
        (hsail_is_debug_facilities_loaded() == HSAIL_AGENT_BINARY_AVAILABLE)
      )
    {
	  hsail_info_command();

      return true;
    }
  /* GPU Stepping: Case#2
     Check if we are "in the predispatch" callback state, we can step into
     GPU execution from here */
  else if (  hsail_is_focus_device() &&
             hsail_is_focus_predispatch() &&
             (hsail_is_debug_facilities_loaded() == HSAIL_AGENT_BINARY_AVAILABLE)
           )
    {
	  hsail_info_command();
      return true;
    }

  return false;
}