This is the mail archive of the gdb@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Buffering problems with "gdb < foo"


Eli Zaretskii writes:
 > 
 > > dir needs no confirmation if not invoked from tty !
 > 
 > Did you actually look at the from_tty variable's value inside
 > dir_command?  I don't have the GDB 5.0 binary here, but GDB certainly
 > *does* ask for confirmation if invoked with stdin and stdout
 > redirected, at least in the DJGPP version.  Elena, is that a bug?
 > 

When I try this on solaris, in directory_command(), from_tty is 1,
but the query() function is the one that finds out that it shouldn't
ask the question to the user.

int
query (char *ctlstr,...)
{
  va_list args;
  register int answer;
  register int ans2;
  int retval;

  va_start (args, ctlstr);

  if (query_hook)
    {
      return query_hook (ctlstr, args);
    }

  /* Automatically answer "yes" if input is not from a terminal.  */
  if (!input_from_terminal_p ())
    return 1;
[...]
}

This input_from_terminal_p() function does:

int
input_from_terminal_p ()
{
  return gdb_has_a_terminal () && (instream == stdin) & caution;
}

In my case the gdb_has_a_terminal() returns 0, so the query is not asked.

All seems to work fine fro solaris. What happens on DJGPP? Is
gdb_has_a terminal() returning 1, maybe?


 > Anyway, the basic point is still valid, even if this particular
 > example is not: when stdin is redirected to a file, GDB should turn
 > editing off.

Or just assume that all the queries have yes as automatic answer,
which is what I always thought it was doing.

 > 
 > > I think its because y is not a valid GDB command !
 > 
 > Invalid commands don't cause GDB to exit, they just result in an error
 > message.  It would be inconceivable to have GDB exit every time I
 > mistype a command ;-).

Yes, the 'y''s  are just generating errors. 

Here is what I get:

kwikemart.cygnus.com: 9 % cat commands
file testsuite/gdb.base/break
dir
y
dir .
break main
run
q
y


kwikemart.cygnus.com: 8 % ./gdb -nw -nx < commands
GNU gdb 4.18.1 (UI_OUT)
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.5.1".
(gdb) file testsuite/gdb.base/break
Reading symbols from testsuite/gdb.base/break...done.
(gdb) dir
Source directories searched: $cdir:$cwd
(gdb) y
Undefined command: "y".  Try "help".
(gdb) dir .
Source directories searched: /kwikemart/homer/ezannoni/flathead-dev/solaris/gdb:$cdir:$cwd
(gdb) break main
Breakpoint 1 at 0x10824: file /kwikemart/marge/ezannoni/flathead-dev/devo/gdb/testsuite/gdb.base/break.c, line 75.
(gdb) run
Starting program: /kwikemart/homer/ezannoni/flathead-dev/solaris/gdb/testsuite/gdb.base/break 

Breakpoint 1, main (argc=1, argv=0xeffff124, envp=0xeffff12c)
    at /kwikemart/marge/ezannoni/flathead-dev/devo/gdb/testsuite/gdb.base/break.c:75
75          if (argc == 12345) {  /* an unlikely value < 2^16, in case uninited */
(gdb) q



Elena

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]