1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-14 12:44:49 +00:00

Fix debug/break search algorithm.

This commit is contained in:
Calvin Rose 2019-09-22 18:08:38 -05:00
parent 9d020c3ec5
commit 45dfc7cc96
2 changed files with 15 additions and 11 deletions

View File

@ -802,28 +802,28 @@ Janet janet_asm_decode_instruction(uint32_t instr) {
case JINT_SU:
case JINT_SD:
ret = tup3(name,
janet_wrap_integer(oparg(1, 0xFF)),
janet_wrap_integer(oparg(2, 0xFFFF)));
janet_wrap_integer(oparg(1, 0xFF)),
janet_wrap_integer(oparg(2, 0xFFFF)));
break;
case JINT_SI:
case JINT_SL:
ret = tup3(name,
janet_wrap_integer(oparg(1, 0xFF)),
janet_wrap_integer((int32_t)instr >> 16));
janet_wrap_integer(oparg(1, 0xFF)),
janet_wrap_integer((int32_t)instr >> 16));
break;
case JINT_SSS:
case JINT_SES:
case JINT_SSU:
ret = tup4(name,
janet_wrap_integer(oparg(1, 0xFF)),
janet_wrap_integer(oparg(2, 0xFF)),
janet_wrap_integer(oparg(3, 0xFF)));
janet_wrap_integer(oparg(1, 0xFF)),
janet_wrap_integer(oparg(2, 0xFF)),
janet_wrap_integer(oparg(3, 0xFF)));
break;
case JINT_SSI:
ret = tup4(name,
janet_wrap_integer(oparg(1, 0xFF)),
janet_wrap_integer(oparg(2, 0xFF)),
janet_wrap_integer((int32_t)instr >> 24));
janet_wrap_integer(oparg(1, 0xFF)),
janet_wrap_integer(oparg(2, 0xFF)),
janet_wrap_integer((int32_t)instr >> 24));
break;
}
#undef oparg

View File

@ -74,7 +74,8 @@ void janet_debug_find(
int32_t line = def->sourcemap[i].line;
int32_t column = def->sourcemap[i].column;
if (line <= sourceLine && line >= best_line) {
if (column <= sourceColumn && column > best_column) {
if (column <= sourceColumn &&
(line > best_line || column > best_column)) {
best_line = line;
best_column = column;
besti = i;
@ -89,6 +90,9 @@ void janet_debug_find(
if (best_def) {
*def_out = best_def;
*pc_out = besti;
if (best_def->name) {
janet_printf("name: %S\n", best_def->name);
}
} else {
janet_panic("could not find breakpoint");
}