Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-26501

Inconsistent display of byte arrays

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • Qt Creator 5.0.2
    • Debugger
    • None
    • Ubuntu 20.04 gdb 9.2
    • Linux/Wayland

    Description

      The following snippet:

      #include <stdint.h>
      
      int main()
      {
      	const char          ascii0[] = "Hello";
      	const uint8_t       ascii1[] = "Hello";
      	const unsigned char ascii2[] = "Hello";
      	const char          data0[] = "\x12\x34\x00\x56\x78";
      	const uint8_t       data1[] = "\x12\x34\x00\x56\x78";
      	const unsigned char data2[] = "\x12\x34\x00\x56\x78";
      	return ascii0[0]
      			+ ascii1[0]
      			+ ascii2[0]
      			+ data0[0]
      			+ data1[0]
      			+ data2[0];
      }
      

      generates total different Debugger outputs for the various arrays.

      • ascii0 and ascii2 are shown completely including the NULL terminator. It is possible to view the array elementsas char, dec and hex when expanding the view
      • ascii1 is similar, but does not show the NULL terminator. When exanding, you only see the decimal value.
      • data0 shows no summary, but you can expand it to see all values Edit: that was due to the "Raw Data" value display format. If you change it back, it behaves like unsigned char.
      • data1 is truncated at the first NULL which is really painful when debugging binary data in uint8_t arrays
      • data2 is nearly perfect. Only improvement would be a display format that shows the summary in hex

      Summary:

      • Don't truncate unit8_t[] at the NULL and handle it like char[]
      • Show a summary for char[] when it contains binary data (like unsigned char)
      • Add a display format to show all characters in hex, as this is mandatory for binary data. Up to now the array is always interpreted as a string in some encoding.

      Attachments

        1. Creator-Debugger-Array.png
          Creator-Debugger-Array.png
          280 kB
        2. MSVC2019.png
          MSVC2019.png
          123 kB
        3. Without trailing null bytes.png
          Without trailing null bytes.png
          197 kB
        For Gerrit Dashboard: QTCREATORBUG-26501
        # Subject Branch Project Status CR V

        Activity

          People

            aha_1980 André Hartmann
            aha_1980 André Hartmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are 2 open Gerrit changes