Sync push
This commit is contained in:
parent
119da0bb1e
commit
327d0dd108
15 changed files with 307 additions and 93 deletions
Binary file not shown.
|
|
@ -29,6 +29,8 @@ _kernel0_main:
|
|||
push 1
|
||||
call $_print_string
|
||||
## debug_break
|
||||
_infinite_loop_0:
|
||||
jmp $_infinite_loop_0
|
||||
|
||||
mov [$cursor_x], 0
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## --
|
||||
## -- This file is automatically generated by the DragonAssembler (version 0.4.1637)
|
||||
## -- This file is automatically generated by the DragonAssembler (version 0.4.1640)
|
||||
## -- Please do not modify this file in any way.
|
||||
## --
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
1639
|
||||
1641
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#include "../tools/GlobalData.hpp"
|
||||
#include "../hardware/VirtualHardDrive.hpp"
|
||||
#include "../hardware/CPUExtensions.hpp"
|
||||
#include "../tools/Utils.hpp"
|
||||
|
||||
namespace dragon
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#include "Assembler.hpp"
|
||||
#include "../tools/Utils.hpp"
|
||||
#include <ostd/Random.hpp>
|
||||
|
||||
namespace dragon
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <ostd/IOHandlers.hpp>
|
||||
#include <ostd/Random.hpp>
|
||||
#include <ostd/String.hpp>
|
||||
#include <ostd/Utils.hpp>
|
||||
#include "DisassemblyLoader.hpp"
|
||||
#include "../runtime/DragonRuntime.hpp"
|
||||
|
||||
|
|
@ -337,6 +338,233 @@ namespace dragon
|
|||
return DragonRuntime::RETURN_VAL_EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
ostd::String DebuggerNew::getCommandInput(void)
|
||||
{
|
||||
// ostd::String cmd;
|
||||
// ostd::KeyboardController kbc;
|
||||
// ostd::eKeys key = ostd::eKeys::NoKeyPressed;
|
||||
|
||||
// while ((key = kbc.getPressedKey()) != ostd::eKeys::Enter)
|
||||
// {
|
||||
// if (key == ostd::eKeys::Escape)
|
||||
// return InputCommandQuit;
|
||||
// }
|
||||
// return kbc.getInputString();
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
int32_t DebuggerNew::executeRuntime(void)
|
||||
{
|
||||
int32_t rValue = 0;
|
||||
bool userQuit = false;
|
||||
output().clear().fg(ostd::ConsoleColors::Green).p("Program running...").nl();
|
||||
if (!data().args.step_exec)
|
||||
output().fg(ostd::ConsoleColors::Yellow).p("Press <Escape> to enter in step-execution mode...").reset().nl();
|
||||
while (!userQuit)
|
||||
{
|
||||
ostd::SignalHandler::refresh();
|
||||
// if (closeEventListener.hasHappened())
|
||||
// userQuit = true;
|
||||
data().command.clr();
|
||||
if (!userQuit && data().args.step_exec)
|
||||
rValue = step_execution(userQuit, true);
|
||||
else if (!userQuit)
|
||||
rValue = normal_runtime(userQuit);
|
||||
data().currentAddress = DragonRuntime::cpu.readRegister(data::Registers::IP);
|
||||
}
|
||||
output().nl().fg(ostd::ConsoleColors::Yellow).p("Execution terminated.").nl().nl().reset();
|
||||
return rValue;
|
||||
}
|
||||
|
||||
int32_t DebuggerNew::step_execution(bool& outUserQuit, bool exec_first_step)
|
||||
{
|
||||
if (exec_first_step && !DragonRuntime::cpu.isHalted())
|
||||
DragonRuntime::runStep(data().trackedAddresses);
|
||||
// Display::printStep();
|
||||
processErrors();
|
||||
if (DragonRuntime::cpu.isInDebugBreakPoint())
|
||||
output().fg(ostd::ConsoleColors::Red).p("Reached Debug Break Point.").reset().nl();
|
||||
// Display::printPrompt();
|
||||
data().command = getCommandInput();
|
||||
data().command.trim().toLower();
|
||||
while (data().command != "")
|
||||
{
|
||||
if (data().command == "q" || data().command == "quit" || data().command == InputCommandQuit)
|
||||
{
|
||||
output().nl();
|
||||
outUserQuit = true;
|
||||
data().command = "";
|
||||
}
|
||||
else if (data().command == "c" || data().command == "continue")
|
||||
{
|
||||
data().args.step_exec = false;
|
||||
data().command = "";
|
||||
output().clear().fg(ostd::ConsoleColors::Green).p("Program running...").nl();
|
||||
output().fg(ostd::ConsoleColors::Yellow).p("Press <Escape> to enter in step-execution mode...").reset().nl();
|
||||
}
|
||||
else if (data().command.startsWith("p ") || data().command.startsWith("print "))
|
||||
{
|
||||
data().command.substr(data().command.indexOf(" ") + 1).trim();
|
||||
const uint8_t TYPE_STRING = 0;
|
||||
const uint8_t TYPE_BYTE = 1;
|
||||
const uint8_t TYPE_WORD = 2;
|
||||
const uint8_t TYPE_DWORD = 4;
|
||||
const uint8_t TYPE_QWORD = 8;
|
||||
uint8_t type = TYPE_WORD;
|
||||
if (data().command.contains(" "))
|
||||
{
|
||||
ostd::String size_str = data().command.new_substr(0, data().command.indexOf(" ")).trim();
|
||||
data().command.substr(data().command.indexOf(" ") + 1).trim();
|
||||
if (size_str == "byte") type = TYPE_BYTE;
|
||||
else if (size_str == "word") type = TYPE_WORD;
|
||||
else if (size_str == "dword") type = TYPE_DWORD;
|
||||
else if (size_str == "qword") type = TYPE_QWORD;
|
||||
else if (size_str == "string") type = TYPE_STRING;
|
||||
}
|
||||
if (data().command.isNumeric())
|
||||
{
|
||||
if (type == TYPE_STRING)
|
||||
type = TYPE_WORD;
|
||||
uint16_t addr = data().command.toInt();
|
||||
uint16_t end_addr = addr;
|
||||
ostd::String tmp = "";
|
||||
tmp.add("*(").add(ostd::Utils::getHexStr(addr, true, 2));
|
||||
if (type != TYPE_BYTE)
|
||||
{
|
||||
end_addr = addr + type - 1;
|
||||
if (end_addr < addr)
|
||||
end_addr = addr;
|
||||
else
|
||||
tmp.add("-").add(ostd::Utils::getHexStr(end_addr, true, 2));
|
||||
}
|
||||
tmp.add(")");
|
||||
ostd::RegexRichString rgx(tmp);
|
||||
rgx.fg("\\(|\\)|-", "darkgray");
|
||||
rgx.fg("\\*", "red");
|
||||
rgx.fg("0x[0-9A-Fa-f]+|0b[0-1]+|(?<!\\w)[0-9]+(?!\\w)", "cyan"); //Number Constants
|
||||
output().pStyled(rgx);
|
||||
output().fg(ostd::ConsoleColors::White).p(" = ");
|
||||
output().fg(ostd::ConsoleColors::Gray).p("[");
|
||||
for (uint16_t a = addr; a <= end_addr; a++)
|
||||
{
|
||||
uint8_t value = DragonRuntime::memMap.read8(a);
|
||||
output().fg(ostd::ConsoleColors::BrightRed).p(ostd::Utils::getHexStr(value, true, 1));
|
||||
if (a < end_addr)
|
||||
output().p(" ");
|
||||
}
|
||||
output().fg(ostd::ConsoleColors::Gray).p("]");
|
||||
output().reset().nl();
|
||||
}
|
||||
else if (data().command.startsWith("$"))
|
||||
{
|
||||
uint16_t size = 0;
|
||||
uint16_t addr = findSymbol(debugger.data, data().command, &size);
|
||||
if (addr == 0)
|
||||
addr = findSymbol(debugger.labels, data().command, &size);
|
||||
if (addr == 0)
|
||||
output().fg(ostd::ConsoleColors::Red).p("Unknown symbol for <print> command.").reset().nl();
|
||||
else
|
||||
{
|
||||
ostd::String tmp = "";
|
||||
tmp.add("*(").add(ostd::Utils::getHexStr(addr, true, 2));
|
||||
if (size > 1)
|
||||
tmp.add("-").add(ostd::Utils::getHexStr((uint16_t)(addr + size - 1), true, 2));
|
||||
tmp.add(")");
|
||||
ostd::RegexRichString rgx(tmp);
|
||||
rgx.fg("\\(|\\)|-", "darkgray");
|
||||
rgx.fg("\\*", "red");
|
||||
rgx.fg("0x[0-9A-Fa-f]+|0b[0-1]+|(?<!\\w)[0-9]+(?!\\w)", "cyan"); //Number Constants
|
||||
output().pStyled(rgx);
|
||||
output().fg(ostd::ConsoleColors::White).p(" = ");
|
||||
output().fg(ostd::ConsoleColors::Gray).p("[");
|
||||
if (type == TYPE_STRING)
|
||||
output().fg(ostd::ConsoleColors::BrightRed).p("\"");
|
||||
for (uint16_t a = addr; a < addr + size; a++)
|
||||
{
|
||||
uint8_t value = DragonRuntime::memMap.read8(a);
|
||||
if (type == TYPE_STRING)
|
||||
{
|
||||
output().fg(ostd::ConsoleColors::BrightRed).pChar((char)value);
|
||||
continue;
|
||||
}
|
||||
output().fg(ostd::ConsoleColors::BrightRed).p(ostd::Utils::getHexStr(value, true, 1));
|
||||
if (a < addr + size - 1)
|
||||
output().p(" ");
|
||||
}
|
||||
if (type == TYPE_STRING)
|
||||
output().fg(ostd::ConsoleColors::BrightRed).p("\"");
|
||||
output().fg(ostd::ConsoleColors::Gray).p("]");
|
||||
output().reset().nl();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
output().fg(ostd::ConsoleColors::Red).p("Invalid value for <print> command.").reset().nl();
|
||||
}
|
||||
// Display::printPrompt();
|
||||
data().command = getCommandInput();
|
||||
}
|
||||
else if (data().command.startsWith("b ") || data().command.startsWith("break "))
|
||||
{//0x2C1D
|
||||
data().command.substr(data().command.indexOf(" ") + 1).trim();
|
||||
uint16_t addr = 0;
|
||||
bool valid = false;
|
||||
if (data().command.isNumeric())
|
||||
{
|
||||
addr = (uint16_t)data().command.toInt();
|
||||
valid = true;
|
||||
}
|
||||
else if (data().command.startsWith("$"))
|
||||
{
|
||||
addr = findSymbol(debugger.labels, data().command);
|
||||
if (addr == 0x0000 || addr == 0xFFFF)
|
||||
output().fg(ostd::ConsoleColors::Red).p("Invalid symbol: ").p(data().command).reset().nl();
|
||||
else
|
||||
valid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
output().fg(ostd::ConsoleColors::Red).p("Invalid value for <break> command.").reset().nl();
|
||||
}
|
||||
if (valid)
|
||||
{
|
||||
if (isBreakPoint(addr))
|
||||
{
|
||||
removeBreakPoint(addr);
|
||||
output().fg(ostd::ConsoleColors::Yellow).p("Breakpoint removed at address: ").p(ostd::Utils::getHexStr(addr, true, 2)).reset().nl();
|
||||
}
|
||||
else
|
||||
{
|
||||
addBreakPoint(addr);
|
||||
output().fg(ostd::ConsoleColors::Yellow).p("Breakpoint set at address: ").p(ostd::Utils::getHexStr(addr, true, 2)).reset().nl();
|
||||
}
|
||||
}
|
||||
// Display::printPrompt();
|
||||
data().command = getCommandInput();
|
||||
}
|
||||
else
|
||||
data().command = "";//Display::changeScreen();
|
||||
}
|
||||
return DragonRuntime::RETURN_VAL_EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DebuggerNew::normal_runtime(bool& outUserQuit)
|
||||
{
|
||||
bool result = DragonRuntime::runStep(data().trackedAddresses);
|
||||
if (isBreakPoint((uint16_t)DragonRuntime::cpu.readRegister(data::Registers::IP)))
|
||||
{
|
||||
data().args.step_exec = true;
|
||||
return step_execution(outUserQuit, false);
|
||||
}
|
||||
bool hasError = DragonRuntime::hasError();
|
||||
bool enableStepExec = !result || hasError || DragonRuntime::cpu.isInDebugBreakPoint();
|
||||
data().args.step_exec = enableStepExec;
|
||||
if (enableStepExec)
|
||||
return step_execution(outUserQuit, false);
|
||||
return DragonRuntime::RETURN_VAL_EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -455,9 +683,9 @@ namespace dragon
|
|||
m_gfx.init(*this);
|
||||
m_gfx.setFont("res/Courier Prime.ttf");
|
||||
|
||||
float w = getWindowWidth();
|
||||
float w = m_consolePosition.x - 12;
|
||||
float h = 40.0f;
|
||||
m_textInput.create({ 0.0f, (float)(getWindowHeight() - h) }, { w, h }, "MainInputTXT");
|
||||
m_textInput.create({ 0.0f, (float)(getWindowHeight() - h) }, { w, h }, "CmdTxt");
|
||||
m_textInput.setEventListener(m_sigHandler);
|
||||
m_textInput.getTheme().extraPaddingTop = 3;
|
||||
|
||||
|
|
@ -472,6 +700,8 @@ namespace dragon
|
|||
m_wout.setConsolePosition(m_consolePosition);
|
||||
m_wout.setWrapMode(ogfx::WindowBaseOutputHandler::eWrapMode::TripleDots);
|
||||
m_wout.setDefaultForegroundColor({ 180, 180, 180, 255 });
|
||||
|
||||
std::cout << STR_BOOL(ostd::Utils::loadByteStreamFromFile("./test.dds", m_test)) << "\n";
|
||||
}
|
||||
|
||||
void DebuggerNew::handleSignal(ostd::tSignal& signal)
|
||||
|
|
@ -517,24 +747,18 @@ namespace dragon
|
|||
m_gfx.outlinedRect(m_wout.getConsoleBounds(), { 0, 0, 20, 255 }, { 255, 255, 255, 200 }, 2);
|
||||
|
||||
m_wout.beginFrame();
|
||||
printStep();
|
||||
// for (int32_t i = m_codeRandomIndex; i < m_codeRandomIndex + m_consoleSize.y; i++)
|
||||
// {
|
||||
// if (i >= m_codeTable.size()) break;
|
||||
// auto code = m_codeTable[i];
|
||||
// m_wout.tab().fg({ 100, 100, 100, 255 }).p(ostd::Utils::getHexStr(code.addr, true, 2));
|
||||
// m_wout.clear().tab().tab();
|
||||
// // colorCodeInstructions(code.code, m_wout);
|
||||
// }
|
||||
ostd::Utils::printByteStream(m_test, 0, 16, 16, m_wout, 8, 4, "HELLO");
|
||||
// printStep();
|
||||
|
||||
// m_textInput.render(m_gfx);
|
||||
m_textInput.render(m_gfx);
|
||||
// m_testBtn.render(m_gfx);
|
||||
}
|
||||
|
||||
void DebuggerNew::onFixedUpdate(void)
|
||||
void DebuggerNew::onFixedUpdate(double frameTime_s)
|
||||
{
|
||||
m_textInput.fixedUpdate();
|
||||
m_testBtn.fixedUpdate();
|
||||
// std::cout << getFPS() << "\n";
|
||||
}
|
||||
|
||||
void DebuggerNew::onUpdate(void)
|
||||
|
|
@ -542,20 +766,4 @@ namespace dragon
|
|||
m_textInput.update();
|
||||
m_testBtn.update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t __debugger_entry_point(void)
|
||||
{
|
||||
DebuggerNew window;
|
||||
window.initialize(1600, 1000, "DragonVM Live Debugger");
|
||||
window.setClearColor({ 0, 2 , 15 });
|
||||
|
||||
while (window.isRunning())
|
||||
{
|
||||
window.update();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <ostd/Color.hpp>
|
||||
#include <ostd/Geometry.hpp>
|
||||
#include <ostd/Types.hpp>
|
||||
#include <ostd/Utils.hpp>
|
||||
#include <ostd/IOHandlers.hpp>
|
||||
#include <ogfx/WindowBase.hpp>
|
||||
|
|
@ -195,6 +196,12 @@ namespace dragon
|
|||
void processErrors(void);
|
||||
int32_t loadArguments(int argc, char** argv);
|
||||
int32_t initRuntime(void);
|
||||
ostd::String getCommandInput(void);
|
||||
inline tDebuggerData& data(void) { return debugger; }
|
||||
inline ostd::ConsoleOutputHandler& output(void) { return out; }
|
||||
int32_t executeRuntime(void);
|
||||
int32_t step_execution(bool& outUserQuit, bool exec_first_step = true);
|
||||
int32_t normal_runtime(bool& outUserQuit);
|
||||
|
||||
//Display
|
||||
void colorizeInstructionBody(const ostd::String& instBody, bool currentLine, const DisassemblyList& labelList);
|
||||
|
|
@ -206,7 +213,7 @@ namespace dragon
|
|||
void onInitialize(void) override;
|
||||
void handleSignal(ostd::tSignal& signal) override;
|
||||
void onRender(void) override;
|
||||
void onFixedUpdate(void) override;
|
||||
void onFixedUpdate(double frameTime_s) override;
|
||||
void onUpdate(void) override;
|
||||
|
||||
private:
|
||||
|
|
@ -224,8 +231,9 @@ namespace dragon
|
|||
ostd::Vec2 m_consolePosition { 650, 8 };
|
||||
// std::vector<code::Assembler::tDisassemblyLine> m_codeTable;
|
||||
// int32_t m_codeRandomIndex { 0 };
|
||||
ostd::ByteStream m_test;
|
||||
|
||||
public:
|
||||
inline static const ostd::String InputCommandQuit = "//quit//";
|
||||
};
|
||||
|
||||
uint32_t __debugger_entry_point(void);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <ostd/Color.hpp>
|
||||
#include "../tools/SDLInclude.hpp"
|
||||
#include "../tools/SDLInclude.hpp" // IWYU pragma: keep
|
||||
|
||||
namespace dragon
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include "../tools/SDLInclude.hpp"
|
||||
#include "../tools/SDLInclude.hpp" // IWYU pragma: keep
|
||||
#include <ostd/Utils.hpp>
|
||||
#include <ostd/Signals.hpp>
|
||||
#include <ostd/IOHandlers.hpp>
|
||||
|
||||
namespace dragon
|
||||
{
|
||||
class Window : public ostd::BaseObject
|
||||
class Window : public ostd::BaseObject
|
||||
{
|
||||
public:
|
||||
inline Window(void) { }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#include "MemoryMapper.hpp"
|
||||
#include <ostd/Utils.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#include "../tools/GlobalData.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include <ostd/Defines.hpp>
|
||||
#include <ostd/Utils.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#include "../runtime/DragonRuntime.hpp"
|
||||
|
||||
|
|
@ -827,7 +826,7 @@ namespace dragon
|
|||
int16_t arg_data = m_memory.read16(pp_val);
|
||||
writeRegister16(data::Registers::PP, pp_val - 2);
|
||||
writeRegister16(regAddr, arg_data);
|
||||
std::cout << ostd::Utils::getHexStr(readRegister(data::Registers::IP), true, 2) << "\n";
|
||||
// std::cout << ostd::Utils::getHexStr(readRegister(data::Registers::IP), true, 2) << "\n";
|
||||
}
|
||||
break;
|
||||
case data::OpCodes::RetInt:
|
||||
|
|
|
|||
|
|
@ -209,7 +209,10 @@ namespace dragon
|
|||
}
|
||||
}
|
||||
|
||||
void VirtualDisplay::onSlowUpdate(void) { }
|
||||
void VirtualDisplay::onSlowUpdate(void)
|
||||
{
|
||||
std::cout << (int)getFPS() << "\n";
|
||||
}
|
||||
|
||||
void VirtualDisplay::__redraw_screen(void)
|
||||
{
|
||||
|
|
@ -243,7 +246,7 @@ namespace dragon
|
|||
{
|
||||
m_singleTextLines.push_back(ostd::String().addChar(c));
|
||||
auto& line = m_singleTextLines[m_singleTextLines.size() - 1];
|
||||
if (invert_colors == 0)
|
||||
if (invert_colors == 0)
|
||||
RawTextRenderer::drawString(ostd::String().addChar(c), line.len() - 1, m_singleTextLines.size() - 1, m_renderer.getScreenPixels(), getWindowWidth(), getWindowHeight(), m_fontPixels, config.singleColor_foreground, config.singleColor_background);
|
||||
else
|
||||
RawTextRenderer::drawString(ostd::String().addChar(c), line.len() - 1, m_singleTextLines.size() - 1, m_renderer.getScreenPixels(), getWindowWidth(), getWindowHeight(), m_fontPixels, config.singleColor_background, config.singleColor_foreground);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
#include "VirtualHardDrive.hpp"
|
||||
#include "MemoryMapper.hpp"
|
||||
#include "VirtualCPU.hpp"
|
||||
#include "VirtualRAM.hpp"
|
||||
|
||||
#include "../runtime/DragonRuntime.hpp"
|
||||
#include "../gui/RawTextRenderer.hpp"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include "../gui/Window.hpp"
|
||||
|
||||
#include "../hardware/VirtualCPU.hpp"
|
||||
#include "../hardware/MemoryMapper.hpp"
|
||||
#include "../hardware/VirtualRAM.hpp"
|
||||
|
|
|
|||
Loading…
Reference in a new issue