1

I think I've broken the rules on thread affinity somewhere in my Qt C++ application.

I'm getting lots of messages like this:

QBasicTimer::stop: Failed. Possibly trying to stop from a different thread
QBasicTimer::start: Timers cannot be started from another thread

I am using DDD/GDB. Can I insert some kind of trap which will catch these errors and give me a backtrace? Ideally suspending all other threads in the meantime?

I tried to halt on writing to stdout (b write if 1==$rdi as per this) but that didn't work.

Community
  • 1
  • 1
spraff
  • 32,570
  • 22
  • 121
  • 229
  • 2
    Can't you just set a breakpoint on the line of code that writes the diagnostic message? – IInspectable Feb 26 '16 at 00:15
  • 1
    No, that line of code is buried somewhere in the Qt libraries. The point of this is to determine where, and what code path triggers it. – spraff Feb 26 '16 at 01:00
  • Qt is available as source code. You cannot hope to debug Qt applications without access to its source code. – IInspectable Feb 26 '16 at 01:50
  • Yes, you can, it's just not ideal. I've [tried setting up debugging symbols](http://unix.stackexchange.com/questions/202374/how-to-debug-an-installed-qt5-library-with-gdb) but that hasn't worked for some reason. I'm asking if there's another way. Such as knowing that Qt routes errors through such-and-such which *is* debuggable, hypothetically, or provides a lesser-known interface for installing event handlers, or whatever. I'm asking for the non-obvious. Use some imagination! – spraff Feb 26 '16 at 02:05
  • Sorry, no imagination from my end. Use the obvious solution, and get your debug symbols properly set up. You'll need those more often than you think, if you plan to keep using Qt. – IInspectable Feb 26 '16 at 02:09
  • 2
    One option is to install a custom Qt message handler using `qInstallMsgHandler`. Then you can check if the debug text is equal to some known timer error and add a breakpoint. But the most straightforward way is to install Qt debug info and add a breakpoint inside the Qt source. – hank Feb 26 '16 at 06:58

0 Answers0