mpw/bin/debugger.h
Kelvin Sherlock 8c9e50cd8f Add backtrace support to the debug console.
Squashed commit of the following:

commit b3afbbf15839d5ad9343d4540674510cbd6cd16d
Author: Kelvin Sherlock <ksherlock@gmail.com>
Date:   Wed Dec 24 17:44:20 2014 -0500

    improve the debugger help a little bit

commit 82e1e4e3e4d802defbf49c965500ffc72c7be1af
Author: Kelvin Sherlock <ksherlock@gmail.com>
Date:   Wed Dec 24 17:32:21 2014 -0500

    prevent filename tab completion in the debugger.

commit 8765e5f428562e5ab6f8d59ec0e0460a834c66b5
Author: Kelvin Sherlock <ksherlock@gmail.com>
Date:   Wed Dec 24 16:06:21 2014 -0500

    skip macsbug names when disassembling via ;list

commit 9b87cfb3851fedc6423629608f53076741116991
Author: Kelvin Sherlock <ksherlock@gmail.com>
Date:   Wed Dec 24 15:43:13 2014 -0500

    improved backtracing.

commit f8e364d7c568fe6728c8efd5587f7edeb49f5816
Author: Kelvin Sherlock <ksherlock@gmail.com>
Date:   Wed Dec 24 15:17:28 2014 -0500

    BackTrace support
2014-12-24 17:44:48 -05:00

145 lines
2.2 KiB
C++

#ifndef __debugger_h__
#define __debugger_h__
#include <cstdint>
#include <map>
#include <functional>
#include <string>
// Debugger is a function in MacTypes.h
namespace Debug {
enum {
cmdNull,
cmdContinue,
cmdStep,
cmdRun,
};
enum {
// subtypes
// ; commands
kHexdump = 1,
kInfo,
kList,
kBreak,
kTBreak
};
struct Command {
bool valid;
int action;
uint32_t argc;
uint32_t argv[10];
};
struct Token {
// constructor is not allowable because
// this is a union in the parser.
#if 0
Token():
intValue(0), stringValue(0), subtype(0)
{}
Token(uint32_t i) :
intValue(i), subtype(0)
{}
Token(std::string *s, unsigned st = 0) :
intValue(0), stringValue(s), subtype(st)
{}
#endif
static Token Make()
{
Token t = {0, 0, 0};
return t;
}
static Token Make(uint32_t i)
{
Token t = { i, 0, 0};
return t;
}
static Token Make(std::string *s, uint32_t st)
{
Token t = { 0, s, st};
return t;
}
uint32_t intValue;
std::string *stringValue;
unsigned subtype;
// unsigned range?
// unsigned modifier?
#if 0
Token& operator=(uint32_t rhs)
{
intValue = rhs;
stringValue = 0;
subtype = 0;
return *this;
}
#endif
operator uint32_t() const
{
return intValue;
}
};
bool ParseLine(const char *iter, Command *command);
void LoadTrapFile(const std::string &path, std::map<std::string, uint16_t> &map);
uint32_t VariableGet(const std::string &);
void VariableSet(const std::string &name, uint32_t value);
void Shell();
void Help();
uint32_t ReadLong(uint32_t);
uint16_t ReadWord(uint32_t);
uint8_t ReadByte(uint32_t);
void Print(uint32_t value);
void PrintRegisters();
void PrintBackTrace();
void Info(uint32_t address);
void Dump(uint32_t address, int count = 256);
void List(uint32_t address, int count = 20);
void List(uint32_t pc, uint32_t endpc);
void SetARegister(unsigned reg, uint32_t value);
void SetDRegister(unsigned reg, uint32_t value);
void SetXRegister(unsigned reg, uint32_t value);
void ToolBreak(int32_t tool);
void ToolBreak();
void Break(int32_t address);
void Break();
void ReadBreak();
void ReadBreak(int32_t address);
void WriteBreak();
void WriteBreak(int32_t address);
void ReadWriteBreak();
void ReadWriteBreak(int32_t address);
}
#endif