qore
qore copied to clipboard
get_local_vars() does not work with top level variables
%new-style
%allow-debugger
string s = 'TOP';
sub test(int param) {
string sss = 'QWERTY';
printf("%d . %s\n", param, sss);
for (int i=0; i<4; i++) {
printf("i:%d: %y\n", i, get_local_vars(i));
}
}
test(9876);
9876 . QWERTY
i:0: {i: {type: "local", value: 0}, sss: {type: "local", value: "QWERTY"}, argv: {type: "local", value: null}, param: {type: "local", value: 9876}}
i:1: {}
i:2: {}
i:3: {}
get_local_vars also does not work in second thread when called from debugger. Even it is apparently normal call.
DebugProgramControl.qm
case 'list':
softlist l = keys get_local_vars(ctxCT.frameId + frameOffset);
logger.log(DUV_DEBUG_1, "get_local_vars(%y): %y, tid:%d", ctxCT.frameId + frameOffset, l, gettid());
for (int ii=0; ii<15; ii++) {
try {
logger.log(DUV_DEBUG_1, "get_local_vars(%y): %y, tid:%d", ii, get_local_vars(ii), gettid());
} catch (ex) {
}
}
Thread 3:
command: ["thread", "local", "", "list"]
get_local_vars(2): [], tid:3
get_local_vars(2): {}, tid:3
get_local_vars(3): {}, tid:3
get_local_vars(4): {}, tid:3
get_local_vars(5): {}, tid:3
get_local_vars(6): {}, tid:3
get_local_vars(7): {}, tid:3
The same place thread 2:
command: ["thread", "local", "", "list"]
get_local_vars(2): ["ref_arg_helper", "sss", "argv", "param"], tid:2
get_local_vars(2): {ref_arg_helper: {type: "local", value: 0}, sss: {type: "local", value: "QWERTY"}, argv: {type: "local", value: null}, param: {type: "local", value: 9876}},
tid:2
get_local_vars(3): {}, tid:2
get_local_vars(4): {}, tid:2
get_local_vars(5): {}, tid:2
get_local_vars(6): {}, tid:2
get_local_vars(7): {}, tid:2
Executed from program it is working:
tid:1, i:0: {i: {type: "local", value: 0}, sss: {type: "local", value: "QWERTY"}, argv: {type: "local", value: null}, param: {type: "local", value: 9876}}
tid:2, i:0: {i: {type: "local", value: 0}, sss: {type: "local", value: "QWERTY"}, argv: {type: "local", value: null}, param: {type: "local", value: 621}}
tid:1, i:1: {}
tid:1, i:2: {}
tid:1, i:3: {}
tid:2, i:1: {i: {type: "local", value: 0}, sss: {type: "local", value: "BACK"}, argv: {type: "local", value: null}}
tid:2, i:2: {}
tid:2, i:3: {}
Toplevel variables are thread variables (TopLevelStatementBlock). See also StatementBlock in block lvars. Both dynamically appears at stack (now).
But the main issue that get_var_frame does not consider context frames and frame boundaries via ThreadFrameBoundaryHelper when calling user function. Using just ProgramThreadCountContextHelper stack is not enough.