#pragma once
#include "ext/imgui/imgui.h"
#include "Common/GhidraClient.h"
#include "Core/MIPS/MIPSDebugInterface.h"
struct ImConfig;
struct ImControl;
class ImStructViewer {
struct Watch {
int id = 0;
std::string expression;
u32 address = 0;
std::string typePathName;
std::string name;
};
struct WatchForm {
char name[256] = {};
std::string typeDisplayName;
std::string typePathName;
char expression[256] = {};
bool dynamic = false;
std::string error;
ImGuiTextFilter typeFilter;
void Clear();
void SetFrom(const std::unordered_map<std::string, GhidraType> &types, const Watch &watch);
};
public:
void Draw(ImConfig &cfg, ImControl &control, MIPSDebugInterface *mipsDebug);
private:
ImControl *control_ = nullptr;
MIPSDebugInterface *mipsDebug_ = nullptr;
ImGuiTextFilter globalFilter_;
ImGuiTextFilter watchFilter_;
GhidraClient ghidraClient_;
char ghidraHost_[128] = "localhost";
int ghidraPort_ = 18489;
bool fetchedAtLeastOnce_ = false;
std::vector<Watch> watches_;
int nextWatchId_ = 0;
int removeWatchId_ = -1;
int editWatchId_ = -1;
Watch addWatch_;
WatchForm watchForm_;
void DrawConnectionSetup();
void DrawStructViewer();
void DrawGlobals();
void DrawWatch();
void DrawWatchForm();
void ClearWatchForm();
void DrawType(
u32 base,
u32 offset,
const std::string &typePathName,
const char *typeDisplayNameOverride,
const char *name,
int watchId,
ImGuiTreeNodeFlags extraTreeNodeFlags = 0);
void DrawIndexedMembers(
u32 base,
u32 offset,
const std::string &typePathName,
const char *name,
u32 elementCount,
int elementLength,
bool openFirst);
void DrawContextMenu(
u32 base,
u32 offset,
int length,
const std::string &typePathName,
const char *name,
int watchId,
const u64 *value);
};