diff --git a/.gitignore b/.gitignore index f1bc8523..75e2e48f 100644 --- a/.gitignore +++ b/.gitignore @@ -63,5 +63,6 @@ packages.config *.zip *.d temp +out output build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e38a89f..3291c861 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -212,6 +212,7 @@ add_executable(quaesar # Recursively glob for all .cpp files in the src directory file(GLOB_RECURSE CROSS_FILES "src/*.cpp") <<<<<<< HEAD +<<<<<<< HEAD file(GLOB_RECURSE QUAE_HEADERS "src/*.h") target_sources(quaesar PRIVATE ${CROSS_FILES} ${QUAE_HEADERS}) @@ -222,12 +223,21 @@ if (APPLE OR LINUX) ======= ======= target_sources(quaesar PRIVATE ${CROSS_FILES}) +======= +file(GLOB_RECURSE QUAE_HEADERS "src/*.h") +target_sources(quaesar PRIVATE ${CROSS_FILES} ${QUAE_HEADERS}) +>>>>>>> ae863fad (Merged with main branch.) >>>>>>> c95323b5 (WIP on Disassembly) if (APPLE OR LINUX OR UNIX) +<<<<<<< HEAD target_compile_options(quaesar PRIVATE -DUAE=1 -D_cdecl= -DFILEFLAG_WRITE=1 -DOS_NAME=\"linux\") target_compile_options(quaesar PRIVATE -DUSHORT=uint16_t -DHWND=uint32_t -DHRESULT=uint32_t -DWPARAM=uint16_t -DLPARAM=uint32_t) >>>>>>> 2134e72d (cmake 'OR UNIX') +======= + target_compile_options(quaesar PRIVATE -DUAE=1 -D_cdecl= -DFILEFLAG_WRITE=1 -DOS_NAME=\"linux\") + target_compile_options(quaesar PRIVATE -DUSHORT=uint16_t -DHWND=uint32_t -DHRESULT=uint32_t -DWPARAM=uint16_t -DLPARAM=uint32_t) +>>>>>>> ae863fad (Merged with main branch.) target_compile_definitions(quaesar PRIVATE FSUAE) target_include_directories(quaesar PRIVATE ${SDL2_INCLUDE_DIRS}) target_link_libraries(quaesar PRIVATE ${SDL2_LIBRARIES}) diff --git a/src/debugger/debugger.cpp b/src/debugger/debugger.cpp index afff01b1..da813b9b 100644 --- a/src/debugger/debugger.cpp +++ b/src/debugger/debugger.cpp @@ -4,6 +4,7 @@ #include #include <<<<<<< HEAD +<<<<<<< HEAD #include #include #include @@ -86,6 +87,11 @@ Debugger* Debugger_create() { cs_option(debugger->capstone, CS_OPT_DETAIL, CS_OPT_ON); >>>>>>> 4380b77f (WIP on debugger) +======= +#include +#include +#include +>>>>>>> ae863fad (Merged with main branch.) namespace qd { void imgui_apply_dark_style() { @@ -182,6 +188,7 @@ void imgui_apply_dark_style() { } } +<<<<<<< HEAD <<<<<<< HEAD /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ======= @@ -194,10 +201,15 @@ void imgui_apply_dark_style() { >>>>>>> ee5fcf82 (Register view and semi working stepping) <<<<<<< HEAD +======= +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +>>>>>>> ae863fad (Merged with main branch.) Debugger* Debugger_create() { uint32_t window_flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_HIDDEN; SDL_Window* window = SDL_CreateWindow("Quaesar: Debugger", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags); +<<<<<<< HEAD // From 2.0.18: Enable native IME. #ifdef SDL_HINT_IME_SHOW_UI @@ -253,6 +265,59 @@ Debugger* Debugger_create() { s_debugger = debugger; >>>>>>> 4380b77f (WIP on debugger) +======= + + // From 2.0.18: Enable native IME. +#ifdef SDL_HINT_IME_SHOW_UI + SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1"); +#endif + + if (!window) { + fprintf(stderr, "Error creating window.\n"); + return nullptr; + } + + SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED); + if (!renderer) { + SDL_DestroyWindow(window); + SDL_Log("Error creating SDL_Renderer!"); + return nullptr; + } + + // Setup Dear ImGui context + IMGUI_CHECKVERSION(); + ImGui::CreateContext(); + ImGuiIO& io = ImGui::GetIO(); + (void)io; + io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls + io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; + + // Setup Dear ImGui style + ImGui::StyleColorsDark(); + // ImGui::StyleColorsLight(); + + // Setup Platform/Renderer backends + ImGui_ImplSDL2_InitForSDLRenderer(window, renderer); + ImGui_ImplSDLRenderer2_Init(renderer); + + Debugger* debugger = new Debugger(); + debugger->window = window; + debugger->renderer = renderer; + + // TODO: Pick correct CPU depending on starting CPU + cs_err err = cs_open(CS_ARCH_M68K, (cs_mode)(CS_MODE_BIG_ENDIAN | CS_MODE_M68K_000), &debugger->capstone); + if (err) { + printf("Failed on cs_open() with error returned: %u\n", err); + abort(); + } + + cs_option(debugger->capstone, CS_OPT_DETAIL, CS_OPT_ON); + + imgui_apply_dark_style(); + + // create windows + debugger->create(); +>>>>>>> ae863fad (Merged with main branch.) return debugger; } @@ -261,11 +326,14 @@ Debugger* Debugger_create() { static void draw_debugger_window(Debugger* self) { ImGuiIO& io = ImGui::GetIO(); +<<<<<<< HEAD <<<<<<< HEAD ======= static bool p_open = true; >>>>>>> c95323b5 (WIP on Disassembly) +======= +>>>>>>> ae863fad (Merged with main branch.) const ImGuiViewport* viewport = ImGui::GetMainViewport(); ImGui::SetNextWindowPos(viewport->WorkPos); ImGui::SetNextWindowSize(viewport->WorkSize); @@ -280,6 +348,7 @@ static void draw_debugger_window(Debugger* self) { bool p_open = true; ImGui::Begin("Quaesar debugger", &p_open, window_flags); ImGui::PopStyleVar(2); +<<<<<<< HEAD <<<<<<< HEAD ImGui::DockSpace(ImGui::GetID("DockSpace"), ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_None); self->gui->drawImGuiFrame(); @@ -344,6 +413,10 @@ static void draw_debugger_window(Debugger* self) { */ >>>>>>> b105bd89 (WIP) +======= + ImGui::DockSpace(ImGui::GetID("DockSpace"), ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_None); + self->gui->drawImGuiFrame(); +>>>>>>> ae863fad (Merged with main branch.) ImGui::End(); } @@ -384,6 +457,9 @@ bool Debugger_is_window_visible(Debugger* debugger) { uint32_t window_flags = SDL_GetWindowFlags(debugger->window); if (window_flags & SDL_WINDOW_HIDDEN) { <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> ae863fad (Merged with main branch.) return false; } else { return true; @@ -392,9 +468,12 @@ bool Debugger_is_window_visible(Debugger* debugger) { void Debugger_toggle(Debugger* debugger, DebuggerMode mode) { if (!Debugger_is_window_visible(debugger)) { +<<<<<<< HEAD ======= activate_debugger_new(); >>>>>>> 4380b77f (WIP on debugger) +======= +>>>>>>> ae863fad (Merged with main branch.) SDL_ShowWindow(debugger->window); } else { deactivate_debugger(); @@ -418,6 +497,7 @@ void Debugger_destroy(Debugger* debugger) { delete debugger; } +<<<<<<< HEAD <<<<<<< HEAD ////////////////////////////////////////////////////////////////////////// @@ -459,59 +539,46 @@ void* Debugger::addrToPtr(uint32_t addr) { }; // namespace qd ======= /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +======= +////////////////////////////////////////////////////////////////////////// +>>>>>>> ae863fad (Merged with main branch.) -static void* create(void* user_data) { - return nullptr; -} -static void check_exception(void* self) { -} -static void cop_debug(void* self, uint32_t addr, uint32_t nextaddr, uint16_t word1, uint16_t word2, int hpos, - int vpos) { +void Debugger::create() { + vm = qd::VM::get(); + gui = new GuiManager(this); } -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -static void update(void* self) { - set_special(SPCFLAG_BRK); - - SDL_Event e; - - while (1) { - while (SDL_PollEvent(&e) != 0) { - // User requests quit - switch (e.type) { - case SDL_QUIT: // User closes the window - // TODO: Fix me - exit(0); - break; - default: - break; - - case SDL_KEYDOWN: - if (e.key.keysym.sym == SDLK_ESCAPE) { - exit(0); - } +void Debugger::destroy() { + if (gui) + gui->destroy(); + delete gui; + gui = nullptr; - if (e.key.keysym.sym == SDLK_F10) { - Debugger_step(s_debugger); - return; - } + vm = nullptr; +} - break; - } +bool Debugger::isDebugActivated() { + return ::debugging != 0; +} - Debugger_update_event(&e); - } +void Debugger::setDebugMode(DebuggerMode debug_mode) { + if (debug_mode == DebuggerMode_Break) { + activate_debugger_new(); - Debugger_update(s_debugger); + // trace_mode = TRACE_MATCH_PC; + // trace_param[0] = nextpc; + // exception_debugging = 1; + // debug_cycles(2); + } else if (debug_mode == DebuggerMode_Live) { + deactivate_debugger(); } } -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void Debugger_step(Debugger* debugger) { - debug_internal_step(); +void* Debugger::addrToPtr(uint32_t addr) { + void* addr_ptr = memory_get_real_address(addr); + return addr_ptr; } +<<<<<<< HEAD /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -530,3 +597,6 @@ DebuggerAPI s_debugger_api = { >>>>>>> 4380b77f (WIP on debugger) ======= >>>>>>> eafcacf8 (Format fixes) +======= +}; // namespace qd +>>>>>>> ae863fad (Merged with main branch.) diff --git a/src/debugger/debugger.h b/src/debugger/debugger.h index 625b706d..4ee1ff5c 100644 --- a/src/debugger/debugger.h +++ b/src/debugger/debugger.h @@ -7,10 +7,14 @@ struct SDL_Window; struct SDL_Renderer; union SDL_Event; <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> ae863fad (Merged with main branch.) namespace qd { class GuiManager; class VM; +<<<<<<< HEAD /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -30,6 +34,11 @@ struct Debugger { }; >>>>>>> ee5fcf82 (Register view and semi working stepping) +======= + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +>>>>>>> ae863fad (Merged with main branch.) enum DebuggerMode { DebuggerMode_Live, DebuggerMode_Break, @@ -67,9 +76,15 @@ void Debugger_update_event(SDL_Event* event); void Debugger_destroy(Debugger* debugger); void Debugger_toggle(Debugger* debugger, DebuggerMode mode); <<<<<<< HEAD +<<<<<<< HEAD bool Debugger_is_window_visible(Debugger* debugger); }; // namespace qd ======= void Debugger_step(Debugger* debugger); >>>>>>> b105bd89 (WIP) +======= +bool Debugger_is_window_visible(Debugger* debugger); + +}; // namespace qd +>>>>>>> ae863fad (Merged with main branch.) diff --git a/src/debugger/window/memory_wnd.cpp b/src/debugger/window/memory_wnd.cpp index a7264689..c5770a4d 100644 --- a/src/debugger/window/memory_wnd.cpp +++ b/src/debugger/window/memory_wnd.cpp @@ -768,8 +768,8 @@ void MemoryView::draw_preview_data(size_t addr, const uint8_t* mem_data, size_t } case ImGuiDataType_COUNT: break; - } - IM_ASSERT(0); + } // Switch + IM_ASSERT(0); // Shouldn't reach } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/dummy.cpp b/src/dummy.cpp index f99c64a4..95f49ea0 100644 --- a/src/dummy.cpp +++ b/src/dummy.cpp @@ -1024,11 +1024,16 @@ int graphics_init(bool) { alloc_colors64k(0, bits, bits, bits, red_shift, green_shift, blue_shift, bits, 24, 0, 0, false); +<<<<<<< HEAD <<<<<<< HEAD s_debugger = qd::Debugger_create(); ======= >>>>>>> fec2cdfe (Fixed crash on macOS) +======= + s_debugger = qd::Debugger_create(); + +>>>>>>> ae863fad (Merged with main branch.) TRACE(); return 1; } @@ -1099,12 +1104,16 @@ void unlockscr(struct vidbuffer* vb_in, int y_start, int y_end) { int amiga_height = vb->outheight; <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> ae863fad (Merged with main branch.) // Change pixels for (int y = 0; y < amiga_height; y++) { uint8_t* dest = (uint8_t*)&pixels[y * 754]; memcpy(dest, sptr, amiga_width * 4); sptr += vb->rowbytes; } +<<<<<<< HEAD ======= int amiga_width = vb->outwidth; int amiga_height = vb->outheight; @@ -1115,6 +1124,8 @@ void unlockscr(struct vidbuffer* vb_in, int y_start, int y_end) { memcpy(dest, sptr, amiga_width * 4); sptr += vb->rowbytes; >>>>>>> fec2cdfe (Fixed crash on macOS) +======= +>>>>>>> ae863fad (Merged with main branch.) } SDL_UnlockTexture(s_texture); } diff --git a/uae_src/debug.cpp b/uae_src/debug.cpp index b782464d..9d4d785d 100644 --- a/uae_src/debug.cpp +++ b/uae_src/debug.cpp @@ -7223,7 +7223,8 @@ static void debug_1 (void) console_out (_T(">")); console_flush (); debug_linecounter = 0; - v = console_get (input, MAX_LINEWIDTH); + // TODO: CONFILCT: terminal stops execution when 'd' was pressed + v = -1; // console_get(input, MAX_LINEWIDTH); if (v < 0) return; if (v == 0) @@ -7231,10 +7232,14 @@ static void debug_1 (void) if (debug_line (input)) return; } +<<<<<<< HEAD #if DEBUGGER_API_ENABLE >>>>>>> 08ecfb3b (stepping working) } #endif +======= +} +>>>>>>> ae863fad (Merged with main branch.) } static void addhistory(void) @@ -8837,4 +8842,12 @@ void debug_internal_step() { trace_param[0] = trace_param[1] = 0; } +<<<<<<< HEAD >>>>>>> 08ecfb3b (stepping working) +======= + +void qd::Debugger::applyConsoleCmd(const char *cmd) { + TCHAR* buf = (TCHAR *)cmd; + ::debug_line(buf); +} +>>>>>>> ae863fad (Merged with main branch.)