Xcode debug and print qstring

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.