ld: fix regressions with rett instructions in sparc tests.
[deliverable/binutils-gdb.git] / gdb / symtab.h
index 6f00baf463f4e20b81cbf62c76e6a00ed868bc54..341deca56fc95074f7db68c8a6ddf990d474b006 100644 (file)
@@ -1,6 +1,6 @@
 /* Symbol table definitions for GDB.
 
-   Copyright (C) 1986-2016 Free Software Foundation, Inc.
+   Copyright (C) 1986-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #if !defined (SYMTAB_H)
 #define SYMTAB_H 1
 
-#include "vec.h"
+#include <vector>
 #include "gdb_vecs.h"
 #include "gdbtypes.h"
 #include "common/enum-flags.h"
+#include "common/function-view.h"
 
 /* Opaque declarations.  */
 struct ui_file;
@@ -137,7 +138,7 @@ struct general_symbol_info
     struct obstack *obstack;
 
     /* This is used by languages which wish to store a demangled name.
-       currently used by Ada, C++, Java, and Objective C.  */
+       currently used by Ada, C++, and Objective C.  */
     const char *demangled_name;
   }
   language_specific;
@@ -261,7 +262,7 @@ extern const char *symbol_demangled_name
 extern int demangle;
 
 /* Macro that returns the name to be used when sorting and searching symbols.
-   In  C++ and Java, we search for the demangled form of a name,
+   In C++, we search for the demangled form of a name,
    and so sort symbols accordingly.  In Ada, however, we search by mangled
    name.  If there is no distinct demangled name, then SYMBOL_SEARCH_NAME
    returns the same value (same pointer) as SYMBOL_LINKAGE_NAME.  */
@@ -629,7 +630,8 @@ struct symbol_computed_ops
      frame FRAME.  If the variable has been optimized out, return
      zero.
 
-     Iff `read_needs_frame (SYMBOL)' is zero, then FRAME may be zero.  */
+     Iff `read_needs_frame (SYMBOL)' is not SYMBOL_NEEDS_FRAME, then
+     FRAME may be zero.  */
 
   struct value *(*read_variable) (struct symbol * symbol,
                                  struct frame_info * frame);
@@ -640,8 +642,11 @@ struct symbol_computed_ops
   struct value *(*read_variable_at_entry) (struct symbol *symbol,
                                           struct frame_info *frame);
 
-  /* Return non-zero if we need a frame to find the value of the SYMBOL.  */
-  int (*read_needs_frame) (struct symbol * symbol);
+  /* Find the "symbol_needs_kind" value for the given symbol.  This
+     value determines whether reading the symbol needs memory (e.g., a
+     global variable), just registers (a thread-local), or a frame (a
+     local variable).  */
+  enum symbol_needs_kind (*get_symbol_read_needs) (struct symbol * symbol);
 
   /* Write to STREAM a natural-language description of the location of
      SYMBOL, in the context of ADDR.  */
@@ -670,7 +675,7 @@ struct symbol_computed_ops
      The generated C code must assign the location to a local
      variable; this variable's name is RESULT_NAME.  */
 
-  void (*generate_c_location) (struct symbol *symbol, struct ui_file *stream,
+  void (*generate_c_location) (struct symbol *symbol, string_file &stream,
                               struct gdbarch *gdbarch,
                               unsigned char *registers_used,
                               CORE_ADDR pc, const char *result_name);
@@ -1603,38 +1608,67 @@ int compare_filenames_for_search (const char *filename,
 int compare_glob_filenames_for_search (const char *filename,
                                       const char *search_name);
 
-int iterate_over_some_symtabs (const char *name,
-                              const char *real_path,
-                              int (*callback) (struct symtab *symtab,
-                                               void *data),
-                              void *data,
-                              struct compunit_symtab *first,
-                              struct compunit_symtab *after_last);
+bool iterate_over_some_symtabs (const char *name,
+                               const char *real_path,
+                               struct compunit_symtab *first,
+                               struct compunit_symtab *after_last,
+                               gdb::function_view<bool (symtab *)> callback);
 
 void iterate_over_symtabs (const char *name,
-                          int (*callback) (struct symtab *symtab,
-                                           void *data),
-                          void *data);
+                          gdb::function_view<bool (symtab *)> callback);
 
-VEC (CORE_ADDR) *find_pcs_for_symtab_line (struct symtab *symtab, int line,
-                                          struct linetable_entry **best_entry);
 
-/* Callback for LA_ITERATE_OVER_SYMBOLS.  The callback will be called
-   once per matching symbol SYM, with DATA being the argument of the
-   same name that was passed to LA_ITERATE_OVER_SYMBOLS.  The callback
-   should return nonzero to indicate that LA_ITERATE_OVER_SYMBOLS
-   should continue iterating, or zero to indicate that the iteration
-   should end.  */
+std::vector<CORE_ADDR> find_pcs_for_symtab_line
+    (struct symtab *symtab, int line, struct linetable_entry **best_entry);
 
-typedef int (symbol_found_callback_ftype) (struct symbol *sym, void *data);
+/* Prototype for callbacks for LA_ITERATE_OVER_SYMBOLS.  The callback
+   is called once per matching symbol SYM.  The callback should return
+   true to indicate that LA_ITERATE_OVER_SYMBOLS should continue
+   iterating, or false to indicate that the iteration should end.  */
+
+typedef bool (symbol_found_callback_ftype) (symbol *sym);
 
 void iterate_over_symbols (const struct block *block, const char *name,
                           const domain_enum domain,
-                          symbol_found_callback_ftype *callback,
-                          void *data);
+                          gdb::function_view<symbol_found_callback_ftype> callback);
+
+/* Storage type used by demangle_for_lookup.  demangle_for_lookup
+   either returns a const char * pointer that points to either of the
+   fields of this type, or a pointer to the input NAME.  This is done
+   this way because the underlying functions that demangle_for_lookup
+   calls either return a std::string (e.g., cp_canonicalize_string) or
+   a malloc'ed buffer (libiberty's demangled), and we want to avoid
+   unnecessary reallocation/string copying.  */
+class demangle_result_storage
+{
+public:
+
+  /* Swap the std::string storage with STR, and return a pointer to
+     the beginning of the new string.  */
+  const char *swap_string (std::string &str)
+  {
+    std::swap (m_string, str);
+    return m_string.c_str ();
+  }
+
+  /* Set the malloc storage to now point at PTR.  Any previous malloc
+     storage is released.  */
+  const char *set_malloc_ptr (char *ptr)
+  {
+    m_malloc.reset (ptr);
+    return ptr;
+  }
+
+private:
+
+  /* The storage.  */
+  std::string m_string;
+  gdb::unique_xmalloc_ptr<char> m_malloc;
+};
 
-struct cleanup *demangle_for_lookup (const char *name, enum language lang,
-                                    const char **result_name);
+const char *
+  demangle_for_lookup (const char *name, enum language lang,
+                      demangle_result_storage &storage);
 
 struct symbol *allocate_symbol (struct objfile *);
 
This page took 0.027239 seconds and 4 git commands to generate.