#include <algorithm>
#include "common/pathstuff.h"
-#if !HAVE_DECL_MALLOC
-extern PTR malloc (); /* ARI: PTR */
-#endif
-#if !HAVE_DECL_REALLOC
-extern PTR realloc (); /* ARI: PTR */
-#endif
-#if !HAVE_DECL_FREE
-extern void free ();
-#endif
-
void (*deprecated_error_begin_hook) (void);
/* Prototypes for local functions */
because while they use the "cleanup API" they are not part of the
"cleanup API". */
-/* Helper for make_cleanup_value_free_to_mark. */
-
-static void
-do_value_free_to_mark (void *value)
-{
- value_free_to_mark ((struct value *) value);
-}
-
-/* Free all values allocated since MARK was obtained by value_mark
- (except for those released) when the cleanup is run. */
-
-struct cleanup *
-make_cleanup_value_free_to_mark (struct value *mark)
-{
- return make_cleanup (do_value_free_to_mark, mark);
-}
-
/* This function is useful for cleanups.
Do
dump_core (void)
{
#ifdef HAVE_SETRLIMIT
- struct rlimit rlim = { RLIM_INFINITY, RLIM_INFINITY };
+ struct rlimit rlim = { (rlim_t) RLIM_INFINITY, (rlim_t) RLIM_INFINITY };
setrlimit (RLIMIT_CORE, &rlim);
#endif /* HAVE_SETRLIMIT */
/* Current count of lines printed on this page, chars on this line. */
static unsigned int lines_printed, chars_printed;
+/* True if pagination is disabled for just one command. */
+
+static bool pagination_disabled_for_command;
+
/* Buffer and start column of buffered text, for doing smarter word-
wrapping. When someone calls wrap_here(), we start buffering output
that comes through fputs_filtered(). If we see a newline, we just
prompt_for_continue_wait_time. */
using namespace std::chrono;
steady_clock::time_point prompt_started = steady_clock::now ();
+ bool disable_pagination = pagination_disabled_for_command;
if (annotation_level > 1)
printf_unfiltered (("\n\032\032pre-prompt-for-continue\n"));
strcpy (cont_prompt,
- "---Type <return> to continue, or q <return> to quit---");
+ "--Type <RET> for more, q to quit, "
+ "c to continue without paging--");
if (annotation_level > 1)
strcat (cont_prompt, "\n\032\032prompt-for-continue\n");
if (p[0] == 'q')
/* Do not call quit here; there is no possibility of SIGINT. */
throw_quit ("Quit");
+ if (p[0] == 'c')
+ disable_pagination = true;
}
/* Now we have to do this again, so that GDB will know that it doesn't
need to save the ---Type <return>--- line at the top of the screen. */
reinitialize_more_filter ();
+ pagination_disabled_for_command = disable_pagination;
dont_repeat (); /* Forget prev cmd -- CR won't repeat it. */
}
{
lines_printed = 0;
chars_printed = 0;
+ pagination_disabled_for_command = false;
}
/* Indicate that if the next sequence of characters overflows the line,
/* Don't do any filtering if it is disabled. */
if (stream != gdb_stdout
|| !pagination_enabled
+ || pagination_disabled_for_command
|| batch_flag
|| (lines_per_page == UINT_MAX && chars_per_line == UINT_MAX)
|| top_level_interpreter () == NULL
- || interp_ui_out (top_level_interpreter ())->is_mi_like_p ())
+ || top_level_interpreter ()->interp_ui_out ()->is_mi_like_p ())
{
fputs_unfiltered (linebuffer, stream);
return;
lineptr = linebuffer;
while (*lineptr)
{
- /* Possible new page. */
- if (filter && (lines_printed >= lines_per_page - 1))
+ /* Possible new page. Note that PAGINATION_DISABLED_FOR_COMMAND
+ might be set during this loop, so we must continue to check
+ it here. */
+ if (filter && (lines_printed >= lines_per_page - 1)
+ && !pagination_disabled_for_command)
prompt_for_continue ();
while (*lineptr && *lineptr != '\n')
if (wrap_column)
fputc_unfiltered ('\n', stream);
- /* Possible new page. */
- if (lines_printed >= lines_per_page - 1)
+ /* Possible new page. Note that
+ PAGINATION_DISABLED_FOR_COMMAND might be set during
+ this loop, so we must continue to check it here. */
+ if (lines_printed >= lines_per_page - 1
+ && !pagination_disabled_for_command)
prompt_for_continue ();
/* Now output indentation and wrapped string. */
CORE_ADDR
address_significant (gdbarch *gdbarch, CORE_ADDR addr)
{
- /* Truncate address to the significant bits of a target address,
- avoiding shifts larger or equal than the width of a CORE_ADDR.
- The local variable ADDR_BIT stops the compiler reporting a shift
- overflow when it won't occur. */
+ /* Clear insignificant bits of a target address and sign extend resulting
+ address, avoiding shifts larger or equal than the width of a CORE_ADDR.
+ The local variable ADDR_BIT stops the compiler reporting a shift overflow
+ when it won't occur. Skip updating of target address if current target
+ has not set gdbarch significant_addr_bit. */
int addr_bit = gdbarch_significant_addr_bit (gdbarch);
- if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
- addr &= ((CORE_ADDR) 1 << addr_bit) - 1;
+ if (addr_bit && (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT)))
+ {
+ CORE_ADDR sign = (CORE_ADDR) 1 << (addr_bit - 1);
+ addr &= ((CORE_ADDR) 1 << addr_bit) - 1;
+ addr = (addr ^ sign) - sign;
+ }
return addr;
}
#define AMBIGUOUS_MESS2 \
".\nUse \"set gnutarget format-name\" to specify the format."
-const char *
+std::string
gdb_bfd_errmsg (bfd_error_type error_tag, char **matching)
{
- char *ret, *retp;
- int ret_len;
char **p;
/* Check if errmsg just need simple return. */
if (error_tag != bfd_error_file_ambiguously_recognized || matching == NULL)
return bfd_errmsg (error_tag);
- ret_len = strlen (bfd_errmsg (error_tag)) + strlen (AMBIGUOUS_MESS1)
- + strlen (AMBIGUOUS_MESS2);
- for (p = matching; *p; p++)
- ret_len += strlen (*p) + 1;
- ret = (char *) xmalloc (ret_len + 1);
- retp = ret;
- make_cleanup (xfree, ret);
-
- strcpy (retp, bfd_errmsg (error_tag));
- retp += strlen (retp);
-
- strcpy (retp, AMBIGUOUS_MESS1);
- retp += strlen (retp);
+ std::string ret (bfd_errmsg (error_tag));
+ ret += AMBIGUOUS_MESS1;
for (p = matching; *p; p++)
{
- sprintf (retp, " %s", *p);
- retp += strlen (retp);
+ ret += " ";
+ ret += *p;
}
- xfree (matching);
+ ret += AMBIGUOUS_MESS2;
- strcpy (retp, AMBIGUOUS_MESS2);
+ xfree (matching);
return ret;
}