Supermodel/Src/Debugger/ConsoleDebugger.h

168 lines
3.9 KiB
C
Raw Normal View History

2011-06-27 22:55:03 +00:00
#ifdef SUPERMODEL_DEBUGGER
#ifndef INCLUDED_CONSOLEDEBUGGER_H
#define INCLUDED_CONSOLEDEBUGGER_H
#include "Debugger.h"
#include "CodeAnalyser.h"
#include "Types.h"
#include <stdarg.h>
#include <stdio.h>
2011-06-27 22:55:03 +00:00
#define NUM_LISTAUTOLABELS (sizeof(s_listAutoLabels) / sizeof(ELabelFlags))
namespace Debugger
{
class CCPUDebug;
class CException;
class CWatch;
class CBreakpoint;
class CRegister;
2011-06-27 22:55:03 +00:00
class CRegMonitor;
/*
* Base class for a console-based debugger.
* TODO - a lot of commands are not yet implemented/missing and the main loop is a big ugly mess :-) !
*/
class CConsoleDebugger : public CDebugger
{
private:
static ELabelFlags s_listAutoLabels[];
CCPUDebug *m_cpu;
bool m_nextFrame;
unsigned m_nextFrameCount;
2011-06-27 22:55:03 +00:00
UINT32 m_listDism;
UINT32 m_listMem;
bool m_analyseCode;
EFormat m_addrFmt;
EFormat m_portFmt;
EFormat m_dataFmt;
bool m_showLabels;
bool m_labelsOverAddr;
bool m_showOpCodes;
unsigned m_memBytesPerRow;
FILE *m_file;
2011-06-27 22:55:03 +00:00
protected:
void Read(char *str, size_t maxLen);
void Print(const char *fmtStr, ...);
void Error(const char *fmtStr, ...);
void PrintVL(const char *fmtStr, va_list vl);
void Flush();
2011-06-27 22:55:03 +00:00
bool CheckToken(const char *token, const char *simple, const char *full);
bool CheckToken(const char *token, const char *simple, const char *full, char *modifier, size_t modSize, const char *defaultMod);
2011-06-27 22:55:03 +00:00
void Truncate(char *dst, size_t maxLen, const char *src);
void UpperFirst(char *dst, const char *src);
2011-06-27 22:55:03 +00:00
void FormatOpCodes(char *str, int addr, int codesLen);
bool GetLabelText(char *str, int maxLen, UINT32 addr);
bool SetBoolConfig(const char *str, bool &cfg);
bool SetNumConfig(const char *str, unsigned &cfg);
const char *GetFmtConfig(EFormat fmt);
bool SetFmtConfig(const char *str, EFormat &cfg);
bool ParseAddress(const char *str, UINT32 *addr);
const char *GetDataSizeStr(unsigned dataSize, bool shortName);
2011-06-27 22:55:03 +00:00
bool ParseDataSize(const char *str, unsigned &dataSize);
bool ParseFormat(const char *str, EFormat &fmt);
bool ParseCPU(const char *str, CCPUDebug *&cpu);
bool ParseRegister(const char *str, CRegister *&reg);
2011-06-27 22:55:03 +00:00
void ListCPUs();
void ListRegisters();
void ListExceptions();
void ListInterrupts();
void ListIOs();
void ListRegions();
void ListLabels(bool customLabels, ELabelFlags autoLabelFlags);
void GetAllMemWatches(vector<CWatch*> &watches);
int GetIndexOfMemWatch(CWatch *watch);
2011-06-27 22:55:03 +00:00
void ListMemWatches();
void GetAllPortWatches(vector<CWatch*> &watches);
int GetIndexOfPortWatch(CWatch *watch);
2011-06-27 22:55:03 +00:00
void ListPortWatches();
void ListBreakpoints();
void ListMonitors();
UINT32 ListDisassembly(UINT32 start, UINT32 end, unsigned numInstrs);
UINT32 ListMemory(UINT32 start, UINT32 end, unsigned bytesPerRow);
virtual void ApplyConfig();
virtual void Attached();
virtual void Detaching();
virtual void AnalysisUpdated(CCodeAnalyser *analyser);
virtual void ExceptionTrapped(CException *ex);
virtual void InterruptTrapped(CInterrupt *ex);
virtual void MemWatchTriggered(CWatch *watch, UINT32 addr, unsigned dataSize, UINT64 data, bool isRead);
virtual void IOWatchTriggered(CWatch *watch, CIO *io, UINT64 data, bool isInput);
virtual void BreakpointReached(CBreakpoint *bp);
virtual void MonitorTriggered(CRegMonitor *regMon);
virtual void ExecutionHalted(CCPUDebug *cpu, EHaltReason reason);
virtual void WaitCommand(CCPUDebug *cpu);
virtual bool ProcessToken(const char *token, const char *cmd);
virtual void Log(CCPUDebug *cpu, const char *typeStr, const char *fmtStr, va_list vl);
2011-06-27 22:55:03 +00:00
public:
CConsoleDebugger();
void Attach();
void Detach();
virtual void Poll();
2011-06-27 22:55:03 +00:00
};
}
#endif // INCLUDED_CONSOLEDEBUGGER_H
#endif // SUPERMODEL_DEBUGGER