Threads are scheduled by the operating system, which has many syscalls to manage their execution status. When Delve hits an interrupt (trap) instruction for a breakpoint, it asks the OS to suspend all the other OS threads. Goroutine thread stacks are managed by Go, and Delve inspects all those stacks to show you goroutines. So, when a goroutine hits a breakpoint, its underlying OS thread hits a trap, and in this trap handler, all the other OS threads are stopped, see here for example:
https://github.com/go-delve/delve/blob/master/pkg/proc/native/proc_linux.go#L546 -- Marcin On Wed, Jun 9, 2021 at 6:48 AM xie cui <cuiwei...@gmail.com> wrote: > as for as i known, in linux, seting a breakpoint means we set int 3 > instruction to the right place, it's easy to understand in single core os > for me. but what happen when it's multi-core multi-thread enviroment like > go program. using goland when set a breakpoint, when the breakpoint hit, it > seems all the thread of the process is pause, how delve stop other thread > that no run to the breakpoint, i am confused. > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/2e6cadaa-51e4-49d5-9a49-6f6ee97d1055n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/2e6cadaa-51e4-49d5-9a49-6f6ee97d1055n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CA%2Bv29LvQQLpRgAqtsXWnzUoyu36M%2BhnosONXaNJQSCf6DxPD_w%40mail.gmail.com.