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

Function load_debugging_information

lua/sp.c:1797–2009  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1795}
1796
1797static int load_debugging_information(struct stored_proc *sp, char **err)
1798{
1799 int i, rc = 0;
1800 char *s;
1801 int idx = 1;
1802 const char *err_str = NULL;
1803 char *debug;
1804 char *sp_source;
1805 int source_size;
1806
1807 enable_global_variables(sp->lua);
1808
1809 sp_source = load_src(sp->spname, &sp->spversion, 0, err);
1810 if (sp_source) {
1811 source_size = strlen(sp_source);
1812 } else {
1813 reset_sp(sp);
1814 return -1;
1815 }
1816
1817 s = sp_source;
1818 lua_newtable(sp->lua);
1819 for (i = 0; i < source_size; i++) {
1820 if (sp_source[i] == '\n') {
1821 sp_source[i] = '\0';
1822 /*printf("%d> %s\n", idx, s);*/
1823 lua_pushstring(sp->lua, s);
1824 lua_rawseti(sp->lua, -2, idx++);
1825 s = &sp_source[i + 1];
1826 }
1827 }
1828 /* make this more hidden somehow? */
1829 lua_setglobal(sp->lua, "_thecode");
1830 if (sp->clnt->want_stored_procedure_trace) {
1831 debug = "function trace (event, line)\n"
1832 " local s = debug.getinfo(0).name \n"
1833 " if (s == 'return_type') then \n"
1834 " s = nil \n"
1835 " end \n"
1836 " if (s and _thecode[line]) then \n"
1837 " db.trace(line .. ':' .. _thecode[line])\n"
1838 " end\n"
1839 "end\n"
1840 "debug.sethook(trace, \"l\")\n";
1841 } else {
1842 /* REM : Use level 4 when trying to access variables in debugging. */
1843 debug = "_SP._breakpoints = {}\n"
1844 "_SP._variables = {}\n"
1845 "_SP.do_next = true\n" /* Have the breakpoint at first running
1846 line. */
1847 "_SP.curr_line = 0\n"
1848 "_SP.set_breakpoint = function(line) \n"
1849 " _SP._breakpoints[line] = true \n"
1850 " db.debug('Breakpoint set at line : ' .. line)\n"
1851 "end \n"
1852 "_SP.delete_breakpoint = function(line) \n"
1853 " _SP._breakpoints[line] = false \n"
1854 " db.debug('Breakpoint deleted from line : ' .. line)\n"

Callers 2

InstructionCountHookFunction · 0.85
setup_sp_intFunction · 0.85

Calls 12

enable_global_variablesFunction · 0.85
load_srcFunction · 0.85
reset_spFunction · 0.85
lua_pushstringFunction · 0.85
lua_rawsetiFunction · 0.85
stack_traceFunction · 0.85
lua_pcallFunction · 0.85
lua_isnumberFunction · 0.85
lua_tonumberFunction · 0.85
freeFunction · 0.85
logmsgFunction · 0.50
strdupFunction · 0.50

Tested by

no test coverage detected