Description
Support for crate level static variable debug info will be added once the patch for #9227 lands, but it does not include support for handling statics declared at the function level.
Fundamentally the new debuginfo::create_global_var_metadata()
function needs to be updated to do the following:
- Identify when the variable it was called with was declared within a function.
- Emit scope metadata indicating that the variable belongs to the function, rather than the containing crate.
The "correct" way to approach this would be to update debuginfo::populate_scope_map::walk_decl()
to handle the DeclItem
case for ItemStatic
items as is done for function local variables.
However, as a consequence of a bug in clang/llvm (see: http://llvm.org/bugs/show_bug.cgi?id=19238), passing the lexical scope metadata from a debuginfo::FunctionDebugContextData::scope_map
member to llvm::LLVMDIBuilderCreateStaticVariable()
results in a segfault when generating debug information.
The suggested work around is to use the function debug info as scope for the variable instead, with the consequence that the generated debug info will be not be entirely correct (similar to the clang case in the bug above).