Xcode has built-in GDB. You can print basic data types using the print command during debugging, but complex types like qstring won't work. Although we can view the corresponding qstring value in the program code by adding the QT debug print statement qdebug () <"Debug strtext:" <strtext and other methods, however, this is obviously inconvenient during debugging. Fortunately, GDB provides the extension function to customize the macro command mode and put the custom command to $ home /. in the gdbinit file, it can be automatically loaded every time GDB is started. The following code is excerpted from the Internet:
Define printqstring
Printf "(qstring) 0x % x (length = % I): \" ", & $ arg0, $ arg0.d-> size
Set $ I = 0
While $ I <$ arg0.d-> size
Set $ c = $ arg0.d-> data [$ I ++]
If $ C <32 | $ C> 127
Printf "\ u0x % 04x", $ C
Else
Printf "% C", (char) $ C
End
End
Printf "\" \ n"
End
In this way, xcode can print the corresponding qstring type value in print strtext mode during project debugging;
The above is for versions earlier than xcode4.0. For Versions later than xcode4.0, the built-in compiler is replaced with llvm, and the original GDB is replaced with lldb, that is, the preceding custom macro command method does not work, in this case, we can use another method to print the related string by converting the qstring type: Print strtext. tolatin1.data ().
Xcode debug and print qstring