mirror of
https://github.com/google/gops.git
synced 2024-11-27 08:31:17 +02:00
add stack-legacy command to dump call traces in legacy format
Unfortunately legacy format is more helpful in debug as it dumps goroutine labels. 'gops stack' doesn't dump them. Golang issue: https://github.com/golang/go/issues/63712
This commit is contained in:
parent
582fc2828e
commit
4b85e90101
@ -208,6 +208,8 @@ func formatBytes(val uint64) string {
|
|||||||
|
|
||||||
func handle(conn io.ReadWriter, msg []byte) error {
|
func handle(conn io.ReadWriter, msg []byte) error {
|
||||||
switch msg[0] {
|
switch msg[0] {
|
||||||
|
case signal.StackTraceLegacy:
|
||||||
|
return pprof.Lookup("goroutine").WriteTo(conn, 1)
|
||||||
case signal.StackTrace:
|
case signal.StackTrace:
|
||||||
return pprof.Lookup("goroutine").WriteTo(conn, 2)
|
return pprof.Lookup("goroutine").WriteTo(conn, 2)
|
||||||
case signal.GC:
|
case signal.GC:
|
||||||
|
@ -35,6 +35,11 @@ func AgentCommands() []*cobra.Command {
|
|||||||
short: "Prints the stack trace.",
|
short: "Prints the stack trace.",
|
||||||
fn: stackTrace,
|
fn: stackTrace,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "stack-legacy",
|
||||||
|
short: "Prints the stack trace in legacy mode but with labels.",
|
||||||
|
fn: stackTraceLegacy,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "gc",
|
name: "gc",
|
||||||
short: "Runs the garbage collector and blocks until successful.",
|
short: "Runs the garbage collector and blocks until successful.",
|
||||||
@ -147,6 +152,10 @@ func stackTrace(addr net.TCPAddr, _ []string) error {
|
|||||||
return cmdWithPrint(addr, signal.StackTrace)
|
return cmdWithPrint(addr, signal.StackTrace)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stackTraceLegacy(addr net.TCPAddr, _ []string) error {
|
||||||
|
return cmdWithPrint(addr, signal.StackTraceLegacy)
|
||||||
|
}
|
||||||
|
|
||||||
func gc(addr net.TCPAddr, _ []string) error {
|
func gc(addr net.TCPAddr, _ []string) error {
|
||||||
_, err := cmd(addr, signal.GC)
|
_, err := cmd(addr, signal.GC)
|
||||||
return err
|
return err
|
||||||
|
@ -35,4 +35,7 @@ const (
|
|||||||
|
|
||||||
// SetGCPercent sets the garbage collection target percentage.
|
// SetGCPercent sets the garbage collection target percentage.
|
||||||
SetGCPercent = byte(0x10)
|
SetGCPercent = byte(0x10)
|
||||||
|
|
||||||
|
// StackTraceLegacy represents a command to print stack trace in a legacy format (but it includes labels).
|
||||||
|
StackTraceLegacy = byte(0x11)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user