Skip to content

Commit 41c3a70

Browse files
committed
stack && PP: Update color scheme
This now differentiate between package main, sources under go.mod, $GOPATH/src/..., $GOPATH/pkg/mod/..., $GOROOT/src/... Fixes #26
1 parent 38f55c2 commit 41c3a70

8 files changed

Lines changed: 27 additions & 63 deletions

File tree

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ panicparse helps make sense of Go crash dumps:
2525
goroutines, much more readable than
2626
[net/http/pprof](https://golang.org/pkg/net/http/pprof).
2727
* >50% more compact output than original stack dump yet more readable.
28-
* Exported symbols are bold, private symbols are darker.
29-
* Stdlib is green, main is yellow, rest is red.
3028
* Deduplicates redundant goroutine stacks. Useful for large server crashes.
3129
* Arguments as pointer IDs instead of raw pointer values.
3230
* Pushes stdlib-only stacks at the bottom to help focus on important code.

cmd/pp/main.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,10 @@
22
// Use of this source code is governed under the Apache License, Version 2.0
33
// that can be found in the LICENSE file.
44

5-
// panicparse: analyzes stack dump of Go processes and simplifies it.
5+
// pp: analyzes stack dump of Go processes and simplifies it.
66
//
77
// It is mostly useful on servers will large number of identical goroutines,
88
// making the crash dump harder to read than strictly necessary.
9-
//
10-
// Colors:
11-
// - Magenta: first goroutine to be listed.
12-
// - Yellow: main package.
13-
// - Green: standard library.
14-
// - Red: other packages.
15-
//
16-
// Bright colors are used for exported symbols.
179
package main
1810

1911
import (

internal/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ var defaultPalette = Palette{
5151
Package: ansi.ColorCode("default+b"),
5252
SrcFile: resetFG,
5353
FuncMain: ansi.ColorCode("yellow+b"),
54-
FuncLocationUnknown: ansi.Red,
55-
FuncLocationUnknownExported: ansi.ColorCode("red+b"),
54+
FuncLocationUnknown: ansi.White,
55+
FuncLocationUnknownExported: ansi.ColorCode("white+b"),
5656
FuncGoMod: ansi.Red,
5757
FuncGoModExported: ansi.ColorCode("red+b"),
58-
FuncGOPATH: ansi.Red,
59-
FuncGOPATHExported: ansi.ColorCode("red+b"),
60-
FuncGoPkg: ansi.Red,
61-
FuncGoPkgExported: ansi.ColorCode("red+b"),
58+
FuncGOPATH: ansi.Cyan,
59+
FuncGOPATHExported: ansi.ColorCode("cyan+b"),
60+
FuncGoPkg: ansi.Blue,
61+
FuncGoPkgExported: ansi.ColorCode("blue+b"),
6262
FuncStdLib: ansi.Green,
6363
FuncStdLibExported: ansi.ColorCode("green+b"),
6464
Arguments: resetFG,

internal/ui.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ import (
1414
// Palette defines the color used.
1515
//
1616
// An empty object Palette{} can be used to disable coloring.
17-
//
18-
// TODO(maruel): Redo the color selection as part of
19-
// https://github.com/maruel/panicparse/issues/26
2017
type Palette struct {
2118
EOLReset string
2219

main.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@
66
//
77
// It is mostly useful on servers will large number of identical goroutines,
88
// making the crash dump harder to read than strictly necessary.
9-
//
10-
// Colors:
11-
// - Magenta: first goroutine to be listed.
12-
// - Yellow: main package.
13-
// - Green: standard library.
14-
// - Red: other packages.
15-
//
16-
// Bright colors are used for exported symbols.
179
package main
1810

1911
import (

stack/data.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

stack/goroutines.tpl

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -194,42 +194,27 @@
194194
margin-top: 5em;
195195
}
196196

197-
{{- /* Highlights based on stack.Location value.
198-
TODO(maruel): Redo the color selection as part of
199-
https://github.com/maruel/panicparse/issues/26
200-
*/ -}}
197+
{{- /* Highlights based on stack.Location value. */ -}}
201198
.FuncMain {
202-
color: #808000;
203-
}
204-
.FuncLocationUnknownExported {
205-
color: #00B000;
199+
color: #880;
206200
}
207201
.FuncLocationUnknown {
208-
color: #00B000;
209-
}
210-
.FuncGoModExported {
211-
color: #C00000;
202+
color: #888;
212203
}
213204
.FuncGoMod {
214-
color: #800000;
215-
}
216-
.FuncGOPATHExported {
217-
color: #C00000;
205+
color: #800;
218206
}
219207
.FuncGOPATH {
220-
color: #800000;
221-
}
222-
.FuncGoPkgExported {
223-
color: #C00000;
208+
color: #109090;
224209
}
225210
.FuncGoPkg {
226-
color: #800000;
227-
}
228-
.FuncStdlibExported {
229-
color: #00B000;
211+
color: #008;
230212
}
231213
.FuncStdlib {
232-
color: #006000;
214+
color: #080;
215+
}
216+
.Exported {
217+
font-weight: 700;
233218
}
234219
</style>
235220
<div id="content">
@@ -309,9 +294,9 @@
309294
<td>
310295
Go module
311296
<span class="tooltip">Sources located inside a directory containing a
312-
go.mod file but outside $GOPATH.</span>
297+
<strong>go.mod</strong> file but outside $GOPATH.</span>
313298
</td>
314-
<td class="FuncGoModExported">pkg.Foo()</td>
299+
<td class="FuncGoMod Exported">pkg.Foo()</td>
315300
<td class="FuncGoMod">pkg.foo()</td>
316301
</tr>
317302
<tr class="call hastooltip">
@@ -320,16 +305,16 @@
320305
<span class="tooltip">Sources located inside the traditional $GOPATH/src
321306
directory.</span>
322307
</td>
323-
<td class="FuncGOPATHExported">pkg.Foo()</td>
308+
<td class="FuncGOPATH Exported">pkg.Foo()</td>
324309
<td class="FuncGOPATH">pkg.foo()</td>
325310
</tr>
326311
<tr class="call hastooltip">
327312
<td>
328-
Go module dependency
313+
$GOPATH/pkg/mod/...
329314
<span class="tooltip">Sources located inside the go module dependency
330315
cache under $GOPATH/pkg/mod. These files are unmodified third parties.</span>
331316
</td>
332-
<td class="FuncGoPkgExported">pkg.Foo()</td>
317+
<td class="FuncGoPkg Exported">pkg.Foo()</td>
333318
<td class="FuncGoPkg">pkg.foo()</td>
334319
</tr>
335320
<tr class="call hastooltip">
@@ -338,7 +323,7 @@
338323
<span class="tooltip">Sources from the Go standard library under
339324
$GOROOT/src/.</span>
340325
</td>
341-
<td class="FuncStdlibExported">pkg.Foo()</td>
326+
<td class="FuncStdlib Exported">pkg.Foo()</td>
342327
<td class="FuncStdlib">pkg.foo()</td>
343328
</tr>
344329
<tr class="call hastooltip">
@@ -347,7 +332,7 @@
347332
<span class="tooltip">Sources which location was not successfully
348333
determined.</span>
349334
</td>
350-
<td class="FuncLocationUnknownExported">pkg.Foo()</td>
335+
<td class="FuncLocationUnknown Exported">pkg.Foo()</td>
351336
<td class="FuncLocationUnknown">pkg.foo()</td>
352337
</tr>
353338
</table>

stack/html.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ var reMethodSymbol = regexp.MustCompile(`^\(\*?([^)]+)\)(\..+)$`)
6666

6767
func funcClass(c *Call) template.HTML {
6868
if c.Func.IsPkgMain {
69-
return "FuncMain"
69+
return "FuncMain Exported"
7070
}
7171
s := c.Location.String()
7272
if c.Func.IsExported {
73-
s += "Exported"
73+
s += " Exported"
7474
}
7575
return template.HTML("Func" + s)
7676
}

0 commit comments

Comments
 (0)