how break point work in multi-thread multi-core linux?

101 views
Skip to first unread message

xie cui

unread,
Jun 9, 2021, 9:47:39 AM6/9/21
to golang-nuts
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.

Marcin Romaszewicz

unread,
Jun 10, 2021, 2:19:35 AM6/10/21
to xie cui, golang-nuts
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:


On Wed, Jun 9, 2021 at 6:48 AM xie cui <cuiw...@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...@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.
Reply all
Reply to author
Forward
0 new messages