Skip to content

Commit 7c1e9d6

Browse files
committed
Use a PrintWriter allowing the output location of the GdbStub log function to be changed
1 parent 1862257 commit 7c1e9d6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ public class GdbStub {
1919
private final Debugger debugger;
2020
private final String binaryLocation;
2121
private OutputStream out;
22+
private PrintWriter logger;
2223
private final SourceMap debugSourceMap; // Remove later, lldb doesn't need this.
2324

2425
public GdbStub(Debugger debugger, String binaryLocation) {
2526
this.debugger = debugger;
2627
this.binaryLocation = binaryLocation;
28+
this.logger = new PrintWriter(System.out);
2729
debugSourceMap = getDwarfSourcemap(binaryLocation);
2830

2931
debugger.getBreakpointsListeners().add((pc) -> {
@@ -335,10 +337,11 @@ private void sendStopPacket(OutputStream out, String signal) throws IOException
335337
}
336338

337339
private void log(String s) {
338-
System.out.print("\u001b[36m");
339-
System.out.print("[GDBSTUB] ");
340-
System.out.println(s);
341-
System.out.print("\u001b[0m");
340+
logger.print("\u001b[36m");
341+
logger.print("[GDBSTUB] ");
342+
logger.println(s);
343+
logger.print("\u001b[0m");
344+
logger.flush();
342345
}
343346

344347
private String recvPacket(InputStream in, OutputStream out) throws IOException {

0 commit comments

Comments
 (0)