mirror of
https://github.com/beego/bee.git
synced 2025-07-01 17:20:17 +00:00
Updated vendor
This commit is contained in:
2094
vendor/github.com/go-delve/delve/pkg/terminal/command.go
generated
vendored
Normal file
2094
vendor/github.com/go-delve/delve/pkg/terminal/command.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
191
vendor/github.com/go-delve/delve/pkg/terminal/config.go
generated
vendored
Normal file
191
vendor/github.com/go-delve/delve/pkg/terminal/config.go
generated
vendored
Normal file
@ -0,0 +1,191 @@
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/go-delve/delve/pkg/config"
|
||||
)
|
||||
|
||||
func configureCmd(t *Term, ctx callContext, args string) error {
|
||||
switch args {
|
||||
case "-list":
|
||||
return configureList(t)
|
||||
case "-save":
|
||||
return config.SaveConfig(t.conf)
|
||||
case "":
|
||||
return fmt.Errorf("wrong number of arguments to \"config\"")
|
||||
default:
|
||||
return configureSet(t, args)
|
||||
}
|
||||
}
|
||||
|
||||
type configureIterator struct {
|
||||
cfgValue reflect.Value
|
||||
cfgType reflect.Type
|
||||
i int
|
||||
}
|
||||
|
||||
func iterateConfiguration(conf *config.Config) *configureIterator {
|
||||
cfgValue := reflect.ValueOf(conf).Elem()
|
||||
cfgType := cfgValue.Type()
|
||||
|
||||
return &configureIterator{cfgValue, cfgType, -1}
|
||||
}
|
||||
|
||||
func (it *configureIterator) Next() bool {
|
||||
it.i++
|
||||
return it.i < it.cfgValue.NumField()
|
||||
}
|
||||
|
||||
func (it *configureIterator) Field() (name string, field reflect.Value) {
|
||||
name = it.cfgType.Field(it.i).Tag.Get("yaml")
|
||||
if comma := strings.Index(name, ","); comma >= 0 {
|
||||
name = name[:comma]
|
||||
}
|
||||
field = it.cfgValue.Field(it.i)
|
||||
return
|
||||
}
|
||||
|
||||
func configureFindFieldByName(conf *config.Config, name string) reflect.Value {
|
||||
it := iterateConfiguration(conf)
|
||||
for it.Next() {
|
||||
fieldName, field := it.Field()
|
||||
if fieldName == name {
|
||||
return field
|
||||
}
|
||||
}
|
||||
return reflect.ValueOf(nil)
|
||||
}
|
||||
|
||||
func configureList(t *Term) error {
|
||||
w := new(tabwriter.Writer)
|
||||
w.Init(os.Stdout, 0, 8, 1, ' ', 0)
|
||||
|
||||
it := iterateConfiguration(t.conf)
|
||||
for it.Next() {
|
||||
fieldName, field := it.Field()
|
||||
if fieldName == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
if field.Kind() == reflect.Ptr {
|
||||
if !field.IsNil() {
|
||||
fmt.Fprintf(w, "%s\t%v\n", fieldName, field.Elem())
|
||||
} else {
|
||||
fmt.Fprintf(w, "%s\t<not defined>\n", fieldName)
|
||||
}
|
||||
} else {
|
||||
fmt.Fprintf(w, "%s\t%v\n", fieldName, field)
|
||||
}
|
||||
}
|
||||
return w.Flush()
|
||||
}
|
||||
|
||||
func configureSet(t *Term, args string) error {
|
||||
v := strings.SplitN(args, " ", 2)
|
||||
|
||||
cfgname := v[0]
|
||||
var rest string
|
||||
if len(v) == 2 {
|
||||
rest = v[1]
|
||||
}
|
||||
|
||||
if cfgname == "alias" {
|
||||
return configureSetAlias(t, rest)
|
||||
}
|
||||
|
||||
field := configureFindFieldByName(t.conf, cfgname)
|
||||
if !field.CanAddr() {
|
||||
return fmt.Errorf("%q is not a configuration parameter", cfgname)
|
||||
}
|
||||
|
||||
if field.Kind() == reflect.Slice && field.Type().Elem().Name() == "SubstitutePathRule" {
|
||||
return configureSetSubstitutePath(t, rest)
|
||||
}
|
||||
|
||||
simpleArg := func(typ reflect.Type) (reflect.Value, error) {
|
||||
switch typ.Kind() {
|
||||
case reflect.Int:
|
||||
n, err := strconv.Atoi(rest)
|
||||
if err != nil {
|
||||
return reflect.ValueOf(nil), fmt.Errorf("argument to %q must be a number", cfgname)
|
||||
}
|
||||
return reflect.ValueOf(&n), nil
|
||||
case reflect.Bool:
|
||||
v := rest == "true"
|
||||
return reflect.ValueOf(&v), nil
|
||||
default:
|
||||
return reflect.ValueOf(nil), fmt.Errorf("unsupported type for configuration key %q", cfgname)
|
||||
}
|
||||
}
|
||||
|
||||
if field.Kind() == reflect.Ptr {
|
||||
val, err := simpleArg(field.Type().Elem())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
field.Set(val)
|
||||
} else {
|
||||
val, err := simpleArg(field.Type())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
field.Set(val.Elem())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func configureSetSubstitutePath(t *Term, rest string) error {
|
||||
argv := config.SplitQuotedFields(rest, '"')
|
||||
switch len(argv) {
|
||||
case 1: // delete substitute-path rule
|
||||
for i := range t.conf.SubstitutePath {
|
||||
if t.conf.SubstitutePath[i].From == argv[0] {
|
||||
copy(t.conf.SubstitutePath[i:], t.conf.SubstitutePath[i+1:])
|
||||
t.conf.SubstitutePath = t.conf.SubstitutePath[:len(t.conf.SubstitutePath)-1]
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("could not find rule for %q", argv[0])
|
||||
case 2: // add substitute-path rule
|
||||
for i := range t.conf.SubstitutePath {
|
||||
if t.conf.SubstitutePath[i].From == argv[0] {
|
||||
t.conf.SubstitutePath[i].To = argv[1]
|
||||
return nil
|
||||
}
|
||||
}
|
||||
t.conf.SubstitutePath = append(t.conf.SubstitutePath, config.SubstitutePathRule{argv[0], argv[1]})
|
||||
default:
|
||||
return fmt.Errorf("too many arguments to \"config substitute-path\"")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func configureSetAlias(t *Term, rest string) error {
|
||||
argv := config.SplitQuotedFields(rest, '"')
|
||||
switch len(argv) {
|
||||
case 1: // delete alias rule
|
||||
for k := range t.conf.Aliases {
|
||||
v := t.conf.Aliases[k]
|
||||
for i := range v {
|
||||
if v[i] == argv[0] {
|
||||
copy(v[i:], v[i+1:])
|
||||
t.conf.Aliases[k] = v[:len(v)-1]
|
||||
}
|
||||
}
|
||||
}
|
||||
case 2: // add alias rule
|
||||
alias, cmd := argv[1], argv[0]
|
||||
if t.conf.Aliases == nil {
|
||||
t.conf.Aliases = make(map[string][]string)
|
||||
}
|
||||
t.conf.Aliases[cmd] = append(t.conf.Aliases[cmd], alias)
|
||||
}
|
||||
t.cmds.Merge(t.conf.Aliases)
|
||||
return nil
|
||||
}
|
32
vendor/github.com/go-delve/delve/pkg/terminal/disasmprint.go
generated
vendored
Normal file
32
vendor/github.com/go-delve/delve/pkg/terminal/disasmprint.go
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"path/filepath"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/go-delve/delve/service/api"
|
||||
)
|
||||
|
||||
func DisasmPrint(dv api.AsmInstructions, out io.Writer) {
|
||||
bw := bufio.NewWriter(out)
|
||||
defer bw.Flush()
|
||||
if len(dv) > 0 && dv[0].Loc.Function != nil {
|
||||
fmt.Fprintf(bw, "TEXT %s(SB) %s\n", dv[0].Loc.Function.Name(), dv[0].Loc.File)
|
||||
}
|
||||
tw := tabwriter.NewWriter(bw, 1, 8, 1, '\t', 0)
|
||||
defer tw.Flush()
|
||||
for _, inst := range dv {
|
||||
atbp := ""
|
||||
if inst.Breakpoint {
|
||||
atbp = "*"
|
||||
}
|
||||
atpc := ""
|
||||
if inst.AtPC {
|
||||
atpc = "=>"
|
||||
}
|
||||
fmt.Fprintf(tw, "%s\t%s:%d\t%#x%s\t%x\t%s\n", atpc, filepath.Base(inst.Loc.File), inst.Loc.Line, inst.Loc.PC, atbp, inst.Bytes, inst.Text)
|
||||
}
|
||||
}
|
54
vendor/github.com/go-delve/delve/pkg/terminal/docgen.go
generated
vendored
Normal file
54
vendor/github.com/go-delve/delve/pkg/terminal/docgen.go
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func replaceDocPath(s string) string {
|
||||
const docpath = "$GOPATH/src/github.com/go-delve/delve/"
|
||||
|
||||
for {
|
||||
start := strings.Index(s, docpath)
|
||||
if start < 0 {
|
||||
return s
|
||||
}
|
||||
var end int
|
||||
for end = start + len(docpath); end < len(s); end++ {
|
||||
if s[end] == ' ' {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
text := s[start+len(docpath) : end]
|
||||
s = s[:start] + fmt.Sprintf("[%s](//github.com/go-delve/delve/tree/master/%s)", text, text) + s[end:]
|
||||
}
|
||||
}
|
||||
|
||||
func (commands *Commands) WriteMarkdown(w io.Writer) {
|
||||
fmt.Fprint(w, "# Commands\n\n")
|
||||
|
||||
fmt.Fprint(w, "Command | Description\n")
|
||||
fmt.Fprint(w, "--------|------------\n")
|
||||
for _, cmd := range commands.cmds {
|
||||
h := cmd.helpMsg
|
||||
if idx := strings.Index(h, "\n"); idx >= 0 {
|
||||
h = h[:idx]
|
||||
}
|
||||
fmt.Fprintf(w, "[%s](#%s) | %s\n", cmd.aliases[0], cmd.aliases[0], h)
|
||||
}
|
||||
fmt.Fprint(w, "\n")
|
||||
|
||||
for _, cmd := range commands.cmds {
|
||||
fmt.Fprintf(w, "## %s\n%s\n\n", cmd.aliases[0], replaceDocPath(cmd.helpMsg))
|
||||
if len(cmd.aliases) > 1 {
|
||||
fmt.Fprint(w, "Aliases:")
|
||||
for _, alias := range cmd.aliases[1:] {
|
||||
fmt.Fprintf(w, " %s", alias)
|
||||
}
|
||||
fmt.Fprint(w, "\n")
|
||||
}
|
||||
fmt.Fprint(w, "\n")
|
||||
}
|
||||
}
|
391
vendor/github.com/go-delve/delve/pkg/terminal/terminal.go
generated
vendored
Normal file
391
vendor/github.com/go-delve/delve/pkg/terminal/terminal.go
generated
vendored
Normal file
@ -0,0 +1,391 @@
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"syscall"
|
||||
|
||||
"github.com/peterh/liner"
|
||||
|
||||
"github.com/go-delve/delve/pkg/config"
|
||||
"github.com/go-delve/delve/service"
|
||||
"github.com/go-delve/delve/service/api"
|
||||
)
|
||||
|
||||
const (
|
||||
historyFile string = ".dbg_history"
|
||||
terminalHighlightEscapeCode string = "\033[%2dm"
|
||||
terminalResetEscapeCode string = "\033[0m"
|
||||
)
|
||||
|
||||
const (
|
||||
ansiBlack = 30
|
||||
ansiRed = 31
|
||||
ansiGreen = 32
|
||||
ansiYellow = 33
|
||||
ansiBlue = 34
|
||||
ansiMagenta = 35
|
||||
ansiCyan = 36
|
||||
ansiWhite = 37
|
||||
ansiBrBlack = 90
|
||||
ansiBrRed = 91
|
||||
ansiBrGreen = 92
|
||||
ansiBrYellow = 93
|
||||
ansiBrBlue = 94
|
||||
ansiBrMagenta = 95
|
||||
ansiBrCyan = 96
|
||||
ansiBrWhite = 97
|
||||
)
|
||||
|
||||
// Term represents the terminal running dlv.
|
||||
type Term struct {
|
||||
client service.Client
|
||||
conf *config.Config
|
||||
prompt string
|
||||
line *liner.State
|
||||
cmds *Commands
|
||||
dumb bool
|
||||
stdout io.Writer
|
||||
InitFile string
|
||||
|
||||
// quitContinue is set to true by exitCommand to signal that the process
|
||||
// should be resumed before quitting.
|
||||
quitContinue bool
|
||||
|
||||
quittingMutex sync.Mutex
|
||||
quitting bool
|
||||
}
|
||||
|
||||
// New returns a new Term.
|
||||
func New(client service.Client, conf *config.Config) *Term {
|
||||
cmds := DebugCommands(client)
|
||||
if conf != nil && conf.Aliases != nil {
|
||||
cmds.Merge(conf.Aliases)
|
||||
}
|
||||
|
||||
if conf == nil {
|
||||
conf = &config.Config{}
|
||||
}
|
||||
|
||||
var w io.Writer
|
||||
|
||||
dumb := strings.ToLower(os.Getenv("TERM")) == "dumb"
|
||||
if dumb {
|
||||
w = os.Stdout
|
||||
} else {
|
||||
w = getColorableWriter()
|
||||
}
|
||||
|
||||
if client != nil {
|
||||
client.SetReturnValuesLoadConfig(&LongLoadConfig)
|
||||
}
|
||||
|
||||
if (conf.SourceListLineColor > ansiWhite &&
|
||||
conf.SourceListLineColor < ansiBrBlack) ||
|
||||
conf.SourceListLineColor < ansiBlack ||
|
||||
conf.SourceListLineColor > ansiBrWhite {
|
||||
conf.SourceListLineColor = ansiBlue
|
||||
}
|
||||
|
||||
return &Term{
|
||||
client: client,
|
||||
conf: conf,
|
||||
prompt: "(dlv) ",
|
||||
line: liner.NewLiner(),
|
||||
cmds: cmds,
|
||||
dumb: dumb,
|
||||
stdout: w,
|
||||
}
|
||||
}
|
||||
|
||||
// Close returns the terminal to its previous mode.
|
||||
func (t *Term) Close() {
|
||||
t.line.Close()
|
||||
}
|
||||
|
||||
func (t *Term) sigintGuard(ch <-chan os.Signal, multiClient bool) {
|
||||
for range ch {
|
||||
if multiClient {
|
||||
answer, err := t.line.Prompt("Would you like to [s]top the target or [q]uit this client, leaving the target running [s/q]? ")
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v", err)
|
||||
continue
|
||||
}
|
||||
answer = strings.TrimSpace(answer)
|
||||
switch answer {
|
||||
case "s":
|
||||
_, err := t.client.Halt()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v", err)
|
||||
}
|
||||
case "q":
|
||||
t.quittingMutex.Lock()
|
||||
t.quitting = true
|
||||
t.quittingMutex.Unlock()
|
||||
err := t.client.Disconnect(false)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v", err)
|
||||
} else {
|
||||
t.Close()
|
||||
}
|
||||
default:
|
||||
fmt.Println("only s or q allowed")
|
||||
}
|
||||
|
||||
} else {
|
||||
fmt.Printf("received SIGINT, stopping process (will not forward signal)\n")
|
||||
_, err := t.client.Halt()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Run begins running dlv in the terminal.
|
||||
func (t *Term) Run() (int, error) {
|
||||
defer t.Close()
|
||||
|
||||
multiClient := t.client.IsMulticlient()
|
||||
|
||||
// Send the debugger a halt command on SIGINT
|
||||
ch := make(chan os.Signal)
|
||||
signal.Notify(ch, syscall.SIGINT)
|
||||
go t.sigintGuard(ch, multiClient)
|
||||
|
||||
t.line.SetCompleter(func(line string) (c []string) {
|
||||
for _, cmd := range t.cmds.cmds {
|
||||
for _, alias := range cmd.aliases {
|
||||
if strings.HasPrefix(alias, strings.ToLower(line)) {
|
||||
c = append(c, alias)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
})
|
||||
|
||||
fullHistoryFile, err := config.GetConfigFilePath(historyFile)
|
||||
if err != nil {
|
||||
fmt.Printf("Unable to load history file: %v.", err)
|
||||
}
|
||||
|
||||
f, err := os.Open(fullHistoryFile)
|
||||
if err != nil {
|
||||
f, err = os.Create(fullHistoryFile)
|
||||
if err != nil {
|
||||
fmt.Printf("Unable to open history file: %v. History will not be saved for this session.", err)
|
||||
}
|
||||
}
|
||||
|
||||
t.line.ReadHistory(f)
|
||||
f.Close()
|
||||
fmt.Println("Type 'help' for list of commands.")
|
||||
|
||||
if t.InitFile != "" {
|
||||
err := t.cmds.executeFile(t, t.InitFile)
|
||||
if err != nil {
|
||||
if _, ok := err.(ExitRequestError); ok {
|
||||
return t.handleExit()
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "Error executing init file: %s\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
for {
|
||||
cmdstr, err := t.promptForInput()
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
fmt.Println("exit")
|
||||
return t.handleExit()
|
||||
}
|
||||
return 1, fmt.Errorf("Prompt for input failed.\n")
|
||||
}
|
||||
|
||||
if err := t.cmds.Call(cmdstr, t); err != nil {
|
||||
if _, ok := err.(ExitRequestError); ok {
|
||||
return t.handleExit()
|
||||
}
|
||||
// The type information gets lost in serialization / de-serialization,
|
||||
// so we do a string compare on the error message to see if the process
|
||||
// has exited, or if the command actually failed.
|
||||
if strings.Contains(err.Error(), "exited") {
|
||||
fmt.Fprintln(os.Stderr, err.Error())
|
||||
} else {
|
||||
t.quittingMutex.Lock()
|
||||
quitting := t.quitting
|
||||
t.quittingMutex.Unlock()
|
||||
if quitting {
|
||||
return t.handleExit()
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "Command failed: %s\n", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Println prints a line to the terminal.
|
||||
func (t *Term) Println(prefix, str string) {
|
||||
if !t.dumb {
|
||||
terminalColorEscapeCode := fmt.Sprintf(terminalHighlightEscapeCode, t.conf.SourceListLineColor)
|
||||
prefix = fmt.Sprintf("%s%s%s", terminalColorEscapeCode, prefix, terminalResetEscapeCode)
|
||||
}
|
||||
fmt.Fprintf(t.stdout, "%s%s\n", prefix, str)
|
||||
}
|
||||
|
||||
// Substitutes directory to source file.
|
||||
//
|
||||
// Ensures that only directory is substituted, for example:
|
||||
// substitute from `/dir/subdir`, substitute to `/new`
|
||||
// for file path `/dir/subdir/file` will return file path `/new/file`.
|
||||
// for file path `/dir/subdir-2/file` substitution will not be applied.
|
||||
//
|
||||
// If more than one substitution rule is defined, the rules are applied
|
||||
// in the order they are defined, first rule that matches is used for
|
||||
// substitution.
|
||||
func (t *Term) substitutePath(path string) string {
|
||||
path = crossPlatformPath(path)
|
||||
if t.conf == nil {
|
||||
return path
|
||||
}
|
||||
|
||||
// On windows paths returned from headless server are as c:/dir/dir
|
||||
// though os.PathSeparator is '\\'
|
||||
|
||||
separator := "/" //make it default
|
||||
if strings.Index(path, "\\") != -1 { //dependent on the path
|
||||
separator = "\\"
|
||||
}
|
||||
for _, r := range t.conf.SubstitutePath {
|
||||
from := crossPlatformPath(r.From)
|
||||
to := r.To
|
||||
|
||||
if !strings.HasSuffix(from, separator) {
|
||||
from = from + separator
|
||||
}
|
||||
if !strings.HasSuffix(to, separator) {
|
||||
to = to + separator
|
||||
}
|
||||
if strings.HasPrefix(path, from) {
|
||||
return strings.Replace(path, from, to, 1)
|
||||
}
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
func crossPlatformPath(path string) string {
|
||||
if runtime.GOOS == "windows" {
|
||||
return strings.ToLower(path)
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
func (t *Term) promptForInput() (string, error) {
|
||||
l, err := t.line.Prompt(t.prompt)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
l = strings.TrimSuffix(l, "\n")
|
||||
if l != "" {
|
||||
t.line.AppendHistory(l)
|
||||
}
|
||||
|
||||
return l, nil
|
||||
}
|
||||
|
||||
func yesno(line *liner.State, question string) (bool, error) {
|
||||
for {
|
||||
answer, err := line.Prompt(question)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
answer = strings.ToLower(strings.TrimSpace(answer))
|
||||
switch answer {
|
||||
case "n", "no":
|
||||
return false, nil
|
||||
case "y", "yes":
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Term) handleExit() (int, error) {
|
||||
fullHistoryFile, err := config.GetConfigFilePath(historyFile)
|
||||
if err != nil {
|
||||
fmt.Println("Error saving history file:", err)
|
||||
} else {
|
||||
if f, err := os.OpenFile(fullHistoryFile, os.O_RDWR, 0666); err == nil {
|
||||
_, err = t.line.WriteHistory(f)
|
||||
if err != nil {
|
||||
fmt.Println("readline history error:", err)
|
||||
}
|
||||
f.Close()
|
||||
}
|
||||
}
|
||||
|
||||
t.quittingMutex.Lock()
|
||||
quitting := t.quitting
|
||||
t.quittingMutex.Unlock()
|
||||
if quitting {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
s, err := t.client.GetState()
|
||||
if err != nil {
|
||||
return 1, err
|
||||
}
|
||||
if !s.Exited {
|
||||
if t.quitContinue {
|
||||
err := t.client.Disconnect(true)
|
||||
if err != nil {
|
||||
return 2, err
|
||||
}
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
doDetach := true
|
||||
if t.client.IsMulticlient() {
|
||||
answer, err := yesno(t.line, "Would you like to kill the headless instance? [Y/n] ")
|
||||
if err != nil {
|
||||
return 2, io.EOF
|
||||
}
|
||||
doDetach = answer
|
||||
}
|
||||
|
||||
if doDetach {
|
||||
kill := true
|
||||
if t.client.AttachedToExistingProcess() {
|
||||
answer, err := yesno(t.line, "Would you like to kill the process? [Y/n] ")
|
||||
if err != nil {
|
||||
return 2, io.EOF
|
||||
}
|
||||
kill = answer
|
||||
}
|
||||
if err := t.client.Detach(kill); err != nil {
|
||||
return 1, err
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// loadConfig returns an api.LoadConfig with the parameterss specified in
|
||||
// the configuration file.
|
||||
func (t *Term) loadConfig() api.LoadConfig {
|
||||
r := api.LoadConfig{true, 1, 64, 64, -1}
|
||||
|
||||
if t.conf != nil && t.conf.MaxStringLen != nil {
|
||||
r.MaxStringLen = *t.conf.MaxStringLen
|
||||
}
|
||||
if t.conf != nil && t.conf.MaxArrayValues != nil {
|
||||
r.MaxArrayValues = *t.conf.MaxArrayValues
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
14
vendor/github.com/go-delve/delve/pkg/terminal/terminal_other.go
generated
vendored
Normal file
14
vendor/github.com/go-delve/delve/pkg/terminal/terminal_other.go
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
// +build !windows
|
||||
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
// getColorableWriter simply returns stdout on
|
||||
// *nix machines.
|
||||
func getColorableWriter() io.Writer {
|
||||
return os.Stdout
|
||||
}
|
35
vendor/github.com/go-delve/delve/pkg/terminal/terminal_windows.go
generated
vendored
Normal file
35
vendor/github.com/go-delve/delve/pkg/terminal/terminal_windows.go
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/mattn/go-colorable"
|
||||
)
|
||||
|
||||
// getColorableWriter will return a writer that is capable
|
||||
// of interpreting ANSI escape codes for terminal colors.
|
||||
func getColorableWriter() io.Writer {
|
||||
if strings.ToLower(os.Getenv("ConEmuANSI")) == "on" {
|
||||
// The ConEmu terminal is installed. Use it.
|
||||
return os.Stdout
|
||||
}
|
||||
|
||||
const ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004
|
||||
|
||||
h, err := syscall.GetStdHandle(syscall.STD_OUTPUT_HANDLE)
|
||||
if err != nil {
|
||||
return os.Stdout
|
||||
}
|
||||
var m uint32
|
||||
err = syscall.GetConsoleMode(h, &m)
|
||||
if err != nil {
|
||||
return os.Stdout
|
||||
}
|
||||
if m&ENABLE_VIRTUAL_TERMINAL_PROCESSING != 0 {
|
||||
return os.Stdout
|
||||
}
|
||||
return colorable.NewColorableStdout()
|
||||
}
|
Reference in New Issue
Block a user