Skip to content

Commit

Permalink
fix: ci lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jayantxie committed Jul 10, 2024
1 parent a5b178f commit 31d7f2a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 52 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Goref

[![WebSite](https://img.shields.io/website?up_message=cloudwego&url=https%3A%2F%2Fwww.cloudwego.io%2F)](https://www.cloudwego.io/)
[![License](https://img.shields.io/github/license/cloudwego/goref)](https://github.com/cloudwego/goref/blob/main/LICENSE)
[![License](https://img.shields.io/github/license/cloudwego/goref)](https://github.com/cloudwego/goref/blob/main/LICENSE-APACHE)

Goref is a Go heap object reference analysis tool based on delve.
It can display the space and object count distribution of Go memory references, which is helpful for efficiently locating memory leak issues or viewing persistent heap objects to optimize GC overhead.
Expand Down Expand Up @@ -35,6 +35,9 @@ $ grf core ${execfile} ${corefile}
successfully output to `grf.out`
```

> Supported go version for executable file: go1.17 ~ go1.22. <br />
> Supported go version to compile the command tool: go1.21 ~ go1.22.
## Credit

Thanks to [Delve](https://github.com/go-delve/delve) for providing powerful golang debugger.
13 changes: 0 additions & 13 deletions pkg/proc/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,6 @@ const (

const fakeAddressUnresolv = 0xbeed000000000000

type localsFlags uint8

const (
// If localsTrustArgOrder is set function arguments that don't have an
// address will have one assigned by looking at their position in the argument
// list.
localsTrustArgOrder localsFlags = 1 << iota

// If localsNoDeclLineCheck the declaration line isn't checked at
// all to determine if the variable is in scope.
localsNoDeclLineCheck
)

type myEvalScope struct {
EvalScope

Expand Down
4 changes: 1 addition & 3 deletions pkg/proc/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,7 @@ func (s *ObjRefScope) specialStructTypes(st *godwarf.StructType) *godwarf.Struct
// v *sync.readOnly
nst := *st
nst.Field = make([]*godwarf.StructField, len(st.Field))
for j := range st.Field {
nst.Field[j] = st.Field[j]
}
copy(nst.Field, st.Field)
nf := *nst.Field[2]
nf.Type = nst.Field[0].Type.(*godwarf.ArrayType).Type
nst.Field[2] = &nf
Expand Down
19 changes: 6 additions & 13 deletions pkg/proc/unsafe.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package proc

import (
"debug/dwarf"
"reflect"
"unsafe"
_ "unsafe"

Expand Down Expand Up @@ -106,18 +105,12 @@ func readVarEntry(entry *godwarf.Tree, image *Image) (name string, typ godwarf.T
//go:linkname newVariable github.com/go-delve/delve/pkg/proc.newVariable
func newVariable(name string, addr uint64, dwarfType godwarf.Type, bi *BinaryInfo, mem MemoryReadWriter) *Variable

func uint64s2str(us []uint64) (s string) {
p := unsafe.Pointer((*reflect.SliceHeader)(unsafe.Pointer(&us)).Data)
hdr := (*reflect.StringHeader)(unsafe.Pointer(&s))
hdr.Data = uintptr(p)
hdr.Len = len(us) * 8
return
func uint64s2str(us []uint64) string {
p := unsafe.Pointer(unsafe.SliceData(us))
return unsafe.String((*byte)(p), len(us)*8)
}

func str2uint64s(s string) (us []uint64) {
p := unsafe.Pointer((*reflect.StringHeader)(unsafe.Pointer(&s)).Data)
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&us))
hdr.Data = uintptr(p)
hdr.Len, hdr.Cap = len(s)/8, len(s)/8
return
func str2uint64s(s string) []uint64 {
p := unsafe.Pointer(unsafe.StringData(s))
return unsafe.Slice((*uint64)(p), len(s)/8)
}
22 changes: 0 additions & 22 deletions pkg/proc/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"errors"
"fmt"
"reflect"
"strconv"

"github.com/go-delve/delve/pkg/dwarf/godwarf"
"github.com/go-delve/delve/pkg/goversion"
Expand Down Expand Up @@ -595,24 +594,3 @@ func resolveTypedef(typ godwarf.Type) godwarf.Type {
}
}
}

func filterVariables(vars []*Variable, pred func(v *Variable) bool) []*Variable {
r := make([]*Variable, 0, len(vars))
for i := range vars {
if pred(vars[i]) {
r = append(r, vars[i])
}
}
return r
}

func logPtrSize(ptrSize int) int {
switch ptrSize {
case 8:
return 3
case 4:
return 2
default:
panic("invalid ptrSize: " + strconv.Itoa(ptrSize))
}
}

0 comments on commit 31d7f2a

Please sign in to comment.