mirror of
https://github.com/ksherlock/mpw.git
synced 2024-11-22 00:32:44 +00:00
8c9e50cd8f
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
283 lines
5.4 KiB
Plaintext
283 lines
5.4 KiB
Plaintext
|
|
%extra_argument { Debug::Command *command }
|
|
%token_prefix tk
|
|
|
|
%token_type { Token }
|
|
%include {
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
#include <cassert>
|
|
#include "debugger.h"
|
|
|
|
#include <toolbox/MM.h>
|
|
|
|
using Debug::Token;
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
uint32_t cpuGetSR();
|
|
uint32_t cpuGetPC();
|
|
uint32_t cpuGetAReg(unsigned);
|
|
uint32_t cpuGetDReg(unsigned);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
|
|
#undef NDEBUG
|
|
|
|
}
|
|
|
|
%parse_failure {
|
|
//fprintf(stderr,"I don't understand.\n");
|
|
command->valid = false;
|
|
}
|
|
|
|
%parse_accept {
|
|
command->valid = true;
|
|
}
|
|
|
|
|
|
|
|
%left PIPEPIPE.
|
|
%left AMPAMP.
|
|
%left PIPE.
|
|
%left CARET.
|
|
%left AMP.
|
|
%left EQEQ BANGEQ.
|
|
%left LT LTEQ GT GTEQ.
|
|
%left LTLT GTGT.
|
|
%left PLUS MINUS.
|
|
%left STAR SLASH PERCENT.
|
|
%right BANG TILDE.
|
|
|
|
|
|
stmt ::= expr(a) EOL.
|
|
{
|
|
Debug::Print(a.intValue);
|
|
}
|
|
|
|
stmt ::= STAR EOL.
|
|
{
|
|
Debug::PrintRegisters();
|
|
}
|
|
|
|
stmt ::= PRINT expr(a) EOL.
|
|
{
|
|
Debug::Print(a.intValue);
|
|
}
|
|
|
|
stmt ::= BREAK EOL.
|
|
{
|
|
Debug::Break();
|
|
}
|
|
|
|
stmt ::= BREAK expr(a) EOL.
|
|
{
|
|
Debug::Break(a.intValue);
|
|
}
|
|
|
|
stmt ::= BACKTRACE EOL.
|
|
{
|
|
Debug::PrintBackTrace();
|
|
}
|
|
|
|
stmt ::= CONTINUE EOL.
|
|
{
|
|
command->action = Debug::cmdContinue;
|
|
command->argc = 0;
|
|
}
|
|
|
|
stmt ::= TBREAK EOL.
|
|
{
|
|
Debug::ToolBreak();
|
|
}
|
|
|
|
stmt ::= TBREAK expr(a) EOL.
|
|
{
|
|
Debug::ToolBreak(a.intValue);
|
|
}
|
|
|
|
stmt ::= RBREAK EOL .
|
|
{
|
|
Debug::ReadBreak();
|
|
}
|
|
|
|
stmt ::= RBREAK expr(a) EOL.
|
|
{
|
|
Debug::ReadBreak(a.intValue);
|
|
}
|
|
|
|
stmt ::= WBREAK EOL.
|
|
{
|
|
Debug::WriteBreak();
|
|
}
|
|
|
|
stmt ::= WBREAK expr(a) EOL.
|
|
{
|
|
Debug::WriteBreak(a.intValue);
|
|
}
|
|
|
|
|
|
stmt ::= RWBREAK expr(a) EOL .
|
|
{
|
|
Debug::ReadWriteBreak(a.intValue);
|
|
}
|
|
|
|
|
|
stmt ::= NEXT EOL.
|
|
{
|
|
command->action = Debug::cmdStep;
|
|
command->argc = 0;
|
|
}
|
|
|
|
stmt ::= NEXT expr(a) EOL.
|
|
{
|
|
command->action = Debug::cmdStep;
|
|
command->argc = 1;
|
|
command->argv[0] = a.intValue;
|
|
}
|
|
|
|
stmt ::= DUMP expr(a) EOL.
|
|
{
|
|
Debug::Dump(a.intValue);
|
|
}
|
|
|
|
stmt ::= DUMP expr(a) COLON expr(b) EOL.
|
|
{
|
|
Debug::Dump(a.intValue, b.intValue - a.intValue);
|
|
}
|
|
|
|
stmt ::= DUMP expr(a) AT expr(b) EOL.
|
|
{
|
|
Debug::Dump(a.intValue, b.intValue);
|
|
}
|
|
|
|
stmt ::= LIST expr(a) EOL.
|
|
{
|
|
Debug::List(a.intValue);
|
|
}
|
|
|
|
|
|
stmt ::= expr(a) SEMI SEMIH EOL.
|
|
{
|
|
Debug::Dump(a.intValue);
|
|
}
|
|
|
|
stmt ::= expr(a) COLON expr(b) SEMI SEMIH EOL.
|
|
{
|
|
Debug::Dump(a.intValue, b.intValue - a.intValue);
|
|
}
|
|
|
|
stmt ::= expr(a) AT expr(b) SEMI SEMIH EOL.
|
|
{
|
|
Debug::Dump(a.intValue, b.intValue);
|
|
}
|
|
|
|
|
|
stmt ::= expr(a) SEMI SEMII EOL.
|
|
{
|
|
Debug::Info(a.intValue);
|
|
}
|
|
|
|
|
|
stmt ::= expr(a) SEMI SEMIL EOL.
|
|
{
|
|
Debug::List(a.intValue);
|
|
}
|
|
|
|
stmt ::= expr(a) AT expr(b) SEMI SEMIL EOL.
|
|
{
|
|
Debug::List(a.intValue, (int)b.intValue);
|
|
}
|
|
|
|
stmt ::= expr(a) COLON expr(b) SEMI SEMIL EOL.
|
|
{
|
|
Debug::List(a.intValue, b.intValue);
|
|
}
|
|
|
|
|
|
stmt ::= DREGISTER(a) EQ expr(b) EOL.
|
|
{
|
|
Debug::SetDRegister(a.intValue, b.intValue);
|
|
}
|
|
|
|
stmt ::= AREGISTER(a) EQ expr(b) EOL.
|
|
{
|
|
Debug::SetARegister(a.intValue, b.intValue);
|
|
}
|
|
|
|
stmt ::= XREGISTER(a) EQ expr(b) EOL.
|
|
{
|
|
Debug::SetXRegister(a.intValue, b.intValue);
|
|
}
|
|
|
|
stmt ::= HELP EOL.
|
|
{
|
|
Debug::Help();
|
|
}
|
|
|
|
stmt ::= IDENTIFIER(a) EQ expr(b) EOL.
|
|
{
|
|
Debug::VariableSet(*a.stringValue, b.intValue);
|
|
}
|
|
|
|
expr(rhs) ::= unary(a). { rhs = a; }
|
|
expr(rhs) ::= expr(a) PLUS expr(b). { rhs = Token::Make(a.intValue + b.intValue); }
|
|
expr(rhs) ::= expr(a) MINUS expr(b). { rhs = Token::Make(a.intValue - b.intValue); }
|
|
expr(rhs) ::= expr(a) STAR expr(b). { rhs = Token::Make(a.intValue * b.intValue); }
|
|
expr(rhs) ::= expr(a) SLASH expr(b). { rhs = Token::Make(a.intValue / b.intValue); }
|
|
expr(rhs) ::= expr(a) PERCENT expr(b). { rhs = Token::Make(a.intValue % b.intValue); }
|
|
expr(rhs) ::= expr(a) LTLT expr(b). { rhs = Token::Make(a.intValue << b.intValue); }
|
|
expr(rhs) ::= expr(a) GTGT expr(b). { rhs = Token::Make(a.intValue >> b.intValue); }
|
|
expr(rhs) ::= expr(a) LT expr(b). { rhs = Token::Make(a.intValue < b.intValue); }
|
|
expr(rhs) ::= expr(a) LTEQ expr(b). { rhs = Token::Make(a.intValue <= b.intValue); }
|
|
expr(rhs) ::= expr(a) GT expr(b). { rhs = Token::Make(a.intValue > b.intValue); }
|
|
expr(rhs) ::= expr(a) GTEQ expr(b). { rhs = Token::Make(a.intValue >= b.intValue); }
|
|
expr(rhs) ::= expr(a) EQEQ expr(b). { rhs = Token::Make(a.intValue == b.intValue); }
|
|
expr(rhs) ::= expr(a) BANGEQ expr(b). { rhs = Token::Make(a.intValue != b.intValue); }
|
|
expr(rhs) ::= expr(a) AMP expr(b). { rhs = Token::Make(a.intValue & b.intValue); }
|
|
expr(rhs) ::= expr(a) CARET expr(b). { rhs = Token::Make(a.intValue ^ b.intValue); }
|
|
expr(rhs) ::= expr(a) PIPE expr(b). { rhs = Token::Make(a.intValue | b.intValue); }
|
|
expr(rhs) ::= expr(a) AMPAMP expr(b). { rhs = Token::Make(a.intValue && b.intValue); }
|
|
expr(rhs) ::= expr(a) PIPEPIPE expr(b). { rhs = Token::Make(a.intValue || b.intValue); }
|
|
|
|
|
|
unary(rhs) ::= term(a). { rhs = a; }
|
|
unary(rhs) ::= PLUS unary(a). [BANG] { rhs = a; }
|
|
unary(rhs) ::= MINUS unary(a). [BANG] { rhs = Token::Make(-a.intValue); }
|
|
unary(rhs) ::= TILDE unary(a). { rhs = Token::Make(~a.intValue); }
|
|
unary(rhs) ::= BANG unary(a). { rhs = Token::Make(!a.intValue); }
|
|
unary(rhs) ::= STAR unary(a). [BANG] { rhs = Token::Make(Debug::ReadLong(a)); }
|
|
|
|
|
|
|
|
term(rhs) ::= LPAREN expr(a) RPAREN. { rhs = a; }
|
|
term(rhs) ::= INTEGER(a). { rhs = a; }
|
|
term(rhs) ::= DREGISTER(a). { rhs = Token::Make(cpuGetDReg(a)); }
|
|
term(rhs) ::= AREGISTER(a). { rhs = Token::Make(cpuGetAReg(a)); }
|
|
term(rhs) ::= XREGISTER(a).
|
|
{
|
|
switch(a)
|
|
{
|
|
case 0:
|
|
rhs = Token::Make(cpuGetPC());
|
|
break;
|
|
case 1:
|
|
rhs = Token::Make(cpuGetSR());
|
|
break;
|
|
default:
|
|
rhs = Token::Make(0);
|
|
}
|
|
}
|
|
|
|
term(rhs) ::= IDENTIFIER(a).
|
|
{
|
|
// should throw/barf if undefined?
|
|
rhs = Token::Make(Debug::VariableGet(*a.stringValue));
|
|
}
|