Closed georgewsinger closed 3 years ago
Thanks for reporting this. It is indeed confusing behavior.
The cause of this is that in an unoptimized debug build the compiler will set aside a stack slot for the variable throughout the entire function lifetime, and emit corresponding debug info, despite the variable not yet being live at the beginning of the function. We need to also check the line numbers (as gdb does) to see if we've reached the right line before including the variable in the locals view (or rendering it without an uninitialized flag or something).
For now we'll just not show these variables. That will be deployed tomorrow.
Deployed.
In a trace, I have a function with local variable
fmt
which isn't immediately defined:When clicking on an execution of this function and opening the "Local Variables" view, Pernosco shows a bunch of garbage data in
fmt
. This tripped me up for a while (longer than I want to admit!) until I realized it was just uninitialized state that was showing garbage values.Pernosco shows the same garbage data values in GDB when you i.e.
print fmt
at the function break; however, if you step a few lines down it will eventually show the correct value through the GDB view. Contrasting with rr: when I try to print uninitialized local variables in rr I get, i.e., "Cannot access memory at address 0x3f8000003f80000".It might be a useful feature to somehow flag that the state being showed is uninitialized and/or show the eventual definition of a value cleverly somehow.