*: replace fmt.Errorf with errors.New (#3752)
This commit is contained in:
parent
7e753701d4
commit
0d0d2e1b16
@ -278,7 +278,7 @@ func (n *Tree) Type(dw *dwarf.Data, index int, typeCache map[dwarf.Offset]Type)
|
|||||||
if n.typ == nil {
|
if n.typ == nil {
|
||||||
offset, ok := n.Val(dwarf.AttrType).(dwarf.Offset)
|
offset, ok := n.Val(dwarf.AttrType).(dwarf.Offset)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("malformed variable DIE (offset)")
|
return nil, errors.New("malformed variable DIE (offset)")
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
@ -41,7 +41,7 @@ func (reader *Reader) AddrFor(name string, staticBase uint64, ptrSize int) (uint
|
|||||||
}
|
}
|
||||||
instructions, ok := entry.Val(dwarf.AttrLocation).([]byte)
|
instructions, ok := entry.Val(dwarf.AttrLocation).([]byte)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("type assertion failed")
|
return 0, errors.New("type assertion failed")
|
||||||
}
|
}
|
||||||
addr, _, err := op.ExecuteStackProgram(op.DwarfRegisters{StaticBase: staticBase}, instructions, ptrSize, nil)
|
addr, _, err := op.ExecuteStackProgram(op.DwarfRegisters{StaticBase: staticBase}, instructions, ptrSize, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -58,7 +58,7 @@ var ErrTypeNotFound = errors.New("no type entry found, use 'types' for a list of
|
|||||||
func (reader *Reader) SeekToType(entry *dwarf.Entry, resolveTypedefs bool, resolvePointerTypes bool) (*dwarf.Entry, error) {
|
func (reader *Reader) SeekToType(entry *dwarf.Entry, resolveTypedefs bool, resolvePointerTypes bool) (*dwarf.Entry, error) {
|
||||||
offset, ok := entry.Val(dwarf.AttrType).(dwarf.Offset)
|
offset, ok := entry.Val(dwarf.AttrType).(dwarf.Offset)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("entry does not have a type attribute")
|
return nil, errors.New("entry does not have a type attribute")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Seek to the first type offset
|
// Seek to the first type offset
|
||||||
@ -187,7 +187,7 @@ func (reader *Reader) InstructionsForEntry(entry *dwarf.Entry) ([]byte, error) {
|
|||||||
if entry.Tag == dwarf.TagMember {
|
if entry.Tag == dwarf.TagMember {
|
||||||
instructions, ok := entry.Val(dwarf.AttrDataMemberLoc).([]byte)
|
instructions, ok := entry.Val(dwarf.AttrDataMemberLoc).([]byte)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("member data has no data member location attribute")
|
return nil, errors.New("member data has no data member location attribute")
|
||||||
}
|
}
|
||||||
// clone slice to prevent stomping on the dwarf data
|
// clone slice to prevent stomping on the dwarf data
|
||||||
return append([]byte{}, instructions...), nil
|
return append([]byte{}, instructions...), nil
|
||||||
@ -196,7 +196,7 @@ func (reader *Reader) InstructionsForEntry(entry *dwarf.Entry) ([]byte, error) {
|
|||||||
// non-member
|
// non-member
|
||||||
instructions, ok := entry.Val(dwarf.AttrLocation).([]byte)
|
instructions, ok := entry.Val(dwarf.AttrLocation).([]byte)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("entry has no location attribute")
|
return nil, errors.New("entry has no location attribute")
|
||||||
}
|
}
|
||||||
|
|
||||||
// clone slice to prevent stomping on the dwarf data
|
// clone slice to prevent stomping on the dwarf data
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package locspec
|
package locspec
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/constant"
|
"go/constant"
|
||||||
"path"
|
"path"
|
||||||
@ -272,7 +273,7 @@ func packageMatch(specPkg, symPkg string, packageMap map[string][]string) bool {
|
|||||||
func (loc *RegexLocationSpec) Find(t *proc.Target, _ []string, scope *proc.EvalScope, locStr string, includeNonExecutableLines bool, _ [][2]string) ([]api.Location, string, error) {
|
func (loc *RegexLocationSpec) Find(t *proc.Target, _ []string, scope *proc.EvalScope, locStr string, includeNonExecutableLines bool, _ [][2]string) ([]api.Location, string, error) {
|
||||||
if scope == nil {
|
if scope == nil {
|
||||||
//TODO(aarzilli): this needs only the list of function we should make it work
|
//TODO(aarzilli): this needs only the list of function we should make it work
|
||||||
return nil, "", fmt.Errorf("could not determine location (scope is nil)")
|
return nil, "", errors.New("could not determine location (scope is nil)")
|
||||||
}
|
}
|
||||||
funcs := scope.BinInfo.Functions
|
funcs := scope.BinInfo.Functions
|
||||||
matches, err := regexFilterFuncs(loc.FuncRegex, funcs)
|
matches, err := regexFilterFuncs(loc.FuncRegex, funcs)
|
||||||
@ -294,7 +295,7 @@ func (loc *AddrLocationSpec) Find(t *proc.Target, _ []string, scope *proc.EvalSc
|
|||||||
if scope == nil {
|
if scope == nil {
|
||||||
addr, err := strconv.ParseInt(loc.AddrExpr, 0, 64)
|
addr, err := strconv.ParseInt(loc.AddrExpr, 0, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", fmt.Errorf("could not determine current location (scope is nil)")
|
return nil, "", errors.New("could not determine current location (scope is nil)")
|
||||||
}
|
}
|
||||||
return []api.Location{{PC: uint64(addr)}}, "", nil
|
return []api.Location{{PC: uint64(addr)}}, "", nil
|
||||||
}
|
}
|
||||||
@ -416,7 +417,7 @@ func (loc *NormalLocationSpec) Find(t *proc.Target, processArgs []string, scope
|
|||||||
if len(candidateFiles) == 1 {
|
if len(candidateFiles) == 1 {
|
||||||
if loc.LineOffset < 0 {
|
if loc.LineOffset < 0 {
|
||||||
//lint:ignore ST1005 backwards compatibility
|
//lint:ignore ST1005 backwards compatibility
|
||||||
return nil, "", fmt.Errorf("Malformed breakpoint location, no line offset specified")
|
return nil, "", errors.New("Malformed breakpoint location, no line offset specified")
|
||||||
}
|
}
|
||||||
addrs, err = proc.FindFileLocation(t, candidateFiles[0], loc.LineOffset)
|
addrs, err = proc.FindFileLocation(t, candidateFiles[0], loc.LineOffset)
|
||||||
if includeNonExecutableLines {
|
if includeNonExecutableLines {
|
||||||
@ -617,7 +618,7 @@ func addressesToLocation(addrs []uint64) api.Location {
|
|||||||
// Find returns the location after adding the offset amount to the current line number.
|
// Find returns the location after adding the offset amount to the current line number.
|
||||||
func (loc *OffsetLocationSpec) Find(t *proc.Target, _ []string, scope *proc.EvalScope, _ string, includeNonExecutableLines bool, _ [][2]string) ([]api.Location, string, error) {
|
func (loc *OffsetLocationSpec) Find(t *proc.Target, _ []string, scope *proc.EvalScope, _ string, includeNonExecutableLines bool, _ [][2]string) ([]api.Location, string, error) {
|
||||||
if scope == nil {
|
if scope == nil {
|
||||||
return nil, "", fmt.Errorf("could not determine current location (scope is nil)")
|
return nil, "", errors.New("could not determine current location (scope is nil)")
|
||||||
}
|
}
|
||||||
file, line, fn := scope.BinInfo.PCToLine(scope.PC)
|
file, line, fn := scope.BinInfo.PCToLine(scope.PC)
|
||||||
if loc.Offset == 0 {
|
if loc.Offset == 0 {
|
||||||
@ -628,7 +629,7 @@ func (loc *OffsetLocationSpec) Find(t *proc.Target, _ []string, scope *proc.Eval
|
|||||||
return []api.Location{{PC: scope.PC}}, subst, nil
|
return []api.Location{{PC: scope.PC}}, subst, nil
|
||||||
}
|
}
|
||||||
if fn == nil {
|
if fn == nil {
|
||||||
return nil, "", fmt.Errorf("could not determine current location")
|
return nil, "", errors.New("could not determine current location")
|
||||||
}
|
}
|
||||||
subst := fmt.Sprintf("%s:%d", file, line+loc.Offset)
|
subst := fmt.Sprintf("%s:%d", file, line+loc.Offset)
|
||||||
addrs, err := proc.FindFileLocation(t, file, line+loc.Offset)
|
addrs, err := proc.FindFileLocation(t, file, line+loc.Offset)
|
||||||
@ -643,11 +644,11 @@ func (loc *OffsetLocationSpec) Find(t *proc.Target, _ []string, scope *proc.Eval
|
|||||||
// Find will return the location at the given line in the current file.
|
// Find will return the location at the given line in the current file.
|
||||||
func (loc *LineLocationSpec) Find(t *proc.Target, _ []string, scope *proc.EvalScope, _ string, includeNonExecutableLines bool, _ [][2]string) ([]api.Location, string, error) {
|
func (loc *LineLocationSpec) Find(t *proc.Target, _ []string, scope *proc.EvalScope, _ string, includeNonExecutableLines bool, _ [][2]string) ([]api.Location, string, error) {
|
||||||
if scope == nil {
|
if scope == nil {
|
||||||
return nil, "", fmt.Errorf("could not determine current location (scope is nil)")
|
return nil, "", errors.New("could not determine current location (scope is nil)")
|
||||||
}
|
}
|
||||||
file, _, fn := scope.BinInfo.PCToLine(scope.PC)
|
file, _, fn := scope.BinInfo.PCToLine(scope.PC)
|
||||||
if fn == nil {
|
if fn == nil {
|
||||||
return nil, "", fmt.Errorf("could not determine current location")
|
return nil, "", errors.New("could not determine current location")
|
||||||
}
|
}
|
||||||
subst := fmt.Sprintf("%s:%d", file, loc.Line)
|
subst := fmt.Sprintf("%s:%d", file, loc.Line)
|
||||||
addrs, err := proc.FindFileLocation(t, file, loc.Line)
|
addrs, err := proc.FindFileLocation(t, file, loc.Line)
|
||||||
|
@ -60,7 +60,7 @@ func (drs *DebugRegisters) breakpoint(idx uint8) (addr uint64, read, write bool,
|
|||||||
// nothing.
|
// nothing.
|
||||||
func (drs *DebugRegisters) SetBreakpoint(idx uint8, addr uint64, read, write bool, sz int) error {
|
func (drs *DebugRegisters) SetBreakpoint(idx uint8, addr uint64, read, write bool, sz int) error {
|
||||||
if int(idx) >= len(drs.pAddrs) {
|
if int(idx) >= len(drs.pAddrs) {
|
||||||
return fmt.Errorf("hardware breakpoints exhausted")
|
return errors.New("hardware breakpoints exhausted")
|
||||||
}
|
}
|
||||||
curaddr, curread, curwrite, cursz := drs.breakpoint(idx)
|
curaddr, curread, curwrite, cursz := drs.breakpoint(idx)
|
||||||
if curaddr != 0 {
|
if curaddr != 0 {
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"debug/elf"
|
"debug/elf"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
@ -147,7 +148,7 @@ func readLinuxOrPlatformIndependentCore(corePath, exePath string) (*process, pro
|
|||||||
case _EM_AARCH64:
|
case _EM_AARCH64:
|
||||||
bi = proc.NewBinaryInfo("linux", "arm64")
|
bi = proc.NewBinaryInfo("linux", "arm64")
|
||||||
default:
|
default:
|
||||||
return nil, nil, fmt.Errorf("unsupported machine type")
|
return nil, nil, errors.New("unsupported machine type")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +287,7 @@ func readNote(r io.ReadSeeker, machineType elf.Machine) (*note, error) {
|
|||||||
case _EM_AARCH64:
|
case _EM_AARCH64:
|
||||||
note.Desc = &linuxPrStatusARM64{}
|
note.Desc = &linuxPrStatusARM64{}
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unsupported machine type")
|
return nil, errors.New("unsupported machine type")
|
||||||
}
|
}
|
||||||
if err := binary.Read(descReader, binary.LittleEndian, note.Desc); err != nil {
|
if err := binary.Read(descReader, binary.LittleEndian, note.Desc); err != nil {
|
||||||
return nil, fmt.Errorf("reading NT_PRSTATUS: %v", err)
|
return nil, fmt.Errorf("reading NT_PRSTATUS: %v", err)
|
||||||
|
@ -387,7 +387,7 @@ func (scope *EvalScope) Locals(flags localsFlags) ([]*Variable, error) {
|
|||||||
declLine := v.DeclLine
|
declLine := v.DeclLine
|
||||||
v = v.maybeDereference()
|
v = v.maybeDereference()
|
||||||
if v.Addr == 0 && v.Unreadable == nil {
|
if v.Addr == 0 && v.Unreadable == nil {
|
||||||
v.Unreadable = fmt.Errorf("no address for escaped variable")
|
v.Unreadable = errors.New("no address for escaped variable")
|
||||||
}
|
}
|
||||||
v.Name = name[1:]
|
v.Name = name[1:]
|
||||||
v.Flags |= VariableEscaped
|
v.Flags |= VariableEscaped
|
||||||
@ -1918,13 +1918,13 @@ func (scope *EvalScope) evalReslice(op *evalop.Reslice, stack *evalStack) {
|
|||||||
return
|
return
|
||||||
case reflect.Map:
|
case reflect.Map:
|
||||||
if op.Node.High != nil {
|
if op.Node.High != nil {
|
||||||
stack.err = fmt.Errorf("second slice argument must be empty for maps")
|
stack.err = errors.New("second slice argument must be empty for maps")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
xev.mapSkip += int(low)
|
xev.mapSkip += int(low)
|
||||||
xev.mapIterator() // reads map length
|
xev.mapIterator() // reads map length
|
||||||
if int64(xev.mapSkip) >= xev.Len {
|
if int64(xev.mapSkip) >= xev.Len {
|
||||||
stack.err = fmt.Errorf("map index out of bounds")
|
stack.err = errors.New("map index out of bounds")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
stack.push(xev)
|
stack.push(xev)
|
||||||
@ -1951,7 +1951,7 @@ func (scope *EvalScope) evalPointerDeref(op *evalop.PointerDeref, stack *evalSta
|
|||||||
}
|
}
|
||||||
|
|
||||||
if xev == nilVariable {
|
if xev == nilVariable {
|
||||||
stack.err = fmt.Errorf("nil can not be dereferenced")
|
stack.err = errors.New("nil can not be dereferenced")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1971,7 +1971,7 @@ func (scope *EvalScope) evalPointerDeref(op *evalop.PointerDeref, stack *evalSta
|
|||||||
}
|
}
|
||||||
rv := &xev.Children[0]
|
rv := &xev.Children[0]
|
||||||
if rv.Addr == 0 {
|
if rv.Addr == 0 {
|
||||||
stack.err = fmt.Errorf("nil pointer dereference")
|
stack.err = errors.New("nil pointer dereference")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
stack.push(rv)
|
stack.push(rv)
|
||||||
@ -2085,7 +2085,7 @@ func negotiateType(op token.Token, xv, yv *Variable) (godwarf.Type, error) {
|
|||||||
// ok
|
// ok
|
||||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||||
if constant.Sign(yv.Value) < 0 {
|
if constant.Sign(yv.Value) < 0 {
|
||||||
return nil, fmt.Errorf("shift count must not be negative")
|
return nil, errors.New("shift count must not be negative")
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("shift count type %s, must be unsigned integer", yv.Kind.String())
|
return nil, fmt.Errorf("shift count type %s, must be unsigned integer", yv.Kind.String())
|
||||||
@ -2253,7 +2253,7 @@ func compareOp(op token.Token, xv *Variable, yv *Variable) (bool, error) {
|
|||||||
yv.loadValue(loadFullValueLongerStrings)
|
yv.loadValue(loadFullValueLongerStrings)
|
||||||
}
|
}
|
||||||
if int64(len(constant.StringVal(xv.Value))) != xv.Len || int64(len(constant.StringVal(yv.Value))) != yv.Len {
|
if int64(len(constant.StringVal(xv.Value))) != xv.Len || int64(len(constant.StringVal(yv.Value))) != yv.Len {
|
||||||
return false, fmt.Errorf("string too long for comparison")
|
return false, errors.New("string too long for comparison")
|
||||||
}
|
}
|
||||||
return constantCompare(op, xv.Value, yv.Value)
|
return constantCompare(op, xv.Value, yv.Value)
|
||||||
}
|
}
|
||||||
@ -2288,7 +2288,7 @@ func compareOp(op token.Token, xv *Variable, yv *Variable) (bool, error) {
|
|||||||
eql = xv.Children[0].Addr == yv.Children[0].Addr
|
eql = xv.Children[0].Addr == yv.Children[0].Addr
|
||||||
case reflect.Array:
|
case reflect.Array:
|
||||||
if int64(len(xv.Children)) != xv.Len || int64(len(yv.Children)) != yv.Len {
|
if int64(len(xv.Children)) != xv.Len || int64(len(yv.Children)) != yv.Len {
|
||||||
return false, fmt.Errorf("array too long for comparison")
|
return false, errors.New("array too long for comparison")
|
||||||
}
|
}
|
||||||
eql, err = equalChildren(xv, yv, true)
|
eql, err = equalChildren(xv, yv, true)
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
@ -2296,7 +2296,7 @@ func compareOp(op token.Token, xv *Variable, yv *Variable) (bool, error) {
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
if int64(len(xv.Children)) != xv.Len || int64(len(yv.Children)) != yv.Len {
|
if int64(len(xv.Children)) != xv.Len || int64(len(yv.Children)) != yv.Len {
|
||||||
return false, fmt.Errorf("structure too deep for comparison")
|
return false, errors.New("structure too deep for comparison")
|
||||||
}
|
}
|
||||||
eql, err = equalChildren(xv, yv, false)
|
eql, err = equalChildren(xv, yv, false)
|
||||||
case reflect.Slice, reflect.Map, reflect.Func, reflect.Chan:
|
case reflect.Slice, reflect.Map, reflect.Func, reflect.Chan:
|
||||||
@ -2483,13 +2483,13 @@ func (v *Variable) sliceAccess(idx int) (*Variable, error) {
|
|||||||
wrong = idx < 0
|
wrong = idx < 0
|
||||||
}
|
}
|
||||||
if wrong {
|
if wrong {
|
||||||
return nil, fmt.Errorf("index out of bounds")
|
return nil, errors.New("index out of bounds")
|
||||||
}
|
}
|
||||||
if v.loaded {
|
if v.loaded {
|
||||||
if v.Kind == reflect.String {
|
if v.Kind == reflect.String {
|
||||||
s := constant.StringVal(v.Value)
|
s := constant.StringVal(v.Value)
|
||||||
if idx >= len(s) {
|
if idx >= len(s) {
|
||||||
return nil, fmt.Errorf("index out of bounds")
|
return nil, errors.New("index out of bounds")
|
||||||
}
|
}
|
||||||
r := v.newVariable("", v.Base+uint64(int64(idx)*v.stride), v.fieldType, v.mem)
|
r := v.newVariable("", v.Base+uint64(int64(idx)*v.stride), v.fieldType, v.mem)
|
||||||
r.loaded = true
|
r.loaded = true
|
||||||
@ -2497,7 +2497,7 @@ func (v *Variable) sliceAccess(idx int) (*Variable, error) {
|
|||||||
return r, nil
|
return r, nil
|
||||||
} else {
|
} else {
|
||||||
if idx >= len(v.Children) {
|
if idx >= len(v.Children) {
|
||||||
return nil, fmt.Errorf("index out of bounds")
|
return nil, errors.New("index out of bounds")
|
||||||
}
|
}
|
||||||
return &v.Children[idx], nil
|
return &v.Children[idx], nil
|
||||||
}
|
}
|
||||||
@ -2548,7 +2548,7 @@ func (v *Variable) mapAccess(idx *Variable) (*Variable, error) {
|
|||||||
return nil, v.Unreadable
|
return nil, v.Unreadable
|
||||||
}
|
}
|
||||||
// go would return zero for the map value type here, we do not have the ability to create zeroes
|
// go would return zero for the map value type here, we do not have the ability to create zeroes
|
||||||
return nil, fmt.Errorf("key not found")
|
return nil, errors.New("key not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadResliced returns a new array, slice or map that starts at index start and contains
|
// LoadResliced returns a new array, slice or map that starts at index start and contains
|
||||||
@ -2570,7 +2570,7 @@ func (v *Variable) LoadResliced(start int, cfg LoadConfig) (newV *Variable, err
|
|||||||
newV.loaded = false
|
newV.loaded = false
|
||||||
newV.mapSkip = start
|
newV.mapSkip = start
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("variable to reslice is not an array, slice, or map")
|
return nil, errors.New("variable to reslice is not an array, slice, or map")
|
||||||
}
|
}
|
||||||
newV.loadValue(cfg)
|
newV.loadValue(cfg)
|
||||||
return newV, nil
|
return newV, nil
|
||||||
@ -2589,14 +2589,14 @@ func (v *Variable) reslice(low int64, high int64, trustLen bool) (*Variable, err
|
|||||||
cptrNeedsFakeSlice = v.Kind != reflect.String
|
cptrNeedsFakeSlice = v.Kind != reflect.String
|
||||||
}
|
}
|
||||||
if wrong {
|
if wrong {
|
||||||
return nil, fmt.Errorf("index out of bounds")
|
return nil, errors.New("index out of bounds")
|
||||||
}
|
}
|
||||||
|
|
||||||
base := v.Base + uint64(low*v.stride)
|
base := v.Base + uint64(low*v.stride)
|
||||||
len := high - low
|
len := high - low
|
||||||
|
|
||||||
if high-low < 0 {
|
if high-low < 0 {
|
||||||
return nil, fmt.Errorf("index out of bounds")
|
return nil, errors.New("index out of bounds")
|
||||||
}
|
}
|
||||||
|
|
||||||
typ := v.DwarfType
|
typ := v.DwarfType
|
||||||
|
@ -262,7 +262,7 @@ func (ctx *compileCtx) compileAST(t ast.Expr) error {
|
|||||||
|
|
||||||
case *ast.SliceExpr:
|
case *ast.SliceExpr:
|
||||||
if node.Slice3 {
|
if node.Slice3 {
|
||||||
return fmt.Errorf("3-index slice expressions not supported")
|
return errors.New("3-index slice expressions not supported")
|
||||||
}
|
}
|
||||||
return ctx.compileReslice(node)
|
return ctx.compileReslice(node)
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package proc
|
|||||||
import (
|
import (
|
||||||
"debug/elf"
|
"debug/elf"
|
||||||
"debug/macho"
|
"debug/macho"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/go-delve/delve/pkg/internal/gosym"
|
"github.com/go-delve/delve/pkg/internal/gosym"
|
||||||
@ -18,12 +19,12 @@ func readPcLnTableElf(exe *elf.File, path string) (*gosym.Table, uint64, error)
|
|||||||
sectionLabel = ".data.rel.ro.gopclntab"
|
sectionLabel = ".data.rel.ro.gopclntab"
|
||||||
section = exe.Section(sectionLabel)
|
section = exe.Section(sectionLabel)
|
||||||
if section == nil {
|
if section == nil {
|
||||||
return nil, 0, fmt.Errorf("could not read section .gopclntab")
|
return nil, 0, errors.New("could not read section .gopclntab")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tableData, err := section.Data()
|
tableData, err := section.Data()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, fmt.Errorf("found section but could not read .gopclntab")
|
return nil, 0, errors.New("found section but could not read .gopclntab")
|
||||||
}
|
}
|
||||||
|
|
||||||
addr := exe.Section(".text").Addr
|
addr := exe.Section(".text").Addr
|
||||||
@ -41,11 +42,11 @@ func readPcLnTableMacho(exe *macho.File, path string) (*gosym.Table, uint64, err
|
|||||||
|
|
||||||
section := exe.Section(sectionLabel)
|
section := exe.Section(sectionLabel)
|
||||||
if section == nil {
|
if section == nil {
|
||||||
return nil, 0, fmt.Errorf("could not read section __gopclntab")
|
return nil, 0, errors.New("could not read section __gopclntab")
|
||||||
}
|
}
|
||||||
tableData, err := section.Data()
|
tableData, err := section.Data()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, fmt.Errorf("found section but could not read __gopclntab")
|
return nil, 0, errors.New("found section but could not read __gopclntab")
|
||||||
}
|
}
|
||||||
|
|
||||||
addr := exe.Section("__text").Addr
|
addr := exe.Section("__text").Addr
|
||||||
|
@ -1237,7 +1237,7 @@ func findFirstNonRuntimeFrame(p *proc.Target) (proc.Stackframe, error) {
|
|||||||
return frame, nil
|
return frame, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return proc.Stackframe{}, fmt.Errorf("non-runtime frame not found")
|
return proc.Stackframe{}, errors.New("non-runtime frame not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
func evalVariableOrError(p *proc.Target, symbol string) (*proc.Variable, error) {
|
func evalVariableOrError(p *proc.Target, symbol string) (*proc.Variable, error) {
|
||||||
@ -3842,9 +3842,9 @@ func checkFrame(frame proc.Stackframe, fnname, file string, line int, inlined bo
|
|||||||
}
|
}
|
||||||
if frame.Inlined != inlined {
|
if frame.Inlined != inlined {
|
||||||
if inlined {
|
if inlined {
|
||||||
return fmt.Errorf("not inlined")
|
return errors.New("not inlined")
|
||||||
}
|
}
|
||||||
return fmt.Errorf("inlined")
|
return errors.New("inlined")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func (grp *TargetGroup) Next() (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if grp.HasSteppingBreakpoints() {
|
if grp.HasSteppingBreakpoints() {
|
||||||
return fmt.Errorf("next while nexting")
|
return errors.New("next while nexting")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = next(grp.Selected, false, false); err != nil {
|
if err = next(grp.Selected, false, false); err != nil {
|
||||||
@ -308,7 +308,7 @@ func conditionErrors(grp *TargetGroup) error {
|
|||||||
if condErr == nil {
|
if condErr == nil {
|
||||||
condErr = bp.CondError
|
condErr = bp.CondError
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("multiple errors evaluating conditions")
|
return errors.New("multiple errors evaluating conditions")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -454,7 +454,7 @@ func (grp *TargetGroup) Step() (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if grp.HasSteppingBreakpoints() {
|
if grp.HasSteppingBreakpoints() {
|
||||||
return fmt.Errorf("next while nexting")
|
return errors.New("next while nexting")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = next(grp.Selected, true, false); err != nil {
|
if err = next(grp.Selected, true, false); err != nil {
|
||||||
@ -504,7 +504,7 @@ func (grp *TargetGroup) StepOut() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if grp.HasSteppingBreakpoints() {
|
if grp.HasSteppingBreakpoints() {
|
||||||
return fmt.Errorf("next while nexting")
|
return errors.New("next while nexting")
|
||||||
}
|
}
|
||||||
|
|
||||||
dbp := grp.Selected
|
dbp := grp.Selected
|
||||||
|
@ -131,7 +131,7 @@ func runtimeTypeToDIE(_type *Variable, dataAddr uint64) (typ godwarf.Type, kind
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, 0, fmt.Errorf("could not resolve interface type")
|
return nil, 0, errors.New("could not resolve interface type")
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolveParametricType returns the real type of t if t is a parametric
|
// resolveParametricType returns the real type of t if t is a parametric
|
||||||
|
@ -1169,7 +1169,7 @@ func (v *Variable) structMember(memberName string) (*Variable, error) {
|
|||||||
func readVarEntry(entry *godwarf.Tree, image *Image) (name string, typ godwarf.Type, err error) {
|
func readVarEntry(entry *godwarf.Tree, image *Image) (name string, typ godwarf.Type, err error) {
|
||||||
name, ok := entry.Val(dwarf.AttrName).(string)
|
name, ok := entry.Val(dwarf.AttrName).(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", nil, fmt.Errorf("malformed variable DIE (name)")
|
return "", nil, errors.New("malformed variable DIE (name)")
|
||||||
}
|
}
|
||||||
|
|
||||||
typ, err = entry.Type(image.dwarf, image.index, image.typeCache)
|
typ, err = entry.Type(image.dwarf, image.index, image.typeCache)
|
||||||
@ -1840,7 +1840,7 @@ func (v *Variable) readFloatRaw(size int64) (float64, error) {
|
|||||||
return n, nil
|
return n, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0.0, fmt.Errorf("could not read float")
|
return 0.0, errors.New("could not read float")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Variable) writeFloatRaw(f float64, size int64) error {
|
func (v *Variable) writeFloatRaw(f float64, size int64) error {
|
||||||
@ -1981,7 +1981,7 @@ func (v *Variable) loadMap(recurseLevel int, cfg LoadConfig) {
|
|||||||
|
|
||||||
for skip := 0; skip < v.mapSkip; skip++ {
|
for skip := 0; skip < v.mapSkip; skip++ {
|
||||||
if ok := it.next(); !ok {
|
if ok := it.next(); !ok {
|
||||||
v.Unreadable = fmt.Errorf("map index out of bounds")
|
v.Unreadable = errors.New("map index out of bounds")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2043,7 +2043,7 @@ func (v *Variable) mapIterator() *mapIterator {
|
|||||||
|
|
||||||
maptype, ok := sv.RealType.(*godwarf.StructType)
|
maptype, ok := sv.RealType.(*godwarf.StructType)
|
||||||
if !ok {
|
if !ok {
|
||||||
v.Unreadable = fmt.Errorf("wrong real type for map")
|
v.Unreadable = errors.New("wrong real type for map")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2184,7 +2184,7 @@ func (it *mapIterator) nextBucket() bool {
|
|||||||
|
|
||||||
// sanity checks
|
// sanity checks
|
||||||
if it.tophashes == nil || it.keys == nil || it.values == nil {
|
if it.tophashes == nil || it.keys == nil || it.values == nil {
|
||||||
it.v.Unreadable = fmt.Errorf("malformed map type")
|
it.v.Unreadable = errors.New("malformed map type")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2333,7 +2333,7 @@ func (v *Variable) loadInterface(recurseLevel int, loadData bool, cfg LoadConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
if data == nil {
|
if data == nil {
|
||||||
v.Unreadable = fmt.Errorf("invalid interface type")
|
v.Unreadable = errors.New("invalid interface type")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,8 +122,8 @@ func TestVariableEvaluation2(t *testing.T) {
|
|||||||
{"a6.Baz", true, "8", "20", "int", nil},
|
{"a6.Baz", true, "8", "20", "int", nil},
|
||||||
{"a7.Baz", true, "5", "25", "int", nil},
|
{"a7.Baz", true, "5", "25", "int", nil},
|
||||||
{"a8.Baz", true, "\"feh\"", "", "string", nil},
|
{"a8.Baz", true, "\"feh\"", "", "string", nil},
|
||||||
{"a9.Baz", true, "nil", "", "int", fmt.Errorf("a9 is nil")},
|
{"a9.Baz", true, "nil", "", "int", errors.New("a9 is nil")},
|
||||||
{"a9.NonExistent", true, "nil", "", "int", fmt.Errorf("a9 has no member NonExistent")},
|
{"a9.NonExistent", true, "nil", "", "int", errors.New("a9 has no member NonExistent")},
|
||||||
{"a8", true, "main.FooBar2 {Bur: 10, Baz: \"feh\"}", "", "main.FooBar2", nil}, // reread variable after member
|
{"a8", true, "main.FooBar2 {Bur: 10, Baz: \"feh\"}", "", "main.FooBar2", nil}, // reread variable after member
|
||||||
{"i32", true, "[2]int32 [1,2]", "", "[2]int32", nil},
|
{"i32", true, "[2]int32 [1,2]", "", "[2]int32", nil},
|
||||||
{"b1", true, "true", "false", "bool", nil},
|
{"b1", true, "true", "false", "bool", nil},
|
||||||
@ -139,10 +139,10 @@ func TestVariableEvaluation2(t *testing.T) {
|
|||||||
{"ms", true, "main.Nest {Level: 0, Nest: *main.Nest {Level: 1, Nest: *(*main.Nest)(…", "", "main.Nest", nil},
|
{"ms", true, "main.Nest {Level: 0, Nest: *main.Nest {Level: 1, Nest: *(*main.Nest)(…", "", "main.Nest", nil},
|
||||||
{"ms.Nest.Nest", true, "*main.Nest {Level: 2, Nest: *main.Nest {Level: 3, Nest: *(*main.Nest)(…", "", "*main.Nest", nil},
|
{"ms.Nest.Nest", true, "*main.Nest {Level: 2, Nest: *main.Nest {Level: 3, Nest: *(*main.Nest)(…", "", "*main.Nest", nil},
|
||||||
{"ms.Nest.Nest.Nest.Nest.Nest", true, "*main.Nest nil", "", "*main.Nest", nil},
|
{"ms.Nest.Nest.Nest.Nest.Nest", true, "*main.Nest nil", "", "*main.Nest", nil},
|
||||||
{"ms.Nest.Nest.Nest.Nest.Nest.Nest", true, "", "", "*main.Nest", fmt.Errorf("ms.Nest.Nest.Nest.Nest.Nest is nil")},
|
{"ms.Nest.Nest.Nest.Nest.Nest.Nest", true, "", "", "*main.Nest", errors.New("ms.Nest.Nest.Nest.Nest.Nest is nil")},
|
||||||
{"main.p1", true, "10", "12", "int", nil},
|
{"main.p1", true, "10", "12", "int", nil},
|
||||||
{"p1", true, "10", "13", "int", nil},
|
{"p1", true, "10", "13", "int", nil},
|
||||||
{"NonExistent", true, "", "", "", fmt.Errorf("could not find symbol value for NonExistent")},
|
{"NonExistent", true, "", "", "", errors.New("could not find symbol value for NonExistent")},
|
||||||
}
|
}
|
||||||
|
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
@ -262,8 +262,8 @@ func TestVariableEvaluationShort(t *testing.T) {
|
|||||||
{"a6.Baz", true, "8", "", "int", nil},
|
{"a6.Baz", true, "8", "", "int", nil},
|
||||||
{"a7.Baz", true, "5", "", "int", nil},
|
{"a7.Baz", true, "5", "", "int", nil},
|
||||||
{"a8.Baz", true, "\"feh\"", "", "string", nil},
|
{"a8.Baz", true, "\"feh\"", "", "string", nil},
|
||||||
{"a9.Baz", true, "nil", "", "int", fmt.Errorf("a9 is nil")},
|
{"a9.Baz", true, "nil", "", "int", errors.New("a9 is nil")},
|
||||||
{"a9.NonExistent", true, "nil", "", "int", fmt.Errorf("a9 has no member NonExistent")},
|
{"a9.NonExistent", true, "nil", "", "int", errors.New("a9 has no member NonExistent")},
|
||||||
{"a8", true, "main.FooBar2 {Bur: 10, Baz: \"feh\"}", "", "main.FooBar2", nil}, // reread variable after member
|
{"a8", true, "main.FooBar2 {Bur: 10, Baz: \"feh\"}", "", "main.FooBar2", nil}, // reread variable after member
|
||||||
{"i32", true, "[2]int32 [...]", "", "[2]int32", nil},
|
{"i32", true, "[2]int32 [...]", "", "[2]int32", nil},
|
||||||
{"b1", true, "true", "false", "bool", nil},
|
{"b1", true, "true", "false", "bool", nil},
|
||||||
@ -279,10 +279,10 @@ func TestVariableEvaluationShort(t *testing.T) {
|
|||||||
{"ms", true, "main.Nest {Level: 0, Nest: (*main.Nest)(0x…", "", "main.Nest", nil},
|
{"ms", true, "main.Nest {Level: 0, Nest: (*main.Nest)(0x…", "", "main.Nest", nil},
|
||||||
{"ms.Nest.Nest", true, "(*main.Nest)(0x…", "", "*main.Nest", nil},
|
{"ms.Nest.Nest", true, "(*main.Nest)(0x…", "", "*main.Nest", nil},
|
||||||
{"ms.Nest.Nest.Nest.Nest.Nest", true, "*main.Nest nil", "", "*main.Nest", nil},
|
{"ms.Nest.Nest.Nest.Nest.Nest", true, "*main.Nest nil", "", "*main.Nest", nil},
|
||||||
{"ms.Nest.Nest.Nest.Nest.Nest.Nest", true, "", "", "*main.Nest", fmt.Errorf("ms.Nest.Nest.Nest.Nest.Nest is nil")},
|
{"ms.Nest.Nest.Nest.Nest.Nest.Nest", true, "", "", "*main.Nest", errors.New("ms.Nest.Nest.Nest.Nest.Nest is nil")},
|
||||||
{"main.p1", true, "10", "", "int", nil},
|
{"main.p1", true, "10", "", "int", nil},
|
||||||
{"p1", true, "10", "", "int", nil},
|
{"p1", true, "10", "", "int", nil},
|
||||||
{"NonExistent", true, "", "", "", fmt.Errorf("could not find symbol value for NonExistent")},
|
{"NonExistent", true, "", "", "", errors.New("could not find symbol value for NonExistent")},
|
||||||
}
|
}
|
||||||
|
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
@ -538,18 +538,18 @@ func getEvalExpressionTestCases() []varTest {
|
|||||||
{"s1[2]", false, "\"three\"", "\"three\"", "string", nil},
|
{"s1[2]", false, "\"three\"", "\"three\"", "string", nil},
|
||||||
{"s1[3]", false, "\"four\"", "\"four\"", "string", nil},
|
{"s1[3]", false, "\"four\"", "\"four\"", "string", nil},
|
||||||
{"s1[4]", false, "\"five\"", "\"five\"", "string", nil},
|
{"s1[4]", false, "\"five\"", "\"five\"", "string", nil},
|
||||||
{"s1[5]", false, "", "", "string", fmt.Errorf("index out of bounds")},
|
{"s1[5]", false, "", "", "string", errors.New("index out of bounds")},
|
||||||
{"a1[0]", false, "\"one\"", "\"one\"", "string", nil},
|
{"a1[0]", false, "\"one\"", "\"one\"", "string", nil},
|
||||||
{"a1[1]", false, "\"two\"", "\"two\"", "string", nil},
|
{"a1[1]", false, "\"two\"", "\"two\"", "string", nil},
|
||||||
{"a1[2]", false, "\"three\"", "\"three\"", "string", nil},
|
{"a1[2]", false, "\"three\"", "\"three\"", "string", nil},
|
||||||
{"a1[3]", false, "\"four\"", "\"four\"", "string", nil},
|
{"a1[3]", false, "\"four\"", "\"four\"", "string", nil},
|
||||||
{"a1[4]", false, "\"five\"", "\"five\"", "string", nil},
|
{"a1[4]", false, "\"five\"", "\"five\"", "string", nil},
|
||||||
{"a1[5]", false, "", "", "string", fmt.Errorf("index out of bounds")},
|
{"a1[5]", false, "", "", "string", errors.New("index out of bounds")},
|
||||||
{"str1[0]", false, "48", "48", "byte", nil},
|
{"str1[0]", false, "48", "48", "byte", nil},
|
||||||
{"str1[1]", false, "49", "49", "byte", nil},
|
{"str1[1]", false, "49", "49", "byte", nil},
|
||||||
{"str1[2]", false, "50", "50", "byte", nil},
|
{"str1[2]", false, "50", "50", "byte", nil},
|
||||||
{"str1[10]", false, "48", "48", "byte", nil},
|
{"str1[10]", false, "48", "48", "byte", nil},
|
||||||
{"str1[11]", false, "", "", "byte", fmt.Errorf("index out of bounds")},
|
{"str1[11]", false, "", "", "byte", errors.New("index out of bounds")},
|
||||||
|
|
||||||
// slice/array/string reslicing
|
// slice/array/string reslicing
|
||||||
{"a1[2:4]", false, "[]string len: 2, cap: 2, [\"three\",\"four\"]", "[]string len: 2, cap: 2, [\"three\",\"four\"]", "[]string", nil},
|
{"a1[2:4]", false, "[]string len: 2, cap: 2, [\"three\",\"four\"]", "[]string len: 2, cap: 2, [\"three\",\"four\"]", "[]string", nil},
|
||||||
@ -558,8 +558,8 @@ func getEvalExpressionTestCases() []varTest {
|
|||||||
{"str1[0:11]", false, "\"01234567890\"", "\"01234567890\"", "string", nil},
|
{"str1[0:11]", false, "\"01234567890\"", "\"01234567890\"", "string", nil},
|
||||||
{"str1[:3]", false, "\"012\"", "\"012\"", "string", nil},
|
{"str1[:3]", false, "\"012\"", "\"012\"", "string", nil},
|
||||||
{"str1[3:]", false, "\"34567890\"", "\"34567890\"", "string", nil},
|
{"str1[3:]", false, "\"34567890\"", "\"34567890\"", "string", nil},
|
||||||
{"str1[0:12]", false, "", "", "string", fmt.Errorf("index out of bounds")},
|
{"str1[0:12]", false, "", "", "string", errors.New("index out of bounds")},
|
||||||
{"str1[5:3]", false, "", "", "string", fmt.Errorf("index out of bounds")},
|
{"str1[5:3]", false, "", "", "string", errors.New("index out of bounds")},
|
||||||
{"str1[11:]", false, "\"\"", "\"\"", "string", nil},
|
{"str1[11:]", false, "\"\"", "\"\"", "string", nil},
|
||||||
{"longbyteslice[:70]", false, "[]uint8 len: 70, cap: 70, [118,101,114,121,32,108,111,110,103,32,115,116,114,105,110,103,32,48,49,50,51,52,53,54,55,56,57,97,48,49,50,51,52,53,54,55,56,57,98,48,49,50,51,52,53,54,55,56,57,99,48,49,50,51,52,53,54,55,56,57,100,48,49,50,51,52,53,54,55,56]", "[]uint8 len: 70, cap: 70, [118,101,114,121,32,108,111,110,103,32,115,116,114,105,110,103,32,48,49,50,51,52,53,54,55,56,57,97,48,49,50,51,52,53,54,55,56,57,98,48,49,50,51,52,53,54,55,56,57,99,48,49,50,51,52,53,54,55,56,57,100,48,49,50,51,52,53,54,55,56]", "[]uint8", nil},
|
{"longbyteslice[:70]", false, "[]uint8 len: 70, cap: 70, [118,101,114,121,32,108,111,110,103,32,115,116,114,105,110,103,32,48,49,50,51,52,53,54,55,56,57,97,48,49,50,51,52,53,54,55,56,57,98,48,49,50,51,52,53,54,55,56,57,99,48,49,50,51,52,53,54,55,56,57,100,48,49,50,51,52,53,54,55,56]", "[]uint8 len: 70, cap: 70, [118,101,114,121,32,108,111,110,103,32,115,116,114,105,110,103,32,48,49,50,51,52,53,54,55,56,57,97,48,49,50,51,52,53,54,55,56,57,98,48,49,50,51,52,53,54,55,56,57,99,48,49,50,51,52,53,54,55,56,57,100,48,49,50,51,52,53,54,55,56]", "[]uint8", nil},
|
||||||
|
|
||||||
@ -572,12 +572,12 @@ func getEvalExpressionTestCases() []varTest {
|
|||||||
{"*p2", false, "5", "5", "int", nil},
|
{"*p2", false, "5", "5", "int", nil},
|
||||||
{"p2", true, "*5", "(*int)(0x…", "*int", nil},
|
{"p2", true, "*5", "(*int)(0x…", "*int", nil},
|
||||||
{"p3", true, "*int nil", "*int nil", "*int", nil},
|
{"p3", true, "*int nil", "*int nil", "*int", nil},
|
||||||
{"*p3", false, "", "", "int", fmt.Errorf("nil pointer dereference")},
|
{"*p3", false, "", "", "int", errors.New("nil pointer dereference")},
|
||||||
|
|
||||||
// channels
|
// channels
|
||||||
{"ch1", true, "chan int 4/11", "chan int 4/11", "chan int", nil},
|
{"ch1", true, "chan int 4/11", "chan int 4/11", "chan int", nil},
|
||||||
{"chnil", true, "chan int nil", "chan int nil", "chan int", nil},
|
{"chnil", true, "chan int nil", "chan int nil", "chan int", nil},
|
||||||
{"ch1+1", false, "", "", "", fmt.Errorf("can not convert 1 constant to chan int")},
|
{"ch1+1", false, "", "", "", errors.New("can not convert 1 constant to chan int")},
|
||||||
{"int3chan.buf", false, "*[5]main.ThreeInts [{a: 1, b: 0, c: 0},{a: 2, b: 0, c: 0},{a: 3, b: 0, c: 0},{a: 0, b: 0, c: 0},{a: 0, b: 0, c: 0}]", "(*[5]main.ThreeInts)(…", "*[5]main.ThreeInts", nil},
|
{"int3chan.buf", false, "*[5]main.ThreeInts [{a: 1, b: 0, c: 0},{a: 2, b: 0, c: 0},{a: 3, b: 0, c: 0},{a: 0, b: 0, c: 0},{a: 0, b: 0, c: 0}]", "(*[5]main.ThreeInts)(…", "*[5]main.ThreeInts", nil},
|
||||||
|
|
||||||
// maps
|
// maps
|
||||||
@ -586,8 +586,8 @@ func getEvalExpressionTestCases() []varTest {
|
|||||||
{"m2[c1.sa[2].B-4].A", false, "10", "10", "int", nil},
|
{"m2[c1.sa[2].B-4].A", false, "10", "10", "int", nil},
|
||||||
{"m2[*p1].B", false, "11", "11", "int", nil},
|
{"m2[*p1].B", false, "11", "11", "int", nil},
|
||||||
{"m3[as1]", false, "42", "42", "int", nil},
|
{"m3[as1]", false, "42", "42", "int", nil},
|
||||||
{"mnil[\"Malone\"]", false, "", "", "", fmt.Errorf("key not found")},
|
{"mnil[\"Malone\"]", false, "", "", "", errors.New("key not found")},
|
||||||
{"m1[80:]", false, "", "", "", fmt.Errorf("map index out of bounds")},
|
{"m1[80:]", false, "", "", "", errors.New("map index out of bounds")},
|
||||||
|
|
||||||
// interfaces
|
// interfaces
|
||||||
{"err1", true, "error(*main.astruct) *{A: 1, B: 2}", "error(*main.astruct) 0x…", "error", nil},
|
{"err1", true, "error(*main.astruct) *{A: 1, B: 2}", "error(*main.astruct) 0x…", "error", nil},
|
||||||
@ -601,13 +601,13 @@ func getEvalExpressionTestCases() []varTest {
|
|||||||
{"iface4", true, "interface {}([]go/constant.Value) [4]", "interface {}([]go/constant.Value) [...]", "interface {}", nil},
|
{"iface4", true, "interface {}([]go/constant.Value) [4]", "interface {}([]go/constant.Value) [...]", "interface {}", nil},
|
||||||
{"ifacenil", true, "interface {} nil", "interface {} nil", "interface {}", nil},
|
{"ifacenil", true, "interface {} nil", "interface {} nil", "interface {}", nil},
|
||||||
{"err1 == err2", false, "false", "false", "", nil},
|
{"err1 == err2", false, "false", "false", "", nil},
|
||||||
{"err1 == iface1", false, "", "", "", fmt.Errorf("mismatched types \"error\" and \"interface {}\"")},
|
{"err1 == iface1", false, "", "", "", errors.New("mismatched types \"error\" and \"interface {}\"")},
|
||||||
{"errnil == nil", false, "true", "true", "", nil},
|
{"errnil == nil", false, "true", "true", "", nil},
|
||||||
{"errtypednil == nil", false, "false", "false", "", nil},
|
{"errtypednil == nil", false, "false", "false", "", nil},
|
||||||
{"nil == errnil", false, "true", "true", "", nil},
|
{"nil == errnil", false, "true", "true", "", nil},
|
||||||
{"err1.(*main.astruct)", false, "*main.astruct {A: 1, B: 2}", "(*main.astruct)(0x…", "*main.astruct", nil},
|
{"err1.(*main.astruct)", false, "*main.astruct {A: 1, B: 2}", "(*main.astruct)(0x…", "*main.astruct", nil},
|
||||||
{"err1.(*main.bstruct)", false, "", "", "", fmt.Errorf("interface conversion: error is *main.astruct, not *main.bstruct")},
|
{"err1.(*main.bstruct)", false, "", "", "", errors.New("interface conversion: error is *main.astruct, not *main.bstruct")},
|
||||||
{"errnil.(*main.astruct)", false, "", "", "", fmt.Errorf("interface conversion: error is nil, not *main.astruct")},
|
{"errnil.(*main.astruct)", false, "", "", "", errors.New("interface conversion: error is nil, not *main.astruct")},
|
||||||
{"const1", true, "go/constant.Value(go/constant.int64Val) 3", "go/constant.Value(go/constant.int64Val) 3", "go/constant.Value", nil},
|
{"const1", true, "go/constant.Value(go/constant.int64Val) 3", "go/constant.Value(go/constant.int64Val) 3", "go/constant.Value", nil},
|
||||||
|
|
||||||
// combined expressions
|
// combined expressions
|
||||||
@ -663,8 +663,8 @@ func getEvalExpressionTestCases() []varTest {
|
|||||||
// builtins
|
// builtins
|
||||||
{"cap(parr)", false, "4", "4", "", nil},
|
{"cap(parr)", false, "4", "4", "", nil},
|
||||||
{"len(parr)", false, "4", "4", "", nil},
|
{"len(parr)", false, "4", "4", "", nil},
|
||||||
{"cap(p1)", false, "", "", "", fmt.Errorf("invalid argument p1 (type *int) for cap")},
|
{"cap(p1)", false, "", "", "", errors.New("invalid argument p1 (type *int) for cap")},
|
||||||
{"len(p1)", false, "", "", "", fmt.Errorf("invalid argument p1 (type *int) for len")},
|
{"len(p1)", false, "", "", "", errors.New("invalid argument p1 (type *int) for len")},
|
||||||
{"cap(a1)", false, "5", "5", "", nil},
|
{"cap(a1)", false, "5", "5", "", nil},
|
||||||
{"len(a1)", false, "5", "5", "", nil},
|
{"len(a1)", false, "5", "5", "", nil},
|
||||||
{"cap(s3)", false, "6", "6", "", nil},
|
{"cap(s3)", false, "6", "6", "", nil},
|
||||||
@ -691,11 +691,11 @@ func getEvalExpressionTestCases() []varTest {
|
|||||||
|
|
||||||
// nil
|
// nil
|
||||||
{"nil", false, "nil", "nil", "", nil},
|
{"nil", false, "nil", "nil", "", nil},
|
||||||
{"nil+1", false, "", "", "", fmt.Errorf("operator + can not be applied to \"nil\"")},
|
{"nil+1", false, "", "", "", errors.New("operator + can not be applied to \"nil\"")},
|
||||||
{"fn1", false, "main.afunc", "main.afunc", "main.functype", nil},
|
{"fn1", false, "main.afunc", "main.afunc", "main.functype", nil},
|
||||||
{"fn2", false, "nil", "nil", "main.functype", nil},
|
{"fn2", false, "nil", "nil", "main.functype", nil},
|
||||||
{"nilslice", false, "[]int len: 0, cap: 0, nil", "[]int len: 0, cap: 0, nil", "[]int", nil},
|
{"nilslice", false, "[]int len: 0, cap: 0, nil", "[]int len: 0, cap: 0, nil", "[]int", nil},
|
||||||
{"fn1 == fn2", false, "", "", "", fmt.Errorf("can not compare func variables")},
|
{"fn1 == fn2", false, "", "", "", errors.New("can not compare func variables")},
|
||||||
{"fn1 == nil", false, "false", "false", "", nil},
|
{"fn1 == nil", false, "false", "false", "", nil},
|
||||||
{"fn1 != nil", false, "true", "true", "", nil},
|
{"fn1 != nil", false, "true", "true", "", nil},
|
||||||
{"fn2 == nil", false, "true", "true", "", nil},
|
{"fn2 == nil", false, "true", "true", "", nil},
|
||||||
@ -713,31 +713,31 @@ func getEvalExpressionTestCases() []varTest {
|
|||||||
{"p1 != nil", false, "true", "true", "", nil},
|
{"p1 != nil", false, "true", "true", "", nil},
|
||||||
{"ch1 == nil", false, "false", "false", "", nil},
|
{"ch1 == nil", false, "false", "false", "", nil},
|
||||||
{"chnil == nil", false, "true", "true", "", nil},
|
{"chnil == nil", false, "true", "true", "", nil},
|
||||||
{"ch1 == chnil", false, "", "", "", fmt.Errorf("can not compare chan variables")},
|
{"ch1 == chnil", false, "", "", "", errors.New("can not compare chan variables")},
|
||||||
{"m1 == nil", false, "false", "false", "", nil},
|
{"m1 == nil", false, "false", "false", "", nil},
|
||||||
{"mnil == m1", false, "", "", "", fmt.Errorf("can not compare map variables")},
|
{"mnil == m1", false, "", "", "", errors.New("can not compare map variables")},
|
||||||
{"mnil == nil", false, "true", "true", "", nil},
|
{"mnil == nil", false, "true", "true", "", nil},
|
||||||
{"nil == 2", false, "", "", "", fmt.Errorf("can not compare int to nil")},
|
{"nil == 2", false, "", "", "", errors.New("can not compare int to nil")},
|
||||||
{"2 == nil", false, "", "", "", fmt.Errorf("can not compare int to nil")},
|
{"2 == nil", false, "", "", "", errors.New("can not compare int to nil")},
|
||||||
|
|
||||||
// errors
|
// errors
|
||||||
{"&3", false, "", "", "", fmt.Errorf("can not take address of \"3\"")},
|
{"&3", false, "", "", "", errors.New("can not take address of \"3\"")},
|
||||||
{"*3", false, "", "", "", fmt.Errorf("expression \"3\" (int) can not be dereferenced")},
|
{"*3", false, "", "", "", errors.New("expression \"3\" (int) can not be dereferenced")},
|
||||||
{"&(i2 + i3)", false, "", "", "", fmt.Errorf("can not take address of \"(i2 + i3)\"")},
|
{"&(i2 + i3)", false, "", "", "", errors.New("can not take address of \"(i2 + i3)\"")},
|
||||||
{"i2 + p1", false, "", "", "", fmt.Errorf("mismatched types \"int\" and \"*int\"")},
|
{"i2 + p1", false, "", "", "", errors.New("mismatched types \"int\" and \"*int\"")},
|
||||||
{"i2 + f1", false, "", "", "", fmt.Errorf("mismatched types \"int\" and \"float64\"")},
|
{"i2 + f1", false, "", "", "", errors.New("mismatched types \"int\" and \"float64\"")},
|
||||||
{"i2 << f1", false, "", "", "", fmt.Errorf("shift count type float64, must be unsigned integer")},
|
{"i2 << f1", false, "", "", "", errors.New("shift count type float64, must be unsigned integer")},
|
||||||
{"i2 << -1", false, "", "", "", fmt.Errorf("shift count must not be negative")},
|
{"i2 << -1", false, "", "", "", errors.New("shift count must not be negative")},
|
||||||
{"*(i2 + i3)", false, "", "", "", fmt.Errorf("expression \"(i2 + i3)\" (int) can not be dereferenced")},
|
{"*(i2 + i3)", false, "", "", "", errors.New("expression \"(i2 + i3)\" (int) can not be dereferenced")},
|
||||||
{"i2.member", false, "", "", "", fmt.Errorf("i2 (type int) is not a struct")},
|
{"i2.member", false, "", "", "", errors.New("i2 (type int) is not a struct")},
|
||||||
{"fmt.Println(\"hello\")", false, "", "", "", fmt.Errorf("function calls not allowed without using 'call'")},
|
{"fmt.Println(\"hello\")", false, "", "", "", errors.New("function calls not allowed without using 'call'")},
|
||||||
{"*nil", false, "", "", "", fmt.Errorf("nil can not be dereferenced")},
|
{"*nil", false, "", "", "", errors.New("nil can not be dereferenced")},
|
||||||
{"!nil", false, "", "", "", fmt.Errorf("operator ! can not be applied to \"nil\"")},
|
{"!nil", false, "", "", "", errors.New("operator ! can not be applied to \"nil\"")},
|
||||||
{"&nil", false, "", "", "", fmt.Errorf("can not take address of \"nil\"")},
|
{"&nil", false, "", "", "", errors.New("can not take address of \"nil\"")},
|
||||||
{"nil[0]", false, "", "", "", fmt.Errorf("expression \"nil\" (nil) does not support indexing")},
|
{"nil[0]", false, "", "", "", errors.New("expression \"nil\" (nil) does not support indexing")},
|
||||||
{"nil[2:10]", false, "", "", "", fmt.Errorf("can not slice \"nil\" (type nil)")},
|
{"nil[2:10]", false, "", "", "", errors.New("can not slice \"nil\" (type nil)")},
|
||||||
{"nil.member", false, "", "", "", fmt.Errorf("nil (type nil) is not a struct")},
|
{"nil.member", false, "", "", "", errors.New("nil (type nil) is not a struct")},
|
||||||
{"(map[string]main.astruct)(0x4000)", false, "", "", "", fmt.Errorf("can not convert \"0x4000\" to map[string]main.astruct")},
|
{"(map[string]main.astruct)(0x4000)", false, "", "", "", errors.New("can not convert \"0x4000\" to map[string]main.astruct")},
|
||||||
|
|
||||||
// typecasts
|
// typecasts
|
||||||
{"uint(i2)", false, "2", "2", "uint", nil},
|
{"uint(i2)", false, "2", "2", "uint", nil},
|
||||||
|
@ -850,7 +850,7 @@ func threads(t *Term, ctx callContext, args string) error {
|
|||||||
|
|
||||||
func thread(t *Term, ctx callContext, args string) error {
|
func thread(t *Term, ctx callContext, args string) error {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
return fmt.Errorf("you must specify a thread")
|
return errors.New("you must specify a thread")
|
||||||
}
|
}
|
||||||
tid, err := strconv.Atoi(args)
|
tid, err := strconv.Atoi(args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1265,7 +1265,7 @@ func restartRecorded(t *Term, ctx callContext, args string) error {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if len(v) > 1 {
|
if len(v) > 1 {
|
||||||
return fmt.Errorf("too many arguments to restart")
|
return errors.New("too many arguments to restart")
|
||||||
}
|
}
|
||||||
restartPos = v[0]
|
restartPos = v[0]
|
||||||
}
|
}
|
||||||
@ -1341,7 +1341,7 @@ func parseNewArgv(args string) (resetArgs bool, newArgv []string, newRedirects [
|
|||||||
}
|
}
|
||||||
if w[0] == "-noargs" {
|
if w[0] == "-noargs" {
|
||||||
if len(w) > 1 {
|
if len(w) > 1 {
|
||||||
return false, nil, [3]string{}, fmt.Errorf("too many arguments to restart")
|
return false, nil, [3]string{}, errors.New("too many arguments to restart")
|
||||||
}
|
}
|
||||||
return true, nil, [3]string{}, nil
|
return true, nil, [3]string{}, nil
|
||||||
}
|
}
|
||||||
@ -1663,7 +1663,7 @@ func (c *Commands) call(t *Term, ctx callContext, args string) error {
|
|||||||
|
|
||||||
func clear(t *Term, ctx callContext, args string) error {
|
func clear(t *Term, ctx callContext, args string) error {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
return fmt.Errorf("not enough arguments")
|
return errors.New("not enough arguments")
|
||||||
}
|
}
|
||||||
id, err := strconv.Atoi(args)
|
id, err := strconv.Atoi(args)
|
||||||
var bp *api.Breakpoint
|
var bp *api.Breakpoint
|
||||||
@ -1722,7 +1722,7 @@ func clearAll(t *Term, ctx callContext, args string) error {
|
|||||||
|
|
||||||
func toggle(t *Term, ctx callContext, args string) error {
|
func toggle(t *Term, ctx callContext, args string) error {
|
||||||
if args == "" {
|
if args == "" {
|
||||||
return fmt.Errorf("not enough arguments")
|
return errors.New("not enough arguments")
|
||||||
}
|
}
|
||||||
id, err := strconv.Atoi(args)
|
id, err := strconv.Atoi(args)
|
||||||
var bp *api.Breakpoint
|
var bp *api.Breakpoint
|
||||||
@ -1843,7 +1843,7 @@ func setBreakpoint(t *Term, ctx callContext, tracepoint bool, argstr string) ([]
|
|||||||
spec = argstr
|
spec = argstr
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("address required")
|
return errors.New("address required")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1984,7 +1984,7 @@ func getEditorName() (string, error) {
|
|||||||
var editor string
|
var editor string
|
||||||
if editor = os.Getenv("DELVE_EDITOR"); editor == "" {
|
if editor = os.Getenv("DELVE_EDITOR"); editor == "" {
|
||||||
if editor = os.Getenv("EDITOR"); editor == "" {
|
if editor = os.Getenv("EDITOR"); editor == "" {
|
||||||
return "", fmt.Errorf("Neither DELVE_EDITOR or EDITOR is set")
|
return "", errors.New("Neither DELVE_EDITOR or EDITOR is set")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return editor, nil
|
return editor, nil
|
||||||
@ -2083,7 +2083,7 @@ loop:
|
|||||||
case "-fmt":
|
case "-fmt":
|
||||||
arg := nextArg()
|
arg := nextArg()
|
||||||
if arg == "" {
|
if arg == "" {
|
||||||
return fmt.Errorf("expected argument after -fmt")
|
return errors.New("expected argument after -fmt")
|
||||||
}
|
}
|
||||||
fmtMapToPriFmt := map[string]byte{
|
fmtMapToPriFmt := map[string]byte{
|
||||||
"oct": 'o',
|
"oct": 'o',
|
||||||
@ -2102,22 +2102,22 @@ loop:
|
|||||||
case "-count", "-len":
|
case "-count", "-len":
|
||||||
arg := nextArg()
|
arg := nextArg()
|
||||||
if arg == "" {
|
if arg == "" {
|
||||||
return fmt.Errorf("expected argument after -count/-len")
|
return errors.New("expected argument after -count/-len")
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
count, err = strconv.Atoi(arg)
|
count, err = strconv.Atoi(arg)
|
||||||
if err != nil || count <= 0 {
|
if err != nil || count <= 0 {
|
||||||
return fmt.Errorf("count/len must be a positive integer")
|
return errors.New("count/len must be a positive integer")
|
||||||
}
|
}
|
||||||
case "-size":
|
case "-size":
|
||||||
arg := nextArg()
|
arg := nextArg()
|
||||||
if arg == "" {
|
if arg == "" {
|
||||||
return fmt.Errorf("expected argument after -size")
|
return errors.New("expected argument after -size")
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
size, err = strconv.Atoi(arg)
|
size, err = strconv.Atoi(arg)
|
||||||
if err != nil || size <= 0 || size > 8 {
|
if err != nil || size <= 0 || size > 8 {
|
||||||
return fmt.Errorf("size must be a positive integer (<=8)")
|
return errors.New("size must be a positive integer (<=8)")
|
||||||
}
|
}
|
||||||
case "-x":
|
case "-x":
|
||||||
isExpr = true
|
isExpr = true
|
||||||
@ -2133,11 +2133,11 @@ loop:
|
|||||||
|
|
||||||
// TODO, maybe configured by user.
|
// TODO, maybe configured by user.
|
||||||
if count*size > 1000 {
|
if count*size > 1000 {
|
||||||
return fmt.Errorf("read memory range (count*size) must be less than or equal to 1000 bytes")
|
return errors.New("read memory range (count*size) must be less than or equal to 1000 bytes")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
return fmt.Errorf("no address specified")
|
return errors.New("no address specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
if isExpr {
|
if isExpr {
|
||||||
@ -2193,7 +2193,7 @@ const maxPrintVarChanGoroutines = 100
|
|||||||
|
|
||||||
func (c *Commands) printVar(t *Term, ctx callContext, args string) error {
|
func (c *Commands) printVar(t *Term, ctx callContext, args string) error {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
return fmt.Errorf("not enough arguments")
|
return errors.New("not enough arguments")
|
||||||
}
|
}
|
||||||
if ctx.Prefix == onPrefix {
|
if ctx.Prefix == onPrefix {
|
||||||
ctx.Breakpoint.Variables = append(ctx.Breakpoint.Variables, args)
|
ctx.Breakpoint.Variables = append(ctx.Breakpoint.Variables, args)
|
||||||
@ -2229,7 +2229,7 @@ func (c *Commands) printVar(t *Term, ctx callContext, args string) error {
|
|||||||
|
|
||||||
func whatisCommand(t *Term, ctx callContext, args string) error {
|
func whatisCommand(t *Term, ctx callContext, args string) error {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
return fmt.Errorf("not enough arguments")
|
return errors.New("not enough arguments")
|
||||||
}
|
}
|
||||||
val, err := t.client.EvalVariable(ctx.Scope, args, ShortLoadConfig)
|
val, err := t.client.EvalVariable(ctx.Scope, args, ShortLoadConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -2258,7 +2258,7 @@ func setVar(t *Term, ctx callContext, args string) error {
|
|||||||
// HACK: in go '=' is not an operator, we detect the error and try to recover from it by splitting the input string
|
// HACK: in go '=' is not an operator, we detect the error and try to recover from it by splitting the input string
|
||||||
_, err := parser.ParseExpr(args)
|
_, err := parser.ParseExpr(args)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return fmt.Errorf("syntax error '=' not found")
|
return errors.New("syntax error '=' not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
el, ok := err.(scanner.ErrorList)
|
el, ok := err.(scanner.ErrorList)
|
||||||
@ -2353,7 +2353,7 @@ func args(t *Term, ctx callContext, args string) error {
|
|||||||
filter, cfg := parseVarArguments(args, t)
|
filter, cfg := parseVarArguments(args, t)
|
||||||
if ctx.Prefix == onPrefix {
|
if ctx.Prefix == onPrefix {
|
||||||
if filter != "" {
|
if filter != "" {
|
||||||
return fmt.Errorf("filter not supported on breakpoint")
|
return errors.New("filter not supported on breakpoint")
|
||||||
}
|
}
|
||||||
ctx.Breakpoint.LoadArgs = &cfg
|
ctx.Breakpoint.LoadArgs = &cfg
|
||||||
return nil
|
return nil
|
||||||
@ -2369,7 +2369,7 @@ func locals(t *Term, ctx callContext, args string) error {
|
|||||||
filter, cfg := parseVarArguments(args, t)
|
filter, cfg := parseVarArguments(args, t)
|
||||||
if ctx.Prefix == onPrefix {
|
if ctx.Prefix == onPrefix {
|
||||||
if filter != "" {
|
if filter != "" {
|
||||||
return fmt.Errorf("filter not supported on breakpoint")
|
return errors.New("filter not supported on breakpoint")
|
||||||
}
|
}
|
||||||
ctx.Breakpoint.LoadLocals = &cfg
|
ctx.Breakpoint.LoadLocals = &cfg
|
||||||
return nil
|
return nil
|
||||||
@ -2483,7 +2483,7 @@ func parseStackArgs(argstr string) (stackArgs, error) {
|
|||||||
case "-mode":
|
case "-mode":
|
||||||
i++
|
i++
|
||||||
if i >= len(args) {
|
if i >= len(args) {
|
||||||
return stackArgs{}, fmt.Errorf("expected normal, simple or fromg after -mode")
|
return stackArgs{}, errors.New("expected normal, simple or fromg after -mode")
|
||||||
}
|
}
|
||||||
switch args[i] {
|
switch args[i] {
|
||||||
case "normal":
|
case "normal":
|
||||||
@ -2494,7 +2494,7 @@ func parseStackArgs(argstr string) (stackArgs, error) {
|
|||||||
case "fromg":
|
case "fromg":
|
||||||
r.opts |= api.StacktraceG | api.StacktraceSimple
|
r.opts |= api.StacktraceG | api.StacktraceSimple
|
||||||
default:
|
default:
|
||||||
return stackArgs{}, fmt.Errorf("expected normal, simple or fromg after -mode")
|
return stackArgs{}, errors.New("expected normal, simple or fromg after -mode")
|
||||||
}
|
}
|
||||||
case "-a":
|
case "-a":
|
||||||
i++
|
i++
|
||||||
@ -2513,7 +2513,7 @@ func parseStackArgs(argstr string) (stackArgs, error) {
|
|||||||
default:
|
default:
|
||||||
n, err := strconv.Atoi(args[i])
|
n, err := strconv.Atoi(args[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return stackArgs{}, fmt.Errorf("depth must be a number")
|
return stackArgs{}, errors.New("depth must be a number")
|
||||||
}
|
}
|
||||||
r.depth = n
|
r.depth = n
|
||||||
}
|
}
|
||||||
@ -2592,7 +2592,7 @@ func listCommand(t *Term, ctx callContext, args string) error {
|
|||||||
|
|
||||||
func (c *Commands) sourceCommand(t *Term, ctx callContext, args string) error {
|
func (c *Commands) sourceCommand(t *Term, ctx callContext, args string) error {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
return fmt.Errorf("wrong number of arguments: source <filename>")
|
return errors.New("wrong number of arguments: source <filename>")
|
||||||
}
|
}
|
||||||
|
|
||||||
if args == "-" {
|
if args == "-" {
|
||||||
@ -3183,7 +3183,7 @@ func conditionCmd(t *Term, ctx callContext, argstr string) error {
|
|||||||
args := config.Split2PartsBySpace(argstr)
|
args := config.Split2PartsBySpace(argstr)
|
||||||
|
|
||||||
if len(args) < 2 {
|
if len(args) < 2 {
|
||||||
return fmt.Errorf("not enough arguments")
|
return errors.New("not enough arguments")
|
||||||
}
|
}
|
||||||
|
|
||||||
hitCondPerG := args[0] == "-per-g-hitcount"
|
hitCondPerG := args[0] == "-per-g-hitcount"
|
||||||
@ -3198,7 +3198,7 @@ func conditionCmd(t *Term, ctx callContext, argstr string) error {
|
|||||||
|
|
||||||
args = config.Split2PartsBySpace(args[1])
|
args = config.Split2PartsBySpace(args[1])
|
||||||
if len(args) < 2 {
|
if len(args) < 2 {
|
||||||
return fmt.Errorf("not enough arguments")
|
return errors.New("not enough arguments")
|
||||||
}
|
}
|
||||||
|
|
||||||
bp, err := getBreakpointByIDOrName(t, args[0])
|
bp, err := getBreakpointByIDOrName(t, args[0])
|
||||||
@ -3341,7 +3341,7 @@ func display(t *Term, ctx callContext, args string) error {
|
|||||||
args = strings.TrimSpace(args[len(addOption):])
|
args = strings.TrimSpace(args[len(addOption):])
|
||||||
fmtstr, args := parseFormatArg(args)
|
fmtstr, args := parseFormatArg(args)
|
||||||
if args == "" {
|
if args == "" {
|
||||||
return fmt.Errorf("not enough arguments")
|
return errors.New("not enough arguments")
|
||||||
}
|
}
|
||||||
t.addDisplay(args, fmtstr)
|
t.addDisplay(args, fmtstr)
|
||||||
t.printDisplay(len(t.displays) - 1)
|
t.printDisplay(len(t.displays) - 1)
|
||||||
@ -3355,14 +3355,14 @@ func display(t *Term, ctx callContext, args string) error {
|
|||||||
return t.removeDisplay(n)
|
return t.removeDisplay(n)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("wrong arguments")
|
return errors.New("wrong arguments")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dump(t *Term, ctx callContext, args string) error {
|
func dump(t *Term, ctx callContext, args string) error {
|
||||||
if args == "" {
|
if args == "" {
|
||||||
return fmt.Errorf("not enough arguments")
|
return errors.New("not enough arguments")
|
||||||
}
|
}
|
||||||
dumpState, err := t.client.CoreDumpStart(args)
|
dumpState, err := t.client.CoreDumpStart(args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -18,7 +18,7 @@ func configureCmd(t *Term, ctx callContext, args string) error {
|
|||||||
case "-save":
|
case "-save":
|
||||||
return config.SaveConfig(t.conf)
|
return config.SaveConfig(t.conf)
|
||||||
case "":
|
case "":
|
||||||
return fmt.Errorf("wrong number of arguments to \"config\"")
|
return errors.New("wrong number of arguments to \"config\"")
|
||||||
default:
|
default:
|
||||||
err := configureSet(t, args)
|
err := configureSet(t, args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -103,7 +103,7 @@ func configureSetSubstitutePath(t *Term, rest string) error {
|
|||||||
}
|
}
|
||||||
t.conf.SubstitutePath = append(t.conf.SubstitutePath, config.SubstitutePathRule{From: argv[0], To: argv[1]})
|
t.conf.SubstitutePath = append(t.conf.SubstitutePath, config.SubstitutePathRule{From: argv[0], To: argv[1]})
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("too many arguments to \"config substitute-path\"")
|
return errors.New("too many arguments to \"config substitute-path\"")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ func (v sliceAsStarlarkValue) Freeze() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v sliceAsStarlarkValue) Hash() (uint32, error) {
|
func (v sliceAsStarlarkValue) Hash() (uint32, error) {
|
||||||
return 0, fmt.Errorf("not hashable")
|
return 0, errors.New("not hashable")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v sliceAsStarlarkValue) String() string {
|
func (v sliceAsStarlarkValue) String() string {
|
||||||
@ -155,7 +155,7 @@ func (v structAsStarlarkValue) Freeze() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v structAsStarlarkValue) Hash() (uint32, error) {
|
func (v structAsStarlarkValue) Hash() (uint32, error) {
|
||||||
return 0, fmt.Errorf("not hashable")
|
return 0, errors.New("not hashable")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v structAsStarlarkValue) String() string {
|
func (v structAsStarlarkValue) String() string {
|
||||||
@ -290,7 +290,7 @@ func (v structVariableAsStarlarkValue) Freeze() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v structVariableAsStarlarkValue) Hash() (uint32, error) {
|
func (v structVariableAsStarlarkValue) Hash() (uint32, error) {
|
||||||
return 0, fmt.Errorf("not hashable")
|
return 0, errors.New("not hashable")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v structVariableAsStarlarkValue) String() string {
|
func (v structVariableAsStarlarkValue) String() string {
|
||||||
@ -350,7 +350,7 @@ func (v sliceVariableAsStarlarkValue) Freeze() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v sliceVariableAsStarlarkValue) Hash() (uint32, error) {
|
func (v sliceVariableAsStarlarkValue) Hash() (uint32, error) {
|
||||||
return 0, fmt.Errorf("not hashable")
|
return 0, errors.New("not hashable")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v sliceVariableAsStarlarkValue) String() string {
|
func (v sliceVariableAsStarlarkValue) String() string {
|
||||||
@ -416,7 +416,7 @@ func (v ptrVariableAsStarlarkValue) Freeze() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v ptrVariableAsStarlarkValue) Hash() (uint32, error) {
|
func (v ptrVariableAsStarlarkValue) Hash() (uint32, error) {
|
||||||
return 0, fmt.Errorf("not hashable")
|
return 0, errors.New("not hashable")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v ptrVariableAsStarlarkValue) String() string {
|
func (v ptrVariableAsStarlarkValue) String() string {
|
||||||
@ -500,7 +500,7 @@ func (v mapVariableAsStarlarkValue) Freeze() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v mapVariableAsStarlarkValue) Hash() (uint32, error) {
|
func (v mapVariableAsStarlarkValue) Hash() (uint32, error) {
|
||||||
return 0, fmt.Errorf("not hashable")
|
return 0, errors.New("not hashable")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v mapVariableAsStarlarkValue) String() string {
|
func (v mapVariableAsStarlarkValue) String() string {
|
||||||
|
@ -34,6 +34,7 @@ package starbind
|
|||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
@ -186,7 +187,7 @@ func MakeLoad() func(thread *starlark.Thread, module string) (starlark.StringDic
|
|||||||
if e == nil {
|
if e == nil {
|
||||||
if ok {
|
if ok {
|
||||||
// request for package whose loading is in progress
|
// request for package whose loading is in progress
|
||||||
return nil, fmt.Errorf("cycle in load graph")
|
return nil, errors.New("cycle in load graph")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a placeholder to indicate "load in progress".
|
// Add a placeholder to indicate "load in progress".
|
||||||
|
@ -2,6 +2,7 @@ package starbind
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
@ -86,7 +87,7 @@ func New(ctx Context, out EchoWriter) *Env {
|
|||||||
for i := range args {
|
for i := range args {
|
||||||
a, ok := args[i].(starlark.String)
|
a, ok := args[i].(starlark.String)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("argument of dlv_command is not a string")
|
return nil, errors.New("argument of dlv_command is not a string")
|
||||||
}
|
}
|
||||||
argstrs[i] = string(a)
|
argstrs[i] = string(a)
|
||||||
}
|
}
|
||||||
@ -100,11 +101,11 @@ func New(ctx Context, out EchoWriter) *Env {
|
|||||||
|
|
||||||
env.env[readFileBuiltinName] = starlark.NewBuiltin(readFileBuiltinName, func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
|
env.env[readFileBuiltinName] = starlark.NewBuiltin(readFileBuiltinName, func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
|
||||||
if len(args) != 1 {
|
if len(args) != 1 {
|
||||||
return nil, decorateError(thread, fmt.Errorf("wrong number of arguments"))
|
return nil, decorateError(thread, errors.New("wrong number of arguments"))
|
||||||
}
|
}
|
||||||
path, ok := args[0].(starlark.String)
|
path, ok := args[0].(starlark.String)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, decorateError(thread, fmt.Errorf("argument of read_file was not a string"))
|
return nil, decorateError(thread, errors.New("argument of read_file was not a string"))
|
||||||
}
|
}
|
||||||
buf, err := os.ReadFile(string(path))
|
buf, err := os.ReadFile(string(path))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -116,11 +117,11 @@ func New(ctx Context, out EchoWriter) *Env {
|
|||||||
|
|
||||||
env.env[writeFileBuiltinName] = starlark.NewBuiltin(writeFileBuiltinName, func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
|
env.env[writeFileBuiltinName] = starlark.NewBuiltin(writeFileBuiltinName, func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
|
||||||
if len(args) != 2 {
|
if len(args) != 2 {
|
||||||
return nil, decorateError(thread, fmt.Errorf("wrong number of arguments"))
|
return nil, decorateError(thread, errors.New("wrong number of arguments"))
|
||||||
}
|
}
|
||||||
path, ok := args[0].(starlark.String)
|
path, ok := args[0].(starlark.String)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, decorateError(thread, fmt.Errorf("first argument of write_file was not a string"))
|
return nil, decorateError(thread, errors.New("first argument of write_file was not a string"))
|
||||||
}
|
}
|
||||||
err := os.WriteFile(string(path), []byte(args[1].String()), 0o640)
|
err := os.WriteFile(string(path), []byte(args[1].String()), 0o640)
|
||||||
return starlark.None, decorateError(thread, err)
|
return starlark.None, decorateError(thread, err)
|
||||||
|
@ -3,6 +3,7 @@ package terminal
|
|||||||
//lint:file-ignore ST1005 errors here can be capitalized
|
//lint:file-ignore ST1005 errors here can be capitalized
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/rpc"
|
"net/rpc"
|
||||||
@ -359,7 +360,7 @@ func (t *Term) Run() (int, error) {
|
|||||||
fmt.Fprintln(t.stdout, "exit")
|
fmt.Fprintln(t.stdout, "exit")
|
||||||
return t.handleExit()
|
return t.handleExit()
|
||||||
}
|
}
|
||||||
return 1, fmt.Errorf("Prompt for input failed.\n")
|
return 1, errors.New("Prompt for input failed.\n")
|
||||||
}
|
}
|
||||||
t.stdout.Echo(t.prompt + cmdstr + "\n")
|
t.stdout.Echo(t.prompt + cmdstr + "\n")
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package dap
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -90,7 +91,7 @@ func configureSetSubstitutePath(args *launchAttachArgs, rest string) error {
|
|||||||
args.substitutePathServerToClient = append(args.substitutePathServerToClient, [2]string{argv[1], argv[0]})
|
args.substitutePathServerToClient = append(args.substitutePathServerToClient, [2]string{argv[1], argv[0]})
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("too many arguments to \"config substitutePath\"")
|
return errors.New("too many arguments to \"config substitutePath\"")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -124,7 +125,7 @@ func configureSetShowPprofLabels(args *launchAttachArgs, rest string) error {
|
|||||||
args.ShowPprofLabels = append(args.ShowPprofLabels, argv[0])
|
args.ShowPprofLabels = append(args.ShowPprofLabels, argv[0])
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("too many arguments to \"config showPprofLabels\"")
|
return errors.New("too many arguments to \"config showPprofLabels\"")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1191,7 +1191,7 @@ func (s *Session) getPackageDir(pkg string) string {
|
|||||||
// requires holding mu lock. It prepares process exec.Cmd to be started.
|
// requires holding mu lock. It prepares process exec.Cmd to be started.
|
||||||
func (s *Session) newNoDebugProcess(program string, targetArgs []string, wd string, redirected bool) (cmd *exec.Cmd, err error) {
|
func (s *Session) newNoDebugProcess(program string, targetArgs []string, wd string, redirected bool) (cmd *exec.Cmd, err error) {
|
||||||
if s.noDebugProcess != nil {
|
if s.noDebugProcess != nil {
|
||||||
return nil, fmt.Errorf("another launch request is in progress")
|
return nil, errors.New("another launch request is in progress")
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = exec.Command(program, targetArgs...)
|
cmd = exec.Command(program, targetArgs...)
|
||||||
@ -1467,7 +1467,7 @@ func (s *Session) setBreakpoints(prefix string, totalBps int, metadataFunc func(
|
|||||||
|
|
||||||
var err error
|
var err error
|
||||||
if _, ok := createdBps[want.name]; ok {
|
if _, ok := createdBps[want.name]; ok {
|
||||||
err = fmt.Errorf("breakpoint already exists")
|
err = errors.New("breakpoint already exists")
|
||||||
} else {
|
} else {
|
||||||
got.Disabled = false
|
got.Disabled = false
|
||||||
got.Cond = want.condition
|
got.Cond = want.condition
|
||||||
@ -1496,7 +1496,7 @@ func (s *Session) setBreakpoints(prefix string, totalBps int, metadataFunc func(
|
|||||||
wantLoc, err := locFunc(i)
|
wantLoc, err := locFunc(i)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if _, ok := createdBps[want.name]; ok {
|
if _, ok := createdBps[want.name]; ok {
|
||||||
err = fmt.Errorf("breakpoint already exists")
|
err = errors.New("breakpoint already exists")
|
||||||
} else {
|
} else {
|
||||||
bp := &api.Breakpoint{
|
bp := &api.Breakpoint{
|
||||||
Name: want.name,
|
Name: want.name,
|
||||||
@ -1572,7 +1572,7 @@ func (s *Session) onSetFunctionBreakpointsRequest(request *dap.SetFunctionBreakp
|
|||||||
}
|
}
|
||||||
|
|
||||||
if want.Name[0] == '.' {
|
if want.Name[0] == '.' {
|
||||||
return nil, fmt.Errorf("breakpoint names that are relative paths are not supported")
|
return nil, errors.New("breakpoint names that are relative paths are not supported")
|
||||||
}
|
}
|
||||||
// Find the location of the function name. CreateBreakpoint requires the name to include the base
|
// Find the location of the function name. CreateBreakpoint requires the name to include the base
|
||||||
// (e.g. main.functionName is supported but not functionName).
|
// (e.g. main.functionName is supported but not functionName).
|
||||||
@ -2900,7 +2900,7 @@ func (s *Session) doCall(goid, frame int, expr string) (*api.DebuggerState, []*p
|
|||||||
// and the user will get an unexpected result or an unexpected symbol error.
|
// and the user will get an unexpected result or an unexpected symbol error.
|
||||||
// We prevent this but disallowing any frames other than topmost.
|
// We prevent this but disallowing any frames other than topmost.
|
||||||
if frame > 0 {
|
if frame > 0 {
|
||||||
return nil, nil, fmt.Errorf("call is only supported with topmost stack frame")
|
return nil, nil, errors.New("call is only supported with topmost stack frame")
|
||||||
}
|
}
|
||||||
stateBeforeCall, err := s.debugger.State( /*nowait*/ true)
|
stateBeforeCall, err := s.debugger.State( /*nowait*/ true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -3266,7 +3266,7 @@ func findInstructions(procInstructions []proc.AsmInstruction, addr uint64, instr
|
|||||||
return procInstructions[i].Loc.PC >= addr
|
return procInstructions[i].Loc.PC >= addr
|
||||||
})
|
})
|
||||||
if ref == len(procInstructions) || procInstructions[ref].Loc.PC != addr {
|
if ref == len(procInstructions) || procInstructions[ref].Loc.PC != addr {
|
||||||
return nil, -1, fmt.Errorf("could not find memory reference")
|
return nil, -1, errors.New("could not find memory reference")
|
||||||
}
|
}
|
||||||
// offset is the number of instructions that should appear before the first instruction
|
// offset is the number of instructions that should appear before the first instruction
|
||||||
// returned by findInstructions.
|
// returned by findInstructions.
|
||||||
@ -3945,7 +3945,7 @@ func parseLogPoint(msg string) (bool, *logMessage, error) {
|
|||||||
if braceCount--; braceCount == 0 {
|
if braceCount--; braceCount == 0 {
|
||||||
argStr := strings.TrimSpace(string(argSlice))
|
argStr := strings.TrimSpace(string(argSlice))
|
||||||
if len(argStr) == 0 {
|
if len(argStr) == 0 {
|
||||||
return false, nil, fmt.Errorf("empty evaluation string")
|
return false, nil, errors.New("empty evaluation string")
|
||||||
}
|
}
|
||||||
args = append(args, argStr)
|
args = append(args, argStr)
|
||||||
formatSlice = append(formatSlice, '%', 's')
|
formatSlice = append(formatSlice, '%', 's')
|
||||||
@ -3961,7 +3961,7 @@ func parseLogPoint(msg string) (bool, *logMessage, error) {
|
|||||||
|
|
||||||
switch r {
|
switch r {
|
||||||
case '}':
|
case '}':
|
||||||
return false, nil, fmt.Errorf("invalid log point format, unexpected '}'")
|
return false, nil, errors.New("invalid log point format, unexpected '}'")
|
||||||
case '{':
|
case '{':
|
||||||
if braceCount++; braceCount == 1 {
|
if braceCount++; braceCount == 1 {
|
||||||
isArg, argSlice = true, []rune{}
|
isArg, argSlice = true, []rune{}
|
||||||
@ -3971,7 +3971,7 @@ func parseLogPoint(msg string) (bool, *logMessage, error) {
|
|||||||
formatSlice = append(formatSlice, r)
|
formatSlice = append(formatSlice, r)
|
||||||
}
|
}
|
||||||
if isArg {
|
if isArg {
|
||||||
return false, nil, fmt.Errorf("invalid log point format")
|
return false, nil, errors.New("invalid log point format")
|
||||||
}
|
}
|
||||||
if len(formatSlice) == 0 {
|
if len(formatSlice) == 0 {
|
||||||
return false, nil, nil
|
return false, nil, nil
|
||||||
|
@ -523,7 +523,7 @@ func (d *Debugger) Restart(rerecord bool, pos string, resetArgs bool, newArgs []
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
// We cannot build a process that we didn't start, because we don't know how it was built.
|
// We cannot build a process that we didn't start, because we don't know how it was built.
|
||||||
return nil, fmt.Errorf("cannot rebuild a binary")
|
return nil, errors.New("cannot rebuild a binary")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2016,7 +2016,7 @@ func (d *Debugger) CurrentPackage() (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
if loc.Fn == nil {
|
if loc.Fn == nil {
|
||||||
return "", fmt.Errorf("unable to determine current package due to unspecified function location")
|
return "", errors.New("unable to determine current package due to unspecified function location")
|
||||||
}
|
}
|
||||||
return loc.Fn.PackageName(), nil
|
return loc.Fn.PackageName(), nil
|
||||||
}
|
}
|
||||||
@ -2443,7 +2443,7 @@ func go11DecodeErrorCheck(err error) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Errorf("executables built by Go 1.11 or later need Delve built by Go 1.11 or later")
|
return errors.New("executables built by Go 1.11 or later need Delve built by Go 1.11 or later")
|
||||||
}
|
}
|
||||||
|
|
||||||
const NoDebugWarning string = "debuggee must not be built with 'go run' or -ldflags='-s -w', which strip debug info"
|
const NoDebugWarning string = "debuggee must not be built with 'go run' or -ldflags='-s -w', which strip debug info"
|
||||||
|
@ -979,7 +979,7 @@ type ExaminedMemoryOut struct {
|
|||||||
|
|
||||||
func (s *RPCServer) ExamineMemory(arg ExamineMemoryIn, out *ExaminedMemoryOut) error {
|
func (s *RPCServer) ExamineMemory(arg ExamineMemoryIn, out *ExaminedMemoryOut) error {
|
||||||
if arg.Length > 1000 {
|
if arg.Length > 1000 {
|
||||||
return fmt.Errorf("len must be less than or equal to 1000")
|
return errors.New("len must be less than or equal to 1000")
|
||||||
}
|
}
|
||||||
Mem, err := s.debugger.ExamineMemory(arg.Address, arg.Length)
|
Mem, err := s.debugger.ExamineMemory(arg.Address, arg.Length)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
@ -113,7 +114,7 @@ func (s *ServerImpl) Run() error {
|
|||||||
s.config.APIVersion = 1
|
s.config.APIVersion = 1
|
||||||
}
|
}
|
||||||
if s.config.APIVersion > 2 {
|
if s.config.APIVersion > 2 {
|
||||||
return fmt.Errorf("unknown API version")
|
return errors.New("unknown API version")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and start the debugger
|
// Create and start the debugger
|
||||||
@ -455,7 +456,7 @@ func (s *RPCServer) SetApiVersion(args api.SetAPIVersionIn, out *api.SetAPIVersi
|
|||||||
args.APIVersion = 1
|
args.APIVersion = 1
|
||||||
}
|
}
|
||||||
if args.APIVersion > 2 {
|
if args.APIVersion > 2 {
|
||||||
return fmt.Errorf("unknown API version")
|
return errors.New("unknown API version")
|
||||||
}
|
}
|
||||||
s.s.config.APIVersion = args.APIVersion
|
s.s.config.APIVersion = args.APIVersion
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user