Skip to content

Commit 437fa8d

Browse files
committed
Use colors for log level + don't append in file + improved log messages
1 parent 1bb344b commit 437fa8d

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public GdbStub(Debugger debugger, String binaryLocation) {
3131

3232
debugger.getBreakpointsListeners().add((pc) -> {
3333
try {
34+
logger.info("Stopped at breakpoint {}", pc);
3435
sendPacket(out, "S05");
3536
} catch (IOException e) {
3637
throw new RuntimeException(e);
@@ -214,7 +215,7 @@ else if (pkt.startsWith("Z")) {
214215
debugger.addBreakpoint((int) addr);
215216

216217
try {
217-
logger.info("Breakpoint line {} {}", debugSourceMap.getLineForPc((int) addr), debugSourceMap.getSourceFileName((int) addr));
218+
logger.info("Add breakpoint at {}:{}", debugSourceMap.getSourceFileName((int) addr), debugSourceMap.getLineForPc((int) addr));
218219
} catch(Exception _) {}
219220

220221
// A remote target shall return an empty string for an unrecognized breakpoint or watchpoint packet type.
@@ -231,8 +232,8 @@ else if (pkt.startsWith("z")) {
231232
debugger.removeBreakpoint((int) addr);
232233

233234
try {
234-
logger.info("Breakpoint line {} {}", debugSourceMap.getLineForPc((int) addr), debugSourceMap.getSourceFileName((int) addr));
235-
} catch(Exception e) {}
235+
logger.info("Remove breakpoint at {}:{}", debugSourceMap.getSourceFileName((int) addr), debugSourceMap.getLineForPc((int) addr));
236+
} catch(Exception _) {}
236237

237238
// A remote target shall return an empty string for an unrecognized breakpoint or watchpoint packet type.
238239
sendPacket(out, "OK");
@@ -274,8 +275,8 @@ else if (pkt.startsWith("stackInfo")) {
274275
sendPacket(out, result);
275276

276277
try {
277-
logger.info("Current line {} {}", debugSourceMap.getLineForPc(state.getPc()), debugSourceMap.getSourceFileName(state.getPc()));
278-
} catch(Exception e) {}
278+
logger.info("At {}:{}", debugSourceMap.getSourceFileName(state.getPc()), debugSourceMap.getLineForPc(state.getPc()));
279+
} catch(Exception _) {}
279280

280281
break;
281282
case "qC": // Get thread id
@@ -303,6 +304,7 @@ else if (pkt.startsWith("stackInfo")) {
303304
sendStopPacket(out, "05");
304305
break;
305306
case "c":
307+
logger.info("Continue execution");
306308
debugger.run();
307309
break;
308310
case "pause":

src/main/resources/logback.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<configuration>
22
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
33
<encoder>
4-
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
4+
<pattern>%d{HH:mm:ss.SSS} [%thread] %highlight(%-5level) %logger{36} - %msg%n</pattern>
55
</encoder>
66
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
77
<level>DEBUG</level>
@@ -10,6 +10,7 @@
1010

1111
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
1212
<file>mio.log</file>
13+
<append>false</append>
1314
<encoder>
1415
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
1516
</encoder>

0 commit comments

Comments
 (0)