MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / db_db_debug

Function db_db_debug

lua/sp.c:1566–1637  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1564}
1565
1566static int db_db_debug(Lua lua)
1567{
1568 char *replace_from = NULL;
1569 int finish_execute = 0;
1570 for (;;) {
1571 char buffer[250] = {0};
1572 int n = get_remote_input(lua, buffer, sizeof(buffer));
1573 if (strncmp(buffer, "cont", 4) == 0) {
1574 Pthread_cond_broadcast(&lua_debug_cond);
1575 sprintf(buffer, " %s", "_SP.do_next = false \n if (db.emit) then "
1576 "\n db_emit = db.emit \n end");
1577 finish_execute = 1;
1578 } else if (strncmp(buffer, "help", 4) == 0) {
1579 sprintf(buffer, " %s()", "_SP.help");
1580 } else if (strncmp(buffer, "next", 4) == 0) {
1581 sprintf(buffer, " %s()", "_SP.debug_next");
1582 finish_execute = 1;
1583 } else if (strncmp(buffer, "breakpoints", 11) == 0) {
1584 sprintf(buffer, " %s()", "_SP.bkps");
1585 } else if (strncmp(buffer, "stop at", 7) == 0) {
1586 int i = atoi(&buffer[7]);
1587 sprintf(buffer, " %s(%d)", "_SP.set_breakpoint", i);
1588 } else if (strncmp(buffer, "list", 4) == 0) {
1589 int i = atoi(&buffer[4]);
1590 sprintf(buffer, " %s(%d)", "_SP.list_code", i);
1591 } else if (strncmp(buffer, "delete at", 9) == 0) {
1592 int i = atoi(&buffer[9]);
1593 sprintf(buffer, " %s(%d)", "_SP.delete_breakpoint", i);
1594 } else if (strncmp(buffer, "print ", 6) == 0) {
1595 char old_buffer[sizeof(buffer)];
1596 sprintf(old_buffer, "%s", buffer);
1597 int len = strlen(&old_buffer[6]);
1598 old_buffer[6 + len - 1] = '\0';
1599 sprintf(buffer, "eval('%s')", old_buffer + 6);
1600 } else if (strncmp(buffer, "getinfo", 7) == 0) {
1601 sprintf(buffer, " %s", "_SP.getinfo(5)");
1602 } else if (strncmp(buffer, "HALT", 4) == 0) {
1603 logmsg(LOGMSG_USER, "Halt should not be coming here...\n");
1604 continue;
1605 } else if (strncmp(buffer, "where", 5) == 0) {
1606 sprintf(buffer, " %s", "_SP.where()");
1607 } else if ((replace_from = strstr(buffer, "getvariable")) != 0) {
1608 char *arguments = replace_from + strlen("getvariable");
1609 snprintf0(buffer, sizeof(buffer), "_SP.get_var%s", arguments);
1610 replace_from = NULL;
1611 } else if ((replace_from = strstr(buffer, "setvariable")) != 0) {
1612 char *arguments = replace_from + strlen("setvariable");
1613 snprintf0(buffer, sizeof(buffer), "_SP.set_var%s", arguments);
1614 replace_from = NULL;
1615 } else if (n == 0) {
1616 /* Debugging socket is closed, let the program continue. */
1617 Pthread_cond_broadcast(&lua_debug_cond);
1618 sprintf(buffer, " %s", "db_emit = db.emit");
1619 finish_execute = 1;
1620 } else if (buffer[0] == '\0') {
1621 /* Debugging socket is closed, let the program continue. */
1622 sprintf(buffer, " %s()", "_SP.debug_next");
1623 }

Callers

nothing calls this directly

Calls 7

get_remote_inputFunction · 0.85
snprintf0Function · 0.85
luaL_loadbufferFunction · 0.85
lua_pcallFunction · 0.85
lua_settopFunction · 0.85
db_debugFunction · 0.70
logmsgFunction · 0.50

Tested by

no test coverage detected