Skip to content

Commit 3319635

Browse files
authored
Add breakpoint hotkey to blinkenlights (#205)
* Map b to breakpoint set * Ignore setting breakpoint if already set
1 parent 118e353 commit 3319635

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

blink/blinkenlights.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ R restart -H disable highlighting\n\
177177
x sse radix -j enables jit\n\
178178
t sse type -m disables memory safety\n\
179179
T sse size -N natural scroll wheel\n\
180-
B pop breakpoint -s system call logging\n\
180+
b push breakpoint -s system call logging\n\
181+
B pop breakpoint\n\
181182
p profiling mode -C PATH chroot directory\n\
182183
ctrl-t turbo -B PATH alternate BIOS image\n\
183184
alt-t slowmo -z zoom\n\
@@ -887,6 +888,14 @@ static void BreakAtNextInstruction(void) {
887888
PushBreakpoint(&breakpoints, &b);
888889
}
889890

891+
static void BreakAtCurrentInstruction(void) {
892+
struct Breakpoint b;
893+
if (IsAtBreakpoint(&breakpoints, m->ip) != -1) return;
894+
memset(&b, 0, sizeof(b));
895+
b.addr = m->ip;
896+
PushBreakpoint(&breakpoints, &b);
897+
}
898+
890899
static int DrainInput(int fd) {
891900
char buf[32];
892901
struct pollfd fds[1];
@@ -3033,6 +3042,7 @@ static void HandleKeyboard(const char *k) {
30333042
CASE('d', OnDown());
30343043
CASE('V', ++verbose);
30353044
CASE('p', showprofile = !showprofile);
3045+
CASE('b', BreakAtCurrentInstruction());
30363046
CASE('B', PopBreakpoint(&breakpoints));
30373047
CASE('M', ToggleMouseTracking());
30383048
CASE('\r', OnEnter());

0 commit comments

Comments
 (0)