delve
delve copied to clipboard
Feature request: invoke debugger from inside program
Python's PDB and Ruby's IRB both have a convenient feature for starting the debugger programatically from inside the code. The advantage is that it's equal or less effort than printf debugging.
Ex:
package main
import "github.com/go-delve/delve"
func main() {
delve.Debug()
}
I don't know if this is feasible, but I figured it would be worth asking.
Maybe what you want is runtime.Breakpoint
.
package main
import (
"fmt"
"runtime"
)
func main() {
runtime.Breakpoint()
fmt.Printf("hello world")
}
dlv debug main.go
then c
@chainhelen I'm aware of runtime.Breakpoint
. What I'm suggesting is a purely ergonomic improvement which would make me (and I think a lot of others) reach for delve in a lot of cases where I/they usually wouldn't. I get that it seems trivial/insignificant, but I think it's the reason I find myself using pdb all the time, any only using delve as a last resort.
The only way to do this would be to have the target program start the delve (as a separate process) and ask it to attach. It's likely to be a lot of work to provide a minor convenience.
@aarzilli complexity aside, would it be possible to run delve in the same process as the target program?
No, it would deadlock itself.
I see. Would you be opposed to leaving this issue open just to gauge interest?
Yes, that's fine.
Doesn't look like there's been enough interest for this in the past 3 years.