Skip to content

Commit

Permalink
Moves GDB server to GUI thread (#1022)
Browse files Browse the repository at this point in the history
  • Loading branch information
ultimaweapon authored Oct 8, 2024
1 parent 7a65dbb commit 612ca53
Show file tree
Hide file tree
Showing 13 changed files with 609 additions and 301 deletions.
4 changes: 2 additions & 2 deletions gui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# External dependencies.
find_package(Qt6 REQUIRED COMPONENTS Svg Widgets)
find_package(Qt6 REQUIRED COMPONENTS Network Svg Widgets)
find_package(Threads REQUIRED)

if(WIN32 OR (UNIX AND NOT APPLE))
Expand Down Expand Up @@ -64,7 +64,7 @@ endif()

target_compile_features(obliteration PRIVATE cxx_std_17)

target_link_libraries(obliteration PRIVATE Qt6::Svg Qt6::Widgets)
target_link_libraries(obliteration PRIVATE Qt6::Network Qt6::Svg Qt6::Widgets)
target_link_libraries(obliteration PRIVATE Threads::Threads)
target_link_libraries(obliteration PRIVATE ${LIBGUI})

Expand Down
64 changes: 48 additions & 16 deletions gui/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ enum VmmLog {
VmmLog_Error,
};

/**
* Reason for [`VmmEvent::Breakpoint`].
*/
struct KernelStop;

/**
* Contains settings to launch the kernel.
*/
Expand Down Expand Up @@ -86,21 +91,15 @@ struct VmmScreen {
*/
enum VmmEvent_Tag {
VmmEvent_Error,
VmmEvent_WaitingDebugger,
VmmEvent_DebuggerDisconnected,
VmmEvent_Exiting,
VmmEvent_Log,
VmmEvent_Breakpoint,
};

struct VmmEvent_Error_Body {
const struct RustError *reason;
};

struct VmmEvent_WaitingDebugger_Body {
const char *addr;
size_t len;
};

struct VmmEvent_Exiting_Body {
bool success;
};
Expand All @@ -111,13 +110,38 @@ struct VmmEvent_Log_Body {
size_t len;
};

struct VmmEvent_Breakpoint_Body {
struct KernelStop *stop;
};

struct VmmEvent {
enum VmmEvent_Tag tag;
union {
struct VmmEvent_Error_Body error;
struct VmmEvent_WaitingDebugger_Body waiting_debugger;
struct VmmEvent_Exiting_Body exiting;
struct VmmEvent_Log_Body log;
struct VmmEvent_Breakpoint_Body breakpoint;
};
};

/**
* Result of [`vmm_dispatch_debug()`].
*/
enum DebugResult_Tag {
DebugResult_Ok,
DebugResult_Disconnected,
DebugResult_ReadFailed,
DebugResult_Error,
};

struct DebugResult_Error_Body {
struct RustError *reason;
};

struct DebugResult {
enum DebugResult_Tag tag;
union {
struct DebugResult_Error_Body error;
};
};

Expand Down Expand Up @@ -183,18 +207,26 @@ struct RustError *update_firmware(const char *root,
void *cx,
void (*status)(const char*, uint64_t, uint64_t, void*));

void vmm_free(struct Vmm *vmm);
struct Vmm *vmm_start(const char *kernel,
const struct VmmScreen *screen,
const struct Profile *profile,
bool (*debug)(void*, const uint8_t*, size_t, int*),
void (*event)(const struct VmmEvent*, void*),
void *cx,
struct RustError **err);

struct Vmm *vmm_run(const char *kernel,
const struct VmmScreen *screen,
const struct Profile *profile,
const char *debug,
void (*event)(const struct VmmEvent*, void*),
void *cx,
struct RustError **err);
void vmm_free(struct Vmm *vmm);

struct RustError *vmm_draw(struct Vmm *vmm);

struct DebugResult vmm_dispatch_debug(struct Vmm *vmm,
struct KernelStop *stop,
bool (*read)(uint8_t*, void*));

void vmm_shutdown(struct Vmm *vmm);

bool vmm_shutting_down(struct Vmm *vmm);

#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
6 changes: 2 additions & 4 deletions gui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,8 @@ int main(int argc, char *argv[])
win.restoreGeometry();

// Run main window.
auto debug = args.value(Args::debug);

if (!debug.isEmpty()) {
win.startVmm(debug);
if (args.isSet(Args::debug)) {
win.startDebug(args.value(Args::debug));
}

return QApplication::exec();
Expand Down
Loading

0 comments on commit 612ca53

Please sign in to comment.