debug_utils.cpp 1.7 KB

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