/* Handle lists of commands, their decoding and documentation, for GDB.
- Copyright 1986, 1989, 1990, 1991, 1998 Free Software Foundation, Inc.
+ Copyright 1986, 1989, 1990, 1991, 1998, 2000 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "value.h"
#include <ctype.h>
#include "gdb_string.h"
-
-#ifdef HAVE_WAIT_H
-#include <wait.h>
-#else
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
+#ifdef UI_OUT
+#include "ui-out.h"
#endif
-#include "wait.h"
+#include "gdb_wait.h"
/* FIXME: this should be auto-configured! */
#ifdef __MSDOS__
static void show_user PARAMS ((char *, int));
-static void show_user_1 PARAMS ((struct cmd_list_element *, GDB_FILE *));
+static void show_user_1 (struct cmd_list_element *, struct ui_file *);
static void make_command PARAMS ((char *, int));
static int parse_binary_operation PARAMS ((char *));
-static void print_doc_line PARAMS ((GDB_FILE *, char *));
+static void print_doc_line (struct ui_file *, char *);
static struct cmd_list_element *find_cmd PARAMS ((char *command,
int len,
void
help_cmd (command, stream)
char *command;
- GDB_FILE *stream;
+ struct ui_file *stream;
{
struct cmd_list_element *c;
extern struct cmd_list_element *cmdlist;
struct cmd_list_element *list;
char *cmdtype;
enum command_class class;
- GDB_FILE *stream;
+ struct ui_file *stream;
{
int len;
char *cmdtype1, *cmdtype2;
/* Print only the first line of STR on STREAM. */
static void
print_doc_line (stream, str)
- GDB_FILE *stream;
+ struct ui_file *stream;
char *str;
{
static char *line_buffer = 0;
line_buffer[p - str] = '\0';
if (islower (line_buffer[0]))
line_buffer[0] = toupper (line_buffer[0]);
+#ifdef UI_OUT
+ ui_out_text (uiout, line_buffer);
+#else
fputs_filtered (line_buffer, stream);
+#endif
}
/*
enum command_class class;
char *prefix;
int recurse;
- GDB_FILE *stream;
+ struct ui_file *stream;
{
register struct cmd_list_element *c;
}
else if (c->type == show_cmd)
{
+#ifdef UI_OUT
+ struct cleanup *old_chain;
+ struct ui_stream *stb;
+ int quote;
+
+ stb = ui_out_stream_new (uiout);
+ old_chain = make_cleanup ((make_cleanup_func) ui_out_stream_delete, stb);
+#endif /* UI_OUT */
+
/* Print doc minus "show" at start. */
print_doc_line (gdb_stdout, c->doc + 5);
+#ifdef UI_OUT
+ ui_out_text (uiout, " is ");
+ ui_out_wrap_hint (uiout, " ");
+ quote = 0;
+ switch (c->var_type)
+ {
+ case var_string:
+ {
+ unsigned char *p;
+
+ if (*(unsigned char **) c->var)
+ fputstr_filtered (*(unsigned char **) c->var, '"', stb->stream);
+ quote = 1;
+ }
+ break;
+ case var_string_noescape:
+ case var_filename:
+ case var_enum:
+ if (*(char **) c->var)
+ fputs_filtered (*(char **) c->var, stb->stream);
+ quote = 1;
+ break;
+ case var_boolean:
+ fputs_filtered (*(int *) c->var ? "on" : "off", stb->stream);
+ break;
+ case var_uinteger:
+ if (*(unsigned int *) c->var == UINT_MAX)
+ {
+ fputs_filtered ("unlimited", stb->stream);
+ break;
+ }
+ /* else fall through */
+ case var_zinteger:
+ fprintf_filtered (stb->stream, "%u", *(unsigned int *) c->var);
+ break;
+ case var_integer:
+ if (*(int *) c->var == INT_MAX)
+ {
+ fputs_filtered ("unlimited", stb->stream);
+ }
+ else
+ fprintf_filtered (stb->stream, "%d", *(int *) c->var);
+ break;
+
+ default:
+ error ("gdb internal error: bad var_type in do_setshow_command");
+ }
+ if (quote)
+ ui_out_text (uiout, "\"");
+ ui_out_field_stream (uiout, "value", stb);
+ if (quote)
+ ui_out_text (uiout, "\"");
+ ui_out_text (uiout, ".\n");
+ do_cleanups (old_chain);
+#else
fputs_filtered (" is ", gdb_stdout);
wrap_here (" ");
switch (c->var_type)
error ("gdb internal error: bad var_type in do_setshow_command");
}
fputs_filtered (".\n", gdb_stdout);
+#endif
}
else
error ("gdb internal error: bad cmd_type in do_setshow_command");
int from_tty;
char *prefix;
{
+#ifdef UI_OUT
+ ui_out_list_begin (uiout, "showlist");
+#endif
for (; list != NULL; list = list->next)
{
/* If we find a prefix, run its list, prefixing our output by its
prefix (with "show " skipped). */
+#ifdef UI_OUT
+ if (list->prefixlist && !list->abbrev_flag)
+ {
+ ui_out_list_begin (uiout, "optionlist");
+ ui_out_field_string (uiout, "prefix", list->prefixname + 5);
+ cmd_show_list (*list->prefixlist, from_tty, list->prefixname + 5);
+ ui_out_list_end (uiout);
+ }
+ if (list->type == show_cmd)
+ {
+ ui_out_list_begin (uiout, "option");
+ ui_out_text (uiout, prefix);
+ ui_out_field_string (uiout, "name", list->name);
+ ui_out_text (uiout, ": ");
+ do_setshow_command ((char *) NULL, from_tty, list);
+ ui_out_list_end (uiout);
+ }
+#else
if (list->prefixlist && !list->abbrev_flag)
cmd_show_list (*list->prefixlist, from_tty, list->prefixname + 5);
if (list->type == show_cmd)
fputs_filtered (": ", gdb_stdout);
do_setshow_command ((char *) NULL, from_tty, list);
}
+#endif
}
+#ifdef UI_OUT
+ ui_out_list_end (uiout);
+#endif
}
/* ARGSUSED */
static void
show_user_1 (c, stream)
struct cmd_list_element *c;
- GDB_FILE *stream;
+ struct ui_file *stream;
{
register struct command_line *cmdlines;
fputs_filtered (c->name, stream);
fputs_filtered (":\n", stream);
+#ifdef UI_OUT
+ print_command_lines (uiout, cmdlines, 1);
+ fputs_filtered ("\n", stream);
+#else
while (cmdlines)
{
print_command_line (cmdlines, 4, stream);
cmdlines = cmdlines->next;
}
fputs_filtered ("\n", stream);
+#endif
}
/* ARGSUSED */