Skip to content

debuginfo: by-value function parameters are not described correctly.  #8512

Closed

Description

@michaelwoerister

Currently, debug info for the following code will not be correct:

struct Struct {
    a: int,
    b: float
}

fn struct_fun(by_val: Struct) {
    {...}
}

When breaking in struct_fun() GDB will report that there is no variable with name by_val. The reason is that by_val, having a non-immediate type, is really passed by reference as far as LLVM is concerned (see trans::base::copy_args_to_allocas()). The ty::t associated with the value, however, is still the non-pointer type. LLVM does not seem to like this during codegen and silently omits the debug info entry for the parameter (see CompileUnit::constructVariableDIE() in llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp). Consequently, GDB won't find anything for the name by_val.

A fix will probably involve DIBuilder::createComplexVariable().

Activity

  1. michaelwoerister commented on Aug 15, 2013

    @michaelwoerister
    MemberAuthor

    Update: After some research it seems that this is not fixable without LLVM modifications. That's the bad news. The good news is that clang has the same problem and there is some work under way to support this case in the DIBuilder: llvm-mirror/llvm@c971cb8

    The fix does not seem to be finished yet though.

  2. alexcrichton commented on Aug 15, 2013

    @alexcrichton
    Member

    That llvm commit will probably get included in #8328

  3. added a commit that references this issue on Nov 21, 2022
    5e29870
  4. added a commit that references this issue on Aug 21, 2026
    4118733
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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