Add conn conn_pop_packet.

This commit is contained in:
Colin 2025-09-22 05:33:48 +00:00
parent b9bef6a9af
commit 9ac39e6a12
3 changed files with 48 additions and 16 deletions

31
.vscode/launch.json vendored
View File

@ -5,11 +5,13 @@
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"name": "mini-gdbstub",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/mini-gdbstub/build/emu",
"args": ["./mini-gdbstub/build/emu_test.bin"],
"args": [
"./mini-gdbstub/build/emu_test.bin"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/mini-gdbstub",
"environment": [],
@ -27,7 +29,30 @@
"ignoreFailures": true
}
]
},
{
"name": "gdbstub",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/gdbstub/build/stub",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/gdbstub",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}

View File

@ -8,5 +8,11 @@ int main(int argc, char *argv[]) {
conn_t conn;
if (!conn_init(&conn, "127.0.0.1", 1234)) std::cout << "conn_init error" << std::endl;
while (1) {
conn_recv_packet(&conn);
packet_t *pkt = conn_pop_packet(&conn);
printf("packet = %s\n", pkt->data);
}
return 0;
}

View File

@ -3,6 +3,7 @@
#include <pthread.h>
#include <stdbool.h>
#include "packet.h"
#define MAX_SEND_PACKET_SIZE (0x1000)