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

Debugger on macOS treats a single argument with spaces inside double quotes as multiple arguments

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • Qt Creator 4.10.0
    • Qt Creator 4.9.2
    • Debugger
    • None
    • macOS 10.14.6 (Mojave)
      Xcode 10.3
      QtCreator 4.9.2
    • macOS
    • 5b33660a575e71b0eb7a70593b69d6efbd1ceebd

    Description

      In my run settings I have a command line argument containing spaces, "foo bar", enclosed in double quotes. When I try to run in QtCreator's debugger this always gets split into two arguments, i.e. the double quotes are ignored. This only happens in the debugger. When running outside the debugger, "foo bar" gets treated correctly as just one argument.

      You can see this even with a trivial test program that just prints out argc and argv:

      #include <iostream>
      using namespace std;
      int main(int argc, char** argv) {
        cout << "argc = " << argc << endl;
        for (int i = 0; i < argc; i++)
          cout << "argc[" << i << "] = " << argv[i] << endl;
        return 0;
      }

      For example, if I run myprog "foo bar" in the debugger, I can see that

        argc = 3
        argv[0] = myprog
        argv[1] = foo
        argv[2] = bar

      so it looks like the double quotes have been stripped before argument parsing happens. However when running with the exact same arguments outside the debugger I get the correct result:

        argc = 2
        argv[0] = myprog
        argv[1] = "foo bar"

      This is a major problem because it means you can't pass a filename containing spaces into your program when debugging.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            hjk hjk
            vilya Vilya Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes