From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D701E38930C3; Wed, 29 Apr 2020 09:14:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D701E38930C3 From: "m.weghorn at posteo dot de" To: gdb-prs@sourceware.org Subject: [Bug server/25893] New: gdbserver incorrectly handles program args containing space Date: Wed, 29 Apr 2020 09:14:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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: Wed, 29 Apr 2020 09:14:50 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D25893 Bug ID: 25893 Summary: gdbserver incorrectly handles program args containing space Product: gdb Version: HEAD Status: UNCONFIRMED Severity: normal Priority: P2 Component: server Assignee: unassigned at sourceware dot org Reporter: m.weghorn at posteo dot de Target Milestone: --- gdbserver cannot handle program arguments containing space, but splits such arguments into separate ones. # Steps to reproduce: 1) compile small sample program ("test.cxx") given below: g++ -g -O0 -o test test.cxx 2) run with gdbserver, passing an arg containing space gdbserver localhost:50505 test "hello world" 3) attach with GDB, and inspect the program arguments: (gdb) target remote localhost:50505 [...] (gdb) break main Breakpoint 1 at 0x555555555174: file test.cxx, line 3. (gdb) c Continuing. [...] Breakpoint 1, main (argc=3D3, argv=3D0x7fffffffddf8) at test.cxx:3 3 std::cout << argv[1] << std::endl; (gdb) p argc $1 =3D 3 (gdb) p argv[1] $2 =3D 0x7fffffffe1a6 "hello" (gdb) p argv[2] $3 =3D 0x7fffffffe1ac "world" (gdb)=20 # Actual result: Instead of showing a single argument "hello world", two separate arguments ("hello", "world") are shown. # Expected result: A single argument "hello world" should have been passed to the program, as = is the case when using "plain" gdb instead of gdbserver: $ gdb --args test "hello world" [...] (gdb) break main Breakpoint 1 at 0x1174: file test.cxx, line 3. (gdb) r Starting program: /home/michi/temp/2020-04-24_gdb_gdbserver_args/test hello\ world Breakpoint 1, main (argc=3D2, argv=3D0x7fffffffddd8) at test.cxx:3 3 std::cout << argv[1] << std::endl; (gdb) p argc $1 =3D 2 (gdb) p argv[1] $2 =3D 0x7fffffffe197 "hello world" # Further notes I initially experienced this bug with gdb version 9.1 in Debian testing (amd64), but it's also reproducible with current git master, as of commit 0b2f8a3bbb595a99dd7977caa6382aab25630115. I plan to submit patches that show a potential approach to fix this. # Sample program "test.cxx": #include int main(int argc, char** argv) { std::cout << argv[1] << std::endl; return 0; } --=20 You are receiving this mail because: You are on the CC list for the bug.=