summaryrefslogtreecommitdiffstats
path: root/src/video_core/debug_utils/debug_utils.cpp
blob: f0ef675353fa57a8ee2c37521faea317483e6196 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.

#include <mutex>

#include "video_core/debug_utils/debug_utils.h"

namespace Tegra {

void DebugContext::DoOnEvent(Event event, void* data) {
    {
        std::unique_lock lock{breakpoint_mutex};

        // TODO(Subv): Commit the rasterizer's caches so framebuffers, render targets, etc. will
        // show on debug widgets

        // TODO: Should stop the CPU thread here once we multithread emulation.

        active_breakpoint = event;
        at_breakpoint = true;

        // Tell all observers that we hit a breakpoint
        for (auto& breakpoint_observer : breakpoint_observers) {
            breakpoint_observer->OnMaxwellBreakPointHit(event, data);
        }

        // Wait until another thread tells us to Resume()
        resume_from_breakpoint.wait(lock, [&] { return !at_breakpoint; });
    }
}

void DebugContext::Resume() {
    {
        std::lock_guard lock{breakpoint_mutex};

        // Tell all observers that we are about to resume
        for (auto& breakpoint_observer : breakpoint_observers) {
            breakpoint_observer->OnMaxwellResume();
        }

        // Resume the waiting thread (i.e. OnEvent())
        at_breakpoint = false;
    }

    resume_from_breakpoint.notify_one();
}

} // namespace Tegra