Skip to content

Commit ee8304b

Browse files
committed
Correctly put return addresses in the callstack
1 parent d4ae94b commit ee8304b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,15 @@ else if (pkt.startsWith("z")) {
267267
sendPacket(out, "PacketSize=4000");
268268
break;
269269
case "qWasmCallStack:1": // Get the callstack for thread 1.
270-
Checkpoint lastCheckpoint = debugger.getCheckpoints().getLast();
271270
WOODDumpResponse state = getCurrentState();
272-
//long currentPc = (long) state.getPc() - codeSection.offset;
273-
long currentPc = (long) state.getPc();
274-
String result = toHex(currentPc);
275-
for (int i = 0; i < state.getCallstack().size() - 1; i++) {
276-
result += toHex(0xdead); // TODO: Add other pc's in the callstack
271+
String result = toHex(state.getPc());
272+
for (int i = state.getCallstack().size() - 1; i >= 0; i--) {
273+
// Only functions are real callstack elements:
274+
Frame f = state.getCallstack().get(i);
275+
if (f.getType() == 0) {
276+
result += toHex(f.getRa());
277+
}
277278
}
278-
log("Callstack size: " + state.getCallstack().size() + " pc = " + currentPc);
279279
sendPacket(out, result);
280280

281281
try {

0 commit comments

Comments
 (0)