Bug 21981 - Document on --help and man that gdbserver --multi can take the program and CLI arguments as arguments
Summary: Document on --help and man that gdbserver --multi can take the program and CL...
Alias: None
Product: gdb
Classification: Unclassified
Component: server (show other bugs)
Version: 7.11
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: good-first-bug
Depends on:
Reported: 2017-08-20 11:33 UTC by Ciro Santilli
Modified: 2018-04-12 19:47 UTC (History)
0 users

See Also:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Ciro Santilli 2017-08-20 11:33:12 UTC
gdbserver --help says:

    Usage:  gdbserver [OPTIONS] COMM PROG [ARGS ...]
            gdbserver [OPTIONS] --attach COMM PID
            gdbserver [OPTIONS] --multi COMM

however it should likely be:

            gdbserver [OPTIONS] --multi COMM [PROG [ARGS ...]]

since --multi can take either PROG or ARGS:

    gdbserver --multi :1234 ./prog.out a b
    gdb -ex 'target extended-remote :1234' ./prog.out

    (gdb) b main
    (gdb) c
    (gdb) show args
    Argument list to give program being debugged when it is started is ""
    (gdb) print argc
    $1 = 3

and that behavior is very useful (you can have a single alias that either runs the program without GDB, or appends "gdbserver" before the command). 

The only annoyance is that the arguments only work for the first run, unlike an explicit "set args" on host, but maybe that should be solved with: https://sourceware.org/bugzilla/show_bug.cgi?id=21980