| 1494 | |
| 1495 | static void InstructionCountHook(Lua, lua_Debug *); |
| 1496 | static int db_debug(lua_State *lua) |
| 1497 | { |
| 1498 | int nargs = lua_gettop(lua); |
| 1499 | const char *trace; |
| 1500 | int rc; |
| 1501 | |
| 1502 | if (nargs > 2) |
| 1503 | return luabb_error(lua, NULL, |
| 1504 | "wrong number of arguments %d, should be 1", nargs); |
| 1505 | |
| 1506 | SP sp = getsp(lua); |
| 1507 | |
| 1508 | if (sp->debug_clnt->sp == NULL) { |
| 1509 | /* To be given as lrl value. */ |
| 1510 | logmsg(LOGMSG_ERROR, "debug client no longer valid \n"); |
| 1511 | sp->debug_clnt = sp->clnt; |
| 1512 | lua_sethook(lua, InstructionCountHook, LUA_MASKCOUNT, 1); |
| 1513 | Pthread_cond_broadcast(&lua_debug_cond); |
| 1514 | return 0; |
| 1515 | } |
| 1516 | |
| 1517 | if (sp->debug_clnt->want_stored_procedure_debug) { |
| 1518 | trace = lua_tostring(lua, -1); |
| 1519 | rc = send_sp_trace(sp->debug_clnt, trace, 0); |
| 1520 | if (rc) { |
| 1521 | if (sp->debug_clnt != sp->clnt) { |
| 1522 | /* To be given as lrl value. */ |
| 1523 | sp->debug_clnt = sp->clnt; |
| 1524 | lua_sethook(lua, InstructionCountHook, LUA_MASKCOUNT, 1); |
| 1525 | Pthread_cond_broadcast(&lua_debug_cond); |
| 1526 | return 0; |
| 1527 | } |
| 1528 | sleep(2); |
| 1529 | return luabb_error(lua, NULL, "Error in sending back data."); |
| 1530 | } |
| 1531 | } |
| 1532 | |
| 1533 | if (gbl_break_all_lua) { |
| 1534 | char sp_info[128]; |
| 1535 | int len; |
| 1536 | if (sp->spversion.version_num) { |
| 1537 | sprintf(sp_info, "%s:%d", sp->spname, sp->spversion.version_num); |
| 1538 | } else { |
| 1539 | sprintf(sp_info, "%s:%s", sp->spname, sp->spversion.version_str); |
| 1540 | } |
| 1541 | len = strlen(sp_info); |
| 1542 | if (strncasecmp(sp_info, gbl_break_spname, len) == 0) { |
| 1543 | gbl_break_lua = pthread_self(); |
| 1544 | } |
| 1545 | } |
| 1546 | |
| 1547 | if (gbl_break_lua && pthread_equal(gbl_break_lua, pthread_self())) { |
| 1548 | if (debug_clnt) { |
| 1549 | sp->debug_clnt = debug_clnt; |
| 1550 | sp->debug_clnt->sp = sp; |
| 1551 | debug_clnt = NULL; |
| 1552 | } |
| 1553 | char *buffer = "_SP.debug_next()"; |
no test coverage detected