2020-12-05 13:08:24 +01:00
|
|
|
#pragma once
|
2020-12-22 09:42:57 +01:00
|
|
|
|
|
|
|
|
#include "util/types.hpp"
|
2025-04-08 18:46:57 +02:00
|
|
|
#include "util/bit_set.h"
|
2025-03-01 17:08:10 +01:00
|
|
|
#include <map>
|
2025-04-08 18:46:57 +02:00
|
|
|
#include "util/mutex.h"
|
2018-03-02 22:40:29 +01:00
|
|
|
|
|
|
|
|
enum class breakpoint_types
|
|
|
|
|
{
|
|
|
|
|
bp_read = 0x1,
|
|
|
|
|
bp_write = 0x2,
|
|
|
|
|
bp_exec = 0x4,
|
2025-03-01 17:08:10 +01:00
|
|
|
__bitset_enum_max
|
2018-03-02 22:40:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
2025-04-05 21:50:45 +02:00
|
|
|
* This class acts as a layer between the UI and Emu for breakpoints.
|
|
|
|
|
*/
|
2018-03-02 22:40:29 +01:00
|
|
|
class breakpoint_handler
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public:
|
2021-04-07 23:05:18 +02:00
|
|
|
breakpoint_handler() = default;
|
|
|
|
|
~breakpoint_handler() = default;
|
2018-03-02 22:40:29 +01:00
|
|
|
|
2025-03-01 17:08:10 +01:00
|
|
|
bool IsBreakOnBPM() const;
|
|
|
|
|
void SetBreakOnBPM(bool break_on_bpm);
|
|
|
|
|
|
2018-03-02 22:40:29 +01:00
|
|
|
/**
|
2025-04-05 21:50:45 +02:00
|
|
|
* Returns true iff breakpoint exists at loc.
|
|
|
|
|
* TODO: Add arg for flags, gameid, and maybe even thread if it should be thread local breakpoint.... breakpoint struct is probably what'll happen
|
|
|
|
|
*/
|
2025-03-01 17:08:10 +01:00
|
|
|
bool HasBreakpoint(u32 loc, bs_t<breakpoint_types> type);
|
2018-03-02 22:40:29 +01:00
|
|
|
|
|
|
|
|
/**
|
2025-04-05 21:50:45 +02:00
|
|
|
* Returns true if added successfully. TODO: flags
|
|
|
|
|
*/
|
2025-03-01 17:08:10 +01:00
|
|
|
bool AddBreakpoint(u32 loc, bs_t<breakpoint_types> type);
|
2018-03-02 22:40:29 +01:00
|
|
|
|
|
|
|
|
/**
|
2025-04-05 21:50:45 +02:00
|
|
|
* Returns true if removed breakpoint at loc successfully.
|
|
|
|
|
*/
|
2018-03-02 22:40:29 +01:00
|
|
|
bool RemoveBreakpoint(u32 loc);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// TODO : generalize to hold multiple games and handle flags.Probably do : std::map<std::string (gameid), std::set<breakpoint>>.
|
2020-12-22 09:42:57 +01:00
|
|
|
// Although, externally, they'll only be accessed by loc (I think) so a map of maps may also do?
|
2025-03-01 17:08:10 +01:00
|
|
|
shared_mutex mutex_breakpoints;
|
|
|
|
|
std::map<u32, bs_t<breakpoint_types>> m_breakpoints; //! Holds all breakpoints.
|
|
|
|
|
bool m_break_on_bpm = false;
|
2018-03-02 22:40:29 +01:00
|
|
|
};
|
2025-03-01 17:08:10 +01:00
|
|
|
|
|
|
|
|
extern breakpoint_handler g_breakpoint_handler;
|