...

Source file src/debug/dwarf/dwarf5ranges_test.go

Documentation: debug/dwarf

     1  // Copyright 2020 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package dwarf
     6  
     7  import (
     8  	"encoding/binary"
     9  	"os"
    10  	"reflect"
    11  	"testing"
    12  )
    13  
    14  func TestDwarf5Ranges(t *testing.T) {
    15  	rngLists, err := os.ReadFile("testdata/debug_rnglists")
    16  	if err != nil {
    17  		t.Fatalf("could not read test data: %v", err)
    18  	}
    19  
    20  	d := &Data{}
    21  	d.order = binary.LittleEndian
    22  	if err := d.AddSection(".debug_rnglists", rngLists); err != nil {
    23  		t.Fatal(err)
    24  	}
    25  	u := &unit{
    26  		asize: 8,
    27  		vers:  5,
    28  		is64:  true,
    29  	}
    30  	ret, err := d.dwarf5Ranges(u, nil, 0x5fbd, 0xc, [][2]uint64{})
    31  	if err != nil {
    32  		t.Fatalf("could not read rnglist: %v", err)
    33  	}
    34  	t.Logf("%#v", ret)
    35  
    36  	tgt := [][2]uint64{{0x0000000000006712, 0x000000000000679f}, {0x00000000000067af}, {0x00000000000067b3}}
    37  
    38  	if reflect.DeepEqual(ret, tgt) {
    39  		t.Errorf("expected %#v got %#x", tgt, ret)
    40  	}
    41  }
    42  

View as plain text