[gnu.gdb.bug] a bug, a feature

csmith@mozart.uucp (Chris Smith) (09/01/89)

A bug: the "set" command  decides that it is looking at a subcommand
when it is actually looking at an expression in cases like this:

    set args_print ()
    set environment_doohickey()

----
A feature: it would be handy to have a command to look up the error
message for an errno value.  

Here is code for the command

    info errno
or  info errno <expression>


static void
errno_info (arg, from_tty)
     char *arg;
     int from_tty;
{
  int err;
  extern int sys_nerr;
  extern char *sys_errlist[];

  if (arg)
    err = parse_and_eval_address (arg);
  else
    err = parse_and_eval_address ("errno");

  printf_filtered ("errno %d: %s\n", err,
		   err < sys_nerr ? sys_errlist[err] : "unknown error");
}

    [...]

  add_info ("errno", errno_info,
"Display the system error message for errno, the error code returned by\n\
the last failing system call.  With an argument, display the message for\n\
that value of errno.");