Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCC: Force a function call after every instruction (for multithreaded testing)?

I'm trying to test a rather threading-sensitive area in my program and was wondering if there's a way to force gcc to insert a call after every instruction it emits so that I can manually yield to a different thread?

Thanks, Robert

like image 540
Robert Fraser Avatar asked Feb 06 '26 06:02

Robert Fraser


1 Answers

No, GCC does not has such an option.

However, you may be able hack together a script that does that job. You can compile your code to assembler using the -S option. Compiler generated assembler is relative easy to parse.

Don't forget to save the flags and all registers inside your debugging code though.

like image 85
Nils Pipenbrinck Avatar answered Feb 07 '26 18:02

Nils Pipenbrinck



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!