Solved Breakpoint in Qt Creator not working...
-
I have a class which contains a bunch of Q_INVOKABLE functions, here is just one of them:
Q_INVOKABLE void notify(const QJsonObject& crobjModule, QJsonObject objCmds);
Here is the function implementation:
void clsScriptHelper::notify(const QJsonObject& crobjModule ,QJsonObject objCmds) { //Not a broadcast, module must be known! QJsonObject::const_iterator citrFound = crobjModule.find(clsJSON::mscszSource); if ( citrFound == crobjModule.end() ) { return; } const QString cstrAlias = citrFound.value().toString(); //Look up the socket for the module clsModule* pModule = clsModule::pGetModule(cstrAlias); if ( pModule == nullptr ) { return; } //Add the origin module name to the packet clsJSON::addCommonJSONflds(objCmds, clsJSON::mscszCmdNotify, pModule); objCmds.insert(clsJSON::mscszAddrTo, cstrAlias); emit pModule->sendJSON(objCmds, pModule->psckGetReceiver()); }
I have a breakpoint on the first line of this function, previously it has always worked and still does and previously I have been able to step into this with the debugger. Now for some reason when a debug my application and this is the only breakpoint enabled, I can see that the routine is being called from my logs and things that are happening in my application, but the breakpoint isn't working.
What could explain this?
The version of Qt Creator:
Qt Creator 4.14.0 Based on Qt 5.15.2 (Clang 11.0 (Apple), 64 bit) Built on Dec 17 2020 07:57:30 From revision 909f74dc56
My project is build using Qt 5.15.2 clang 64bit.
Whats an unclaimed breakpoint?
-
@JonB , sorry, I thought I had explained, I've put several breakpoints in the application and none of them halt the application whilst it is running in debug mode.
Fixed now...I was chasing a rabbit down a whole with the Unclaimed breakpoint thinking that was what was wrong, when in actual fact it was a bug in the code which I've fixed and not its all back to working.
-
@SPlatten
Did you start by deleting all files in the build directory and rebuilding for debug from scratch, before going any further?An "an unclaimed breakpoint" is one lost in the ether :) Not good if that coincides with this issue.
-
@JonB Thank you, I've just deleted everything from the build folder including hidden files, will build now. Its still the same, do I need to close Qt Creator and then restart as the breakpoint is still unclaimed ?
[Edit] Closed Qt Creator, then deleted everything from build folder including hidden folders, restarted Qt Creator, breakpoint still unclaimed. Build completed, tried debugging, breakpoint still doesn't work.
This together with the clazy messages are not giving me any faith in the IDE.
-
@SPlatten
I think it's not an IDE issue, more a debugger one. And clazy isn't the IDE either :)I presume you have deleted the breakpoint (make sure "unclaimed" goes away) and re-created.
Does this only happen on the first line? Or when it's the only breakpoint? Can you have a working breakpoint later in the method?
-
@JonB , I've tried restarting system, deleting and recreating breakpoints, deleted folder contents again, rebuilt, still getting the same...what has caused this?
I just did the following:
- Removed all breakpoints.
- Closed Qt Creator
- Checked build folder was empty, which it is.
- Restarted Qt Creator
- Went to the first line in the function:
void clsScriptHelper::notify(const QJsonObject& crobjModule ,QJsonObject objCmds) { //Not a broadcast, module must be known! QJsonObject::const_iterator citrFound = crobjModule.find(clsJSON::mscszSource); if ( citrFound == crobjModule.end() ) { return; } const QString cstrAlias = citrFound.value().toString(); //Look up the socket for the module clsModule* pModule = clsModule::pGetModule(cstrAlias); if ( pModule == nullptr ) { return; } //Add the origin module name to the packet clsJSON::addCommonJSONflds(objCmds, clsJSON::mscszCmdNotify, pModule); objCmds.insert(clsJSON::mscszAddrTo, cstrAlias); emit pModule->sendJSON(objCmds, pModule->psckGetReceiver()); }
Breakpont set on:
QJsonObject::const_iterator citrFound = crobjModule.find(clsJSON::mscszSource);
When I hover over the breakpoint:
Unclaimed Breakpoint State: Enabled Breakpoint Type: Breakpoint by File and Line Filename: Users/Sy/XMLMPAM/clsScriptHelper.cpp Line Number: 788 Module: Breakpoint Address:
Every breakpoint that is created exhibits the same behaviour.
-
@SPlatten
First, let's be clear. A breakpoint can only be claimed when you are running in the debugger. So, you do not say, but if you are hovering over breakpoints not while debugging they will always be "Unclaimed", and show much as you quote. Only once you start debugging does a breakpoint get claimed. And then only if/when it loads the module. And then only if thinks the source code being shown matches what it thinks was used to do the compilation of the loaded module/debug symbols file. Which is where occasionally things go sticky.So, let's start with: when are you hovering breakpoints? We are only interested in when debugging. Given that, is it failing to claim all breakpoints in this file? In other files?
-
@JonB , I click on the icon bottom left with the tool tip "Start debugging of startup project", the project is to Debug mode and thats it what is built.
When the application is started it should go directly to the breakpoint, I can see by the log file that it has passed the breakpoint. Whilst the application is starting up the breakpoint is no longer unclaimed, but once the application has started, no tool tips are displayed when I hover over the breakpoint and it doesn't stop at the breakpoint.
Then...after a while when the mouse is over the breakpoint it does display:
Breakpoint Internal ID 2 State Enabled, breakpoint inserted Breakpoint Type: Breakpoint by File and Line Filename: Users/Sy/XMLMPAM/clsScriptHelper.cpp Line Number: 788 Module: Breakpoint Address: Property Requested Obtained Breakpoint Address 0x100099683
-
@SPlatten said in Breakpoint in Qt Creator not working...:
When the application is started it should go directly to the breakpoint, I can see by the log file that it has passed the breakpoint
I do understand this.
Then...after a while when the mouse is over the breakpoint it does display:
Then it looks claimed. It may take a second to find it after first load. I don't know if you have an unusually long delay which is indicative of anything.
I have now asked you a couple of times: can you put a breakpoint (which acts correctly) anywhere else in that module/file? Can you put a breakpoint on any other module in your project?
-
@JonB , sorry, I thought I had explained, I've put several breakpoints in the application and none of them halt the application whilst it is running in debug mode.
Fixed now...I was chasing a rabbit down a whole with the Unclaimed breakpoint thinking that was what was wrong, when in actual fact it was a bug in the code which I've fixed and not its all back to working.
-
@SPlatten
So the summary is: "for functionclsScriptHelper::notify
only, no breakpoint works on any line". Right?It's as though the debug loader cannot find it/tie it with this code. Please make certain there is no chance of another definition of
void clsScriptHelper::notify()
in some other module!Not sure what it will reveal, but put a
Q_ASSERT(false);
somewhere in the function. When it's hit the debugger ought jump to that line, but I think it won't for you? Examine the stack trace for where it claims you are broken at in what source file.If you cannot rename it to test for that, I can only suggest you start chopping out lines and see if you ever get to place a breakpoint which works. If it happened "suddenly", revert to an older version of code from VC and see how that behaved.
-
@JonB Thank you for your input and time, please see edit to previous post whilst you were posting.
-
@SPlatten
I don't see how " it was a bug in the code which I've fixed" could resolve an unclaimed breakpoint. But there you are. -
@JonB , that I don't understand, but as you said it was only showing as Unclaimed whilst not debugging and in the editor. Now it's working.