Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: DW_AT_decl_line ignores //line directives #23704

Closed
heschik opened this issue Feb 5, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@heschik
Copy link
Contributor

commented Feb 5, 2018

What version of Go are you using (go version)?

go version devel +4558321eb2 Mon Feb 5 18:37:02 2018 +0000 linux/amd64

Does this issue reproduce with the latest release?

No, 1.9 doesn't have DW_AT_decl_line

What did you do?

$ cat > linedir.go
package main

func main() {
//line /foobar.go:200
	s := "hi world"
	println(s)
}

$ go build -gcflags="-N -l" linedir.go
$ readelf --debug-dump=info linedir

What did you expect to see?

DW_AT_decl_line 200

What did you see instead?

 <2><31721>: Abbrev Number: 9 (DW_TAG_variable)
    <31722>   DW_AT_name        : s
    <31724>   DW_AT_decl_line   : 5
    <31725>   DW_AT_type        : <0x23901>
    <31729>   DW_AT_location    : 2 byte block: 91 60   (DW_OP_fbreg: -32)

I verified that if I introduce a syntax error the compiler reports it at 200:

# command-line-arguments
/foobar.go:200: syntax error: unexpected ! at end of statement

@thanm Presumably this boils down to

declpos := Ctxt.InnermostPos(n.Pos)
returning the wrong thing somehow; any ideas how to fix it?

@heschik heschik added the Debugging label Feb 5, 2018

@thanm

This comment has been minimized.

Copy link
Member

commented Feb 5, 2018

I'd be happy to poke and it and see what I can find out. Off the top of my head I am not sure what the issue is (the code on line 422 is just picking the pos off the autom).

@thanm thanm self-assigned this Feb 5, 2018

@heschik

This comment has been minimized.

Copy link
Contributor Author

commented Feb 5, 2018

I was mostly just hoping you knew more about the way position information works than I did. Maybe @griesemer or @mdempsky can help?

@thanm

This comment has been minimized.

Copy link
Member

commented Feb 5, 2018

It looks as though perhaps the DWARF code should be using

			DeclFile:      declpos.RelFilename(),
			DeclLine:      declpos.RelLine(),

instead of the existing

			DeclFile:      declpos.Base().SymFilename(),
			DeclLine:      declpos.Line(),

?

@heschik

This comment has been minimized.

Copy link
Contributor Author

commented Feb 5, 2018

Good call. I looked at DW_AT_decl_file for functions, and it seems that's already correct, though I don't see how it happens exactly. You want to send the CL or shall I?

@gopherbot

This comment has been minimized.

Copy link

commented Feb 6, 2018

Change https://golang.org/cl/92255 mentions this issue: compiler: honor //line directives in DWARF variable file/line attrs

@thanm thanm added this to the Go1.11 milestone Feb 6, 2018

@gopherbot gopherbot closed this in b3cb740 Feb 15, 2018

@golang golang locked and limited conversation to collaborators Feb 15, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.