Hello all-

Given the following bttest.pike on a recent pike master, I get some unexpected behavior.

int main(int argc, array argv) {
mixed bt = backtrace(1)[(int)argv[1]]; 
write("%O\n", bt->fun); 
for(int i = 0; i < bt->num_locals; i++) 
  write("%O: %O\n", bt->get_local_name(i), bt->get_local(i));
return 0;
}

Run 1:
bin/pike bttest 0

master()->_main
"debugger": ({ /* 5 elements */
    "/Users/hww3/pikedbg/build/darwin-18.7.0-x86_64/pike",
    "-DPRECOMPILED_SEARCH_MORE",
    "-m/Users/hww3/pikedbg/build/darwin-18.7.0-x86_64/master.pike",
    "bttest",
    "0"
})
"argv": ({ /* 2 elements */
    "/Users/hww3/pikedbg/bttest",
    "0"
})
"debug": 0
"trace": 0
"run_tool": 0
"tmp": Getopt
"postparseaction": 0
"parts": 0
"i": master()->Version(8.1)
"have_debugger": 0
"debugger_wait": 0
"debugger_signal": 0
"debugger_port": 0
"t": /Users/hww3/pikedbg/bttest
"err": 0
"script": /Users/hww3/pikedbg/bttest()
"first_arg": int
0: 0
0: 0
0: 0
0: 0
0: 0
0: 0
0: 0
0: 0

Run 2:

bin/pike bttest 1

/main()->main
0: 2
0: ({ /* 2 elements */
    "/Users/hww3/pikedbg/bttest",
    "1"
})
"bt": _static_modules.Builtin()->LiveBacktraceFrame()
0: 3

Some questions:

1. It seems logical to me that out-of-scope locals have a local name of zero. However, it’s strange to me that function arguments, while treated as locals, don’t have names (see both examples). 
2. It’s also strange that the for-loop variable ‘i' doesn’t have a name. If I move the definition of ‘i’ ahead of the for loop, it does have a name.
3. The value of “debugger” from the first listing looks more like the value of orig_argv, which doesn’t appear elsewhere in the locals list. I also don’t seem to have a variable called “debugger” in my definition of “_main” (but there is a variable called “debugger” in the containing (master) object.

Am I doing something wrong in my use of these frames? I get similar strange behavior in the debugger itself, when the thread of the backtrace I’m examining is paused.

Bill