From 96c7cf41bd5888b2cdb7ffd4686073c32a622f34 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sun, 28 Apr 2024 09:44:25 +0200 Subject: [PATCH] console::debugger is no longer required --- console.cpp | 27 --------------------------- console.h | 2 -- debugger.cpp | 14 +++++++------- 3 files changed, 7 insertions(+), 36 deletions(-) diff --git a/console.cpp b/console.cpp index efb8001..884b9a5 100644 --- a/console.cpp +++ b/console.cpp @@ -270,33 +270,6 @@ std::string console::read_line(const std::string & prompt) return edit_lines_hist.at(line_nr); } -void console::debug(const std::string fmt, ...) -{ -#if defined(BUILD_FOR_RP2040) - char buffer[128]; - va_list ap; - - va_start(ap, fmt); - vsnprintf(buffer, sizeof buffer, fmt.c_str(), ap); - va_end(ap); - - put_string_lf(buffer); -#else - char *buffer = nullptr; - - va_list ap; - va_start(ap, fmt); - - vasprintf(&buffer, fmt.c_str(), ap); - - va_end(ap); - - put_string_lf(buffer); - - free(buffer); -#endif -} - void console::put_char(const char c) { put_char_ll(c); diff --git a/console.h b/console.h index 3b8d7bd..88e1b3c 100644 --- a/console.h +++ b/console.h @@ -79,8 +79,6 @@ public: void put_string(const std::string & what); virtual void put_string_lf(const std::string & what) = 0; - void debug(const std::string fmt, ...); - virtual void resize_terminal() = 0; virtual void refresh_virtual_terminal() = 0; diff --git a/debugger.cpp b/debugger.cpp index 2087c19..cf59b1c 100644 --- a/debugger.cpp +++ b/debugger.cpp @@ -82,10 +82,10 @@ std::optional select_disk_file(console *const c) #if IS_POSIX c->put_string_lf("Files in current directory: "); #else - c->debug("MISO: %d", int(MISO)); - c->debug("MOSI: %d", int(MOSI)); - c->debug("SCK : %d", int(SCK )); - c->debug("SS : %d", int(SS )); + c->put_string_lf(format("MISO: %d", int(MISO))); + c->put_string_lf(format("MOSI: %d", int(MOSI))); + c->put_string_lf(format("SCK : %d", int(SCK ))); + c->put_string_lf(format("SS : %d", int(SS ))); c->put_string_lf("Files on SD-card:"); @@ -96,9 +96,9 @@ std::optional select_disk_file(console *const c) if (!SD.begin(SS, SD_SCK_MHZ(15))) { auto err = SD.sdErrorCode(); if (err) - c->debug("SDerror: 0x%x, data: 0x%x", err, SD.sdErrorData()); + c->put_string_lf(format("SDerror: 0x%x, data: 0x%x", err, SD.sdErrorData())); else - c->debug("Failed to initialize SD card"); + c->put_string_lf("Failed to initialize SD card"); return { }; } @@ -355,7 +355,7 @@ int disassemble(cpu *const c, console *const cnsl, const uint16_t pc, const bool ); if (cnsl) - cnsl->debug(result); + cnsl->put_string_lf(result); else DOLOG(debug, false, "%s", result.c_str());