summaryrefslogtreecommitdiff
path: root/gdb/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/utils.h')
-rw-r--r--gdb/utils.h310
1 files changed, 35 insertions, 275 deletions
diff --git a/gdb/utils.h b/gdb/utils.h
index ac30fd5f114..7e2028580bf 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -63,11 +63,14 @@ enum class strncmp_iw_mode
MATCH_FOR_LCD is passed down so that the function can mark parts of
the symbol name as ignored for completion matching purposes (e.g.,
- to handle abi tags). */
+ to handle abi tags). If IGNORE_TEMPLATE_PARAMS is true, all template
+ parameter lists will be ignored when language is C++. */
+
extern int strncmp_iw_with_mode
(const char *string1, const char *string2, size_t string2_len,
strncmp_iw_mode mode, enum language language,
- completion_match_for_lcd *match_for_lcd = NULL);
+ completion_match_for_lcd *match_for_lcd = NULL,
+ bool ignore_template_params = false);
/* Do a strncmp() type operation on STRING1 and STRING2, ignoring any
differences in whitespace. STRING2_LEN is STRING2's length.
@@ -120,204 +123,9 @@ extern int parse_pid_to_attach (const char *args);
extern int parse_escape (struct gdbarch *, const char **);
-/* A wrapper for an array of char* that was allocated in the way that
- 'buildargv' does, and should be freed with 'freeargv'. */
-
-class gdb_argv
-{
-public:
-
- /* A constructor that initializes to NULL. */
-
- gdb_argv ()
- : m_argv (NULL)
- {
- }
-
- /* A constructor that calls buildargv on STR. STR may be NULL, in
- which case this object is initialized with a NULL array. */
-
- explicit gdb_argv (const char *str)
- : m_argv (NULL)
- {
- reset (str);
- }
-
- /* A constructor that takes ownership of an existing array. */
-
- explicit gdb_argv (char **array)
- : m_argv (array)
- {
- }
-
- gdb_argv (const gdb_argv &) = delete;
- gdb_argv &operator= (const gdb_argv &) = delete;
-
- gdb_argv &operator= (gdb_argv &&other)
- {
- freeargv (m_argv);
- m_argv = other.m_argv;
- other.m_argv = nullptr;
- return *this;
- }
-
- gdb_argv (gdb_argv &&other)
- {
- m_argv = other.m_argv;
- other.m_argv = nullptr;
- }
-
- ~gdb_argv ()
- {
- freeargv (m_argv);
- }
-
- /* Call buildargv on STR, storing the result in this object. Any
- previous state is freed. STR may be NULL, in which case this
- object is reset with a NULL array. If buildargv fails due to
- out-of-memory, call malloc_failure. Therefore, the value is
- guaranteed to be non-NULL, unless the parameter itself is
- NULL. */
-
- void reset (const char *str);
-
- /* Return the underlying array. */
-
- char **get ()
- {
- return m_argv;
- }
-
- const char * const * get () const
- {
- return m_argv;
- }
-
- /* Return the underlying array, transferring ownership to the
- caller. */
-
- ATTRIBUTE_UNUSED_RESULT char **release ()
- {
- char **result = m_argv;
- m_argv = NULL;
- return result;
- }
-
- /* Return the number of items in the array. */
-
- int count () const
- {
- return countargv (m_argv);
- }
-
- /* Index into the array. */
-
- char *operator[] (int arg)
- {
- gdb_assert (m_argv != NULL);
- return m_argv[arg];
- }
-
- /* Return the arguments array as an array view. */
-
- gdb::array_view<char *> as_array_view ()
- {
- return gdb::array_view<char *> (this->get (), this->count ());
- }
-
- gdb::array_view<const char * const> as_array_view () const
- {
- return gdb::array_view<const char * const> (this->get (), this->count ());
- }
-
- /* Append arguments to this array. */
- void append (gdb_argv &&other)
- {
- int size = count ();
- int argc = other.count ();
- m_argv = XRESIZEVEC (char *, m_argv, (size + argc + 1));
-
- for (int argi = 0; argi < argc; argi++)
- {
- /* Transfer ownership of the string. */
- m_argv[size++] = other.m_argv[argi];
- /* Ensure that destruction of OTHER works correctly. */
- other.m_argv[argi] = nullptr;
- }
- m_argv[size] = nullptr;
- }
-
- /* Append arguments to this array. */
- void append (const gdb_argv &other)
- {
- int size = count ();
- int argc = other.count ();
- m_argv = XRESIZEVEC (char *, m_argv, (size + argc + 1));
-
- for (int argi = 0; argi < argc; argi++)
- m_argv[size++] = xstrdup (other.m_argv[argi]);
- m_argv[size] = nullptr;
- }
-
- /* The iterator type. */
-
- typedef char **iterator;
-
- /* Return an iterator pointing to the start of the array. */
-
- iterator begin ()
- {
- return m_argv;
- }
-
- /* Return an iterator pointing to the end of the array. */
-
- iterator end ()
- {
- return m_argv + count ();
- }
-
- bool operator!= (std::nullptr_t)
- {
- return m_argv != NULL;
- }
-
- bool operator== (std::nullptr_t)
- {
- return m_argv == NULL;
- }
-
-private:
-
- /* The wrapped array. */
-
- char **m_argv;
-};
-
/* Cleanup utilities. */
-/* A deleter for a hash table. */
-struct htab_deleter
-{
- void operator() (htab *ptr) const
- {
- htab_delete (ptr);
- }
-};
-
-/* A unique_ptr wrapper for htab_t. */
-typedef std::unique_ptr<htab, htab_deleter> htab_up;
-
-/* A wrapper for 'delete' that can used as a hash table entry deletion
- function. */
-template<typename T>
-void
-htab_delete_entry (void *ptr)
-{
- delete (T *) ptr;
-}
-
extern void init_page_info (void);
/* Temporarily set BATCH_FLAG and the associated unlimited terminal size.
@@ -367,7 +175,7 @@ extern int yquery (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
extern void begin_line (void);
-extern void wrap_here (const char *);
+extern void wrap_here (int);
extern void reinitialize_more_filter (void);
@@ -377,16 +185,16 @@ extern int get_chars_per_line ();
extern bool pagination_enabled;
+/* A flag indicating whether to timestamp debugging messages. */
+extern bool debug_timestamp;
+
extern struct ui_file **current_ui_gdb_stdout_ptr (void);
extern struct ui_file **current_ui_gdb_stdin_ptr (void);
extern struct ui_file **current_ui_gdb_stderr_ptr (void);
extern struct ui_file **current_ui_gdb_stdlog_ptr (void);
-/* Flush STREAM. This is a wrapper for ui_file_flush that also
- flushes any output pending from uses of the *_filtered output
- functions; that output is kept in a special buffer so that
- pagination and styling are handled properly. */
-extern void gdb_flush (struct ui_file *);
+/* Flush STREAM. */
+extern void gdb_flush (struct ui_file *stream);
/* The current top level's ui_file streams. */
@@ -394,20 +202,16 @@ extern void gdb_flush (struct ui_file *);
#define gdb_stdout (*current_ui_gdb_stdout_ptr ())
/* Input stream */
#define gdb_stdin (*current_ui_gdb_stdin_ptr ())
-/* Serious error notifications */
+/* Serious error notifications. This bypasses the pager, if one is in
+ use. */
#define gdb_stderr (*current_ui_gdb_stderr_ptr ())
-/* Log/debug/trace messages that should bypass normal stdout/stderr
- filtering. For moment, always call this stream using
- *_unfiltered. In the very near future that restriction shall be
- removed - either call shall be unfiltered. (cagney 1999-06-13). */
+/* Log/debug/trace messages that bypasses the pager, if one is in
+ use. */
#define gdb_stdlog (*current_ui_gdb_stdlog_ptr ())
/* Truly global ui_file streams. These are all defined in main.c. */
-/* Target output that should bypass normal stdout/stderr filtering.
- For moment, always call this stream using *_unfiltered. In the
- very near future that restriction shall be removed - either call
- shall be unfiltered. (cagney 1999-07-02). */
+/* Target output that should bypass the pager, if one is in use. */
extern struct ui_file *gdb_stdtarg;
extern struct ui_file *gdb_stdtargerr;
extern struct ui_file *gdb_stdtargin;
@@ -416,58 +220,43 @@ extern struct ui_file *gdb_stdtargin;
extern void set_screen_width_and_height (int width, int height);
-/* More generic printf like operations. Filtered versions may return
- non-locally on error. As an extension over plain printf, these
- support some GDB-specific format specifiers. Particularly useful
- here are the styling formatters: '%p[', '%p]' and '%ps'. See
- ui_out::message for details. */
-
-extern void fputs_filtered (const char *, struct ui_file *);
-
-extern void fputs_unfiltered (const char *, struct ui_file *);
-
-extern int fputc_filtered (int c, struct ui_file *);
+/* Generic stdio-like operations. */
-extern int fputc_unfiltered (int c, struct ui_file *);
+extern void gdb_puts (const char *, struct ui_file *);
-extern int putchar_filtered (int c);
+extern void gdb_putc (int c, struct ui_file *);
-extern int putchar_unfiltered (int c);
+extern void gdb_putc (int c);
-extern void puts_filtered (const char *);
+extern void gdb_puts (const char *);
-extern void puts_unfiltered (const char *);
+extern void puts_tabular (char *string, int width, int right);
-extern void puts_filtered_tabular (char *string, int width, int right);
+/* Generic printf-like operations. As an extension over plain
+ printf, these support some GDB-specific format specifiers.
+ Particularly useful here are the styling formatters: '%p[', '%p]'
+ and '%ps'. See ui_out::message for details. */
-extern void vprintf_filtered (const char *, va_list) ATTRIBUTE_PRINTF (1, 0);
+extern void gdb_vprintf (const char *, va_list) ATTRIBUTE_PRINTF (1, 0);
-extern void vfprintf_filtered (struct ui_file *, const char *, va_list)
+extern void gdb_vprintf (struct ui_file *, const char *, va_list)
ATTRIBUTE_PRINTF (2, 0);
-extern void fprintf_filtered (struct ui_file *, const char *, ...)
+extern void gdb_printf (struct ui_file *, const char *, ...)
ATTRIBUTE_PRINTF (2, 3);
-extern void printf_filtered (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
-
-extern void vprintf_unfiltered (const char *, va_list) ATTRIBUTE_PRINTF (1, 0);
-
-extern void vfprintf_unfiltered (struct ui_file *, const char *, va_list)
- ATTRIBUTE_PRINTF (2, 0);
-
-extern void fprintf_unfiltered (struct ui_file *, const char *, ...)
- ATTRIBUTE_PRINTF (2, 3);
+extern void gdb_printf (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
extern void printf_unfiltered (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
-extern void print_spaces_filtered (int, struct ui_file *);
+extern void print_spaces (int, struct ui_file *);
extern const char *n_spaces (int);
/* Return nonzero if filtered printing is initialized. */
extern int filtered_printing_initialized (void);
-/* Like fprintf_filtered, but styles the output according to STYLE,
+/* Like gdb_printf, but styles the output according to STYLE,
when appropriate. */
extern void fprintf_styled (struct ui_file *stream,
@@ -476,43 +265,19 @@ extern void fprintf_styled (struct ui_file *stream,
...)
ATTRIBUTE_PRINTF (3, 4);
-extern void vfprintf_styled (struct ui_file *stream,
- const ui_file_style &style,
- const char *fmt,
- va_list args)
- ATTRIBUTE_PRINTF (3, 0);
-
-/* Like vfprintf_styled, but do not process gdb-specific format
- specifiers. */
-extern void vfprintf_styled_no_gdbfmt (struct ui_file *stream,
- const ui_file_style &style,
- bool filter,
- const char *fmt, va_list args)
- ATTRIBUTE_PRINTF (4, 0);
-
-/* Like fputs_filtered, but styles the output according to STYLE, when
+/* Like gdb_puts, but styles the output according to STYLE, when
appropriate. */
extern void fputs_styled (const char *linebuffer,
const ui_file_style &style,
struct ui_file *stream);
-/* Unfiltered variant of fputs_styled. */
-
-extern void fputs_styled_unfiltered (const char *linebuffer,
- const ui_file_style &style,
- struct ui_file *stream);
-
/* Like fputs_styled, but uses highlight_style to highlight the
parts of STR that match HIGHLIGHT. */
extern void fputs_highlighted (const char *str, const compiled_regex &highlight,
struct ui_file *stream);
-/* Reset the terminal style to the default, if needed. */
-
-extern void reset_terminal_style (struct ui_file *stream);
-
/* Return the address only having significant bits. */
extern CORE_ADDR address_significant (gdbarch *gdbarch, CORE_ADDR addr);
@@ -528,8 +293,8 @@ extern const char *print_core_address (struct gdbarch *gdbarch,
extern CORE_ADDR string_to_core_addr (const char *my_string);
-extern void fprintf_symbol_filtered (struct ui_file *, const char *,
- enum language, int);
+extern void fprintf_symbol (struct ui_file *, const char *,
+ enum language, int);
extern void throw_perror_with_name (enum errors errcode, const char *string)
ATTRIBUTE_NORETURN;
@@ -558,11 +323,6 @@ extern void demangler_warning (const char *file, int line,
/* Misc. utilities. */
-/* Allocation and deallocation functions for the libiberty hash table
- which use obstacks. */
-void *hashtab_obstack_allocate (void *data, size_t size, size_t count);
-void dummy_obstack_deallocate (void *object, void *data);
-
#ifdef HAVE_WAITPID
extern pid_t wait_to_die_with_timeout (pid_t pid, int *status, int timeout);
#endif