comp.lang.ada
 help / color / mirror / Atom feed
From: Leslie <jlturriff@centurytel.net>
Subject: Re: gdb hijacks my argument list
Date: Mon, 04 Jan 2010 19:06:15 -0600
Date: 2010-01-04T19:06:15-06:00	[thread overview]
Message-ID: <hhu38g$8pj$1@news.albasani.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 2089 bytes --]

Hi,
        Has anyone else seen this problem with gdb?  I had originally
posted it to bug-gdb@gnu.org, but got no useful response. 
Original post:

     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)
=================================================

        I have tried using the 'run PROGNAME ARGUMENTS...' method, but
it gives 
me the same results.  I have attached 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

[-- Attachment #2: gdbSession.txt --]
[-- Type: text/plain, Size: 6463 bytes --]

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".

[-- Attachment #3: testcmdline.adb --]
[-- Type: text/plain, Size: 380 bytes --]

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;


             reply	other threads:[~2010-01-05  1:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-05  1:06 Leslie [this message]
2010-01-05 11:39 ` gdb hijacks my argument list Niklas Holsti
2010-01-05 15:21   ` Leslie
2010-01-05 16:15     ` John B. Matthews
2010-01-05 19:25       ` Leslie
2010-01-05 21:19         ` John B. Matthews
2010-01-05 17:34     ` Niklas Holsti
2010-01-05 19:18       ` Leslie
2010-01-05 19:36         ` Niklas Holsti
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox