Hi,
Sorry for the delayed response.
Yes, I have tried using the 'run PROGNAME ARGUMENTS...' method, but it
gives
me the same results. I'll append the source code and a terminal session
showing exactly what I have tried, so that you can (presumably) duplicate my
results. Perhaps I am misunderstanding somehow the proper gdb syntax to be
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
> try this:
>
> gdb your_program_name
>
> now the gdb shell will open:
>
> (gdb) run Write_the_arguments_of_your_program_here
>
>
> I believe it will help you
>
> Thanks,
> Trib
>
> --- On Fri, 4/12/09, Leslie Turriff <[email protected]> wrote:
>
>
> From: Leslie Turriff <[email protected]>
> Subject: gdb hijacks my argument list
> To: [email protected]
> Date: Friday, 4 December, 2009, 2:36 PM
>
>
> Hi,
>
> I'm writing a package that accepts arbitrary character strings from the
> command line, and I'm trying to debug it with gdb.
>
> 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:
> =================================================
> ./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
>
> Before: TokenFrom = 1
> TextLeft = 71
>
> After: TokenFrom = 1
> TextLeft = 71
>
> Token 1 is: ' (name testtoken endchar \) < testtoken.adb | (trace) count
> lines|cons '
>
> End of tokens reached.
>
> =================================================
>
> Example with gdb:
> =================================================
> gdb testtoken --args ' (name testtoken endchar \) < testtoken.adb | (trace)
> 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. 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)
> =================================================
>
> How do I make gdb pass this string through to the program under test?
>
> Leslie
>
>
> _______________________________________________
> bug-gdb mailing list
> [email protected]
> http://lists.gnu.org/mailman/listinfo/bug-gdb
>
>
>
> The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.
> http://in.yahoo.com/
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;
15:48:37 turr...@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 turr...@pinto
~/Documents/SourceCode$
cat /etc/SuSE-release
openSUSE 11.0 (i586)
VERSION = 11.0
15:48:46 turr...@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 turr...@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 turr...@pinto
~/Documents/SourceCode$
ll testcmdline*
-rw-r--r-- 1 turriff users 379 2009-12-19 14:27 testcmdline.adb
15:49:00 turr...@pinto
~/Documents/SourceCode$
gcc -c -g testcmdline.adb && gnatmake -g testcmdline
gnatbind -x testcmdline.ali
gnatlink testcmdline.ali -g
15:49:19 turr...@pinto
~/Documents/SourceCode$
./testcmdline with an arbitrary command string
with
15:49:35 turr...@pinto
~/Documents/SourceCode$
./testcmdline 'with an arbitrary command string'
with an arbitrary command string
15:49:44 turr...@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 turr...@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 turr...@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 turr...@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 "[email protected]"._______________________________________________
bug-gdb mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-gdb