Skip to content

Commit 8bb65aa

Browse files
committed
Implement D packet
Maybe in the future we might want to support keeping the connection open when detaching so you can keep it running and transfer debugging to a different machine.
1 parent ee8304b commit 8bb65aa

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/main/java/be/ugent/topl/mio/GdbStub.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ public void start() throws IOException {
110110
InputStream in = sock.getInputStream();
111111
out = sock.getOutputStream();
112112

113-
while (true) {
113+
boolean attached = true;
114+
115+
while (attached) {
114116
String pkt = recvPacket(in, out);
115117
if (pkt == null) {
116118
System.out.println("GDB closed");
@@ -246,6 +248,11 @@ else if (pkt.startsWith("z")) {
246248
sendPacket(out, "OK");
247249
continue;
248250
}
251+
else if (pkt.startsWith("stackInfo")) {
252+
//debugger.stepBack(1, wasmData);
253+
sendPacket(out, getCurrentState().getStack().toString());
254+
continue;
255+
}
249256

250257
switch (pkt) {
251258
/*case "QStartNoAckMode":
@@ -310,7 +317,12 @@ else if (pkt.startsWith("z")) {
310317
debugger.run();
311318
//sendPacket(out, "S05");
312319
break;
313-
320+
case "D":
321+
attached = false;
322+
log("Detach from target");
323+
debugger.close();
324+
sendPacket(out, "OK");
325+
break;
314326
default:
315327
System.out.println("Unknown packet: " + pkt);
316328
sendPacket(out, ""); // unsupported

0 commit comments

Comments
 (0)