-
Notifications
You must be signed in to change notification settings - Fork 20.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
internal: support optional filter expression for debug.stacks #23605
Conversation
I don't understand what I'm doing wrong.
|
It seems to split up
|
@holiman Sorry about that, made the last min modification to not auto-expand into |
Would be pretty neat if this was supported too:
|
internal/debug/api.go
Outdated
expanded = regexp.MustCompile("[/\\.A-Za-z0-9_-]+").ReplaceAllString(expanded, "`$0` in Value") | ||
expanded = regexp.MustCompile("!(`[/\\.A-Za-z0-9_-]+`)").ReplaceAllString(expanded, "$1 not") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expanded = regexp.MustCompile("[/\\.A-Za-z0-9_-]+").ReplaceAllString(expanded, "`$0` in Value") | |
expanded = regexp.MustCompile("!(`[/\\.A-Za-z0-9_-]+`)").ReplaceAllString(expanded, "$1 not") | |
expanded = regexp.MustCompile("[/\\:.A-Za-z0-9_-]+").ReplaceAllString(expanded, "`$0` in Value") | |
expanded = regexp.MustCompile("!(`[/\\:.A-Za-z0-9_-]+`)").ReplaceAllString(expanded, "$1 not") |
For
> debug.stacks("console.go:419")
INFO [09-20|13:22:16.459] Expanded filter expression filter=console.go:419 expanded="`console.go:419` in Value"
goroutine 140 [chan receive]:
github.com/ethereum/go-ethereum/console.(*Console).readLines(0xc000596310, 0xc0004566e8, 0xc000dc3ff0, 0xc0000bb7b0)
github.com/ethereum/go-ethereum/console/console.go:419 +0x46
created by github.com/ethereum/go-ethereum/console.(*Console).Interactive
github.com/ethereum/go-ethereum/console/console.go:363 +0x1ef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just move the :
to the front of the regexp. I think the -
must be the last, otherwise it's interpreted as an interval i.e. from _
to :
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. THat's actually how I had it in my own code, but when I wrote the comment here I moved it. WCGW right? ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once :
is supported
…um#23605) * internal: support optional filter expression for debug.stacks * internal/debug: fix string regexp * internal/debug: support searching for line numbers too
Whenever Geth hangs, we use the
debug.stacks
API endpoint to try and find what might be off. This is fine-ish, but it generates a huge dump of goroutines and it's quite a pain to find a needle in the haystack and see if there's something wrong or not.The initial idea was to add a filter parameter where we can specify packages to filter for, potentially multiple - comma separated - but even that produces too much noise. Adding both inclusion filters and exclusion filters would be necessary, but that would get both nasty as well as probably still not flexible enough.
The solution is to use a single filter that can contain both inclusion and exclusion clauses, as well as the possibility to combine these arbitrarily. Without hinting further, the only way to solve it is to have the filter be a boolean expression that gets evaluated runtime and returns those goroutines which evaluate to
true
.The PR uses HashiCorp's boolean expression parser and evaluator, but to keep the filter complexity down, I've defined a simpler purpose-built syntax that gets transformed under the hood to the one used by
bexpr
. Our filter language consists of:/downloader/
,handler.go
,wait
)&&
and||
(e.g.downloader || snap
)!
(e.g.snap && !p2p
)exclude
a paranthesis.(downloader || snap) && select
)