/* Helper routines for C++ support in GDB.
- Copyright (C) 2002-2018 Free Software Foundation, Inc.
+ Copyright (C) 2002-2019 Free Software Foundation, Inc.
Contributed by MontaVista Software.
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+
+/* Standard C includes. */
+#include <signal.h>
+
+/* Local non-gdb includes. */
+#include "block.h"
+#include "common/gdb_setjmp.h"
+#include "common/selftest.h"
+#include "complaints.h"
+#include "cp-abi.h"
#include "cp-support.h"
#include "demangle.h"
-#include "gdbcmd.h"
#include "dictionary.h"
-#include "objfiles.h"
+#include "expression.h"
#include "frame.h"
-#include "symtab.h"
-#include "block.h"
-#include "complaints.h"
+#include "gdbcmd.h"
#include "gdbtypes.h"
-#include "expression.h"
-#include "value.h"
-#include "cp-abi.h"
#include "namespace.h"
-#include <signal.h>
-#include "gdb_setjmp.h"
+#include "objfiles.h"
#include "safe-ctype.h"
-#include "selftest.h"
+#include "symtab.h"
+#include "value.h"
#define d_left(dc) (dc)->u.s_binary.left
#define d_right(dc) (dc)->u.s_binary.right
/* If FULL_NAME is the demangled name of a C++ function (including an
arg list, possibly including namespace/class qualifications),
return a new string containing only the function name (without the
- arg list/class qualifications). Otherwise, return NULL. The
- caller is responsible for freeing the memory in question. */
+ arg list/class qualifications). Otherwise, return NULL. */
-char *
+gdb::unique_xmalloc_ptr<char>
cp_func_name (const char *full_name)
{
gdb::unique_xmalloc_ptr<char> ret;
info = cp_demangled_name_to_comp (full_name, NULL);
if (!info)
- return NULL;
+ return nullptr;
ret_comp = unqualified_name_from_comp (info->tree);
if (ret_comp != NULL)
ret = cp_comp_to_string (ret_comp, 10);
- return ret.release ();
+ return ret;
}
/* Helper for cp_remove_params. DEMANGLED_NAME is the name of a
add_symbol_overload_list_qualified (const char *func_name,
std::vector<symbol *> *overload_list)
{
- struct compunit_symtab *cust;
- struct objfile *objfile;
const struct block *b, *surrounding_static_block = 0;
/* Look through the partial symtabs for all symbols which begin by
matching FUNC_NAME. Make sure we read that symbol table in. */
- ALL_OBJFILES (objfile)
- {
- if (objfile->sf)
- objfile->sf->qf->expand_symtabs_for_function (objfile, func_name);
- }
+ for (objfile *objf : current_program_space->objfiles ())
+ {
+ if (objf->sf)
+ objf->sf->qf->expand_symtabs_for_function (objf, func_name);
+ }
/* Search upwards from currently selected frame (so that we can
complete on local vars. */
/* Go through the symtabs and check the externs and statics for
symbols which match. */
- ALL_COMPUNITS (objfile, cust)
- {
- QUIT;
- b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), GLOBAL_BLOCK);
- add_symbol_overload_list_block (func_name, b, overload_list);
- }
+ for (objfile *objfile : current_program_space->objfiles ())
+ {
+ for (compunit_symtab *cust : objfile->compunits ())
+ {
+ QUIT;
+ b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), GLOBAL_BLOCK);
+ add_symbol_overload_list_block (func_name, b, overload_list);
+ }
+ }
- ALL_COMPUNITS (objfile, cust)
- {
- QUIT;
- b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK);
- /* Don't do this block twice. */
- if (b == surrounding_static_block)
- continue;
- add_symbol_overload_list_block (func_name, b, overload_list);
- }
+ for (objfile *objfile : current_program_space->objfiles ())
+ {
+ for (compunit_symtab *cust : objfile->compunits ())
+ {
+ QUIT;
+ b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK);
+ /* Don't do this block twice. */
+ if (b == surrounding_static_block)
+ continue;
+ add_symbol_overload_list_block (func_name, b, overload_list);
+ }
+ }
}
/* Lookup the rtti type for a class name. */
struct type *
-cp_lookup_rtti_type (const char *name, struct block *block)
+cp_lookup_rtti_type (const char *name, const struct block *block)
{
struct symbol * rtti_sym;
struct type * rtti_type;