cris: Check UNDEFWEAK_NO_DYNAMIC_RELOC
[deliverable/binutils-gdb.git] / gdb / utils.h
index 48330a16f7fb3456950328573d3a433cc72088d9..17d625819583741bf42611fadaeb1aef391e7675 100644 (file)
@@ -85,37 +85,136 @@ extern int parse_pid_to_attach (const char *args);
 
 extern int parse_escape (struct gdbarch *, const char **);
 
-char **gdb_buildargv (const char *);
-\f
-/* Cleanup utilities.  */
+/* A wrapper for an array of char* that was allocated in the way that
+   'buildargv' does, and should be freed with 'freeargv'.  */
 
-extern struct cleanup *make_cleanup_freeargv (char **);
+class gdb_argv
+{
+public:
 
-struct ui_out;
-extern struct cleanup *
-  make_cleanup_ui_out_redirect_pop (struct ui_out *uiout);
+  /* A constructor that initializes to NULL.  */
 
-struct section_addr_info;
-extern struct cleanup *(make_cleanup_free_section_addr_info 
-                        (struct section_addr_info *));
+  gdb_argv ()
+    : m_argv (NULL)
+  {
+  }
 
-/* For make_cleanup_close see common/filestuff.h.  */
+  /* A constructor that calls buildargv on STR.  STR may be NULL, in
+     which case this object is initialized 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.  */
+
+  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 ()
+  {
+    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;
+  }
+
+  /* Return the underlying array, transferring ownership to the
+     caller.  */
+
+  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];
+  }
 
-extern struct cleanup *make_cleanup_fclose (FILE *file);
+  /* The iterator type.  */
 
-extern struct cleanup *make_cleanup_restore_integer (int *variable);
-extern struct cleanup *make_cleanup_restore_uinteger (unsigned int *variable);
+  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;
+};
+
+\f
+/* Cleanup utilities.  */
+
+struct section_addr_info;
+extern struct cleanup *make_cleanup_free_section_addr_info
+                       (struct section_addr_info *);
+
+/* For make_cleanup_close see common/filestuff.h.  */
 
 struct target_ops;
 extern struct cleanup *make_cleanup_unpush_target (struct target_ops *ops);
 
 extern struct cleanup *make_cleanup_value_free_to_mark (struct value *);
-extern struct cleanup *make_cleanup_value_free (struct value *);
-
-struct so_list;
-extern struct cleanup *make_cleanup_free_so (struct so_list *so);
-
-extern struct cleanup *make_cleanup_restore_current_language (void);
 
 /* A deleter for a hash table.  */
 struct htab_deleter
@@ -129,27 +228,41 @@ struct htab_deleter
 /* A unique_ptr wrapper for htab_t.  */
 typedef std::unique_ptr<htab, htab_deleter> htab_up;
 
-struct parser_state;
-extern struct cleanup *make_cleanup_clear_parser_state
-  (struct parser_state **p);
-
 extern void free_current_contents (void *);
 
 extern void init_page_info (void);
 
-extern struct cleanup *make_cleanup_restore_page_info (void);
-extern struct cleanup *
-  set_batch_flag_and_make_cleanup_restore_page_info (void);
+/* Temporarily set BATCH_FLAG and the associated unlimited terminal size.
+   Restore when destroyed.  */
+
+struct set_batch_flag_and_restore_page_info
+{
+public:
+
+  set_batch_flag_and_restore_page_info ();
+  ~set_batch_flag_and_restore_page_info ();
+
+  DISABLE_COPY_AND_ASSIGN (set_batch_flag_and_restore_page_info);
+
+private:
+
+  /* Note that this doesn't use scoped_restore, because it's important
+     to control the ordering of operations in the destruction, and it
+     was simpler to avoid introducing a new ad hoc class.  */
+  unsigned m_save_lines_per_page;
+  unsigned m_save_chars_per_line;
+  int m_save_batch_flag;
+};
 
 extern struct cleanup *make_bpstat_clear_actions_cleanup (void);
 \f
 /* Path utilities.  */
 
-extern char *gdb_realpath (const char *);
+extern gdb::unique_xmalloc_ptr<char> gdb_realpath (const char *);
 
-extern char *gdb_realpath_keepfile (const char *);
+extern gdb::unique_xmalloc_ptr<char> gdb_realpath_keepfile (const char *);
 
-extern char *gdb_abspath (const char *);
+extern gdb::unique_xmalloc_ptr<char> gdb_abspath (const char *);
 
 extern int gdb_filename_fnmatch (const char *pattern, const char *string,
                                 int flags);
@@ -343,9 +456,6 @@ void dummy_obstack_deallocate (void *object, void *data);
 extern pid_t wait_to_die_with_timeout (pid_t pid, int *status, int timeout);
 #endif
 
-extern int producer_is_gcc_ge_4 (const char *producer);
-extern int producer_is_gcc (const char *producer, int *major, int *minor);
-
 extern int myread (int, char *, int);
 
 /* Ensure that V is aligned to an N byte boundary (B's assumed to be a
This page took 0.02498 seconds and 4 git commands to generate.