• Austin Clements's avatar
    debug/dwarf: heuristically handle both UNIX and Windows paths · c31231cc
    Austin Clements authored
    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: 's avatarIan Lance Taylor <iant@golang.org>
    Reviewed-by: 's avatarAlex Brainman <alex.brainman@gmail.com>
    c31231cc