source: code/trunk/vendor/modernc.org/ccgo/v3/lib/cover.go@ 822

Last change on this file since 822 was 822, checked in by yakumo.izuru, 22 months ago

Prefer immortal.run over runit and rc.d, use vendored modules
for convenience.

Signed-off-by: Izuru Yakumo <yakumo.izuru@…>

File size: 735 bytes
Line 
1// Copyright 2020 The CCGO 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
5package ccgo // import "modernc.org/ccgo/v3/lib"
6
7import (
8 "fmt"
9 "runtime"
10 "sort"
11 "strings"
12)
13
14var (
15 coverMap = map[uintptr]struct{}{}
16)
17
18func pc2origin(pc uintptr) string {
19 f := runtime.FuncForPC(pc)
20 var fn, fns string
21 var fl int
22 if f != nil {
23 fn, fl = f.FileLine(pc)
24 fns = f.Name()
25 if x := strings.LastIndex(fns, "."); x > 0 {
26 fns = fns[x+1:]
27 }
28 }
29 return fmt.Sprintf("%s:%d:%s", fn, fl, fns)
30}
31
32func coverReport() string {
33 var a []string
34 for pc := range coverMap {
35 a = append(a, pc2origin(pc))
36 }
37 sort.Strings(a)
38 return strings.Join(a, "\n")
39}
Note: See TracBrowser for help on using the repository browser.