Skip to content

Commit b60d4fd

Browse files
committed
Merge branch 'debugger'
`:info` will output an error when there is no such function within the given function name.
2 parents fb2d307 + db2b19f commit b60d4fd

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/commands/debugger.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
#include "laco.h"
1010
#include "util.h"
1111

12-
void laco_print_debug_info(struct LacoState* laco,
13-
const char* function_name) {
12+
void laco_print_debug_info(LacoState* laco, const char* function_name) {
1413
int i;
1514
char* namespace;
1615
lua_State* L = laco_get_laco_lua_state(laco);
@@ -23,7 +22,15 @@ void laco_print_debug_info(struct LacoState* laco,
2322
/* Walk down the namespace if there is something to go down */
2423
for(i = 0; (namespace = namespaces[i]); i++) {
2524
lua_getfield(L, index, namespace);
25+
2626
index = lua_gettop(L);
27+
28+
if(lua_type(L, index) == LUA_TNIL) {
29+
printf("Couldn't find the function named \"%s\"\n", function_name);
30+
lua_pop(L, i + 1);
31+
32+
return;
33+
}
2734
}
2835

2936
lua_getinfo(L, ">Sl", &debug_info);

0 commit comments

Comments
 (0)