@@ -8,9 +8,11 @@ import (
8
8
intdwarf "cmd/internal/dwarf"
9
9
objfilepkg "cmd/internal/objfile" // renamed to avoid conflict with objfile function
10
10
"debug/dwarf"
11
+ "debug/pe"
11
12
"errors"
12
13
"fmt"
13
14
"internal/testenv"
15
+ "io"
14
16
"io/ioutil"
15
17
"os"
16
18
"os/exec"
@@ -1282,3 +1284,67 @@ func TestMachoIssue32233(t *testing.T) {
1282
1284
f := gobuildTestdata (t , tmpdir , pdir , DefaultOpt )
1283
1285
f .Close ()
1284
1286
}
1287
+
1288
+ func TestWindowsIssue36495 (t * testing.T ) {
1289
+ testenv .MustHaveGoBuild (t )
1290
+ if runtime .GOOS != "windows" {
1291
+ t .Skip ("skipping: test only on windows" )
1292
+ }
1293
+
1294
+ dir , err := ioutil .TempDir ("" , "TestEmbeddedStructMarker" )
1295
+ if err != nil {
1296
+ t .Fatalf ("could not create directory: %v" , err )
1297
+ }
1298
+ defer os .RemoveAll (dir )
1299
+
1300
+ prog := `
1301
+ package main
1302
+
1303
+ import "fmt"
1304
+
1305
+ func main() {
1306
+ fmt.Println("Hello World")
1307
+ }`
1308
+ f := gobuild (t , dir , prog , NoOpt )
1309
+ exe , err := pe .Open (f .path )
1310
+ if err != nil {
1311
+ t .Fatalf ("error opening pe file: %v" , err )
1312
+ }
1313
+ dw , err := exe .DWARF ()
1314
+ if err != nil {
1315
+ t .Fatalf ("error parsing DWARF: %v" , err )
1316
+ }
1317
+ rdr := dw .Reader ()
1318
+ for {
1319
+ e , err := rdr .Next ()
1320
+ if err != nil {
1321
+ t .Fatalf ("error reading DWARF: %v" , err )
1322
+ }
1323
+ if e == nil {
1324
+ break
1325
+ }
1326
+ if e .Tag != dwarf .TagCompileUnit {
1327
+ continue
1328
+ }
1329
+ lnrdr , err := dw .LineReader (e )
1330
+ if err != nil {
1331
+ t .Fatalf ("error creating DWARF line reader: %v" , err )
1332
+ }
1333
+ if lnrdr != nil {
1334
+ var lne dwarf.LineEntry
1335
+ for {
1336
+ err := lnrdr .Next (& lne )
1337
+ if err == io .EOF {
1338
+ break
1339
+ }
1340
+ if err != nil {
1341
+ t .Fatalf ("error reading next DWARF line: %v" , err )
1342
+ }
1343
+ if strings .Contains (lne .File .Name , `\` ) {
1344
+ t .Errorf ("filename should not contain backslash: %v" , lne .File .Name )
1345
+ }
1346
+ }
1347
+ }
1348
+ rdr .SkipChildren ()
1349
+ }
1350
+ }
0 commit comments