Skip to content

Commit

Permalink
[debugger] Add verbose option
Browse files Browse the repository at this point in the history
  • Loading branch information
tgtakaoka committed May 2, 2024
1 parent 63a0653 commit ed89cd1
Show file tree
Hide file tree
Showing 39 changed files with 126 additions and 79 deletions.
5 changes: 4 additions & 1 deletion debugger/cdp1802/pins_cdp1802.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ inline void clock_cycle() {

} // namespace

void PinsCdp1802::reset() {
void PinsCdp1802::reset(bool show) {
pinsMode(PINS_LOW, sizeof(PINS_LOW), OUTPUT, LOW);
pinsMode(PINS_HIGH, sizeof(PINS_HIGH), OUTPUT, HIGH);
pinsMode(PINS_INPUT, sizeof(PINS_INPUT), INPUT);
Expand All @@ -171,6 +171,7 @@ void PinsCdp1802::reset() {
for (auto i = 0; i < 100; i++)
clock_cycle();
negate_reset();
Signals::resetCycles();
// The first machine cycle after termination of reset is an
// intialization cycle which requires 9 clock pulses.
for (auto i = 0; i < 20; i++) {
Expand All @@ -180,6 +181,8 @@ void PinsCdp1802::reset() {
}
Regs.reset();
Regs.save();
if (show)
printCycles();
}

Signals *PinsCdp1802::rawPrepareCycle() {
Expand Down
2 changes: 1 addition & 1 deletion debugger/cdp1802/pins_cdp1802.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace debugger {
namespace cdp1802 {

struct PinsCdp1802 final : Pins {
void reset() override;
void reset(bool show) override;
void idle() override;
bool step(bool show) override;
void run() override;
Expand Down
63 changes: 34 additions & 29 deletions debugger/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ constexpr char USAGE_ROM[] = " roM";

void usage() {
cli.println();
cli.print(F("* Bionic"));
cli.print("* Bionic");
Target::printIdentity();
cli.print(F(" * "));
cli.print(" * ");
cli.println(F(VERSION_TEXT));
cli.print(USAGE);
if (Debugger.mems().hasRomArea())
Expand All @@ -68,7 +68,7 @@ void commandHandler(char c, uintptr_t extra) {
}

void printPrompt() {
cli.print(F("> "));
cli.print("> ");
cli.readLetter(commandHandler, 0);
}

Expand Down Expand Up @@ -96,7 +96,7 @@ void memoryDump(uint32_t addr, uint16_t len, const char *space = nullptr) {
for (auto i = 0; i < 16; i++) {
const auto a = addr + i;
if (a < start || a >= end) {
cli.print(F(" "));
cli.print(" ");
} else {
const auto data = Debugger.mems().get(a, space);
mem_buffer[i] = data;
Expand Down Expand Up @@ -239,7 +239,7 @@ void handleMemory(uint32_t value, uintptr_t extra, State state) {
void handleAssembleLine(char *line, uintptr_t extra, State state) {
(void)extra;
if (state == State::CLI_CANCEL || *line == 0) {
cli.println(F("end"));
cli.println("end");
printPrompt();
return;
}
Expand Down Expand Up @@ -378,7 +378,7 @@ void handleLoadFile(char *line, uintptr_t extra, State state) {
File file = SD.open(line);
if (!file) {
cli.print(line);
cli.println(F(" not found"));
cli.println(" not found");
} else {
uint16_t size = 0;
char buffer[80];
Expand Down Expand Up @@ -406,7 +406,7 @@ void handleLoadFile(char *line, uintptr_t extra, State state) {
file.close();
cli.println();
cli.print(size);
cli.println(F(" bytes loaded"));
cli.println(" bytes loaded");
}
}
printPrompt();
Expand All @@ -425,7 +425,7 @@ void handleUploadFile(char *line, uintptr_t extra, State state) {
UploadContext *context = UploadContext::context(extra);
if (state == State::CLI_CANCEL) {
cli.print(context->size);
cli.println(F(" bytes uploaded"));
cli.println(" bytes uploaded");
printPrompt();
return;
}
Expand Down Expand Up @@ -535,9 +535,9 @@ void handleRomArea(uint32_t value, uintptr_t extra, State state) {
void handleSetBreak(uint32_t value, uintptr_t extra, State state) {
if (state != State::CLI_CANCEL) {
if (Debugger.pins().setBreakPoint(value)) {
cli.print(F("Set"));
cli.print("Set");
} else {
cli.print(F("Full"));
cli.print("Full");
}
Debugger.pins().printBreakPoints();
}
Expand All @@ -549,7 +549,7 @@ void handleClearBreak(char *line, uintptr_t extra, State state) {
if (str_buffer[0]) {
const auto index = atoi(str_buffer);
if (Debugger.pins().clearBreakPoint(index)) {
cli.print(F(" Clear"));
cli.print(" Clear");
Debugger.pins().printBreakPoints();
}
}
Expand All @@ -572,63 +572,63 @@ void Debugger::exec(char c) {
const auto maxAddr = mems().maxAddr();
switch (c) {
case 'R':
cli.println(F("Reset"));
target().reset();
cli.println("Reset");
target().reset(_verbose);
goto regs;
case 'd':
cli.print(F("Dump? "));
cli.print("Dump? ");
cli.readHex(handleDump, DUMP_ADDR, maxAddr);
return;
#ifdef WITH_DISASSEMBLER
case 'D':
cli.print(F("Disassemble? "));
cli.print("Disassemble? ");
cli.readHex(handleDisassemble, DIS_ADDR, maxAddr);
return;
#endif
#ifdef WITH_ASSEMBLER
case 'A':
cli.print(F("Assemble? "));
cli.print("Assemble? ");
cli.readHex(handleAssembler, 0, maxAddr);
return;
#endif
case 'm':
cli.print(F("Memory? "));
cli.print("Memory? ");
cli.readHex(handleMemory, MEMORY_ADDR, maxAddr);
return;
case 'M':
if (target().printRomArea()) {
cli.print(F(" ROM area? "));
cli.print(" ROM area? ");
cli.readHex(handleRomArea, MEMORY_ADDR, maxAddr);
return;
}
break;
case 'B':
cli.print(F("Set break? "));
cli.print("Set break? ");
cli.readHex(handleSetBreak, 0, maxAddr);
return;
case 'b':
if (target().printBreakPoints()) {
cli.print(F("Clear break? "));
cli.print("Clear break? ");
cli.readLine(handleClearBreak, 0, str_buffer, sizeof(str_buffer));
return;
}
break;
case 'r':
cli.println(F("Registers"));
cli.println("Registers");
regs:
target().printRegisters();
target().disassembleNext();
break;
case '=':
cli.print(F("Set register? "));
cli.print("Set register? ");
cli.readWord(handleSetRegister, 0, str_buffer, sizeof(str_buffer));
return;
case 'S':
cli.println(F("Step"));
cli.println("Step");
target().step(true);
goto regs;
case 'G':
cli.println(F("Go"));
cli.println("Go");
if (target().isOnBreakPoint()) {
// step over break point
if (!target().step(false))
Expand All @@ -637,29 +637,34 @@ void Debugger::exec(char c) {
target().run();
goto regs;
case 'F':
cli.print(F("Files? "));
cli.print("Files? ");
cli.readLine(handleFileListing, 0, str_buffer, sizeof(str_buffer));
return;
case 'L':
cli.print(F("Load? "));
cli.print("Load? ");
cli.readLine(handleLoadFile, 0, str_buffer, sizeof(str_buffer));
return;
case 'U':
cli.println(F("Upload waiting..."));
cli.println("Upload waiting...");
upload_context.size = 0;
cli.readLine(handleUploadFile, upload_context.extra(),
upload_context.buffer, sizeof(upload_context.buffer));
return;
case 'I':
cli.println();
target().printDevices();
cli.print(F("Io? "));
cli.print("Io? ");
cli.readWord(handleIo, 0, str_buffer, sizeof(str_buffer));
return;
case 'W':
cli.print(F("Write identity? "));
cli.print("Write identity? ");
cli.readLine(handleWriteIdentity, 0, str_buffer, sizeof(str_buffer));
return;
case 'v':
_verbose = !_verbose;
cli.print("Verbose ");
cli.println(_verbose ? "ON" : "OFF");
break;
case '?':
usage();
break;
Expand Down
1 change: 1 addition & 0 deletions debugger/debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct Debugger {

private:
Target *_target;
bool _verbose;
};

extern struct Debugger Debugger;
Expand Down
6 changes: 4 additions & 2 deletions debugger/f3850/pins_f3850.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,11 @@ inline void xtly_cycle_hi() {

} // namespace

void PinsF3850::reset() {
void PinsF3850::reset(bool show) {
pinsMode(PINS_LOW, sizeof(PINS_LOW), OUTPUT, LOW);
pinsMode(PINS_HIGH, sizeof(PINS_HIGH), OUTPUT, HIGH);
pinsMode(PINS_INPUT, sizeof(PINS_INPUT), INPUT);

Signals::resetCycles();
assert_extres();
for (auto i = 0; i < 10 * 4; ++i)
xtly_cycle();
Expand All @@ -162,12 +161,15 @@ void PinsF3850::reset() {
// WRITE=H
negate_extres();
delayNanoseconds(xtly_hi_ns);
Signals::resetCycles();

cycle(); // IDLE
delayNanoseconds(xtly_idle_ns);
cycle(); // RESET PC0

Regs.save();
if (show)
printCycles();
}

Signals *PinsF3850::cycle() {
Expand Down
2 changes: 1 addition & 1 deletion debugger/f3850/pins_f3850.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace debugger {
namespace f3850 {

struct PinsF3850 final : Pins {
void reset() override;
void reset(bool show) override;
void idle() override;
bool step(bool show) override;
void run() override;
Expand Down
4 changes: 3 additions & 1 deletion debugger/i8048/pins_i8048.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ inline void xtal1_cycle() {

} // namespace

void PinsI8048::reset() {
void PinsI8048::reset(bool show) {
pinsMode(PINS_LOW, sizeof(PINS_LOW), OUTPUT, LOW);
pinsMode(PINS_HIGH, sizeof(PINS_HIGH), OUTPUT, HIGH);
pinsMode(PINS_PULLUP, sizeof(PINS_PULLUP), INPUT_PULLUP);
Expand All @@ -198,6 +198,8 @@ void PinsI8048::reset() {
// #SS=L
Signals::resetCycles();
_regs.save();
if (show)
printCycles();
}

Signals *PinsI8048::prepareCycle() {
Expand Down
2 changes: 1 addition & 1 deletion debugger/i8048/pins_i8048.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct InstI8048;
struct PinsI8048 final : Pins {
PinsI8048(RegsI8048 &regs, ProgI8048 &mems, const InstI8048 &inst)
: Pins(), _regs(regs), _mems(mems), _inst(inst) {}
void reset() override;
void reset(bool show) override;
void idle() override;
bool step(bool show) override;
void run() override;
Expand Down
5 changes: 4 additions & 1 deletion debugger/i8085/pins_i8085.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ inline void clk_lo() {

} // namespace

void PinsI8085::reset() {
void PinsI8085::reset(bool show) {
pinsMode(PINS_LOW, sizeof(PINS_LOW), OUTPUT, LOW);
pinsMode(PINS_HIGH, sizeof(PINS_HIGH), OUTPUT, HIGH);
pinsMode(PINS_INPUT, sizeof(PINS_INPUT), INPUT);
Expand All @@ -235,11 +235,14 @@ void PinsI8085::reset() {
clk_lo();
}
negate_reset();
Signals::resetCycles();
// #RESET_IN is sampled here falling transition of next CLK.
cycleT1();
cycleT2Pause();

Regs.save();
if (show)
printCycles();
}

Signals *PinsI8085::cycleT1() const {
Expand Down
2 changes: 1 addition & 1 deletion debugger/i8085/pins_i8085.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ enum IntrName : uint8_t {
};

struct PinsI8085 final : Pins {
void reset() override;
void reset(bool show) override;
void idle() override;
bool step(bool show) override;
void run() override;
Expand Down
5 changes: 4 additions & 1 deletion debugger/ins8060/pins_ins8060.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ inline void xin_cycle() {

} // namespace

void PinsIns8060::reset() {
void PinsIns8060::reset(bool show) {
pinsMode(PINS_LOW, sizeof(PINS_LOW), OUTPUT, LOW);
pinsMode(PINS_HIGH, sizeof(PINS_HIGH), OUTPUT, HIGH);
pinsMode(PINS_PULLUP, sizeof(PINS_PULLUP), INPUT_PULLUP);
Expand All @@ -207,9 +207,12 @@ void PinsIns8060::reset() {
xin_cycle();
negate_enin();
negate_reset();
Signals::resetCycles();
// The #BREQ output goes low, indicating the start of execution;
// this occurs at a time whithin 13 Tc after #RST is set high.
Regs.save();
if (show)
printCycles();
}

Signals *PinsIns8060::prepareCycle() const {
Expand Down
2 changes: 1 addition & 1 deletion debugger/ins8060/pins_ins8060.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace debugger {
namespace ins8060 {

struct PinsIns8060 final : Pins {
void reset() override;
void reset(bool show) override;
void idle() override;
bool step(bool show) override;
void run() override;
Expand Down
5 changes: 4 additions & 1 deletion debugger/ins8070/pins_ins8070.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ inline void xin_cycle() {

} // namespace

void PinsIns8070::reset() {
void PinsIns8070::reset(bool show) {
pinsMode(PINS_LOW, sizeof(PINS_LOW), OUTPUT, LOW);
pinsMode(PINS_HIGH, sizeof(PINS_HIGH), OUTPUT, HIGH);
pinsMode(PINS_PULLUP, sizeof(PINS_PULLUP), INPUT_PULLUP);
Expand All @@ -195,9 +195,12 @@ void PinsIns8070::reset() {
xin_cycle();
negate_reset();
negate_enin();
Signals::resetCycles();
// The first instruction will be fetched within 13 Tc after #RST
// has gone high.
Regs.save();
if (show)
printCycles();
}

Signals *PinsIns8070::prepareCycle() {
Expand Down
Loading

0 comments on commit ed89cd1

Please sign in to comment.