Skip to content

Commit 1862257

Browse files
committed
Use --port/-p to start debug server
1 parent 60572f9 commit 1862257

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ public WOODDumpResponse getCurrentState() {
9191
return debugger.getCheckpoints().getLast().getSnapshot();
9292
}
9393

94-
public void start() throws IOException {
94+
public void start(int port) throws IOException {
9595
debugger.pause();
9696

9797
byte[] wasmData = Files.readAllBytes(Path.of(binaryLocation));
9898

99-
ServerSocket server = new ServerSocket(1234);
100-
System.out.println("Waiting for GDB on port 1234...");
99+
ServerSocket server = new ServerSocket(port);
100+
System.out.printf("Waiting for GDB on port %d...", port);
101101
Socket sock = server.accept();
102102
System.out.println("GDB connected!");
103103

src/main/kotlin/be/ugent/topl/mio/Main.kt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@ fun main(args: Array<String>) {
5252
}
5353
expectNArguments(args, 1)
5454
val config = DebuggerConfig()
55+
56+
if (args[0].startsWith("-p=") || args[0].startsWith("--port=")) {
57+
expectNArguments(args, 2)
58+
val wasmFilename = args[1]
59+
val port = args[0].split("=")[1].toInt()
60+
val debugger = Debugger(ProcessConnection(config.wdcliPath, wasmFilename, "--no-socket", "--paused"))
61+
debugger.pause()
62+
debugger.setSnapshotPolicy(Debugger.SnapshotPolicy.Checkpointing())
63+
val stub = GdbStub(debugger, wasmFilename)
64+
stub.start(port)
65+
return
66+
}
67+
5568
when (args[0]) {
5669
"debug" -> {
5770
expectNArguments(args, 2)
@@ -151,15 +164,6 @@ fun main(args: Array<String>) {
151164
config.port!!
152165
)
153166
}
154-
"debug-server" -> {
155-
expectNArguments(args, 2)
156-
val wasmFilename = args[1]
157-
val debugger = Debugger(ProcessConnection(config.wdcliPath, wasmFilename, "--no-socket", "--paused"))
158-
debugger.pause()
159-
debugger.setSnapshotPolicy(Debugger.SnapshotPolicy.Checkpointing())
160-
val stub = GdbStub(debugger, wasmFilename)
161-
stub.start()
162-
}
163167
else -> {
164168
println("Invalid option \"${args[0]}\"!")
165169
exitProcess(1)

0 commit comments

Comments
 (0)