*: clean up staticcheck problems (#2723)
Fix problems that can be fixed, ignore the ones that don't make sense
This commit is contained in:
parent
efc4483175
commit
29eae8f617
@ -1,62 +0,0 @@
|
||||
pkg/dwarf/dwarfbuilder/info.go:122:2: redundant return statement (S1023)
|
||||
pkg/dwarf/dwarfbuilder/info.go:127:5: builtin function len does not return negative values (SA4024)
|
||||
pkg/dwarf/line/line_parser.go:249:6: every value of type uint64 is >= 0 (SA4003)
|
||||
pkg/dwarf/line/line_parser.go:286:15: should omit type int from declaration; it will be inferred from the right-hand side (ST1023)
|
||||
pkg/dwarf/line/state_machine.go:151:2: redundant return statement (S1023)
|
||||
pkg/dwarf/line/state_machine.go:154:5: error var NoSourceError should have name of the form ErrFoo (ST1012)
|
||||
pkg/dwarf/line/state_machine.go:193:2: should merge variable declaration with assignment on next line (S1021)
|
||||
pkg/dwarf/reader/reader.go:77:5: error var TypeNotFoundErr should have name of the form ErrFoo (ST1012)
|
||||
pkg/goversion/compat.go:12:2: error var goTooOldErr should have name of the form errFoo (ST1012)
|
||||
pkg/goversion/compat.go:12:33: error strings should not be capitalized (ST1005)
|
||||
pkg/goversion/compat.go:13:2: error var dlvTooOldErr should have name of the form errFoo (ST1012)
|
||||
pkg/goversion/compat.go:13:33: error strings should not be capitalized (ST1005)
|
||||
pkg/locspec/locations.go:71:10: error strings should not be capitalized (ST1005)
|
||||
pkg/locspec/locations.go:110:10: error strings should not be capitalized (ST1005)
|
||||
pkg/locspec/locations.go:423:16: error strings should not be capitalized (ST1005)
|
||||
pkg/proc/bininfo.go:249:18: unnecessary assignment to the blank identifier (S1005)
|
||||
pkg/proc/bininfo.go:253:19: unnecessary assignment to the blank identifier (S1005)
|
||||
pkg/proc/bininfo.go:257:19: unnecessary assignment to the blank identifier (S1005)
|
||||
pkg/proc/bininfo.go:1268:2: unnecessary nil check around range (S1031)
|
||||
pkg/proc/core/minidump/fileflags_string.go:62:7: every value of type uint16 is >= 0 (SA4003)
|
||||
pkg/proc/core/minidump/minidump.go:424:3: should merge variable declaration with assignment on next line (S1021)
|
||||
pkg/proc/eval.go:324:10: error strings should not be capitalized (ST1005)
|
||||
pkg/proc/eval.go:395:10: error strings should not be capitalized (ST1005)
|
||||
pkg/proc/eval.go:399:10: error strings should not be capitalized (ST1005)
|
||||
pkg/proc/native/threads_linux_amd64.go:42:3: redundant return statement (S1023)
|
||||
pkg/proc/stack.go:398:2: this value of err is never used (SA4006)
|
||||
pkg/proc/stack.go:424:12: error strings should not be capitalized (ST1005)
|
||||
pkg/proc/target_exec.go:161:6: this value of err is never used (SA4006)
|
||||
pkg/proc/target_exec.go:810:3: when isexists is true, err can't be nil (S1020)
|
||||
pkg/proc/variables.go:1481:21: error strings should not be capitalized (ST1005)
|
||||
pkg/proc/variables.go:1569:18: error strings should not be capitalized (ST1005)
|
||||
pkg/proc/variables.go:2243:44: should use !strings.Contains(typename, ".") instead (S1003)
|
||||
pkg/proc/variables.go:2385:4: should replace this if statement with an unconditional strings.TrimPrefix (S1017)
|
||||
pkg/proc/winutil/regs.go:167:2: should merge variable declaration with assignment on next line (S1021)
|
||||
pkg/terminal/command.go:650:5: error var noCmdError should have name of the form errFoo (ST1012)
|
||||
pkg/terminal/command.go:986:9: unnecessary assignment to the blank identifier (S1005)
|
||||
pkg/terminal/command.go:1062:10: error strings should not be capitalized (ST1005)
|
||||
pkg/terminal/command.go:1069:10: error strings should not be capitalized (ST1005)
|
||||
pkg/terminal/command.go:1337:15: error strings should not be capitalized (ST1005)
|
||||
pkg/terminal/command.go:1521:15: error strings should not be capitalized (ST1005)
|
||||
pkg/terminal/command.go:1544:5: error var notOnFrameZeroErr should have name of the form errFoo (ST1012)
|
||||
pkg/terminal/command.go:1600:10: error strings should not be capitalized (ST1005)
|
||||
pkg/terminal/command.go:1915:11: error strings should not be capitalized (ST1005)
|
||||
pkg/terminal/command.go:2420:25: error strings should not be capitalized (ST1005)
|
||||
pkg/terminal/command.go:2479:5: error var disasmUsageError should have name of the form errFoo (ST1012)
|
||||
pkg/terminal/starbind/conv.go:243:40: 'bitSize' argument is invalid, must be either 32 or 64 (SA1030)
|
||||
pkg/terminal/starbind/conv.go:292:9: the argument is already a string, there's no need to use fmt.Sprintf (S1025)
|
||||
pkg/terminal/starbind/conv.go:352:9: the argument is already a string, there's no need to use fmt.Sprintf (S1025)
|
||||
pkg/terminal/starbind/conv.go:418:9: the argument is already a string, there's no need to use fmt.Sprintf (S1025)
|
||||
pkg/terminal/starbind/conv.go:497:9: the argument is already a string, there's no need to use fmt.Sprintf (S1025)
|
||||
pkg/terminal/terminal.go:282:14: error strings should not be capitalized (ST1005)
|
||||
pkg/terminal/terminal.go:282:14: error strings should not end with punctuation or a newline (ST1005)
|
||||
service/api/prettyprint.go:156:9: should omit type bool from declaration; it will be inferred from the right-hand side (ST1023)
|
||||
service/api/prettyprint.go:190:9: should omit type complex128 from declaration; it will be inferred from the right-hand side (ST1023)
|
||||
service/dap/server.go:1448:11: should omit type AttachConfig from declaration; it will be inferred from the right-hand side (ST1023)
|
||||
service/dap/utils.go:5:6: func min is unused (U1000)
|
||||
service/debugger/debugger.go:946:5: builtin function len does not return negative values (SA4024)
|
||||
service/debugger/debugger_linux.go:20:12: error strings should not be capitalized (ST1005)
|
||||
service/debugger/debugger_linux.go:27:12: error strings should not be capitalized (ST1005)
|
||||
service/rpc1/client.go:23:5: error var unsupportedApiError should have name of the form errFoo (ST1012)
|
||||
service/rpc1/client.go:78:17: error strings should not be capitalized (ST1005)
|
||||
service/rpc2/client.go:111:17: error strings should not be capitalized (ST1005)
|
@ -888,7 +888,15 @@ func TestStaticcheck(t *testing.T) {
|
||||
t.Skip("staticcheck not installed")
|
||||
}
|
||||
// default checks minus SA1019 which complains about deprecated identifiers, which change between versions of Go.
|
||||
args := []string{"-tests=false", "-checks=all,-SA1019,-ST1000,-ST1003,-ST1016,-ST1020,-ST1021,-ST1022", "github.com/go-delve/delve/..."}
|
||||
args := []string{"-tests=false", "-checks=all,-SA1019,-ST1000,-ST1003,-ST1016,-S1021,-ST1023", "github.com/go-delve/delve/..."}
|
||||
// * SA1019 is disabled because new deprecations get added on every version
|
||||
// of Go making the output of staticcheck inconsistent depending on the
|
||||
// version of Go used to run it.
|
||||
// * ST1000,ST1003,ST1016 are disabled in the default
|
||||
// staticcheck configuration
|
||||
// * S1021 "Merge variable declaration and assignment" is disabled because
|
||||
// where we don't do this it is a deliberate style choice.
|
||||
// * ST1023 "Redundant type in variable declaration" same as S1021.
|
||||
cmd := exec.Command("staticcheck", args...)
|
||||
cmd.Dir = projectRoot()
|
||||
cmd.Env = append(os.Environ(), "GOOS=linux", "GOARCH=amd64")
|
||||
|
@ -119,12 +119,11 @@ func (b *Builder) TagClose() {
|
||||
b.info.WriteByte(0)
|
||||
}
|
||||
b.tagStack = b.tagStack[:len(b.tagStack)-1]
|
||||
return
|
||||
}
|
||||
|
||||
// Attr adds an attribute to the current DIE.
|
||||
func (b *Builder) Attr(attr dwarf.Attr, val interface{}) dwarf.Offset {
|
||||
if len(b.tagStack) < 0 {
|
||||
if len(b.tagStack) == 0 {
|
||||
panic("Attr with no open tags")
|
||||
}
|
||||
off := dwarf.Offset(b.info.Len())
|
||||
|
@ -529,7 +529,7 @@ func (t *UnsupportedType) stringIntl(recCheck) string {
|
||||
|
||||
func (t *UnsupportedType) String() string { return t.stringIntl(nil) }
|
||||
|
||||
// Type reads the type at off in the DWARF ``info'' section.
|
||||
// ReadType reads the type at off in the DWARF ``info'' section.
|
||||
func ReadType(d *dwarf.Data, index int, off dwarf.Offset, typeCache map[dwarf.Offset]Type) (Type, error) {
|
||||
typ, err := readType(d, "info", d.Reader(), off, typeCache, nil)
|
||||
if typ != nil {
|
||||
|
@ -246,7 +246,7 @@ func readFileEntry(info *DebugLineInfo, buf *bytes.Buffer, exitOnEmptyPath bool)
|
||||
entry.LastModTime, _ = util.DecodeULEB128(buf)
|
||||
entry.Length, _ = util.DecodeULEB128(buf)
|
||||
if !pathIsAbs(entry.Path) {
|
||||
if entry.DirIdx >= 0 && entry.DirIdx < uint64(len(info.IncludeDirs)) {
|
||||
if entry.DirIdx < uint64(len(info.IncludeDirs)) {
|
||||
entry.Path = path.Join(info.IncludeDirs[entry.DirIdx], entry.Path)
|
||||
}
|
||||
}
|
||||
@ -283,7 +283,8 @@ func parseFileEntries5(info *DebugLineInfo, buf *bytes.Buffer) bool {
|
||||
for fileEntryFormReader.next(buf) {
|
||||
entry := new(FileEntry)
|
||||
var p string
|
||||
var diridx int = -1
|
||||
var diridx int
|
||||
diridx = -1
|
||||
|
||||
switch fileEntryFormReader.contentType {
|
||||
case _DW_LNCT_path:
|
||||
|
@ -148,16 +148,15 @@ func (lineInfo *DebugLineInfo) AllPCsForFileLines(f string, m map[int][]uint64)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var NoSourceError = errors.New("no source available")
|
||||
var ErrNoSource = errors.New("no source available")
|
||||
|
||||
// AllPCsBetween returns all PC addresses between begin and end (including both begin and end)
|
||||
// that have the is_stmt flag set and do not belong to excludeFile:excludeLine.
|
||||
func (lineInfo *DebugLineInfo) AllPCsBetween(begin, end uint64, excludeFile string, excludeLine int) ([]uint64, error) {
|
||||
if lineInfo == nil {
|
||||
return nil, NoSourceError
|
||||
return nil, ErrNoSource
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -33,7 +33,7 @@ func (reader *Reader) SeekToEntry(entry *dwarf.Entry) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Returns the address for the named entry.
|
||||
// AddrFor returns the address for the named entry.
|
||||
func (reader *Reader) AddrFor(name string, staticBase uint64, ptrSize int) (uint64, error) {
|
||||
entry, err := reader.FindEntryNamed(name, false)
|
||||
if err != nil {
|
||||
@ -50,31 +50,7 @@ func (reader *Reader) AddrFor(name string, staticBase uint64, ptrSize int) (uint
|
||||
return uint64(addr), nil
|
||||
}
|
||||
|
||||
// Returns the address for the named struct member. Expects the reader to be at the parent entry
|
||||
// or one of the parents children, thus does not seek to parent by itself.
|
||||
func (reader *Reader) AddrForMember(member string, initialInstructions []byte, ptrSize int) (uint64, error) {
|
||||
for {
|
||||
entry, err := reader.NextMemberVariable()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if entry == nil {
|
||||
return 0, fmt.Errorf("nil entry for member named %s", member)
|
||||
}
|
||||
name, ok := entry.Val(dwarf.AttrName).(string)
|
||||
if !ok || name != member {
|
||||
continue
|
||||
}
|
||||
instructions, ok := entry.Val(dwarf.AttrDataMemberLoc).([]byte)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
addr, _, err := op.ExecuteStackProgram(op.DwarfRegisters{}, append(initialInstructions, instructions...), ptrSize, nil)
|
||||
return uint64(addr), err
|
||||
}
|
||||
}
|
||||
|
||||
var TypeNotFoundErr = errors.New("no type entry found, use 'types' for a list of valid types")
|
||||
var ErrTypeNotFound = errors.New("no type entry found, use 'types' for a list of valid types")
|
||||
|
||||
// SeekToType moves the reader to the type specified by the entry,
|
||||
// optionally resolving typedefs and pointer types. If the reader is set
|
||||
@ -110,7 +86,7 @@ func (reader *Reader) SeekToType(entry *dwarf.Entry, resolveTypedefs bool, resol
|
||||
reader.Seek(offset)
|
||||
}
|
||||
|
||||
return nil, TypeNotFoundErr
|
||||
return nil, ErrTypeNotFound
|
||||
}
|
||||
|
||||
func (reader *Reader) NextType() (*dwarf.Entry, error) {
|
||||
@ -148,10 +124,10 @@ func (reader *Reader) SeekToTypeNamed(name string) (*dwarf.Entry, error) {
|
||||
}
|
||||
}
|
||||
|
||||
return nil, TypeNotFoundErr
|
||||
return nil, ErrTypeNotFound
|
||||
}
|
||||
|
||||
// Finds the entry for 'name'.
|
||||
// FindEntryNamed finds the entry for 'name'.
|
||||
func (reader *Reader) FindEntryNamed(name string, member bool) (*dwarf.Entry, error) {
|
||||
depth := 1
|
||||
for entry, err := reader.Next(); entry != nil; entry, err = reader.Next() {
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
// Buffered reading and decoding of DWARF data streams.
|
||||
|
||||
//lint:file-ignore ST1021 imported file
|
||||
|
||||
package util
|
||||
|
||||
import (
|
||||
|
@ -173,7 +173,7 @@ func WriteUint(writer io.Writer, order binary.ByteOrder, ptrSize int, data uint6
|
||||
return fmt.Errorf("pointer size %d not supported", ptrSize)
|
||||
}
|
||||
|
||||
// ReadDwarfLength reads a DWARF length field followed by a version field
|
||||
// ReadDwarfLengthVersion reads a DWARF length field followed by a version field
|
||||
func ReadDwarfLengthVersion(data []byte) (length uint64, dwarf64 bool, version uint8, byteOrder binary.ByteOrder) {
|
||||
if len(data) < 4 {
|
||||
return 0, false, 0, binary.LittleEndian
|
||||
|
@ -68,6 +68,7 @@ func Parse(locStr string) (LocationSpec, error) {
|
||||
rest := locStr
|
||||
|
||||
malformed := func(reason string) error {
|
||||
//lint:ignore ST1005 backwards compatibility
|
||||
return fmt.Errorf("Malformed breakpoint location \"%s\" at %d: %s", locStr, len(locStr)-len(rest), reason)
|
||||
}
|
||||
|
||||
@ -107,6 +108,7 @@ func Parse(locStr string) (LocationSpec, error) {
|
||||
|
||||
func parseLocationSpecDefault(locStr, rest string) (LocationSpec, error) {
|
||||
malformed := func(reason string) error {
|
||||
//lint:ignore ST1005 backwards compatibility
|
||||
return fmt.Errorf("Malformed breakpoint location \"%s\" at %d: %s", locStr, len(locStr)-len(rest), reason)
|
||||
}
|
||||
|
||||
@ -420,6 +422,7 @@ func (loc *NormalLocationSpec) Find(t *proc.Target, processArgs []string, scope
|
||||
var err error
|
||||
if len(candidateFiles) == 1 {
|
||||
if loc.LineOffset < 0 {
|
||||
//lint:ignore ST1005 backwards compatibility
|
||||
return nil, fmt.Errorf("Malformed breakpoint location, no line offset specified")
|
||||
}
|
||||
addrs, err = proc.FindFileLocation(t, candidateFiles[0], loc.LineOffset)
|
||||
|
@ -246,15 +246,15 @@ func (e *ErrUnsupportedArch) Error() string {
|
||||
var supportArchs []cpuArch
|
||||
switch e.os {
|
||||
case "linux":
|
||||
for linuxArch, _ := range supportedLinuxArch {
|
||||
for linuxArch := range supportedLinuxArch {
|
||||
supportArchs = append(supportArchs, linuxArch)
|
||||
}
|
||||
case "windows":
|
||||
for windowArch, _ := range supportedWindowsArch {
|
||||
for windowArch := range supportedWindowsArch {
|
||||
supportArchs = append(supportArchs, windowArch)
|
||||
}
|
||||
case "darwin":
|
||||
for darwinArch, _ := range supportedDarwinArch {
|
||||
for darwinArch := range supportedDarwinArch {
|
||||
supportArchs = append(supportArchs, darwinArch)
|
||||
}
|
||||
}
|
||||
@ -1265,14 +1265,12 @@ func (bi *BinaryInfo) loadSymbolName(image *Image, file *elf.File, wg *sync.Wait
|
||||
bi.SymNames = make(map[uint64]*elf.Symbol)
|
||||
}
|
||||
symSecs, _ := file.Symbols()
|
||||
if symSecs != nil {
|
||||
for _, symSec := range symSecs {
|
||||
if symSec.Info == _STT_FUNC { // TODO(chainhelen), need to parse others types.
|
||||
s := symSec
|
||||
bi.SymNames[symSec.Value+image.StaticBase] = &s
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (bi *BinaryInfo) parseDebugFrameElf(image *Image, exe *elf.File, debugInfoBytes []byte, wg *sync.WaitGroup) {
|
||||
@ -1599,7 +1597,7 @@ func (bi *BinaryInfo) macOSDebugFrameBugWorkaround() {
|
||||
func (bi *BinaryInfo) findType(name string) (godwarf.Type, error) {
|
||||
ref, found := bi.types[name]
|
||||
if !found {
|
||||
return nil, reader.TypeNotFoundErr
|
||||
return nil, reader.ErrTypeNotFound
|
||||
}
|
||||
image := bi.Images[ref.imageIndex]
|
||||
return godwarf.ReadType(image.dwarf, ref.imageIndex, ref.offset, image.typeCache)
|
||||
|
@ -724,7 +724,7 @@ func (t *Target) ClearBreakpoint(addr uint64) (*Breakpoint, error) {
|
||||
return bp, nil
|
||||
}
|
||||
|
||||
// ClearInternalBreakpoints removes all stepping breakpoints from the map,
|
||||
// ClearSteppingBreakpoints removes all stepping breakpoints from the map,
|
||||
// calling clearBreakpoint on each one.
|
||||
func (t *Target) ClearSteppingBreakpoints() error {
|
||||
bpmap := t.Breakpoints()
|
||||
|
@ -59,7 +59,7 @@ var (
|
||||
|
||||
func (i Arch) String() string {
|
||||
switch {
|
||||
case 0 <= i && i <= 10:
|
||||
case i <= 10:
|
||||
return _Arch_name_0[_Arch_index_0[i]:_Arch_index_0[i+1]]
|
||||
case i == 12:
|
||||
return _Arch_name_1
|
||||
|
@ -155,7 +155,7 @@ type Module struct {
|
||||
MiscRecord []byte
|
||||
}
|
||||
|
||||
// VSFixedFileInfo: Visual Studio Fixed File Info.
|
||||
// VSFixedFileInfo Visual Studio Fixed File Info.
|
||||
// See: https://docs.microsoft.com/en-us/windows/win32/api/verrsrc/ns-verrsrc-vs_fixedfileinfo
|
||||
type VSFixedFileInfo struct {
|
||||
Signature uint32
|
||||
|
@ -321,6 +321,7 @@ func (scope *EvalScope) setValue(dstv, srcv *Variable, srcExpr string) error {
|
||||
}
|
||||
|
||||
if srcv.Unreadable != nil {
|
||||
//lint:ignore ST1005 backwards compatibility
|
||||
return fmt.Errorf("Expression \"%s\" is unreadable: %v", srcExpr, srcv.Unreadable)
|
||||
}
|
||||
|
||||
@ -392,10 +393,12 @@ func (scope *EvalScope) SetVariable(name, value string) error {
|
||||
}
|
||||
|
||||
if xv.Addr == 0 {
|
||||
//lint:ignore ST1005 backwards compatibility
|
||||
return fmt.Errorf("Can not assign to \"%s\"", name)
|
||||
}
|
||||
|
||||
if xv.Unreadable != nil {
|
||||
//lint:ignore ST1005 backwards compatibility
|
||||
return fmt.Errorf("Expression \"%s\" is unreadable: %v", name, xv.Unreadable)
|
||||
}
|
||||
|
||||
@ -701,7 +704,7 @@ func (scope *EvalScope) evalAST(t ast.Expr) (*Variable, error) {
|
||||
case *ast.CallExpr:
|
||||
if len(node.Args) == 1 {
|
||||
v, err := scope.evalTypeCast(node)
|
||||
if err == nil || err != reader.TypeNotFoundErr {
|
||||
if err == nil || err != reader.ErrTypeNotFound {
|
||||
return v, err
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"github.com/go-delve/delve/pkg/proc"
|
||||
)
|
||||
|
||||
// Regs is a wrapper for sys.PtraceRegs.
|
||||
// ARM64Registers is a wrapper for sys.PtraceRegs.
|
||||
type ARM64Registers struct {
|
||||
Regs *ARM64PtraceRegs //general-purpose registers
|
||||
iscgo bool
|
||||
|
@ -39,7 +39,6 @@ func (t *nativeThread) restoreRegisters(savedRegs proc.Registers) error {
|
||||
}
|
||||
|
||||
_, _, restoreRegistersErr = syscall.Syscall6(syscall.SYS_PTRACE, sys.PTRACE_SETFPREGS, uintptr(t.ID), uintptr(0), uintptr(unsafe.Pointer(&sr.Fpregset.AMD64PtraceFpRegs)), 0, 0)
|
||||
return
|
||||
})
|
||||
if restoreRegistersErr == syscall.Errno(0) {
|
||||
restoreRegistersErr = nil
|
||||
|
@ -397,7 +397,7 @@ func (it *stackIterator) advanceRegs() (callFrameRegs op.DwarfRegisters, ret uin
|
||||
|
||||
cfareg, err := it.executeFrameRegRule(0, framectx.CFA, 0)
|
||||
if cfareg == nil {
|
||||
it.err = fmt.Errorf("CFA becomes undefined at PC %#x", it.pc)
|
||||
it.err = fmt.Errorf("CFA becomes undefined at PC %#x: %v", it.pc, err)
|
||||
return op.DwarfRegisters{}, 0, 0
|
||||
}
|
||||
it.regs.CFA = int64(cfareg.Uint64Val)
|
||||
@ -421,6 +421,7 @@ func (it *stackIterator) advanceRegs() (callFrameRegs op.DwarfRegisters, ret uin
|
||||
if i == framectx.RetAddrReg {
|
||||
if reg == nil {
|
||||
if err == nil {
|
||||
//lint:ignore ST1005 backwards compatibility
|
||||
err = fmt.Errorf("Undefined return address at %#x", it.pc)
|
||||
}
|
||||
it.err = err
|
||||
|
@ -158,7 +158,7 @@ func (dbp *Target) Continue() error {
|
||||
if !arch.BreakInstrMovesPC() {
|
||||
bpsize := arch.BreakpointSize()
|
||||
bp := make([]byte, bpsize)
|
||||
_, err = dbp.Memory().ReadMemory(bp, loc.PC)
|
||||
dbp.Memory().ReadMemory(bp, loc.PC)
|
||||
if bytes.Equal(bp, arch.BreakpointInstruction()) {
|
||||
setPC(curthread, loc.PC+uint64(bpsize))
|
||||
}
|
||||
@ -807,6 +807,7 @@ func setStepIntoBreakpoint(dbp *Target, curfn *Function, text []AsmInstruction,
|
||||
|
||||
func allowDuplicateBreakpoint(bp *Breakpoint, err error) (*Breakpoint, error) {
|
||||
if err != nil {
|
||||
//lint:ignore S1020 this is clearer
|
||||
if _, isexists := err.(BreakpointExistsError); isexists {
|
||||
return bp, nil
|
||||
}
|
||||
|
@ -1478,6 +1478,7 @@ func (v *Variable) loadSliceInfo(t *godwarf.SliceType) {
|
||||
// Dereference array type to get value type
|
||||
ptrType, ok := f.Type.(*godwarf.PtrType)
|
||||
if !ok {
|
||||
//lint:ignore ST1005 backwards compatibility
|
||||
v.Unreadable = fmt.Errorf("Invalid type %s in slice array", f.Type)
|
||||
return
|
||||
}
|
||||
@ -1566,6 +1567,7 @@ func (v *Variable) loadArrayValues(recurseLevel int, cfg LoadConfig) {
|
||||
return
|
||||
}
|
||||
if v.Len < 0 {
|
||||
//lint:ignore ST1005 backwards compatibility
|
||||
v.Unreadable = errors.New("Negative array length")
|
||||
return
|
||||
}
|
||||
@ -2240,7 +2242,7 @@ func (v *Variable) ConstDescr() string {
|
||||
if ctyp == nil {
|
||||
return ""
|
||||
}
|
||||
if typename := v.DwarfType.Common().Name; strings.Index(typename, ".") < 0 || strings.HasPrefix(typename, "C.") {
|
||||
if typename := v.DwarfType.Common().Name; !strings.Contains(typename, ".") || strings.HasPrefix(typename, "C.") {
|
||||
// only attempt to use constants for user defined type, otherwise every
|
||||
// int variable with value 1 will be described with os.SEEK_CUR and other
|
||||
// similar problems.
|
||||
@ -2382,9 +2384,7 @@ func (cm constantsMap) Get(typ godwarf.Type) *constantType {
|
||||
ctyp.initialized = true
|
||||
sort.Sort(constantValuesByValue(ctyp.values))
|
||||
for i := range ctyp.values {
|
||||
if strings.HasPrefix(ctyp.values[i].name, typepkg) {
|
||||
ctyp.values[i].name = ctyp.values[i].name[len(typepkg):]
|
||||
}
|
||||
ctyp.values[i].name = strings.TrimPrefix(ctyp.values[i].name, typepkg)
|
||||
if popcnt(uint64(ctyp.values[i].value)) == 1 {
|
||||
ctyp.values[i].singleBit = true
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
// input and dispatching to appropriate backend commands.
|
||||
package terminal
|
||||
|
||||
//lint:file-ignore ST1005 errors here can be capitalized
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
@ -647,10 +649,10 @@ func (c *Commands) Merge(allAliases map[string][]string) {
|
||||
}
|
||||
}
|
||||
|
||||
var noCmdError = errors.New("command not available")
|
||||
var errNoCmd = errors.New("command not available")
|
||||
|
||||
func noCmdAvailable(t *Term, ctx callContext, args string) error {
|
||||
return noCmdError
|
||||
return errNoCmd
|
||||
}
|
||||
|
||||
func nullCommand(t *Term, ctx callContext, args string) error {
|
||||
@ -667,7 +669,7 @@ func (c *Commands) help(t *Term, ctx callContext, args string) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
return noCmdError
|
||||
return errNoCmd
|
||||
}
|
||||
|
||||
fmt.Println("The following commands are available:")
|
||||
@ -983,7 +985,7 @@ func selectedGID(state *api.DebuggerState) int {
|
||||
|
||||
func split2PartsBySpace(s string) []string {
|
||||
v := strings.SplitN(s, " ", 2)
|
||||
for i, _ := range v {
|
||||
for i := range v {
|
||||
v[i] = strings.TrimSpace(v[i])
|
||||
}
|
||||
return v
|
||||
@ -1541,14 +1543,14 @@ func (c *Commands) step(t *Term, ctx callContext, args string) error {
|
||||
return continueUntilCompleteNext(t, state, "step", true)
|
||||
}
|
||||
|
||||
var notOnFrameZeroErr = errors.New("not on topmost frame")
|
||||
var errNotOnFrameZero = errors.New("not on topmost frame")
|
||||
|
||||
func (c *Commands) stepInstruction(t *Term, ctx callContext, args string) error {
|
||||
if err := scopePrefixSwitch(t, ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if c.frame != 0 {
|
||||
return notOnFrameZeroErr
|
||||
return errNotOnFrameZero
|
||||
}
|
||||
|
||||
defer t.onStop()
|
||||
@ -1584,7 +1586,7 @@ func (c *Commands) next(t *Term, ctx callContext, args string) error {
|
||||
return err
|
||||
}
|
||||
if c.frame != 0 {
|
||||
return notOnFrameZeroErr
|
||||
return errNotOnFrameZero
|
||||
}
|
||||
|
||||
nextfn := t.client.Next
|
||||
@ -1622,7 +1624,7 @@ func (c *Commands) stepout(t *Term, ctx callContext, args string) error {
|
||||
return err
|
||||
}
|
||||
if c.frame != 0 {
|
||||
return notOnFrameZeroErr
|
||||
return errNotOnFrameZero
|
||||
}
|
||||
|
||||
stepoutfn := t.client.StepOut
|
||||
@ -2476,7 +2478,7 @@ func (c *Commands) sourceCommand(t *Term, ctx callContext, args string) error {
|
||||
return c.executeFile(t, args)
|
||||
}
|
||||
|
||||
var disasmUsageError = errors.New("wrong number of arguments: disassemble [-a <start> <end>] [-l <locspec>]")
|
||||
var errDisasmUsage = errors.New("wrong number of arguments: disassemble [-a <start> <end>] [-l <locspec>]")
|
||||
|
||||
func disassCommand(t *Term, ctx callContext, args string) error {
|
||||
var cmd, rest string
|
||||
@ -2484,7 +2486,7 @@ func disassCommand(t *Term, ctx callContext, args string) error {
|
||||
if args != "" {
|
||||
argv := split2PartsBySpace(args)
|
||||
if len(argv) != 2 {
|
||||
return disasmUsageError
|
||||
return errDisasmUsage
|
||||
}
|
||||
cmd = argv[0]
|
||||
rest = argv[1]
|
||||
@ -2515,7 +2517,7 @@ func disassCommand(t *Term, ctx callContext, args string) error {
|
||||
case "-a":
|
||||
v := split2PartsBySpace(rest)
|
||||
if len(v) != 2 {
|
||||
return disasmUsageError
|
||||
return errDisasmUsage
|
||||
}
|
||||
startpc, err := strconv.ParseInt(v[0], 0, 64)
|
||||
if err != nil {
|
||||
@ -2536,7 +2538,7 @@ func disassCommand(t *Term, ctx callContext, args string) error {
|
||||
}
|
||||
disasm, disasmErr = t.client.DisassemblePC(ctx.Scope, locs[0].PC, flavor)
|
||||
default:
|
||||
return disasmUsageError
|
||||
return errDisasmUsage
|
||||
}
|
||||
|
||||
if disasmErr != nil {
|
||||
|
@ -240,7 +240,7 @@ func (env *Env) variableValueToStarlarkValue(v *api.Variable, top bool) (starlar
|
||||
case "NaN":
|
||||
return starlark.Float(math.NaN()), nil
|
||||
default:
|
||||
n, _ := strconv.ParseFloat(v.Value, 0)
|
||||
n, _ := strconv.ParseFloat(v.Value, 64)
|
||||
return starlark.Float(n), nil
|
||||
}
|
||||
case reflect.Ptr, reflect.Interface:
|
||||
@ -289,7 +289,7 @@ func (v structVariableAsStarlarkValue) Hash() (uint32, error) {
|
||||
}
|
||||
|
||||
func (v structVariableAsStarlarkValue) String() string {
|
||||
return fmt.Sprintf("%s", v.v.SinglelineString())
|
||||
return v.v.SinglelineString()
|
||||
}
|
||||
|
||||
func (v structVariableAsStarlarkValue) Truth() starlark.Bool {
|
||||
@ -349,7 +349,7 @@ func (v sliceVariableAsStarlarkValue) Hash() (uint32, error) {
|
||||
}
|
||||
|
||||
func (v sliceVariableAsStarlarkValue) String() string {
|
||||
return fmt.Sprintf("%s", v.v.SinglelineString())
|
||||
return v.v.SinglelineString()
|
||||
}
|
||||
|
||||
func (v sliceVariableAsStarlarkValue) Truth() starlark.Bool {
|
||||
@ -415,7 +415,7 @@ func (v ptrVariableAsStarlarkValue) Hash() (uint32, error) {
|
||||
}
|
||||
|
||||
func (v ptrVariableAsStarlarkValue) String() string {
|
||||
return fmt.Sprintf("%s", v.v.SinglelineString())
|
||||
return v.v.SinglelineString()
|
||||
}
|
||||
|
||||
func (v ptrVariableAsStarlarkValue) Truth() starlark.Bool {
|
||||
@ -494,7 +494,7 @@ func (v mapVariableAsStarlarkValue) Hash() (uint32, error) {
|
||||
}
|
||||
|
||||
func (v mapVariableAsStarlarkValue) String() string {
|
||||
return fmt.Sprintf("%s", v.v.SinglelineString())
|
||||
return v.v.SinglelineString()
|
||||
}
|
||||
|
||||
func (v mapVariableAsStarlarkValue) Truth() starlark.Bool {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package terminal
|
||||
|
||||
//lint:file-ignore ST1005 errors here can be capitalized
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
@ -593,7 +593,7 @@ const (
|
||||
StacktraceG
|
||||
)
|
||||
|
||||
// ImportPathToDirectoryPath maps an import path to a directory path.
|
||||
// PackageBuildInfo maps an import path to a directory path.
|
||||
type PackageBuildInfo struct {
|
||||
ImportPath string
|
||||
DirectoryPath string
|
||||
|
@ -225,7 +225,7 @@ func (c *Client) DisconnectRequest() {
|
||||
c.send(request)
|
||||
}
|
||||
|
||||
// DisconnectRequest sends a 'disconnect' request with an option to specify
|
||||
// DisconnectRequestWithKillOption sends a 'disconnect' request with an option to specify
|
||||
// `terminateDebuggee`.
|
||||
func (c *Client) DisconnectRequestWithKillOption(kill bool) {
|
||||
request := &dap.DisconnectRequest{Request: *c.newRequest("disconnect")}
|
||||
@ -358,7 +358,7 @@ func (c *Client) NamedVariablesRequest(variablesReference int) {
|
||||
c.send(request)
|
||||
}
|
||||
|
||||
// TeriminateRequest sends a 'terminate' request.
|
||||
// TerminateRequest sends a 'terminate' request.
|
||||
func (c *Client) TerminateRequest() {
|
||||
c.send(&dap.TerminateRequest{Request: *c.newRequest("terminate")})
|
||||
}
|
||||
|
@ -941,7 +941,7 @@ func (d *Debugger) clearBreakpoint(requestedBp *api.Breakpoint) (*api.Breakpoint
|
||||
}
|
||||
|
||||
clearedBp := api.ConvertBreakpoints(bps)
|
||||
if len(clearedBp) < 0 {
|
||||
if len(clearedBp) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
d.log.Infof("cleared breakpoint: %#v", clearedBp)
|
||||
|
@ -9,6 +9,8 @@ import (
|
||||
sys "golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
//lint:file-ignore ST1005 errors here can be capitalized
|
||||
|
||||
func attachErrorMessage(pid int, err error) error {
|
||||
fallbackerr := fmt.Errorf("could not attach to pid %d: %s", pid, err)
|
||||
if serr, ok := err.(syscall.Errno); ok {
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
"github.com/go-delve/delve/service/api"
|
||||
)
|
||||
|
||||
// Client is a RPC service.Client.
|
||||
// RPCClient is a RPC service.Client.
|
||||
type RPCClient struct {
|
||||
addr string
|
||||
client *rpc.Client
|
||||
@ -20,7 +20,7 @@ type RPCClient struct {
|
||||
haltReq bool
|
||||
}
|
||||
|
||||
var unsupportedApiError = errors.New("unsupported")
|
||||
var errAPIUnsupported = errors.New("unsupported")
|
||||
|
||||
// NewClient creates a new RPCClient.
|
||||
func NewClient(addr string) *RPCClient {
|
||||
@ -75,6 +75,7 @@ func (c *RPCClient) Continue() <-chan *api.DebuggerState {
|
||||
}
|
||||
if state.Exited {
|
||||
// Error types apparently cannot be marshalled by Go correctly. Must reset error here.
|
||||
//lint:ignore ST1005 backwards compatibility
|
||||
state.Err = fmt.Errorf("Process %d has exited with status %d", c.ProcessPid(), state.ExitStatus)
|
||||
}
|
||||
ch <- state
|
||||
@ -202,7 +203,7 @@ func (c *RPCClient) AmendBreakpoint(bp *api.Breakpoint) error {
|
||||
}
|
||||
|
||||
func (c *RPCClient) CancelNext() error {
|
||||
return unsupportedApiError
|
||||
return errAPIUnsupported
|
||||
}
|
||||
|
||||
func (c *RPCClient) ListThreads() ([]*api.Thread, error) {
|
||||
@ -300,14 +301,14 @@ func (c *RPCClient) FindLocation(scope api.EvalScope, loc string) ([]api.Locatio
|
||||
return answer, err
|
||||
}
|
||||
|
||||
// Disassemble code between startPC and endPC
|
||||
// DisassembleRange disassembles code between startPC and endPC
|
||||
func (c *RPCClient) DisassembleRange(scope api.EvalScope, startPC, endPC uint64, flavour api.AssemblyFlavour) (api.AsmInstructions, error) {
|
||||
var r api.AsmInstructions
|
||||
err := c.call("Disassemble", DisassembleRequest{scope, startPC, endPC, flavour}, &r)
|
||||
return r, err
|
||||
}
|
||||
|
||||
// Disassemble function containing pc
|
||||
// DisassemblePC disassembles function containing pc
|
||||
func (c *RPCClient) DisassemblePC(scope api.EvalScope, pc uint64, flavour api.AssemblyFlavour) (api.AsmInstructions, error) {
|
||||
var r api.AsmInstructions
|
||||
err := c.call("Disassemble", DisassembleRequest{scope, pc, 0, flavour}, &r)
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
"github.com/go-delve/delve/service/api"
|
||||
)
|
||||
|
||||
// Client is a RPC service.Client.
|
||||
// RPCClient is a RPC service.Client.
|
||||
type RPCClient struct {
|
||||
client *rpc.Client
|
||||
|
||||
@ -108,6 +108,7 @@ func (c *RPCClient) continueDir(cmd string) <-chan *api.DebuggerState {
|
||||
}
|
||||
if state.Exited {
|
||||
// Error types apparently cannot be marshalled by Go correctly. Must reset error here.
|
||||
//lint:ignore ST1005 backwards compatibility
|
||||
state.Err = fmt.Errorf("Process %d has exited with status %d", c.ProcessPid(), state.ExitStatus)
|
||||
}
|
||||
ch <- &state
|
||||
@ -404,14 +405,14 @@ func (c *RPCClient) FindLocation(scope api.EvalScope, loc string, findInstructio
|
||||
return out.Locations, err
|
||||
}
|
||||
|
||||
// Disassemble code between startPC and endPC
|
||||
// DisassembleRange disassembles code between startPC and endPC
|
||||
func (c *RPCClient) DisassembleRange(scope api.EvalScope, startPC, endPC uint64, flavour api.AssemblyFlavour) (api.AsmInstructions, error) {
|
||||
var out DisassembleOut
|
||||
err := c.call("Disassemble", DisassembleIn{scope, startPC, endPC, flavour}, &out)
|
||||
return out.Disassemble, err
|
||||
}
|
||||
|
||||
// Disassemble function containing pc
|
||||
// DisassemblePC disassembles function containing pc
|
||||
func (c *RPCClient) DisassemblePC(scope api.EvalScope, pc uint64, flavour api.AssemblyFlavour) (api.AsmInstructions, error) {
|
||||
var out DisassembleOut
|
||||
err := c.call("Disassemble", DisassembleIn{scope, pc, 0, flavour}, &out)
|
||||
|
@ -521,7 +521,7 @@ type EvalOut struct {
|
||||
Variable *api.Variable
|
||||
}
|
||||
|
||||
// EvalVariable returns a variable in the specified context.
|
||||
// Eval returns a variable in the specified context.
|
||||
//
|
||||
// See https://github.com/go-delve/delve/blob/master/Documentation/cli/expr.md
|
||||
// for a description of acceptable values of arg.Expr.
|
||||
|
@ -404,7 +404,7 @@ func (s *RPCServer) GetVersion(args api.GetVersionIn, out *api.GetVersionOut) er
|
||||
return s.s.debugger.GetVersion(out)
|
||||
}
|
||||
|
||||
// Changes version of the API being served.
|
||||
// SetApiVersion changes version of the API being served.
|
||||
func (s *RPCServer) SetApiVersion(args api.SetAPIVersionIn, out *api.SetAPIVersionOut) error {
|
||||
if args.APIVersion < 2 {
|
||||
args.APIVersion = 1
|
||||
|
Loading…
Reference in New Issue
Block a user