146 lines
2.6 KiB
C++
146 lines
2.6 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <vector>
|
|
#include <string>
|
|
#include <variant>
|
|
#include "msg.h"
|
|
#include "frontend/target.h"
|
|
|
|
namespace dbgui::frontend
|
|
{
|
|
struct Frontend;
|
|
|
|
enum class WindowType : uint8_t
|
|
{
|
|
regs,
|
|
source,
|
|
memory,
|
|
variables,
|
|
frames,
|
|
threads,
|
|
disassembly,
|
|
breakpoints,
|
|
};
|
|
|
|
struct RegWindow
|
|
{
|
|
enum class RegValType : uint8_t
|
|
{
|
|
flag,
|
|
u64,
|
|
u128,
|
|
u256,
|
|
u512,
|
|
};
|
|
|
|
// TODO: store last_drawn val and which regs we should draw
|
|
/*struct Reg {
|
|
uint16_t set_idx;
|
|
uint16_t reg_idx;
|
|
RegValType type;
|
|
union {
|
|
bool bval;
|
|
uint64_t u64val;
|
|
uint64_t u128_val[2];
|
|
uint64_t u256_val[4];
|
|
uint64_t u512_val[8];
|
|
};
|
|
};
|
|
|
|
std::vector<Reg> regs;*/
|
|
|
|
bool draw(const Frontend &);
|
|
|
|
std::string id;
|
|
bool open;
|
|
};
|
|
|
|
struct ThreadWindow
|
|
{
|
|
bool draw(const Frontend &);
|
|
|
|
std::string id;
|
|
bool open;
|
|
};
|
|
|
|
struct FrameWindow
|
|
{
|
|
bool draw(const Frontend &);
|
|
|
|
std::string id;
|
|
bool open;
|
|
};
|
|
|
|
struct DisasmWindow
|
|
{
|
|
struct Instruction
|
|
{
|
|
// "<mnem>%*c<op>%*c[ ; <comment>]"
|
|
std::string fmt_str;
|
|
uint64_t addr;
|
|
uint8_t mnem_len, op_len, comm_len;
|
|
};
|
|
|
|
bool draw(Frontend &);
|
|
|
|
void handle_source_updated(Target& target, size_t id);
|
|
|
|
std::string id;
|
|
bool open;
|
|
bool first;
|
|
bool ip_unsuccessful;
|
|
bool disas_unsuccessful;
|
|
bool ip_changed;
|
|
|
|
size_t ip_src_id, disas_src_id;
|
|
uint64_t ip;
|
|
uint8_t max_mnem_len, max_op_len;
|
|
std::vector<Instruction> insts;
|
|
};
|
|
|
|
struct BreakpointWindow
|
|
{
|
|
bool draw(Frontend &);
|
|
|
|
std::string id;
|
|
bool open;
|
|
};
|
|
|
|
struct SourceWindow
|
|
{
|
|
bool draw(Frontend &);
|
|
void handle_source_updated(Target& target, size_t id);
|
|
|
|
std::string id;
|
|
bool open;
|
|
bool first;
|
|
bool line_changed;
|
|
|
|
size_t ip_src_id, line_entry_src_id;
|
|
std::string file_name;
|
|
uint32_t line;
|
|
std::vector<char> file_data;
|
|
std::vector<std::string_view> lines;
|
|
};
|
|
|
|
struct Window
|
|
{
|
|
WindowType type;
|
|
std::variant<std::monostate, RegWindow, ThreadWindow, FrameWindow,
|
|
DisasmWindow, BreakpointWindow, SourceWindow>
|
|
data;
|
|
|
|
// if true, window is closed and should be deleted
|
|
bool draw(Frontend &);
|
|
|
|
static Window create_regs(size_t window_id);
|
|
static Window create_threads(size_t window_id);
|
|
static Window create_frames(size_t window_id);
|
|
static Window create_disas(size_t window_id);
|
|
static Window create_bp(size_t window_id);
|
|
static Window create_source(size_t window_id);
|
|
|
|
void handle_source_updated(Target& target, size_t id);
|
|
};
|
|
} // namespace dbgui::frontend
|