public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug server/25893] New: gdbserver incorrectly handles program args containing space
@ 2020-04-29  9:14 m.weghorn at posteo dot de
  2020-04-29  9:15 ` [Bug server/25893] " m.weghorn at posteo dot de
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: m.weghorn at posteo dot de @ 2020-04-29  9:14 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25893

            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=3, argv=0x7fffffffddf8) at test.cxx:3
3           std::cout << argv[1] << std::endl;
(gdb) p argc
$1 = 3
(gdb) p argv[1]
$2 = 0x7fffffffe1a6 "hello"
(gdb) p argv[2]
$3 = 0x7fffffffe1ac "world"
(gdb) 


# 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=2, argv=0x7fffffffddd8) at test.cxx:3
3           std::cout << argv[1] << std::endl;
(gdb) p argc
$1 = 2
(gdb) p argv[1]
$2 = 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 <iostream>
  int main(int argc, char** argv) {
      std::cout << argv[1] << std::endl;
      return 0;
  }

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-07-16 19:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-29  9:14 [Bug server/25893] New: gdbserver incorrectly handles program args containing space m.weghorn at posteo dot de
2020-04-29  9:15 ` [Bug server/25893] " m.weghorn at posteo dot de
2020-04-29 11:23 ` m.weghorn at posteo dot de
2020-05-25 15:42 ` cvs-commit at gcc dot gnu.org
2020-05-25 15:43 ` simark at simark dot ca
2020-07-16 19:48 ` tromey at sourceware dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).