Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Limitation of string length for qDebug() output?
QtWS25 Last Chance

Limitation of string length for qDebug() output?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qdebugstring limitqstringqtcreatorbug-17
8 Posts 3 Posters 5.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    koahnig
    wrote on 12 Oct 2016, 20:17 last edited by koahnig
    #1

    The output of strings to qDebug() is limited to 1023 characters. Does this make sense?

    I am checking with some print routines. Typically I am writing to a std::ostringstream and very often I am writing this string later on to a file. Respectively I am using qDebug() for display.

    This time the output of the routine is a bit longer about 1800 byte. qDebug() prints the characters correctly up to character 1023 and afterwards some random bytes are showing up. The output holds a couple of linefeed to make a nice output. There are already several before the "magic" limit.

    ostringstream ostrc;
    gen7.print( cout );
    gen7.print( ostrc );
    qDebug() << "String length " << ostrc.str().length();
    QString qstr ( ostrc.str().c_str() );
    qDebug() << qstr;
    qDebug() << ostrc.str().c_str();
    

    When running in the debugger the print to cout is shown correctly in Application output pane. The outputs based on QString and directly from the ostringstream show the behaviour. I have checked the qstr ist correctly filled with 1800 something bytes. Nothing special shown in the debugger around 1023. Therefore, I assume this is a speciality of qDebug().

    Vote the answer(s) that helped you to solve your issue(s)

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 12 Oct 2016, 22:11 last edited by
      #2

      Hi,

      Maybe a silly question but aren't you seeing the escaped version of the linefeed characters you are using ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      K 2 Replies Last reply 13 Oct 2016, 06:23
      0
      • S SGaist
        12 Oct 2016, 22:11

        Hi,

        Maybe a silly question but aren't you seeing the escaped version of the linefeed characters you are using ?

        K Offline
        K Offline
        koahnig
        wrote on 13 Oct 2016, 06:23 last edited by
        #3

        @SGaist

        No, I do not.

        The text is shown as it would be in a text file written to with the print routines.

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on 13 Oct 2016, 08:45 last edited by
          #4

          Digging a bit deeper I have found another reason.
          Creating a small example case:

          #include <QCoreApplication>
          
          #include <QDebug>
          #include <sstream>
          #include <iomanip>
          
          int main(int argc, char *argv[])
          {
              QCoreApplication a(argc, argv);
          
              std::ostringstream ostr;
          
              for ( unsigned i = 0; i < 120; ++i )
                  ostr << std:: setw( 10 ) << i << std::endl;
          
              qDebug() << ostr.str().c_str();
          
              return 0;
          }
          

          In the application output pane this shown:

          Debugging starts
                   0
                   1
                   2
                   3
                   4
                   5
                   6
                   7
                   8
                   9
                  10
                  11
                  12
                  13
                  14
                  15
                  16
                  17
                  18
                  19
                  20
                  21
                  22
                  23
                  24
                  25
                  26
                  27
                  28
                  29
                  30
                  31
                  32
                  33
                  34
                  35
                  36
                  37
                  38
                  39
                  40
                  41
                  42
                  43
                  44
                  45
                  46
                  47
                  48
                  49
                  50
                  51
                  52
                  53
                  54
                  55
                  56
                  57
                  58
                  59
                  60
                  61
                  62
                  63
                  64
                  65
                  66
                  67
                  68
                  69
                  70
                  71
                  72
                  73
                  74
                  75
                  76
                  77
                  78
                  79
                  80
                  81
                  82
                  83
                  84
                  85
                  86
                  87
                  88
                  89
                  90
                  91
                  92
           ‘Ø7kDebugging has finished
          

          Actually it is showing 2 Japanese or Chinese style characters which are not shown here. However, that is not the point anyway.

          At first I had run the small application in terminal mode. The problem does NOT appear in terminal output. It is limited to the output pane of Qt creator.

          Therefore the focus shifts to Qt creator. Which is version 4.0.3 on windows 10 (64bit).
          The tests were done with Qt 5.4.2 and Qt 5.7.0 precompiled libs and tools as required.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • K Offline
            K Offline
            koahnig
            wrote on 13 Oct 2016, 11:03 last edited by
            #5

            I have updated Qt creator to 4.1.0 and the bahviour is still there.
            Bug report on JIRA created QTCREATORBUG-17117

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            0
            • S SGaist
              12 Oct 2016, 22:11

              Hi,

              Maybe a silly question but aren't you seeing the escaped version of the linefeed characters you are using ?

              K Offline
              K Offline
              koahnig
              wrote on 13 Oct 2016, 11:06 last edited by
              #6

              @SGaist

              I think you are referring to this closed bug report QTBUG-50722.
              Luckily I have used Qt lib versions navigating around this bug ;)
              Neither Qt5.4.2 nor Qt5.7.0 does show this.

              Vote the answer(s) that helped you to solve your issue(s)

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 13 Oct 2016, 12:12 last edited by
                #7

                Thanks for the report !

                I was thinking more about QTBUG-47316.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • aha_1980A Offline
                  aha_1980A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on 16 Sept 2020, 18:15 last edited by
                  #8

                  The reason for this is a GDB limitation on Windows. See QTCREATORBUG-24649 for more information.

                  Regards

                  Qt has to stay free or it will die.

                  1 Reply Last reply
                  2

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved