aboutsummaryrefslogtreecommitdiff
path: root/src/debug/dwarf
diff options
context:
space:
mode:
Diffstat (limited to 'src/debug/dwarf')
-rw-r--r--src/debug/dwarf/line.go6
-rw-r--r--src/debug/dwarf/line_test.go8
2 files changed, 13 insertions, 1 deletions
diff --git a/src/debug/dwarf/line.go b/src/debug/dwarf/line.go
index 7692f05552..c4937ca7dd 100644
--- a/src/debug/dwarf/line.go
+++ b/src/debug/dwarf/line.go
@@ -814,7 +814,11 @@ func pathJoin(dirname, filename string) string {
// Drives are the same. Ignore drive on filename.
}
if !(strings.HasSuffix(dirname, "/") || strings.HasSuffix(dirname, `\`)) && dirname != "" {
- dirname += `\`
+ sep := `\`
+ if strings.HasPrefix(dirname, "/") {
+ sep = `/`
+ }
+ dirname += sep
}
return drive + dirname + filename
}
diff --git a/src/debug/dwarf/line_test.go b/src/debug/dwarf/line_test.go
index 1fd9b19b03..b13818e8b5 100644
--- a/src/debug/dwarf/line_test.go
+++ b/src/debug/dwarf/line_test.go
@@ -341,6 +341,14 @@ var joinTests = []joinTest{
{`\\host\share\`, `foo\bar`, `\\host\share\foo\bar`},
{`//host/share/`, `foo/bar`, `//host/share/foo/bar`},
+ // Note: the Go compiler currently emits DWARF line table paths
+ // with '/' instead of '\' (see issues #19784, #36495). These
+ // tests are to cover cases that might come up for Windows Go
+ // binaries.
+ {`c:/workdir/go/src/x`, `y.go`, `c:/workdir/go/src/x/y.go`},
+ {`d:/some/thing/`, `b.go`, `d:/some/thing/b.go`},
+ {`e:\blah\`, `foo.c`, `e:\blah\foo.c`},
+
// The following are "best effort". We shouldn't see relative
// base directories in DWARF, but these test that pathJoin
// doesn't fail miserably if it sees one.