1
0
mirror of https://github.com/golang/go synced 2024-11-14 15:00:27 -07:00
go/src/debug
Austin Clements c31231ccab 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>
2017-05-26 14:35:20 +00:00
..
dwarf debug/dwarf: heuristically handle both UNIX and Windows paths 2017-05-26 14:35:20 +00:00
elf debug/elf: SPARC64 relocation type is only 8 bits 2016-11-10 22:58:49 +00:00
gosym cmd/objdump: copy gosym.PCValue into internal package 2016-12-01 18:20:04 +00:00
macho
pe cmd/link: actually generate .debug_gdb_scripts section on windows 2017-05-15 06:16:19 +00:00
plan9obj