Skip to content

debuginfo: Generate debugging information for function level static variables #13144

Closed
@cmacknz

Description

@cmacknz

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:

  1. Identify when the variable it was called with was declared within a function.
  2. 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions