From 502db632d582365ed182c9f9ef99143cbfaa2d61 Mon Sep 17 00:00:00 2001 From: Caleb Bassi Date: Thu, 6 Sep 2018 13:57:56 -0700 Subject: [PATCH] Remove panicparse --- .gitignore | 2 ++ Gopkg.lock | 9 --------- Gopkg.toml | 4 ---- render.go | 53 ++--------------------------------------------------- 4 files changed, 4 insertions(+), 64 deletions(-) diff --git a/.gitignore b/.gitignore index 8b156b0..a3825c9 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ _testmain.go *.prof .DS_Store /vendor +.vscode/ +.mypy_cache/ diff --git a/Gopkg.lock b/Gopkg.lock index 2f46fa4..006ad54 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -9,14 +9,6 @@ revision = "346938d642f2ec3594ed81d874461961cd0faa76" version = "v1.1.0" -[[projects]] - branch = "master" - digest = "1:2eeeebccad4f052e6037527e86b8114c6bfd184a97f84d4449a5ea6ad202c216" - name = "github.com/maruel/panicparse" - packages = ["stack"] - pruneopts = "UT" - revision = "4417700b5a8d33fbb4416bb04359d20329f60008" - [[projects]] digest = "1:e2d1d410fb367567c2b53ed9e2d719d3c1f0891397bb2fa49afd747cfbf1e8e4" name = "github.com/mattn/go-runewidth" @@ -70,7 +62,6 @@ analyzer-version = 1 input-imports = [ "github.com/davecgh/go-spew/spew", - "github.com/maruel/panicparse/stack", "github.com/mattn/go-runewidth", "github.com/mitchellh/go-wordwrap", "github.com/nsf/termbox-go", diff --git a/Gopkg.toml b/Gopkg.toml index ecf4d0b..8ef822b 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -1,7 +1,3 @@ -[[constraint]] - name = "github.com/maruel/panicparse" - branch = "master" - [[constraint]] name = "github.com/davecgh/go-spew" version = "1.1.0" diff --git a/render.go b/render.go index 7b4fbb2..999e632 100644 --- a/render.go +++ b/render.go @@ -6,19 +6,10 @@ package termui import ( "image" - "io" + "runtime/debug" "sync" "time" - "fmt" - - "os" - - "runtime/debug" - - "bytes" - - "github.com/maruel/panicparse/stack" tm "github.com/nsf/termbox-go" ) @@ -104,47 +95,7 @@ func render(bs ...Bufferer) { defer func() { if e := recover(); e != nil { Close() - fmt.Fprintf(os.Stderr, "Captured a panic(value=%v) when rendering Bufferer. Exit termui and clean terminal...\nPrint stack trace:\n\n", e) - //debug.PrintStack() - gs, err := stack.ParseDump(bytes.NewReader(debug.Stack()), os.Stderr, false) - if err != nil { - debug.PrintStack() - os.Exit(1) - } - buckets := stack.Aggregate(gs.Goroutines, stack.AnyValue) - for _, bucket := range buckets { - srcLen, pkgLen := 0, 0 - for _, line := range bucket.Signature.Stack.Calls { - if l := len(line.SrcLine()); l > srcLen { - srcLen = l - } - if l := len(line.Func.PkgName()); l > pkgLen { - pkgLen = l - } - } - extra := "" - if s := bucket.SleepString(); s != "" { - extra += " [" + s + "]" - } - if bucket.Locked { - extra += " [locked]" - } - if c := bucket.CreatedByString(false); c != "" { - extra += " [Created by " + c + "]" - } - io.WriteString(os.Stdout, fmt.Sprintf("%d: %s%s\n", len(bucket.IDs), bucket.State, extra)) - - for _, line := range bucket.Stack.Calls { - io.WriteString(os.Stdout, fmt.Sprintf( - " %-*s %-*s %s(%s)\n", - pkgLen, line.Func.PkgName(), srcLen, line.SrcLine(), - line.Func.Name(), &line.Args)) - } - if bucket.Stack.Elided { - io.WriteString(os.Stdout, " (...)\n") - } - } - os.Exit(1) + panic(debug.Stack()) } }() for _, b := range bs {