]> Cypherpunks repositories - gostls13.git/commit
debug/dwarf: heuristically handle both UNIX and Windows paths
authorAustin Clements <austin@google.com>
Wed, 24 May 2017 20:21:01 +0000 (16:21 -0400)
committerAustin Clements <austin@google.com>
Fri, 26 May 2017 14:35:20 +0000 (14:35 +0000)
commitc31231ccab371b31f5563a91e68720657799fe70
tree7f039d6252213823319e747269054150965acb7c
parent6654e3e0a1fa1deff4acf7d5ea68cd078df7e2fa
debug/dwarf: heuristically handle both UNIX and Windows paths

Currently debug/dwarf assumes all paths in line tables will be
UNIX-style paths, which obviously isn't the case for binaries built on
Windows. However, we can't simply switch from the path package to the
filepath package because we don't know that we're running on the same
host type that built the binary and we want this to work even if we're
not. This is essentially the approach taken by GDB, which treats paths
in accordance with the system GDB itself is compiled for. In fact, we
can't even guess the compilation system from the type of the binary
because it may have been cross-compiled.

We fix this by heuristically determining whether paths are UNIX-style
or DOS-style by looking for a drive letter or UNC path. If we see a
DOS-style path, we use appropriate logic for determining whether the
path is absolute and for joining two paths. This is helped by the fact
that we should basically always be starting with an absolute path.
However, it could mistake a relative UNIX-style path that begins with
a directory like "C:" for an absolute DOS-style path. There doesn't
seem to be any way around this.

Fixes #19784.

Change-Id: Ie13b546d2f1dcd8b02e668583a627b571b281588
Reviewed-on: https://go-review.googlesource.com/44017
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
src/debug/dwarf/export_test.go [new file with mode: 0644]
src/debug/dwarf/line.go
src/debug/dwarf/line_test.go
src/debug/dwarf/testdata/line-gcc-win.bin [new file with mode: 0644]
src/debug/dwarf/type_test.go