debug_utils.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2
  3. // Refer to the license.txt file included.
  4. #include <mutex>
  5. #include "video_core/debug_utils/debug_utils.h"
  6. namespace Tegra {
  7. void DebugContext::DoOnEvent(Event event, void* data) {
  8. {
  9. std::unique_lock<std::mutex> lock(breakpoint_mutex);
  10. // TODO(Subv): Commit the rasterizer's caches so framebuffers, render targets, etc. will
  11. // show on debug widgets
  12. // TODO: Should stop the CPU thread here once we multithread emulation.
  13. active_breakpoint = event;
  14. at_breakpoint = true;
  15. // Tell all observers that we hit a breakpoint
  16. for (auto& breakpoint_observer : breakpoint_observers) {
  17. breakpoint_observer->OnMaxwellBreakPointHit(event, data);
  18. }
  19. // Wait until another thread tells us to Resume()
  20. resume_from_breakpoint.wait(lock, [&] { return !at_breakpoint; });
  21. }
  22. }
  23. void DebugContext::Resume() {
  24. {
  25. std::lock_guard<std::mutex> lock(breakpoint_mutex);
  26. // Tell all observers that we are about to resume
  27. for (auto& breakpoint_observer : breakpoint_observers) {
  28. breakpoint_observer->OnMaxwellResume();
  29. }
  30. // Resume the waiting thread (i.e. OnEvent())
  31. at_breakpoint = false;
  32. }
  33. resume_from_breakpoint.notify_one();
  34. }
  35. } // namespace Tegra