From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 98A0E3857C52; Fri, 1 Oct 2021 07:56:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 98A0E3857C52 From: "m.weghorn at posteo dot de" To: gdb-prs@sourceware.org Subject: [Bug server/28392] gdb server no longer supports argument globbing and variable substitution Date: Fri, 01 Oct 2021 07:56:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: server X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: m.weghorn at posteo dot de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Oct 2021 07:56:15 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D28392 --- Comment #1 from Michael Weghorn --- Thanks for the detailed report. I have to admit I was not aware of the feat= ures my commit broke, nor the '--no-startup-with-shell' arg for gdbserver. Some thoughts/observations: * Args with spaces still don't work when using the '--no-startup-with-shell' arg for gdbserver. (Before bea571ebd78ee29cb94adf648fbcda1e109e1be6, such a= rgs were silently split into multiple args as described in PR 25893, now gdbser= ver exits saying "can't handle command-line argument containing whitespace".) T= hat should IMHO be fixed independently of the case where 'startup-with-shell' is enabled. * What gdb essentially does on UNIX-like systems when 'startup-with-shell' = is enabled is to run the program in a shell using " -c ' '". * "Plain" gdb by default has "startup-with-shell" enabled, but it still esc= apes special characters in args passed when running 'gdb --args ', as gdbserver does now after bea571ebd78ee29cb94adf648fbcda1e109e1be6 ("plain" = GDB also uses 'construct_inferior_arguments', s. 'set_inferior_args_vector' in gdb/infcmd.c). Features (described in "startup-with-shell" section at [1]) like variable substitution, expanding wildcard characters and I/O redirection in the shell only apply for args set in the GDB prompt or via the '--eval-command' arg, = e.g. using 'run ' or 'set args '. * So far, I see no way to make both, the features described here as well as= the case with spaces in arguments (as described in PR 25893) work at the same t= ime for args passed on the command line when 'startup-with-shell' is enabled. F= rom how I understand it, just escaping specific characters wouldn't help. E.g. = when only escaping spaces, an '>out.txt 2>err.txt' would then still not work as previously/expected, would behave like an unescaped '>"out.txt 2" >"err.txt"'. Given that, the most reasonable approach I can currently come up with to br= ing back globbing, variable substitution and I/O redirection in the shell: * for the case where 'startup-with-shell' is enabled, change back to the behaviour before commit bea571ebd78ee29cb94adf648fbcda1e109e1be6 * accept that gdbserver and "plain" gdb treat args passed via command l= ine differently by default (i.e. when '--no-startup-with-shell' is not explicit= ly set for gdbserver) * given that args are passed to the shell in an unmodified way, the scenario from PR 25893 is then possibly supposed to be regarded as a featur= e, not a bug... * As opposed to the expectation in PR 25893, args with spaces and special characters then need to be escaped/quoted by the user when startup-with-she= ll is enabled for gdbserver, e.g. by running gdbserver localhost:50505 ./myprogram '"hello world"' or gdbserver localhost:50505 ./myprogram "hello\ world" instead of just gdbserver localhost:50505 ./myprogram "hello world" * when using the '--no-startup-with-shell' arg for gdbserver, no extra esca= ping needs to be done by the user, i.e. the following should work and result in a single "hello world" arg being passed to the inferior: gdbserver --no-startup-with-shell localhost:50505 ./myprogram "hello wo= rld" What do you think? Any thoughts or better ideas how to deal with the situat= ion are highly appreciated. [1] https://sourceware.org/gdb/onlinedocs/gdb/Starting.html --=20 You are receiving this mail because: You are on the CC list for the bug.=