Skip to content

cmd/compile: missing variables in debug_info for inlined subroutines #24460

@aarzilli

Description

@aarzilli

go version devel +ae10914 Tue Mar 20 09:44:50 2018 +0000 linux/amd64

If I compile the following:

package main

import "fmt"

func inlineThis(a int) int {
	z := a * a
	return z + a/a
}

func initialize(a, b *int) {
	*a = 3
	*b = 4
}

func main() {
	var a, b int
	initialize(&a, &b)
	a = inlineThis(a)
	b = inlineThis(b)
	fmt.Printf("%d %d\n", a, b)
}

with -gcflags='-N' the DIE for main.inlineThis is:

 <1><63404>: Abbrev Number: 3 (DW_TAG_subprogram)
    <63405>   DW_AT_name        : main.inlineThis
    <63415>   DW_AT_inline      : 1     (inlined)
    <63416>   DW_AT_external    : 1
 <2><63417>: Abbrev Number: 0

which doesn't have any local variables/parameters and neither do the corresponding DW_TAG_inlined_subroutine entries.

while with 1.10 I got:

 <1><649a0>: Abbrev Number: 3 (DW_TAG_subprogram)
    <649a1>   DW_AT_name        : main.inlineThis
    <649b1>   DW_AT_inline      : 1     (inlined)
    <649b2>   DW_AT_external    : 1
 <2><649b3>: Abbrev Number: 16 (DW_TAG_formal_parameter)
    <649b4>   DW_AT_name        : a
    <649b6>   DW_AT_variable_parameter: 0
    <649b7>   DW_AT_type        : <0x220d>
 <2><649bb>: Abbrev Number: 11 (DW_TAG_variable)
    <649bc>   DW_AT_name        : z
    <649be>   DW_AT_decl_line   : 6
    <649bf>   DW_AT_type        : <0x220d>
 <2><649c3>: Abbrev Number: 0

Bisect says b3cb740 is the first bad commit. However that commit seems pretty tame, I'm not sure what's going on.

cc @heschik @thanm

Metadata

Metadata

Assignees

No one assigned

    Labels

    DebuggingFrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions