gdb disable breakpoint in particular thread
Asked Answered
B

1

6

Is it possible to disable gdb breakpoints on a per-thread basis?

I have a breakpoint which triggers every 100 milliseconds in the background worker thread. But I need to debug the same location in any other threads. So it would be cool to disable breakpoint only in the background worker thread. Is it possible?

Maybe I can disable thread by adding some specially crafted condition to this breakpoint when I know thread's number?

Bole answered 22/6, 2016 at 21:32 Comment(0)
H
7

Gdb provides two convenience variables, $_thread and $_gthread (the latter being pretty new), which can be used in conditions to refer to the current thread.

So, once the worker thread has started, you can use info thread to find its number. Then you can change your breakpoint (supposing for this example that it is breakpoint 2) like:

(gdb) cond 2 $_thread != 57
Horus answered 23/6, 2016 at 14:2 Comment(2)
Thank you. This is what I was looking for.Bole
I was too, but found a case where it does not work as I've interpreted it to work: #76585090Jetliner

© 2022 - 2024 — McMap. All rights reserved.