xfree);
}
+/* Helper for make_cleanup_unpush_target. */
+
+static void
+do_unpush_target (void *arg)
+{
+ struct target_ops *ops = arg;
+
+ unpush_target (ops);
+}
+
+/* Return a new cleanup that unpushes OPS. */
+
+struct cleanup *
+make_cleanup_unpush_target (struct target_ops *ops)
+{
+ return make_my_cleanup (&cleanup_chain, do_unpush_target, ops);
+}
+
struct cleanup *
make_my_cleanup2 (struct cleanup **pmy_chain, make_cleanup_ftype *function,
void *arg, void (*free_arg) (void *))
{
}
+/* If nonzero, display time usage both at startup and for each command. */
+
+static int display_time;
+
+/* If nonzero, display space usage both at startup and for each command. */
+
+static int display_space;
+
+/* Records a run time and space usage to be used as a base for
+ reporting elapsed time or change in space. In addition,
+ the msg_type field indicates whether the saved time is from the
+ beginning of GDB execution (0) or the beginning of an individual
+ command execution (1). */
+struct cmd_stats
+{
+ int msg_type;
+ long start_time;
+ long start_space;
+};
+
+/* Set whether to display time statistics to NEW_VALUE (non-zero
+ means true). */
+void
+set_display_time (int new_value)
+{
+ display_time = new_value;
+}
+
+/* Set whether to display space statistics to NEW_VALUE (non-zero
+ means true). */
+void
+set_display_space (int new_value)
+{
+ display_space = new_value;
+}
+
+/* As indicated by display_time and display_space, report GDB's elapsed time
+ and space usage from the base time and space provided in ARG, which
+ must be a pointer to a struct cmd_stat. This function is intended
+ to be called as a cleanup. */
+static void
+report_command_stats (void *arg)
+{
+ struct cmd_stats *start_stats = (struct cmd_stats *) arg;
+ int msg_type = start_stats->msg_type;
+
+ if (display_time)
+ {
+ long cmd_time = get_run_time () - start_stats->start_time;
+
+ printf_unfiltered (msg_type == 0
+ ? _("Startup time: %ld.%06ld\n")
+ : _("Command execution time: %ld.%06ld\n"),
+ cmd_time / 1000000, cmd_time % 1000000);
+ }
+
+ if (display_space)
+ {
+#ifdef HAVE_SBRK
+ char *lim = (char *) sbrk (0);
+
+ long space_now = lim - lim_at_start;
+ long space_diff = space_now - start_stats->start_space;
+
+ printf_unfiltered (msg_type == 0
+ ? _("Space used: %ld (%c%ld during startup)\n")
+ : _("Space used: %ld (%c%ld for this command)\n"),
+ space_now,
+ (space_diff >= 0 ? '+' : '-'),
+ space_diff);
+#endif
+ }
+}
+
+/* Create a cleanup that reports time and space used since its
+ creation. Precise messages depend on MSG_TYPE:
+ 0: Initial time/space
+ 1: Individual command time/space. */
+struct cleanup *
+make_command_stats_cleanup (int msg_type)
+{
+ struct cmd_stats *new_stat = XMALLOC (struct cmd_stats);
+
+#ifdef HAVE_SBRK
+ char *lim = (char *) sbrk (0);
+ new_stat->start_space = lim - lim_at_start;
+#endif
+
+ new_stat->msg_type = msg_type;
+ new_stat->start_time = get_run_time ();
+
+ return make_cleanup_dtor (report_command_stats, new_stat, xfree);
+}
+
/* Continuations are implemented as cleanups internally. Inherit from
cleanups. */
struct continuation
/* Don't allow infinite error/warning recursion. */
{
static char msg[] = "Recursive internal problem.\n";
+
switch (dejavu)
{
case 0:
so that the user knows that they are living on the edge. */
{
char *msg;
+
msg = xstrvprintf (fmt, ap);
reason = xstrprintf ("\
%s:%d: %s: %s\n\
question we're asking, and then answer the default automatically. This
way, important error messages don't get lost when talking to GDB
over a pipe. */
- if (batch_flag || ! input_from_terminal_p ())
+ if (! input_from_terminal_p ())
{
wrap_here ("");
vfprintf_filtered (gdb_stdout, ctlstr, args);
void (*do_fprintf) (struct ui_file *, const char *, ...)
ATTRIBUTE_FPTR_PRINTF_2, struct ui_file *stream, int quoter)
{
-
c &= 0xFF; /* Avoid sign bit follies */
if (c < 0x20 || /* Low control chars */
struct ui_file *stream)
{
int i;
+
for (i = 0; i < n; i++)
printchar (str[i], fputs_unfiltered, fprintf_unfiltered, stream, quoter);
}
if (ignore)
{
char *p = ignore;
+
while (*p == ' ' || *p == '\t')
++p;
if (p[0] == 'q')
/* Don't do any filtering if it is disabled. */
if (stream != gdb_stdout
- || !pagination_enabled
+ || ! pagination_enabled
+ || ! input_from_terminal_p ()
|| (lines_per_page == UINT_MAX && chars_per_line == UINT_MAX)
|| top_level_interpreter () == NULL
|| ui_out_is_mi_like_p (interp_ui_out (top_level_interpreter ())))
about the real size of addr as the above does? */
unsigned long temp[3];
char *str = get_cell ();
-
int i = 0;
+
do
{
temp[i] = addr % (1000 * 1000 * 1000);
{
unsigned long temp[3];
char *str = get_cell ();
-
int i = 0;
+
do
{
temp[i] = addr % (0100000 * 0100000);
case 8:
{
unsigned long high = (unsigned long) (l >> thirty_two);
+
str = get_cell ();
if (high == 0)
xsnprintf (str, CELLSIZE, "%lx",
case 16:
{
char *result;
+
if (width == 0)
result = hex_string (val);
else
case 8:
{
char *result = octal2str (val, width);
+
if (use_c_format || val == 0)
return result;
else
{
/* Assume that it is in hex. */
int i;
+
for (i = 2; my_string[i] != '\0'; i++)
{
if (isdigit (my_string[i]))
{
/* Assume that it is in decimal. */
int i;
+
for (i = 0; my_string[i] != '\0'; i++)
{
if (isdigit (my_string[i]))
# endif
# if defined (USE_REALPATH)
const char *rp = realpath (filename, buf);
+
if (rp == NULL)
rp = filename;
return xstrdup (rp);
#if defined(HAVE_CANONICALIZE_FILE_NAME)
{
char *rp = canonicalize_file_name (filename);
+
if (rp == NULL)
return xstrdup (filename);
else
{
/* Find out the max path size. */
long path_max = pathconf ("/", _PC_PATH_MAX);
+
if (path_max > 0)
{
/* PATH_MAX is bounded. */
char *buf = alloca (path_max);
char *rp = realpath (filename, buf);
+
return xstrdup (rp ? rp : filename);
}
}