5 ms·
The problem is that the normal implementation of a breakpoint/step is replace a single byte with a 0xCC opcode (INT 3), which will be hit by every thread. Makin
by 1_player 8y ago
The problem is that the normal implementation of a breakpoint/step is replace a single byte with a 0xCC opcode (INT 3), which will be hit by every thread. Making it lock onto a single thread would require a conditional breakpoint, checking the thread ID every time that code path is executed, which might potentially use a lot of CPU. I'm not sure that kind of conditional breakpoint has hardware support.
It's definitely possible to implement, but not as easy as using a regular INT 3 instruction.
- legulere 8y agoShould be doable with help from the operating system to have thread-local storage for the code segment when debugging.
- 1_player 8y agoThat sounds like a pretty good idea, would be nice to see gdb implement something like that.
- nitwit005 8y agoNot sure anyone would care about that cost. Generally people are glad to waste CPU time instead of human time.