How do I set a breakpoint inside a q function?
Consider the following function, testfunc:
testfunc: {[]
x: `aaa;
y: `bbb;
z:: `ccc;
-1 "finished!";
}
Let’s demonstrate the placement of a breakpoint prior to the assignment of global variable z. Although there is no explicit support for breakpoints in q, insertion of non-compliant code, such as breakhere; shown below, does the job (don’t forget the trailing semicolon):
testfunc: {[] x: `aaa;
y: `bbb;
breakhere;
z:: `ccc;
-1 “finished!”
}
We are tricking q into throwing a signal ‘breakhere.
q)testfunc[] {[] x: `aaa;
y: `bbb;
breakhere;
z:: `ccc;
-1 “finished!”
}
‘breakhere
q))
At this point, we can examine the local stack.
q))x
`aaa
q))y
`bbb
q))z
()
q))
kdb has suspended execution, leaving the remaining two lines of function testfunc unexecuted. : (colon) resumes execution.
q)):
finished!
-1
q)x
‘x
q)y
‘y
q)z
`ccc
q)
See: global amend (::)