ddd 3.3.12 eating command line options after --args
"Wallace, Brooke T (US 348F-Affiliate)" <[email protected]> Fri, 28 Feb 2020 02:21:12 +0000
| Newsgroups | gmane.comp.debugging.ddd.bugs |
|---|---|
| Message-ID | <[email protected]> |
--_000_f43889107c10484aaed25631000d4590jplnasagov_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Running ddd from the command line using the -args option starts up ddd to d=
ebug the correct application but is consuming arguments intended for the ap=
plication.
For example:
$ cat cmdline.cc
//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
// FILE cmdline.cc
//
// DESCRIPTION:
// Simple program that prints its command line args
// This was used to test DDD and GDB --args feature
//
//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
#include <stdint.h>
#include <stdio.h>
typedef uint32_t uint32;
int main(int argc, char** argv) {
int i =3D 0;
printf("command line has %d args:\n", argc);
while(i < argc) {
printf(" arg[%d] %s\n", i, argv[i]);
i++;
}
return 0;
}
$ ddd --args ./a.out -session abcd -a -b -c
Produces:
GNU DDD 3.3.12 (x86_64-redhat-linux-gnu), by Dorothea Lwarning: could not s=
et baud rate to `-c'.
Reading symbols from /home/bwallace/workspace/examples/cmdline/a.out...done=
.
(gdb) run
Starting program: /home/bwallace/workspace/examples/cmdline/./a.out -a
command line has 2 args:
arg[0] /home/bwallace/workspace/examples/cmdline/./a.out
arg[1] -a
[Inferior 1 (process 6341) exited normally]
The -session option and its argument is mysteriously eaten, the -b option i=
s interpreted as ddd's baud rate option, -c is interpreted as the baudrate
This command lines work as expected if I use gdb:
$ gdb --args ./a.out -session abcd -a -b -c
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-94.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.htm=
l>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/bwallace/workspace/examples/cmdline/a.out...done=
.
(gdb) run
Starting program: /home/bwallace/workspace/examples/cmdline/./a.out -sessio=
n abcd -a -b -c
command line has 6 args:
arg[0] /home/bwallace/workspace/examples/cmdline/./a.out
arg[1] -session
arg[2] abcd
arg[3] -a
arg[4] -b
arg[5] -c
[Inferior 1 (process 6357) exited normally]
I'm running DDD version 3.3.12 (x86_64-unknown-linux-gnu)
Compiled with GCC 4.8.5 20150623 (Red Hat 4.8.5-11), GNU libc 2.17
--_000_f43889107c10484aaed25631000d4590jplnasagov_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-US" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">Running ddd from the command line using the –a=
rgs option starts up ddd to debug the correct application but is consuming =
arguments intended for the application.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">For example:<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">$ cat cmdline.cc <o:p></o:p></p>
<p class=3D"MsoNormal">//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<o:p></o:p></p>
<p class=3D"MsoNormal">// FILE cmdline.cc<o:p></o:p></p>
<p class=3D"MsoNormal">//<o:p></o:p></p>
<p class=3D"MsoNormal">// DESCRIPTION:<o:p></o:p></p>
<p class=3D"MsoNormal">// Simple program that prints its command line args<=
o:p></o:p></p>
<p class=3D"MsoNormal">// This was used to test DDD and GDB --args feature<=
o:p></o:p></p>
<p class=3D"MsoNormal">//<o:p></o:p></p>
<p class=3D"MsoNormal">//=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<o:p></o:p></p>
<p class=3D"MsoNormal">#include <stdint.h><o:p></o:p></p>
<p class=3D"MsoNormal">#include <stdio.h><o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">typedef uint32_t uint32;<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">int main(int argc, char** argv) {<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal"> int i =3D 0;<o:p></o:p></p>
<p class=3D"MsoNormal"> printf("command line has %d args:\=
n", argc);<o:p></o:p></p>
<p class=3D"MsoNormal"> while(i < argc) {<o:p></o:p></p>
<p class=3D"MsoNormal"> printf(" &n=
bsp; arg[%d] %s\n", i, argv[i]);<o:p></o:p></p>
<p class=3D"MsoNormal"> i++;<o:p></o:=
p></p>
<p class=3D"MsoNormal"> }<o:p></o:p></p>
<p class=3D"MsoNormal"> return 0;<o:p></o:p></p>
<p class=3D"MsoNormal">}<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">$ ddd --args ./a.out -session abcd -a -b –c<o:=
p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">Produces:<o:p></o:p></p>
<p class=3D"MsoNormal">GNU DDD 3.3.12 (x86_64-redhat-linux-gnu), by Dorothe=
a Lwarning: could not set baud rate to `-c'.<o:p></o:p></p>
<p class=3D"MsoNormal">Reading symbols from /home/bwallace/workspace/exampl=
es/cmdline/a.out...done.<o:p></o:p></p>
<p class=3D"MsoNormal">(gdb) run<o:p></o:p></p>
<p class=3D"MsoNormal">Starting program: /home/bwallace/workspace/examples/=
cmdline/./a.out -a<o:p></o:p></p>
<p class=3D"MsoNormal">command line has 2 args:<o:p></o:p></p>
<p class=3D"MsoNormal"> arg[0] /home/bwallace/workspace/example=
s/cmdline/./a.out<o:p></o:p></p>
<p class=3D"MsoNormal"> arg[1] -a<o:p></o:p></p>
<p class=3D"MsoNormal">[Inferior 1 (process 6341) exited normally]<o:p></o:=
p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">The –session option and its argument is myster=
iously eaten, the –b option is interpreted as ddd’s baud rate o=
ption, -c is interpreted as the baudrate<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">This command lines work as expected if I use g=
db:<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">$ gdb --args ./a.out -session abcd -a -b -c<o:p></o:=
p></p>
<p class=3D"MsoNormal">GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-94.el7<=
o:p></o:p></p>
<p class=3D"MsoNormal">Copyright (C) 2013 Free Software Foundation, Inc.<o:=
p></o:p></p>
<p class=3D"MsoNormal">License GPLv3+: GNU GPL version 3 or later <h=
ttp://gnu.org/licenses/gpl.html><o:p></o:p></p>
<p class=3D"MsoNormal">This is free software: you are free to change and re=
distribute it.<o:p></o:p></p>
<p class=3D"MsoNormal">There is NO WARRANTY, to the extent permitted by law=
. Type "show copying"<o:p></o:p></p>
<p class=3D"MsoNormal">and "show warranty" for details.<o:p></o:p=
></p>
<p class=3D"MsoNormal">This GDB was configured as "x86_64-redhat-linux=
-gnu".<o:p></o:p></p>
<p class=3D"MsoNormal">For bug reporting instructions, please see:<o:p></o:=
p></p>
<p class=3D"MsoNormal"><http://www.gnu.org/software/gdb/bugs/>...<o:p=
></o:p></p>
<p class=3D"MsoNormal">Reading symbols from /home/bwallace/workspace/exampl=
es/cmdline/a.out...done.<o:p></o:p></p>
<p class=3D"MsoNormal">(gdb) run<o:p></o:p></p>
<p class=3D"MsoNormal">Starting program: /home/bwallace/workspace/examples/=
cmdline/./a.out -session abcd -a -b -c<o:p></o:p></p>
<p class=3D"MsoNormal">command line has 6 args:<o:p></o:p></p>
<p class=3D"MsoNormal"> arg[0] /home/bwallace/workspace/example=
s/cmdline/./a.out<o:p></o:p></p>
<p class=3D"MsoNormal"> arg[1] -session<o:p></o:p></p>
<p class=3D"MsoNormal"> arg[2] abcd<o:p></o:p></p>
<p class=3D"MsoNormal"> arg[3] -a<o:p></o:p></p>
<p class=3D"MsoNormal"> arg[4] -b<o:p></o:p></p>
<p class=3D"MsoNormal"> arg[5] -c<o:p></o:p></p>
<p class=3D"MsoNormal">[Inferior 1 (process 6357) exited normally]<o:p></o:=
p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">I’m running DDD version 3.3.12 (x86_64-unknown=
-linux-gnu)<o:p></o:p></p>
<p class=3D"MsoNormal">Compiled with GCC 4.8.5 20150623 (Red Hat 4.8.5-11),=
GNU libc 2.17<o:p></o:p></p>
</div>
</body>
</html>
--_000_f43889107c10484aaed25631000d4590jplnasagov_--