Article View: gnu.gdb.bug
Article #1055Re: gdb hijacks my argument list
From: Leslie Turriff
Date: Sat, 19 Dec 2009 22:05
Date: Sat, 19 Dec 2009 22:05
307 lines
13097 bytes
13097 bytes
--Boundary-00=_w4ULLVNBjusKxdA
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Hi,
Sorry for the delayed response.
Yes, I have tried using the 'run PROGNAME ARGUMENTS...' method, but it giv=
es=20
me the same results. I'll append the source code and a terminal session=20
showing exactly what I have tried, so that you can (presumably) duplicate m=
y=20
results. Perhaps I am misunderstanding somehow the proper gdb syntax to be=
=20
used, or have wrong versions of tools?
Leslie
On Sunday 13 December 2009 06:37:30 Tribhuwan Kandpal wrote:
> Hi Leslie,
> I believe you want to pass the arguments to your program but you need to
> pass it within gdb. so give those arguments when you give run command=20
> try this:
> =C2=A0
> gdb your_program_name
> =C2=A0
> now the gdb shell will open:
> =C2=A0
> (gdb) run Write_the_arguments_of_your_program_here
> =C2=A0
> =C2=A0
> I believe it will help you
> =C2=A0
> Thanks,
> Trib
>
> --- On Fri, 4/12/09, Leslie Turriff <jlturriff@centurytel.net> wrote:
>
>
> From: Leslie Turriff <jlturriff@centurytel.net>
> Subject: gdb hijacks my argument list
> To: bug-gdb@gnu.org
> Date: Friday, 4 December, 2009, 2:36 PM
>
>
> Hi,
>
> =C2=A0=C2=A0=C2=A0 I'm writing a package that accepts arbitrary character=
strings from the
> command line, and I'm trying to debug it with gdb.
>
> =C2=A0=C2=A0=C2=A0 When run without gdb the command line string is passed=
directly to my
> program, but when I tell gdb to pass it, gdb insists on interpreting it as
> a filename, and won't pass it through.
>
> Example without gdb:
> =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
> ./testtoken ' (name testtoken endchar \) < testtoken.adb | (trace) count
> lines|cons '
>
> Input string is:
> ....+....1....+....2....+....3....+....4....+....5....+....6
> (name testtoken endchar \) < testtoken.adb | (trace) count lines|cons
>
> =C2=A0 =C2=A0 Before: TokenFrom =3D=C2=A0=C2=A0=C2=A01
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 TextLeft=C2=A0 =3D=C2=A0 71
>
> =C2=A0 =C2=A0 After:=C2=A0 TokenFrom =3D=C2=A0=C2=A0=C2=A01
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 TextLeft=C2=A0 =3D=C2=A0 71
>
> Token=C2=A0 1 is: ' (name testtoken endchar \) < testtoken.adb | (trace) =
count
> lines|cons '
>
> End of tokens reached.
>
> =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
>
> Example with gdb:
> =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
> gdb testtoken --args ' (name testtoken endchar \) < testtoken.adb | (trac=
e)
> count lines|cons '
> GNU gdb 6.8
> Copyright (C) 2008 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later
> <http://gnu.org/licenses/gpl.html> This is free software: you are free to
> change and redistribute it. There is NO WARRANTY, to the extent permitted
> by law.=C2=A0 Type "show copying" and "show warranty" for details.
> This GDB was configured as "i586-suse-linux"...
> (name testtoken endchar \) < testtoken.adb | (trace) count lines|cons : No
> such file or directory.
> (gdb)
> =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
>
> =C2=A0=C2=A0=C2=A0 How do I make gdb pass this string through to the prog=
ram under test?
>
> Leslie
>
>
> _______________________________________________
> bug-gdb mailing list
> bug-gdb@gnu.org
> http://lists.gnu.org/mailman/listinfo/bug-gdb
>
>
>
> The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.
> http://in.yahoo.com/
--Boundary-00=_w4ULLVNBjusKxdA
Content-Type: text/x-adasrc;
charset="iso 8859-15";
name="testcmdline.adb"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="testcmdline.adb"
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings; use Ada.Strings;
with Ada.Text_IO; use Ada.Text_IO;
procedure testcmdline is
TextLine : unbounded_string;
begin
TextLine := to_unbounded_string(argument(1));
put_line(to_string(TextLine));
end testcmdline;
--Boundary-00=_w4ULLVNBjusKxdA
Content-Type: text/plain;
charset="iso 8859-15";
name="gdbSession.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="gdbSession.txt"
15:48:37 turriff@pinto
~/Documents/SourceCode$
uname -a
Linux pinto 2.6.25.20-0.5-pae #1 SMP 2009-08-14 01:48:11 +0200 i686 i686 i386 GNU/Linux
15:48:39 turriff@pinto
~/Documents/SourceCode$
cat /etc/SuSE-release
openSUSE 11.0 (i586)
VERSION = 11.0
15:48:46 turriff@pinto
~/Documents/SourceCode$
gcc -v
Using built-in specs.
Target: i586-suse-linux
Configured with: ../configure --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.3 --enable-ssp --disable-libssp --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --with-slibdir=/lib --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --program-suffix=-4.3 --enable-version-specific-runtime-libs --enable-linux-futex --without-system-libunwind --with-cpu=generic --build=i586-suse-linux
Thread model: posix
gcc version 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036] (SUSE Linux)
15:48:50 turriff@pinto
~/Documents/SourceCode$
gnat
GNAT 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036]
Copyright 1996-2007, Free Software Foundation, Inc.
List of available commands
gnat bind gnatbind
gnat chop gnatchop
gnat clean gnatclean
gnat compile gnatmake -f -u -c
gnat check gnatcheck
gnat elim gnatelim
gnat find gnatfind
gnat krunch gnatkr
gnat link gnatlink
gnat list gnatls
gnat make gnatmake
gnat metric gnatmetric
gnat name gnatname
gnat preprocess gnatprep
gnat pretty gnatpp
gnat stack gnatstack
gnat stub gnatstub
gnat xref gnatxref
Commands find, list, metric, pretty, stack, stub and xref accept project file switches -vPx, -Pprj and -Xnam=val
15:48:54 turriff@pinto
~/Documents/SourceCode$
ll testcmdline*
-rw-r--r-- 1 turriff users 379 2009-12-19 14:27 testcmdline.adb
15:49:00 turriff@pinto
~/Documents/SourceCode$
gcc -c -g testcmdline.adb && gnatmake -g testcmdline
gnatbind -x testcmdline.ali
gnatlink testcmdline.ali -g
15:49:19 turriff@pinto
~/Documents/SourceCode$
./testcmdline with an arbitrary command string
with
15:49:35 turriff@pinto
~/Documents/SourceCode$
./testcmdline 'with an arbitrary command string'
with an arbitrary command string
15:49:44 turriff@pinto
~/Documents/SourceCode$
gdb -v
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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 "i586-suse-linux".
15:49:55 turriff@pinto
~/Documents/SourceCode$
gdb --quiet testcmdline
(gdb) break testcmdline
Breakpoint 1 at 0x8049bdb: file testcmdline.adb, line 5.
(gdb) set args 'with an arbitrary command string'
(gdb) run
Starting program: /home/turriff/Documents/SourceCode/testcmdline 'with an arbitrary command string'
unable to open script file 'exec /home/turriff/Documents/SourceCode/testcmdline 'with an arbitrary command string'' : file not found
Program exited with code 01.
You can't do that without a process to debug.
(gdb) quit
15:50:36 turriff@pinto
~/Documents/SourceCode$
gdb --quiet --args testcmdline 'with an arbitrary command string'
(gdb) break testcmdline
Breakpoint 1 at 0x8049bdb: file testcmdline.adb, line 5.
(gdb) show args
Argument list to give program being debugged when it is started is "".
(gdb) run
Starting program: /home/turriff/Documents/SourceCode/testcmdline with\ an\ arbitrary\ command\ string
unable to open script file 'exec /home/turriff/Documents/SourceCode/testcmdline with\ an\ arbitrary\ command\ string' : file not found
Program exited with code 01.
You can't do that without a process to debug.
(gdb) quit
15:51:40 turriff@pinto
~/Documents/SourceCode$
gdb --help
This is the GNU debugger. Usage:
gdb [options] [executable-file [core-file or process-id]]
gdb [options] --args executable-file [inferior-arguments ...]
Options:
--args Arguments after executable-file are passed to inferior
-b BAUDRATE Set serial port baud rate used for remote debugging.
--batch Exit after processing options.
--batch-silent As for --batch, but suppress all gdb stdout output.
--return-child-result
GDB exit code will be the child's exit code.
--cd=DIR Change current directory to DIR.
--command=FILE, -x Execute GDB commands from FILE.
--eval-command=COMMAND, -ex
Execute a single GDB command.
May be used multiple times and in conjunction
with --command.
--core=COREFILE Analyze the core dump COREFILE.
--pid=PID Attach to running process PID.
--dbx DBX compatibility mode.
--directory=DIR Search for source files in DIR.
--epoch Output information used by epoch emacs-GDB interface.
--exec=EXECFILE Use EXECFILE as the executable.
--fullname Output information used by emacs-GDB interface.
--help Print this message.
--interpreter=INTERP
Select a specific interpreter / user interface
-l TIMEOUT Set timeout in seconds for remote debugging.
--nw Do not use a window interface.
--nx Do not read .gdbinit file.
--quiet Do not print version number on startup.
--readnow Fully read symbol files on first access.
--se=FILE Use FILE as symbol file and executable file.
--symbols=SYMFILE Read symbols from SYMFILE.
--tty=TTY Use TTY for input/output by the program being debugged.
--tui Use a terminal user interface.
--version Print version information and then exit.
-w Use a window interface.
--write Set writing into executable and core files.
--xdb XDB compatibility mode.
For more information, type "help" from within GDB, or consult the
GDB manual (available as on-line info or a printed manual).
Report bugs to "bug-gdb@gnu.org".
--Boundary-00=_w4ULLVNBjusKxdA--
Technical Details
Message-ID:
<mailman.13216.1261260322.2239.bug-gdb@gnu.org>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!usenet.stanford.edu!news.stanford.edu!not-for-mailReferences:
<308370.18171.qm@web95309.mail.in2.yahoo.com>Show Full Headers
Complete Article Headers
X-Google-Thread: f0ead4270c,d38ae7920432c7db,start X-Google-Attributes: gidf0ead4270c,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!usenet.stanford.edu!news.stanford.edu!not-for-mail From: Leslie Turriff <jlturriff@centurytel.net> Newsgroups: gnu.gdb.bug Subject: Re: gdb hijacks my argument list Date: Sat, 19 Dec 2009 16:05:35 -0600 Lines: 309 Approved: bug-gdb@gnu.org Message-ID: <mailman.13216.1261260322.2239.bug-gdb@gnu.org> References: <308370.18171.qm@web95309.mail.in2.yahoo.com> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_w4ULLVNBjusKxdA" X-Trace: news.stanford.edu 1261260323 19409 199.232.76.165 (19 Dec 2009 22:05:23 GMT) X-Complaints-To: news@news.stanford.edu To: bug-gdb@gnu.org Envelope-to: bug-gdb@gnu.org X-Authenticated-User: jlturriff.centurytel.net User-Agent: KMail/1.9.9 In-Reply-To: <308370.18171.qm@web95309.mail.in2.yahoo.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: bug-gdb@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GDB, the GNU debugger" <bug-gdb.gnu.org> List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-gdb>, <mailto:bug-gdb-request@gnu.org?subject=unsubscribe> List-Archive: <http://lists.gnu.org/pipermail/bug-gdb> List-Post: <mailto:bug-gdb@gnu.org> List-Help: <mailto:bug-gdb-request@gnu.org?subject=help> List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-gdb>, <mailto:bug-gdb-request@gnu.org?subject=subscribe>