summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-05-10 13:09:42 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-05-10 13:09:42 -0700
commitd60c4bf851c33a684464e2d64aa2785d11fac245 (patch)
tree2f8e40edf31c05c2f5e0d26a1422795987c1a3e9
parent0c5ddba6ea88bd27ef14fcccb26c51db6d607ad1 (diff)
parent86cd6bc8f69613d81a2024d7d3436b774a4039cd (diff)
downloadbinutils-gdb-d60c4bf851c33a684464e2d64aa2785d11fac245.tar.gz
Merge remote-tracking branch 'origin/master' into users/hjl/linux/master
-rw-r--r--bfd/version.h2
-rw-r--r--gdb/ChangeLog177
-rw-r--r--gdb/ada-lang.c4
-rw-r--r--gdb/ada-tasks.c4
-rw-r--r--gdb/ada-typeprint.c4
-rw-r--r--gdb/async-event.c74
-rw-r--r--gdb/break-catch-throw.c12
-rw-r--r--gdb/breakpoint.c228
-rw-r--r--gdb/c-exp.y11
-rw-r--r--gdb/c-typeprint.c4
-rw-r--r--gdb/cp-support.c41
-rw-r--r--gdb/cp-support.h11
-rw-r--r--gdb/dbxread.c9
-rw-r--r--gdb/dwarf2/read.c51
-rw-r--r--gdb/exec.c3
-rw-r--r--gdb/extension.c153
-rw-r--r--gdb/gdbtypes.c57
-rw-r--r--gdb/gdbtypes.h45
-rw-r--r--gdb/gnu-v3-abi.c14
-rw-r--r--gdb/guile/scm-progspace.c11
-rw-r--r--gdb/infrun.c6
-rw-r--r--gdb/linespec.c143
-rw-r--r--gdb/mi/mi-cmd-file.c3
-rw-r--r--gdb/printcmd.c193
-rw-r--r--gdb/probe.c4
-rw-r--r--gdb/progspace.c81
-rw-r--r--gdb/progspace.h17
-rw-r--r--gdb/psymtab.c4
-rw-r--r--gdb/python/python.c14
-rw-r--r--gdb/rust-lang.c3
-rw-r--r--gdb/solib-frv.c18
-rw-r--r--gdb/solib-svr4.c8
-rw-r--r--gdb/solib.c50
-rw-r--r--gdb/solib.h9
-rw-r--r--gdb/solist.h8
-rw-r--r--gdb/source.c4
-rw-r--r--gdb/stabsread.c12
-rw-r--r--gdb/symfile-debug.c4
-rw-r--r--gdb/symmisc.c134
-rw-r--r--gdb/symtab.c28
-rw-r--r--gdb/symtab.h17
-rw-r--r--gdb/testsuite/ChangeLog52
-rw-r--r--gdb/testsuite/gdb.dwarf2/clang-debug-names.c25
-rw-r--r--gdb/testsuite/gdb.dwarf2/clang-debug-names.exp145
-rw-r--r--gdb/testsuite/gdb.fortran/array-bounds-high.exp5
-rw-r--r--gdb/testsuite/gdb.fortran/array-bounds.exp5
-rw-r--r--gdb/testsuite/gdb.fortran/array-slices.exp3
-rw-r--r--gdb/testsuite/gdb.fortran/block-data.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/charset.exp6
-rw-r--r--gdb/testsuite/gdb.fortran/common-block.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/complex.exp5
-rw-r--r--gdb/testsuite/gdb.fortran/derived-type-function.exp5
-rw-r--r--gdb/testsuite/gdb.fortran/derived-type.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/info-modules.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/info-types.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/intrinsics.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/library-module.exp5
-rw-r--r--gdb/testsuite/gdb.fortran/logical.exp5
-rw-r--r--gdb/testsuite/gdb.fortran/max-depth.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/module.exp6
-rw-r--r--gdb/testsuite/gdb.fortran/multi-dim.exp4
-rwxr-xr-xgdb/testsuite/gdb.fortran/nested-funcs.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/print-formatted.exp4
-rwxr-xr-xgdb/testsuite/gdb.fortran/print_type.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/printing-types.exp5
-rw-r--r--gdb/testsuite/gdb.fortran/ptr-indentation.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/ptype-on-functions.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/subarray.exp5
-rw-r--r--gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp3
-rw-r--r--gdb/testsuite/gdb.fortran/vla-datatypes.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/vla-history.exp3
-rw-r--r--gdb/testsuite/gdb.fortran/vla-ptr-info.exp3
-rw-r--r--gdb/testsuite/gdb.fortran/vla-ptype-sub.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/vla-ptype.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/vla-sizeof.exp3
-rwxr-xr-xgdb/testsuite/gdb.fortran/vla-type.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp3
-rw-r--r--gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp3
-rw-r--r--gdb/testsuite/gdb.fortran/vla-value-sub.exp3
-rw-r--r--gdb/testsuite/gdb.fortran/vla-value.exp6
-rw-r--r--gdb/testsuite/gdb.fortran/whatis_type.exp4
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-child-f.exp2
-rw-r--r--gdb/testsuite/lib/fortran.exp20
-rw-r--r--gdb/top.c2
-rw-r--r--gdb/top.h2
-rw-r--r--gdb/value.c2
86 files changed, 1151 insertions, 918 deletions
diff --git a/bfd/version.h b/bfd/version.h
index 2ea547ed187..b62450116c3 100644
--- a/bfd/version.h
+++ b/bfd/version.h
@@ -16,7 +16,7 @@
In releases, the date is not included in either version strings or
sonames. */
-#define BFD_VERSION_DATE 20200507
+#define BFD_VERSION_DATE 20200510
#define BFD_VERSION @bfd_version@
#define BFD_VERSION_STRING @bfd_version_package@ @bfd_version_string@
#define REPORT_BUGS_TO @report_bugs_to@
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1eb8c111c69..a132f20dde5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,180 @@
+2020-05-09 Tom de Vries <tdevries@suse.de>
+
+ PR gdb/25955
+ * break-catch-throw.c (check_status_exception_catchpoint): Fix name
+ calculation.
+
+2020-05-09 Tom Tromey <tom@tromey.com>
+
+ * top.c (server_command): Now bool.
+ * top.h (server_command): Now bool.
+
+2020-05-08 Tom Tromey <tromey@adacore.com>
+
+ * dwarf2/read.c (read_lexical_block_scope): Don't process a DIE
+ already being processed.
+
+2020-05-08 Tom Tromey <tom@tromey.com>
+
+ * printcmd.c (struct display) <next>: Remove.
+ <display>: New constructor.
+ <exp_string>: Now a std::string.
+ <enabled_p>: Now a bool.
+ (display_number): Move definition earlier.
+ (displays): Rename from display_chain. Now a std::vector.
+ (ALL_DISPLAYS, ALL_DISPLAYS_SAFE): Remove.
+ (display_command): Update.
+ (do_one_display, disable_display)
+ (enable_disable_display_command, do_enable_disable_display):
+ Update.
+ (free_display): Remove.
+ (clear_displays): Rewrite.
+ (delete_display): Update.
+ (map_display_numbers): Use function_view. Remove "data"
+ parameter. Update.
+ (do_delete_display): Remove.
+ (undisplay_command): Update.
+ (do_one_display, do_displays, disable_display)
+ (info_display_command): Update.
+ (do_enable_disable_display): Remove.
+ (enable_disable_display_command)
+ (clear_dangling_display_expressions): Update.
+
+2020-05-08 Tom Tromey <tom@tromey.com>
+
+ * symtab.c (set_symbol_cache_size)
+ (maintenance_print_symbol_cache, maintenance_flush_symbol_cache)
+ (maintenance_print_symbol_cache_statistics): Update.
+ * symmisc.c (print_symbol_bcache_statistics)
+ (print_objfile_statistics, maintenance_print_objfiles)
+ (maintenance_info_symtabs, maintenance_check_symtabs)
+ (maintenance_expand_symtabs, maintenance_info_line_tables):
+ Update.
+ * symfile-debug.c (set_debug_symfile): Update.
+ * source.c (forget_cached_source_info): Update.
+ * python/python.c (gdbpy_progspaces): Update.
+ * psymtab.c (maintenance_info_psymtabs): Update.
+ * probe.c (parse_probes): Update.
+ * linespec.c (iterate_over_all_matching_symtabs)
+ (collect_symtabs_from_filename, search_minsyms_for_name): Update.
+ * guile/scm-progspace.c (gdbscm_progspaces): Update.
+ * exec.c (exec_target::close): Update.
+ * ada-tasks.c (ada_tasks_new_objfile_observer): Update.
+ * breakpoint.c (print_one_breakpoint_location)
+ (create_longjmp_master_breakpoint)
+ (create_std_terminate_master_breakpoint): Update.
+ * progspace.c (program_spaces): Now a std::vector.
+ (maybe_new_address_space): Update.
+ (add_program_space): Remove.
+ (program_space::program_space): Update.
+ (remove_program_space): Update.
+ (number_of_program_spaces): Remove.
+ (print_program_space, update_address_spaces): Update.
+ * progspace.h (program_spaces): Change type.
+ (ALL_PSPACES): Remove.
+ (number_of_program_spaces): Don't declare.
+ (struct program_space) <next>: Remove.
+
+2020-05-08 Tom Tromey <tom@tromey.com>
+
+ * mi/mi-cmd-file.c (mi_cmd_file_list_shared_libraries): Update.
+ * solib-svr4.c (svr4_fetch_objfile_link_map): Update.
+ (enable_break): Update.
+ * solib-frv.c (frv_fdpic_find_global_pointer): Update.
+ (frv_fdpic_find_canonical_descriptor): Update.
+ (frv_fetch_objfile_link_map): Update.
+ * progspace.c (program_space::free_all_objfiles): Update.
+ (program_space::solibs): New method.
+ * progspace.h (struct program_space) <solibs>: New method.
+ * solist.h (master_so_list): Don't declare.
+ (ALL_SO_LIBS): Remove.
+ * solib.h (so_list_head): Remove.
+ (update_solib_list): Update comment.
+ * solib.c (master_so_list): Remove.
+ (solib_used, update_solib_list, solib_add)
+ (info_sharedlibrary_command, clear_solib)
+ (reload_shared_libraries_1, remove_user_added_objfile): Update.
+
+2020-05-08 Tom Tromey <tom@tromey.com>
+
+ * extension.c (extension_languages): Now a std::array.
+ (ALL_EXTENSION_LANGUAGES): Remove.
+ (get_ext_lang_defn, get_ext_lang_of_file)
+ (eval_ext_lang_from_control_command): Update.
+ (finish_ext_lang_initialization)
+ (auto_load_ext_lang_scripts_for_objfile)
+ (ext_lang_type_printers::ext_lang_type_printers)
+ (apply_ext_lang_type_printers)
+ (ext_lang_type_printers::~ext_lang_type_printers)
+ (apply_ext_lang_val_pretty_printer, apply_ext_lang_frame_filter)
+ (preserve_ext_lang_values, get_breakpoint_cond_ext_lang)
+ (breakpoint_ext_lang_cond_says_stop, check_quit_flag)
+ (get_matching_xmethod_workers, ext_lang_colorize)
+ (ext_lang_before_prompt): Update.
+ (ALL_ENABLED_EXTENSION_LANGUAGES): Remove.
+
+2020-05-08 Tom Tromey <tom@tromey.com>
+
+ * symtab.h (class demangle_result_storage) <set_malloc_ptr>: New
+ overload.
+ <swap_string, m_string>: Remove.
+ * symtab.c (demangle_for_lookup, completion_list_add_symbol):
+ Update.
+ * stabsread.c (define_symbol, read_type): Update.
+ * linespec.c (find_linespec_symbols): Update.
+ * gnu-v3-abi.c (gnuv3_get_typeid): Update.
+ * dwarf2/read.c (dwarf2_canonicalize_name): Update.
+ * dbxread.c (read_dbx_symtab): Update.
+ * cp-support.h (cp_canonicalize_string_full)
+ (cp_canonicalize_string, cp_canonicalize_string_no_typedefs):
+ Return unique_xmalloc_ptr.
+ * cp-support.c (inspect_type): Update.
+ (cp_canonicalize_string_full): Return unique_xmalloc_ptr.
+ (cp_canonicalize_string_no_typedefs, cp_canonicalize_string):
+ Likewise.
+ * c-typeprint.c (print_name_maybe_canonical): Update.
+ * break-catch-throw.c (check_status_exception_catchpoint):
+ Update.
+
+2020-05-08 Tom de Vries <tdevries@suse.de>
+
+ * infrun.c (follow_fork): Copy current_line and current_symtab to
+ child thread.
+
+2020-05-07 Simon Marchi <simon.marchi@efficios.com>
+
+ * async-event.c (struct async_signal_handler, struct
+ async_event_handler): Reformat, remove typedef.
+
+2020-05-07 Simon Marchi <simon.marchi@efficios.com>
+
+ * gdbtypes.h (TYPE_DYN_PROP_LIST): Remove. Update all users
+ access thistype->main_type->dyn_prop_list directly.
+
+2020-05-07 Simon Marchi <simon.marchi@efficios.com>
+
+ * gdbtypes.h (struct type) <remove_dyn_prop>: New method.
+ (remove_dyn_prop): Remove. Update all users to use
+ type::remove_dyn_prop.
+ * gdbtypes.c (remove_dyn_prop): Rename to...
+ (type::remove_dyn_prop): ... this.
+
+2020-05-07 Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
+
+ * gdbtypes.h (struct type) <add_dyn_prop>: New method.
+ (add_dyn_prop): Remove. Update all users to use
+ type::add_dyn_prop.
+ * gdbtypes.c (add_dyn_prop): Rename to...
+ (type::add_dyn_prop): ... this.
+
+2020-05-07 Simon Marchi <simon.marchi@efficios.com>
+
+ * gdbtypes.h (struct type) <get_dyn_prop>: New method.
+ (get_dyn_prop): Remove. Update all users to use
+ type::dyn_prop.
+ * gdbtypes.c (get_dyn_prop): Rename to...
+ (type::dyn_prop): ... this.
+
2020-05-06 Simon Marchi <simon.marchi@efficios.com>
* gdbtypes.h (struct main_type) <flag_static>: Remove.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index bfbc69084ec..be26231524d 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -2812,7 +2812,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
= create_static_range_type (NULL, base_index_type, low, high);
struct type *slice_type = create_array_type_with_stride
(NULL, TYPE_TARGET_TYPE (type0), index_type,
- get_dyn_prop (DYN_PROP_BYTE_STRIDE, type0),
+ type0->dyn_prop (DYN_PROP_BYTE_STRIDE),
TYPE_FIELD_BITSIZE (type0, 0));
int base_low = ada_discrete_type_low_bound (TYPE_INDEX_TYPE (type0));
LONGEST base_low_pos, low_pos;
@@ -2842,7 +2842,7 @@ ada_value_slice (struct value *array, int low, int high)
= create_static_range_type (NULL, TYPE_INDEX_TYPE (type), low, high);
struct type *slice_type = create_array_type_with_stride
(NULL, TYPE_TARGET_TYPE (type), index_type,
- get_dyn_prop (DYN_PROP_BYTE_STRIDE, type),
+ type->dyn_prop (DYN_PROP_BYTE_STRIDE),
TYPE_FIELD_BITSIZE (type, 0));
LONGEST low_pos, high_pos;
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 589d5e84e0a..266335387a3 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -1433,9 +1433,7 @@ ada_tasks_new_objfile_observer (struct objfile *objfile)
{
/* All objfiles are being cleared, so we should clear all
our caches for all program spaces. */
- struct program_space *pspace;
-
- for (pspace = program_spaces; pspace != NULL; pspace = pspace->next)
+ for (struct program_space *pspace : program_spaces)
ada_tasks_invalidate_pspace_data (pspace);
}
else
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index 83972fe125d..7ef8bd5ef9e 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -776,13 +776,13 @@ print_record_field_types (struct type *type, struct type *outer_type,
struct ui_file *stream, int show, int level,
const struct type_print_options *flags)
{
- struct dynamic_prop *prop = get_dyn_prop (DYN_PROP_VARIANT_PARTS, type);
+ struct dynamic_prop *prop = type->dyn_prop (DYN_PROP_VARIANT_PARTS);
if (prop != nullptr)
{
if (prop->kind == PROP_TYPE)
{
type = prop->data.original_type;
- prop = get_dyn_prop (DYN_PROP_VARIANT_PARTS, type);
+ prop = type->dyn_prop (DYN_PROP_VARIANT_PARTS);
}
gdb_assert (prop->kind == PROP_VARIANT_PARTS);
print_record_field_types_dynamic (*prop->data.variant_parts,
diff --git a/gdb/async-event.c b/gdb/async-event.c
index dd65c17468b..4354175edfa 100644
--- a/gdb/async-event.c
+++ b/gdb/async-event.c
@@ -32,16 +32,21 @@
Async_init_signals takes care of setting up such an
async_signal_handler for each interesting signal. */
-typedef struct async_signal_handler
- {
- int ready; /* If ready, call this handler
- from the main event loop, using
- invoke_async_handler. */
- struct async_signal_handler *next_handler; /* Ptr to next handler. */
- sig_handler_func *proc; /* Function to call to do the work. */
- gdb_client_data client_data; /* Argument to async_handler_func. */
- }
-async_signal_handler;
+struct async_signal_handler
+{
+ /* If ready, call this handler from the main event loop, using
+ invoke_async_handler. */
+ int ready;
+
+ /* Pointer to next handler. */
+ struct async_signal_handler *next_handler;
+
+ /* Function to call to do the work. */
+ sig_handler_func *proc;
+
+ /* Argument to PROC. */
+ gdb_client_data client_data;
+};
/* PROC is a function to be invoked when the READY flag is set. This
happens when the event has been marked with
@@ -49,45 +54,44 @@ async_signal_handler;
to an event will be carried out by PROC at a later time, within
process_event. This provides a deferred execution of event
handlers. */
-typedef struct async_event_handler
- {
- /* If ready, call this handler from the main event loop, using
- invoke_event_handler. */
- int ready;
+struct async_event_handler
+{
+ /* If ready, call this handler from the main event loop, using
+ invoke_event_handler. */
+ int ready;
- /* Point to next handler. */
- struct async_event_handler *next_handler;
+ /* Pointer to next handler. */
+ struct async_event_handler *next_handler;
- /* Function to call to do the work. */
- async_event_handler_func *proc;
+ /* Function to call to do the work. */
+ async_event_handler_func *proc;
- /* Argument to PROC. */
- gdb_client_data client_data;
- }
-async_event_handler;
+ /* Argument to PROC. */
+ gdb_client_data client_data;
+};
/* All the async_signal_handlers gdb is interested in are kept onto
this list. */
static struct
- {
- /* Pointer to first in handler list. */
- async_signal_handler *first_handler;
+{
+ /* Pointer to first in handler list. */
+ async_signal_handler *first_handler;
- /* Pointer to last in handler list. */
- async_signal_handler *last_handler;
- }
+ /* Pointer to last in handler list. */
+ async_signal_handler *last_handler;
+}
sighandler_list;
/* All the async_event_handlers gdb is interested in are kept onto
this list. */
static struct
- {
- /* Pointer to first in handler list. */
- async_event_handler *first_handler;
+{
+ /* Pointer to first in handler list. */
+ async_event_handler *first_handler;
- /* Pointer to last in handler list. */
- async_event_handler *last_handler;
- }
+ /* Pointer to last in handler list. */
+ async_event_handler *last_handler;
+}
async_event_handler_list;
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 07dcc7dc0e7..7f4a9f955df 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -156,26 +156,28 @@ check_status_exception_catchpoint (struct bpstats *bs)
if (self->pattern == NULL)
return;
+ const char *name = nullptr;
+ gdb::unique_xmalloc_ptr<char> canon;
try
{
struct value *typeinfo_arg;
- std::string canon;
fetch_probe_arguments (NULL, &typeinfo_arg);
type_name = cplus_typename_from_type_info (typeinfo_arg);
canon = cp_canonicalize_string (type_name.c_str ());
- if (!canon.empty ())
- std::swap (type_name, canon);
+ name = (canon != nullptr
+ ? canon.get ()
+ : type_name.c_str ());
}
catch (const gdb_exception_error &e)
{
exception_print (gdb_stderr, e);
}
- if (!type_name.empty ())
+ if (name != nullptr)
{
- if (self->pattern->exec (type_name.c_str (), 0, NULL, 0) != 0)
+ if (self->pattern->exec (name, 0, NULL, 0) != 0)
bs->stop = 0;
}
}
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 4cba7740097..22ddb3d5e81 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -3224,153 +3224,151 @@ create_overlay_event_breakpoint (void)
static void
create_longjmp_master_breakpoint (void)
{
- struct program_space *pspace;
-
scoped_restore_current_program_space restore_pspace;
- ALL_PSPACES (pspace)
- {
- set_current_program_space (pspace);
+ for (struct program_space *pspace : program_spaces)
+ {
+ set_current_program_space (pspace);
- for (objfile *objfile : current_program_space->objfiles ())
- {
- int i;
- struct gdbarch *gdbarch;
- struct breakpoint_objfile_data *bp_objfile_data;
+ for (objfile *objfile : current_program_space->objfiles ())
+ {
+ int i;
+ struct gdbarch *gdbarch;
+ struct breakpoint_objfile_data *bp_objfile_data;
- gdbarch = objfile->arch ();
+ gdbarch = objfile->arch ();
- bp_objfile_data = get_breakpoint_objfile_data (objfile);
+ bp_objfile_data = get_breakpoint_objfile_data (objfile);
- if (!bp_objfile_data->longjmp_searched)
- {
- std::vector<probe *> ret
- = find_probes_in_objfile (objfile, "libc", "longjmp");
+ if (!bp_objfile_data->longjmp_searched)
+ {
+ std::vector<probe *> ret
+ = find_probes_in_objfile (objfile, "libc", "longjmp");
- if (!ret.empty ())
- {
- /* We are only interested in checking one element. */
- probe *p = ret[0];
+ if (!ret.empty ())
+ {
+ /* We are only interested in checking one element. */
+ probe *p = ret[0];
- if (!p->can_evaluate_arguments ())
- {
- /* We cannot use the probe interface here, because it does
- not know how to evaluate arguments. */
- ret.clear ();
- }
- }
- bp_objfile_data->longjmp_probes = ret;
- bp_objfile_data->longjmp_searched = 1;
- }
+ if (!p->can_evaluate_arguments ())
+ {
+ /* We cannot use the probe interface here,
+ because it does not know how to evaluate
+ arguments. */
+ ret.clear ();
+ }
+ }
+ bp_objfile_data->longjmp_probes = ret;
+ bp_objfile_data->longjmp_searched = 1;
+ }
- if (!bp_objfile_data->longjmp_probes.empty ())
- {
- for (probe *p : bp_objfile_data->longjmp_probes)
- {
- struct breakpoint *b;
-
- b = create_internal_breakpoint (gdbarch,
- p->get_relocated_address (objfile),
- bp_longjmp_master,
- &internal_breakpoint_ops);
- b->location = new_probe_location ("-probe-stap libc:longjmp");
- b->enable_state = bp_disabled;
- }
+ if (!bp_objfile_data->longjmp_probes.empty ())
+ {
+ for (probe *p : bp_objfile_data->longjmp_probes)
+ {
+ struct breakpoint *b;
+
+ b = create_internal_breakpoint (gdbarch,
+ p->get_relocated_address (objfile),
+ bp_longjmp_master,
+ &internal_breakpoint_ops);
+ b->location = new_probe_location ("-probe-stap libc:longjmp");
+ b->enable_state = bp_disabled;
+ }
- continue;
- }
+ continue;
+ }
- if (!gdbarch_get_longjmp_target_p (gdbarch))
- continue;
+ if (!gdbarch_get_longjmp_target_p (gdbarch))
+ continue;
- for (i = 0; i < NUM_LONGJMP_NAMES; i++)
- {
- struct breakpoint *b;
- const char *func_name;
- CORE_ADDR addr;
- struct explicit_location explicit_loc;
+ for (i = 0; i < NUM_LONGJMP_NAMES; i++)
+ {
+ struct breakpoint *b;
+ const char *func_name;
+ CORE_ADDR addr;
+ struct explicit_location explicit_loc;
- if (msym_not_found_p (bp_objfile_data->longjmp_msym[i].minsym))
- continue;
+ if (msym_not_found_p (bp_objfile_data->longjmp_msym[i].minsym))
+ continue;
- func_name = longjmp_names[i];
- if (bp_objfile_data->longjmp_msym[i].minsym == NULL)
- {
- struct bound_minimal_symbol m;
+ func_name = longjmp_names[i];
+ if (bp_objfile_data->longjmp_msym[i].minsym == NULL)
+ {
+ struct bound_minimal_symbol m;
- m = lookup_minimal_symbol_text (func_name, objfile);
- if (m.minsym == NULL)
- {
- /* Prevent future lookups in this objfile. */
- bp_objfile_data->longjmp_msym[i].minsym = &msym_not_found;
- continue;
- }
- bp_objfile_data->longjmp_msym[i] = m;
- }
+ m = lookup_minimal_symbol_text (func_name, objfile);
+ if (m.minsym == NULL)
+ {
+ /* Prevent future lookups in this objfile. */
+ bp_objfile_data->longjmp_msym[i].minsym = &msym_not_found;
+ continue;
+ }
+ bp_objfile_data->longjmp_msym[i] = m;
+ }
- addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->longjmp_msym[i]);
- b = create_internal_breakpoint (gdbarch, addr, bp_longjmp_master,
- &internal_breakpoint_ops);
- initialize_explicit_location (&explicit_loc);
- explicit_loc.function_name = ASTRDUP (func_name);
- b->location = new_explicit_location (&explicit_loc);
- b->enable_state = bp_disabled;
- }
- }
- }
+ addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->longjmp_msym[i]);
+ b = create_internal_breakpoint (gdbarch, addr, bp_longjmp_master,
+ &internal_breakpoint_ops);
+ initialize_explicit_location (&explicit_loc);
+ explicit_loc.function_name = ASTRDUP (func_name);
+ b->location = new_explicit_location (&explicit_loc);
+ b->enable_state = bp_disabled;
+ }
+ }
+ }
}
/* Create a master std::terminate breakpoint. */
static void
create_std_terminate_master_breakpoint (void)
{
- struct program_space *pspace;
const char *const func_name = "std::terminate()";
scoped_restore_current_program_space restore_pspace;
- ALL_PSPACES (pspace)
- {
- CORE_ADDR addr;
+ for (struct program_space *pspace : program_spaces)
+ {
+ CORE_ADDR addr;
- set_current_program_space (pspace);
+ set_current_program_space (pspace);
- for (objfile *objfile : current_program_space->objfiles ())
- {
- struct breakpoint *b;
- struct breakpoint_objfile_data *bp_objfile_data;
- struct explicit_location explicit_loc;
+ for (objfile *objfile : current_program_space->objfiles ())
+ {
+ struct breakpoint *b;
+ struct breakpoint_objfile_data *bp_objfile_data;
+ struct explicit_location explicit_loc;
- bp_objfile_data = get_breakpoint_objfile_data (objfile);
+ bp_objfile_data = get_breakpoint_objfile_data (objfile);
- if (msym_not_found_p (bp_objfile_data->terminate_msym.minsym))
- continue;
+ if (msym_not_found_p (bp_objfile_data->terminate_msym.minsym))
+ continue;
- if (bp_objfile_data->terminate_msym.minsym == NULL)
- {
- struct bound_minimal_symbol m;
+ if (bp_objfile_data->terminate_msym.minsym == NULL)
+ {
+ struct bound_minimal_symbol m;
- m = lookup_minimal_symbol (func_name, NULL, objfile);
- if (m.minsym == NULL || (MSYMBOL_TYPE (m.minsym) != mst_text
- && MSYMBOL_TYPE (m.minsym) != mst_file_text))
- {
- /* Prevent future lookups in this objfile. */
- bp_objfile_data->terminate_msym.minsym = &msym_not_found;
- continue;
- }
- bp_objfile_data->terminate_msym = m;
- }
+ m = lookup_minimal_symbol (func_name, NULL, objfile);
+ if (m.minsym == NULL || (MSYMBOL_TYPE (m.minsym) != mst_text
+ && MSYMBOL_TYPE (m.minsym) != mst_file_text))
+ {
+ /* Prevent future lookups in this objfile. */
+ bp_objfile_data->terminate_msym.minsym = &msym_not_found;
+ continue;
+ }
+ bp_objfile_data->terminate_msym = m;
+ }
- addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->terminate_msym);
- b = create_internal_breakpoint (objfile->arch (), addr,
- bp_std_terminate_master,
- &internal_breakpoint_ops);
- initialize_explicit_location (&explicit_loc);
- explicit_loc.function_name = ASTRDUP (func_name);
- b->location = new_explicit_location (&explicit_loc);
- b->enable_state = bp_disabled;
- }
- }
+ addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->terminate_msym);
+ b = create_internal_breakpoint (objfile->arch (), addr,
+ bp_std_terminate_master,
+ &internal_breakpoint_ops);
+ initialize_explicit_location (&explicit_loc);
+ explicit_loc.function_name = ASTRDUP (func_name);
+ b->location = new_explicit_location (&explicit_loc);
+ b->enable_state = bp_disabled;
+ }
+ }
}
/* Install a master breakpoint on the unwinder's debug hook. */
@@ -6088,7 +6086,7 @@ print_one_breakpoint_location (struct breakpoint *b,
there are several. Always display for MI. */
if (allflag
|| (!gdbarch_has_global_breakpoints (target_gdbarch ())
- && (number_of_program_spaces () > 1
+ && (program_spaces.size () > 1
|| number_of_inferiors () > 1)
/* LOC is for existing B, it cannot be in
moribund_locations and thus having NULL OWNER. */
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index feab51a8e2c..f84691a62e7 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -1739,13 +1739,14 @@ oper: OPERATOR NEW
c_print_type ($2, NULL, &buf, -1, 0,
&type_print_raw_options);
+ std::string name = std::move (buf.string ());
/* This also needs canonicalization. */
- std::string canon
- = cp_canonicalize_string (buf.c_str ());
- if (canon.empty ())
- canon = std::move (buf.string ());
- $$ = operator_stoken ((" " + canon).c_str ());
+ gdb::unique_xmalloc_ptr<char> canon
+ = cp_canonicalize_string (name.c_str ());
+ if (canon != nullptr)
+ name = canon.get ();
+ $$ = operator_stoken ((" " + name).c_str ());
}
;
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 50d0eaa2dde..aaf9e0dfe0a 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -84,14 +84,14 @@ print_name_maybe_canonical (const char *name,
const struct type_print_options *flags,
struct ui_file *stream)
{
- std::string s;
+ gdb::unique_xmalloc_ptr<char> s;
if (!flags->raw)
s = cp_canonicalize_string_full (name,
find_typedef_for_canonicalize,
(void *) flags);
- fputs_filtered (!s.empty () ? s.c_str () : name, stream);
+ fputs_filtered (s != nullptr ? s.get () : name, stream);
}
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 6601272e717..92a2e3b4904 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -274,12 +274,13 @@ inspect_type (struct demangle_parse_info *info,
Canonicalize the name again, and store it in the
current node (RET_COMP). */
- std::string canon = cp_canonicalize_string_no_typedefs (name);
+ gdb::unique_xmalloc_ptr<char> canon
+ = cp_canonicalize_string_no_typedefs (name);
- if (!canon.empty ())
+ if (canon != nullptr)
{
/* Copy the canonicalization into the obstack. */
- name = copy_string_to_obstack (&info->obstack, canon.c_str (), &len);
+ name = copy_string_to_obstack (&info->obstack, canon.get (), &len);
}
ret_comp->u.s_name.s = name;
@@ -506,16 +507,15 @@ replace_typedefs (struct demangle_parse_info *info,
/* Parse STRING and convert it to canonical form, resolving any
typedefs. If parsing fails, or if STRING is already canonical,
- return the empty string. Otherwise return the canonical form. If
+ return nullptr. Otherwise return the canonical form. If
FINDER is not NULL, then type components are passed to FINDER to be
looked up. DATA is passed verbatim to FINDER. */
-std::string
+gdb::unique_xmalloc_ptr<char>
cp_canonicalize_string_full (const char *string,
canonicalization_ftype *finder,
void *data)
{
- std::string ret;
unsigned int estimated_len;
std::unique_ptr<demangle_parse_info> info;
@@ -531,41 +531,42 @@ cp_canonicalize_string_full (const char *string,
estimated_len);
gdb_assert (us);
- ret = us.get ();
/* Finally, compare the original string with the computed
name, returning NULL if they are the same. */
- if (ret == string)
- return std::string ();
+ if (strcmp (us.get (), string) == 0)
+ return nullptr;
+
+ return us;
}
- return ret;
+ return nullptr;
}
/* Like cp_canonicalize_string_full, but always passes NULL for
FINDER. */
-std::string
+gdb::unique_xmalloc_ptr<char>
cp_canonicalize_string_no_typedefs (const char *string)
{
return cp_canonicalize_string_full (string, NULL, NULL);
}
/* Parse STRING and convert it to canonical form. If parsing fails,
- or if STRING is already canonical, return the empty string.
+ or if STRING is already canonical, return nullptr.
Otherwise return the canonical form. */
-std::string
+gdb::unique_xmalloc_ptr<char>
cp_canonicalize_string (const char *string)
{
std::unique_ptr<demangle_parse_info> info;
unsigned int estimated_len;
if (cp_already_canonical (string))
- return std::string ();
+ return nullptr;
info = cp_demangled_name_to_comp (string, NULL);
if (info == NULL)
- return std::string ();
+ return nullptr;
estimated_len = strlen (string) * 2;
gdb::unique_xmalloc_ptr<char> us (cp_comp_to_string (info->tree,
@@ -575,15 +576,13 @@ cp_canonicalize_string (const char *string)
{
warning (_("internal error: string \"%s\" failed to be canonicalized"),
string);
- return std::string ();
+ return nullptr;
}
- std::string ret (us.get ());
-
- if (ret == string)
- return std::string ();
+ if (strcmp (us.get (), string) == 0)
+ return nullptr;
- return ret;
+ return us;
}
/* Convert a mangled name to a demangle_component tree. *MEMORY is
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index 6f148342714..6ca898315bb 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -77,15 +77,16 @@ struct demangle_parse_info
/* Functions from cp-support.c. */
-extern std::string cp_canonicalize_string (const char *string);
+extern gdb::unique_xmalloc_ptr<char> cp_canonicalize_string
+ (const char *string);
-extern std::string cp_canonicalize_string_no_typedefs (const char *string);
+extern gdb::unique_xmalloc_ptr<char> cp_canonicalize_string_no_typedefs
+ (const char *string);
typedef const char *(canonicalization_ftype) (struct type *, void *);
-extern std::string cp_canonicalize_string_full (const char *string,
- canonicalization_ftype *finder,
- void *data);
+extern gdb::unique_xmalloc_ptr<char> cp_canonicalize_string_full
+ (const char *string, canonicalization_ftype *finder, void *data);
extern char *cp_class_name_from_physname (const char *physname);
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index c0155593e3b..1e1a5dc9b97 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -1434,12 +1434,13 @@ read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
if (psymtab_language == language_cplus)
{
std::string name (namestring, p - namestring);
- std::string new_name = cp_canonicalize_string (name.c_str ());
- if (!new_name.empty ())
+ gdb::unique_xmalloc_ptr<char> new_name
+ = cp_canonicalize_string (name.c_str ());
+ if (new_name != nullptr)
{
- sym_len = new_name.length ();
+ sym_len = strlen (new_name.get ());
sym_name = obstack_strdup (&objfile->objfile_obstack,
- new_name);
+ new_name.get ());
}
}
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 1813085d0d7..4c8a0717c78 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -5352,6 +5352,18 @@ dw2_debug_names_iterator::next ()
ull = read_unsigned_leb128 (abfd, m_addr, &bytes_read);
m_addr += bytes_read;
break;
+ case DW_FORM_ref4:
+ ull = read_4_bytes (abfd, m_addr);
+ m_addr += 4;
+ break;
+ case DW_FORM_ref8:
+ ull = read_8_bytes (abfd, m_addr);
+ m_addr += 8;
+ break;
+ case DW_FORM_ref_sig8:
+ ull = read_8_bytes (abfd, m_addr);
+ m_addr += 8;
+ break;
default:
complaint (_("Unsupported .debug_names form %s [in module %s]"),
dwarf_form_name (attr.form),
@@ -5384,6 +5396,12 @@ dw2_debug_names_iterator::next ()
}
per_cu = &dwarf2_per_objfile->get_tu (ull)->per_cu;
break;
+ case DW_IDX_die_offset:
+ /* In a per-CU index (as opposed to a per-module index), index
+ entries without CU attribute implicitly refer to the single CU. */
+ if (per_cu == NULL)
+ per_cu = dwarf2_per_objfile->get_cu (0);
+ break;
case DW_IDX_GNU_internal:
if (!m_map.augmentation_is_gdb)
break;
@@ -9218,7 +9236,7 @@ alloc_rust_variant (struct obstack *obstack, struct type *type,
prop.kind = PROP_VARIANT_PARTS;
prop.data.variant_parts = prop_value;
- add_dyn_prop (DYN_PROP_VARIANT_PARTS, prop, type);
+ type->add_dyn_prop (DYN_PROP_VARIANT_PARTS, prop);
}
/* Some versions of rustc emitted enums in an unusual way.
@@ -13102,7 +13120,16 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
for (child_die = die->child;
child_die != NULL && child_die->tag;
child_die = child_die->sibling)
- process_die (child_die, cu);
+ {
+ /* We might already be processing this DIE. This can happen
+ in an unusual circumstance -- where a subroutine A
+ appears lexically in another subroutine B, but A actually
+ inlines B. The recursion is broken here, rather than in
+ inherit_abstract_dies, because it seems better to simply
+ drop concrete children here. */
+ if (!child_die->in_process)
+ process_die (child_die, cu);
+ }
return;
case PC_BOUNDS_INVALID:
return;
@@ -14706,7 +14733,7 @@ add_variant_property (struct field_info *fip, struct type *type,
= ((gdb::array_view<variant_part> *)
obstack_copy (&objfile->objfile_obstack, &parts, sizeof (parts)));
- add_dyn_prop (DYN_PROP_VARIANT_PARTS, prop, type);
+ type->add_dyn_prop (DYN_PROP_VARIANT_PARTS, prop);
}
/* Create the vector of fields, and attach it to the type. */
@@ -15355,7 +15382,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
struct dynamic_prop prop;
if (attr_to_dynamic_prop (attr, die, cu, &prop,
cu->per_cu->addr_type ()))
- add_dyn_prop (DYN_PROP_BYTE_SIZE, prop, type);
+ type->add_dyn_prop (DYN_PROP_BYTE_SIZE, prop);
TYPE_LENGTH (type) = 0;
}
}
@@ -21736,13 +21763,11 @@ dwarf2_canonicalize_name (const char *name, struct dwarf2_cu *cu,
{
if (name && cu->language == language_cplus)
{
- std::string canon_name = cp_canonicalize_string (name);
+ gdb::unique_xmalloc_ptr<char> canon_name
+ = cp_canonicalize_string (name);
- if (!canon_name.empty ())
- {
- if (canon_name != name)
- name = objfile->intern (canon_name);
- }
+ if (canon_name != nullptr)
+ name = objfile->intern (canon_name.get ());
}
return name;
@@ -23605,7 +23630,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
{
struct type *prop_type = cu->per_cu->addr_sized_int_type (false);
if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type))
- add_dyn_prop (DYN_PROP_ALLOCATED, prop, type);
+ type->add_dyn_prop (DYN_PROP_ALLOCATED, prop);
}
else if (attr != NULL)
{
@@ -23620,7 +23645,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
{
struct type *prop_type = cu->per_cu->addr_sized_int_type (false);
if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type))
- add_dyn_prop (DYN_PROP_ASSOCIATED, prop, type);
+ type->add_dyn_prop (DYN_PROP_ASSOCIATED, prop);
}
else if (attr != NULL)
{
@@ -23633,7 +23658,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
attr = dwarf2_attr (die, DW_AT_data_location, cu);
if (attr_to_dynamic_prop (attr, die, cu, &prop,
cu->per_cu->addr_type ()))
- add_dyn_prop (DYN_PROP_DATA_LOCATION, prop, type);
+ type->add_dyn_prop (DYN_PROP_DATA_LOCATION, prop);
if (dwarf2_per_objfile->die_type_hash == NULL)
dwarf2_per_objfile->die_type_hash
diff --git a/gdb/exec.c b/gdb/exec.c
index c885709c94e..a2added5e22 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -177,10 +177,9 @@ exec_close (void)
void
exec_target::close ()
{
- struct program_space *ss;
scoped_restore_current_program_space restore_pspace;
- ALL_PSPACES (ss)
+ for (struct program_space *ss : program_spaces)
{
set_current_program_space (ss);
clear_section_table (current_target_sections);
diff --git a/gdb/extension.c b/gdb/extension.c
index 09aa7d91c31..e4b3b3cbd12 100644
--- a/gdb/extension.c
+++ b/gdb/extension.c
@@ -32,24 +32,7 @@
#include "cli/cli-script.h"
#include "python/python.h"
#include "guile/guile.h"
-
-/* Iterate over all external extension languages, regardless of whether the
- support has been compiled in or not.
- This does not include GDB's own scripting language. */
-
-#define ALL_EXTENSION_LANGUAGES(i, extlang) \
- for (/*int*/ i = 0, extlang = extension_languages[0]; \
- extlang != NULL; \
- extlang = extension_languages[++i])
-
-/* Iterate over all external extension languages that are supported.
- This does not include GDB's own scripting language. */
-
-#define ALL_ENABLED_EXTENSION_LANGUAGES(i, extlang) \
- for (/*int*/ i = 0, extlang = extension_languages[0]; \
- extlang != NULL; \
- extlang = extension_languages[++i]) \
- if (extlang->ops != NULL)
+#include <array>
static script_sourcer_func source_gdb_script;
static objfile_script_sourcer_func source_gdb_objfile_script;
@@ -99,12 +82,11 @@ const struct extension_language_defn extension_language_gdb =
pretty-printed value is the one that is used. This algorithm is employed
throughout. */
-static const struct extension_language_defn * const extension_languages[] =
+static const std::array<const extension_language_defn *, 2> extension_languages
{
/* To preserve existing behaviour, python should always appear first. */
&extension_language_python,
&extension_language_guile,
- NULL
};
/* Return a pointer to the struct extension_language_defn object of
@@ -115,15 +97,12 @@ static const struct extension_language_defn * const extension_languages[] =
const struct extension_language_defn *
get_ext_lang_defn (enum extension_language lang)
{
- int i;
- const struct extension_language_defn *extlang;
-
gdb_assert (lang != EXT_LANG_NONE);
if (lang == EXT_LANG_GDB)
return &extension_language_gdb;
- ALL_EXTENSION_LANGUAGES (i, extlang)
+ for (const struct extension_language_defn *extlang : extension_languages)
{
if (extlang->language == lang)
return extlang;
@@ -151,13 +130,10 @@ has_extension (const char *file, const char *extension)
const struct extension_language_defn *
get_ext_lang_of_file (const char *file)
{
- int i;
- const struct extension_language_defn *extlang;
-
if (has_extension (file, extension_language_gdb.suffix))
return &extension_language_gdb;
- ALL_EXTENSION_LANGUAGES (i, extlang)
+ for (const struct extension_language_defn *extlang : extension_languages)
{
if (has_extension (file, extlang->suffix))
return extlang;
@@ -331,12 +307,10 @@ ext_lang_auto_load_enabled (const struct extension_language_defn *extlang)
void
finish_ext_lang_initialization (void)
{
- int i;
- const struct extension_language_defn *extlang;
-
- ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
+ for (const struct extension_language_defn *extlang : extension_languages)
{
- if (extlang->ops->finish_initialization != NULL)
+ if (extlang->ops != nullptr
+ && extlang->ops->finish_initialization != NULL)
extlang->ops->finish_initialization (extlang);
}
}
@@ -355,10 +329,7 @@ finish_ext_lang_initialization (void)
void
eval_ext_lang_from_control_command (struct command_line *cmd)
{
- int i;
- const struct extension_language_defn *extlang;
-
- ALL_EXTENSION_LANGUAGES (i, extlang)
+ for (const struct extension_language_defn *extlang : extension_languages)
{
if (extlang->cli_control_type == cmd->control_type)
{
@@ -385,16 +356,14 @@ eval_ext_lang_from_control_command (struct command_line *cmd)
void
auto_load_ext_lang_scripts_for_objfile (struct objfile *objfile)
{
- int i;
- const struct extension_language_defn *extlang;
-
- extlang = &extension_language_gdb;
- if (ext_lang_auto_load_enabled (extlang))
- auto_load_objfile_script (objfile, extlang);
+ const struct extension_language_defn *gdb = &extension_language_gdb;
+ if (ext_lang_auto_load_enabled (gdb))
+ auto_load_objfile_script (objfile, gdb);
- ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
+ for (const struct extension_language_defn *extlang : extension_languages)
{
- if (ext_lang_auto_load_enabled (extlang))
+ if (extlang->ops != nullptr
+ && ext_lang_auto_load_enabled (extlang))
auto_load_objfile_script (objfile, extlang);
}
}
@@ -410,12 +379,10 @@ auto_load_ext_lang_scripts_for_objfile (struct objfile *objfile)
ext_lang_type_printers::ext_lang_type_printers ()
{
- int i;
- const struct extension_language_defn *extlang;
-
- ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
+ for (const struct extension_language_defn *extlang : extension_languages)
{
- if (extlang->ops->start_type_printers != NULL)
+ if (extlang->ops != nullptr
+ && extlang->ops->start_type_printers != NULL)
extlang->ops->start_type_printers (extlang, this);
}
}
@@ -429,15 +396,13 @@ char *
apply_ext_lang_type_printers (struct ext_lang_type_printers *printers,
struct type *type)
{
- int i;
- const struct extension_language_defn *extlang;
-
- ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
+ for (const struct extension_language_defn *extlang : extension_languages)
{
char *result = NULL;
enum ext_lang_rc rc;
- if (extlang->ops->apply_type_printers == NULL)
+ if (extlang->ops == nullptr
+ || extlang->ops->apply_type_printers == NULL)
continue;
rc = extlang->ops->apply_type_printers (extlang, printers, type,
&result);
@@ -460,12 +425,10 @@ apply_ext_lang_type_printers (struct ext_lang_type_printers *printers,
ext_lang_type_printers::~ext_lang_type_printers ()
{
- int i;
- const struct extension_language_defn *extlang;
-
- ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
+ for (const struct extension_language_defn *extlang : extension_languages)
{
- if (extlang->ops->free_type_printers != NULL)
+ if (extlang->ops != nullptr
+ && extlang->ops->free_type_printers != NULL)
extlang->ops->free_type_printers (extlang, this);
}
}
@@ -490,14 +453,12 @@ apply_ext_lang_val_pretty_printer (struct value *val,
const struct value_print_options *options,
const struct language_defn *language)
{
- int i;
- const struct extension_language_defn *extlang;
-
- ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
+ for (const struct extension_language_defn *extlang : extension_languages)
{
enum ext_lang_rc rc;
- if (extlang->ops->apply_val_pretty_printer == NULL)
+ if (extlang->ops == nullptr
+ || extlang->ops->apply_val_pretty_printer == NULL)
continue;
rc = extlang->ops->apply_val_pretty_printer (extlang, val, stream,
recurse, options, language);
@@ -544,14 +505,12 @@ apply_ext_lang_frame_filter (struct frame_info *frame,
struct ui_out *out,
int frame_low, int frame_high)
{
- int i;
- const struct extension_language_defn *extlang;
-
- ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
+ for (const struct extension_language_defn *extlang : extension_languages)
{
enum ext_lang_bt_status status;
- if (extlang->ops->apply_frame_filter == NULL)
+ if (extlang->ops == nullptr
+ || extlang->ops->apply_frame_filter == NULL)
continue;
status = extlang->ops->apply_frame_filter (extlang, frame, flags,
args_type, out,
@@ -577,12 +536,10 @@ apply_ext_lang_frame_filter (struct frame_info *frame,
void
preserve_ext_lang_values (struct objfile *objfile, htab_t copied_types)
{
- int i;
- const struct extension_language_defn *extlang;
-
- ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
+ for (const struct extension_language_defn *extlang : extension_languages)
{
- if (extlang->ops->preserve_values != NULL)
+ if (extlang->ops != nullptr
+ && extlang->ops->preserve_values != NULL)
extlang->ops->preserve_values (extlang, objfile, copied_types);
}
}
@@ -600,12 +557,10 @@ const struct extension_language_defn *
get_breakpoint_cond_ext_lang (struct breakpoint *b,
enum extension_language skip_lang)
{
- int i;
- const struct extension_language_defn *extlang;
-
- ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
+ for (const struct extension_language_defn *extlang : extension_languages)
{
- if (extlang->language != skip_lang
+ if (extlang->ops != nullptr
+ && extlang->language != skip_lang
&& extlang->ops->breakpoint_has_cond != NULL
&& extlang->ops->breakpoint_has_cond (extlang, b))
return extlang;
@@ -620,18 +575,17 @@ get_breakpoint_cond_ext_lang (struct breakpoint *b,
int
breakpoint_ext_lang_cond_says_stop (struct breakpoint *b)
{
- int i;
- const struct extension_language_defn *extlang;
enum ext_lang_bp_stop stop = EXT_LANG_BP_STOP_UNSET;
- ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
+ for (const struct extension_language_defn *extlang : extension_languages)
{
/* There is a rule that a breakpoint can have at most one of any of a
CLI or extension language condition. However, Python hacks in "finish
breakpoints" on top of the "stop" check, so we have to call this for
every language, even if we could first determine whether a "stop"
method exists. */
- if (extlang->ops->breakpoint_cond_says_stop != NULL)
+ if (extlang->ops != nullptr
+ && extlang->ops->breakpoint_cond_says_stop != NULL)
{
enum ext_lang_bp_stop this_stop
= extlang->ops->breakpoint_cond_says_stop (extlang, b);
@@ -813,12 +767,12 @@ set_quit_flag (void)
int
check_quit_flag (void)
{
- int i, result = 0;
- const struct extension_language_defn *extlang;
+ int result = 0;
- ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
+ for (const struct extension_language_defn *extlang : extension_languages)
{
- if (extlang->ops->check_quit_flag != NULL)
+ if (extlang->ops != nullptr
+ && extlang->ops->check_quit_flag != NULL)
if (extlang->ops->check_quit_flag (extlang) != 0)
result = 1;
}
@@ -843,16 +797,14 @@ void
get_matching_xmethod_workers (struct type *type, const char *method_name,
std::vector<xmethod_worker_up> *workers)
{
- int i;
- const struct extension_language_defn *extlang;
-
- ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
+ for (const struct extension_language_defn *extlang : extension_languages)
{
enum ext_lang_rc rc;
/* If an extension language does not support xmethods, ignore
it. */
- if (extlang->ops->get_matching_xmethod_workers == NULL)
+ if (extlang->ops == nullptr
+ || extlang->ops->get_matching_xmethod_workers == NULL)
continue;
rc = extlang->ops->get_matching_xmethod_workers (extlang,
@@ -901,13 +853,12 @@ xmethod_worker::get_result_type (value *object, gdb::array_view<value *> args)
gdb::optional<std::string>
ext_lang_colorize (const std::string &filename, const std::string &contents)
{
- int i;
- const struct extension_language_defn *extlang;
gdb::optional<std::string> result;
- ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
+ for (const struct extension_language_defn *extlang : extension_languages)
{
- if (extlang->ops->colorize == nullptr)
+ if (extlang->ops == nullptr
+ || extlang->ops->colorize == nullptr)
continue;
result = extlang->ops->colorize (filename, contents);
if (result.has_value ())
@@ -925,14 +876,12 @@ ext_lang_colorize (const std::string &filename, const std::string &contents)
static void
ext_lang_before_prompt (const char *current_gdb_prompt)
{
- int i;
- const struct extension_language_defn *extlang;
-
- ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
+ for (const struct extension_language_defn *extlang : extension_languages)
{
enum ext_lang_rc rc;
- if (extlang->ops->before_prompt == NULL)
+ if (extlang->ops == nullptr
+ || extlang->ops->before_prompt == NULL)
continue;
rc = extlang->ops->before_prompt (extlang, current_gdb_prompt);
switch (rc)
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 9a6a6dd74b1..3f829241f05 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1188,7 +1188,7 @@ update_static_array_size (struct type *type)
struct type *range_type = TYPE_INDEX_TYPE (type);
- if (get_dyn_prop (DYN_PROP_BYTE_STRIDE, type) == nullptr
+ if (type->dyn_prop (DYN_PROP_BYTE_STRIDE) == nullptr
&& has_static_range (TYPE_RANGE_DATA (range_type))
&& (!type_not_associated (type)
&& !type_not_allocated (type)))
@@ -1286,7 +1286,7 @@ create_array_type_with_stride (struct type *result_type,
(struct field *) TYPE_ZALLOC (result_type, sizeof (struct field));
TYPE_INDEX_TYPE (result_type) = range_type;
if (byte_stride_prop != NULL)
- add_dyn_prop (DYN_PROP_BYTE_STRIDE, *byte_stride_prop, result_type);
+ result_type->add_dyn_prop (DYN_PROP_BYTE_STRIDE, *byte_stride_prop);
else if (bit_stride > 0)
TYPE_FIELD_BITSIZE (result_type, 0) = bit_stride;
@@ -1957,7 +1957,7 @@ stub_noname_complaint (void)
static int
array_type_has_dynamic_stride (struct type *type)
{
- struct dynamic_prop *prop = get_dyn_prop (DYN_PROP_BYTE_STRIDE, type);
+ struct dynamic_prop *prop = type->dyn_prop (DYN_PROP_BYTE_STRIDE);
return (prop != NULL && prop->kind != PROP_CONST);
}
@@ -1990,7 +1990,7 @@ is_dynamic_type_internal (struct type *type, int top_level)
if (TYPE_ALLOCATED_PROP (type))
return 1;
- struct dynamic_prop *prop = get_dyn_prop (DYN_PROP_VARIANT_PARTS, type);
+ struct dynamic_prop *prop = type->dyn_prop (DYN_PROP_VARIANT_PARTS);
if (prop != nullptr && prop->kind != PROP_TYPE)
return 1;
@@ -2199,12 +2199,12 @@ resolve_dynamic_array_or_string (struct type *type,
else
elt_type = TYPE_TARGET_TYPE (type);
- prop = get_dyn_prop (DYN_PROP_BYTE_STRIDE, type);
+ prop = type->dyn_prop (DYN_PROP_BYTE_STRIDE);
if (prop != NULL)
{
if (dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
{
- remove_dyn_prop (DYN_PROP_BYTE_STRIDE, type);
+ type->remove_dyn_prop (DYN_PROP_BYTE_STRIDE);
bit_stride = (unsigned int) (value * 8);
}
else
@@ -2436,8 +2436,7 @@ resolve_dynamic_struct (struct type *type,
resolved_type = copy_type (type);
- struct dynamic_prop *variant_prop = get_dyn_prop (DYN_PROP_VARIANT_PARTS,
- resolved_type);
+ dynamic_prop *variant_prop = resolved_type->dyn_prop (DYN_PROP_VARIANT_PARTS);
if (variant_prop != nullptr && variant_prop->kind == PROP_VARIANT_PARTS)
{
compute_variant_fields (type, resolved_type, addr_stack,
@@ -2622,7 +2621,7 @@ resolve_dynamic_type_internal (struct type *type,
if (type_length.has_value ())
{
TYPE_LENGTH (resolved_type) = *type_length;
- remove_dyn_prop (DYN_PROP_BYTE_SIZE, resolved_type);
+ resolved_type->remove_dyn_prop (DYN_PROP_BYTE_SIZE);
}
/* Resolve data_location attribute. */
@@ -2652,10 +2651,10 @@ resolve_dynamic_type (struct type *type,
/* See gdbtypes.h */
-struct dynamic_prop *
-get_dyn_prop (enum dynamic_prop_node_kind prop_kind, const struct type *type)
+dynamic_prop *
+type::dyn_prop (dynamic_prop_node_kind prop_kind) const
{
- struct dynamic_prop_list *node = TYPE_DYN_PROP_LIST (type);
+ dynamic_prop_list *node = this->main_type->dyn_prop_list;
while (node != NULL)
{
@@ -2669,43 +2668,41 @@ get_dyn_prop (enum dynamic_prop_node_kind prop_kind, const struct type *type)
/* See gdbtypes.h */
void
-add_dyn_prop (enum dynamic_prop_node_kind prop_kind, struct dynamic_prop prop,
- struct type *type)
+type::add_dyn_prop (dynamic_prop_node_kind prop_kind, dynamic_prop prop)
{
struct dynamic_prop_list *temp;
- gdb_assert (TYPE_OBJFILE_OWNED (type));
+ gdb_assert (TYPE_OBJFILE_OWNED (this));
- temp = XOBNEW (&TYPE_OBJFILE (type)->objfile_obstack,
+ temp = XOBNEW (&TYPE_OBJFILE (this)->objfile_obstack,
struct dynamic_prop_list);
temp->prop_kind = prop_kind;
temp->prop = prop;
- temp->next = TYPE_DYN_PROP_LIST (type);
+ temp->next = this->main_type->dyn_prop_list;
- TYPE_DYN_PROP_LIST (type) = temp;
+ this->main_type->dyn_prop_list = temp;
}
-/* Remove dynamic property from TYPE in case it exists. */
+/* See gdbtypes.h. */
void
-remove_dyn_prop (enum dynamic_prop_node_kind prop_kind,
- struct type *type)
+type::remove_dyn_prop (dynamic_prop_node_kind kind)
{
struct dynamic_prop_list *prev_node, *curr_node;
- curr_node = TYPE_DYN_PROP_LIST (type);
+ curr_node = this->main_type->dyn_prop_list;
prev_node = NULL;
while (NULL != curr_node)
{
- if (curr_node->prop_kind == prop_kind)
+ if (curr_node->prop_kind == kind)
{
/* Update the linked list but don't free anything.
The property was allocated on objstack and it is not known
if we are on top of it. Nevertheless, everything is released
when the complete objstack is freed. */
if (NULL == prev_node)
- TYPE_DYN_PROP_LIST (type) = curr_node->next;
+ this->main_type->dyn_prop_list = curr_node->next;
else
prev_node->next = curr_node->next;
@@ -5353,10 +5350,10 @@ copy_type_recursive (struct objfile *objfile,
*TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type);
}
- if (TYPE_DYN_PROP_LIST (type) != NULL)
- TYPE_DYN_PROP_LIST (new_type)
+ if (type->main_type->dyn_prop_list != NULL)
+ new_type->main_type->dyn_prop_list
= copy_dynamic_prop_list (&objfile->objfile_obstack,
- TYPE_DYN_PROP_LIST (type));
+ type->main_type->dyn_prop_list);
/* Copy pointers to other types. */
@@ -5421,10 +5418,10 @@ copy_type (const struct type *type)
TYPE_LENGTH (new_type) = TYPE_LENGTH (type);
memcpy (TYPE_MAIN_TYPE (new_type), TYPE_MAIN_TYPE (type),
sizeof (struct main_type));
- if (TYPE_DYN_PROP_LIST (type) != NULL)
- TYPE_DYN_PROP_LIST (new_type)
+ if (type->main_type->dyn_prop_list != NULL)
+ new_type->main_type->dyn_prop_list
= copy_dynamic_prop_list (&TYPE_OBJFILE (type) -> objfile_obstack,
- TYPE_DYN_PROP_LIST (type));
+ type->main_type->dyn_prop_list);
return new_type;
}
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index d9bfa56cc45..7514bd27f7c 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -339,15 +339,15 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags);
/* * True if this type is allocatable. */
#define TYPE_IS_ALLOCATABLE(t) \
- (get_dyn_prop (DYN_PROP_ALLOCATED, t) != NULL)
+ ((t)->dyn_prop (DYN_PROP_ALLOCATED) != NULL)
/* * True if this type has variant parts. */
#define TYPE_HAS_VARIANT_PARTS(t) \
- (get_dyn_prop (DYN_PROP_VARIANT_PARTS, t) != nullptr)
+ ((t)->dyn_prop (DYN_PROP_VARIANT_PARTS) != nullptr)
/* * True if this type has a dynamic length. */
#define TYPE_HAS_DYNAMIC_LENGTH(t) \
- (get_dyn_prop (DYN_PROP_BYTE_SIZE, t) != nullptr)
+ ((t)->dyn_prop (DYN_PROP_BYTE_SIZE) != nullptr)
/* * Instruction-space delimited type. This is for Harvard architectures
which have separate instruction and data address spaces (and perhaps
@@ -874,6 +874,19 @@ struct main_type
struct type
{
+ /* * Return the dynamic property of the requested KIND from this type's
+ list of dynamic properties. */
+ dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const;
+
+ /* * Given a dynamic property PROP of a given KIND, add this dynamic
+ property to this type.
+
+ This function assumes that this type is objfile-owned. */
+ void add_dyn_prop (dynamic_prop_node_kind kind, dynamic_prop prop);
+
+ /* * Remove dynamic property of kind KIND from this type, if it exists. */
+ void remove_dyn_prop (dynamic_prop_node_kind kind);
+
/* * Type that is a pointer to this type.
NULL if no such pointer-to type is known yet.
The debugger may add the address of such a type
@@ -1433,7 +1446,7 @@ extern bool set_type_align (struct type *, ULONGEST);
/* Property accessors for the type data location. */
#define TYPE_DATA_LOCATION(thistype) \
- get_dyn_prop (DYN_PROP_DATA_LOCATION, thistype)
+ ((thistype)->dyn_prop (DYN_PROP_DATA_LOCATION))
#define TYPE_DATA_LOCATION_BATON(thistype) \
TYPE_DATA_LOCATION (thistype)->data.baton
#define TYPE_DATA_LOCATION_ADDR(thistype) \
@@ -1441,17 +1454,15 @@ extern bool set_type_align (struct type *, ULONGEST);
#define TYPE_DATA_LOCATION_KIND(thistype) \
TYPE_DATA_LOCATION (thistype)->kind
#define TYPE_DYNAMIC_LENGTH(thistype) \
- get_dyn_prop (DYN_PROP_BYTE_SIZE, thistype)
+ ((thistype)->dyn_prop (DYN_PROP_BYTE_SIZE))
/* Property accessors for the type allocated/associated. */
#define TYPE_ALLOCATED_PROP(thistype) \
- get_dyn_prop (DYN_PROP_ALLOCATED, thistype)
+ ((thistype)->dyn_prop (DYN_PROP_ALLOCATED))
#define TYPE_ASSOCIATED_PROP(thistype) \
- get_dyn_prop (DYN_PROP_ASSOCIATED, thistype)
+ ((thistype)->dyn_prop (DYN_PROP_ASSOCIATED))
/* Attribute accessors for dynamic properties. */
-#define TYPE_DYN_PROP_LIST(thistype) \
- TYPE_MAIN_TYPE(thistype)->dyn_prop_list
#define TYPE_DYN_PROP_BATON(dynprop) \
dynprop->data.baton
#define TYPE_DYN_PROP_ADDR(dynprop) \
@@ -2093,22 +2104,6 @@ extern struct type *resolve_dynamic_type
/* * Predicate if the type has dynamic values, which are not resolved yet. */
extern int is_dynamic_type (struct type *type);
-/* * Return the dynamic property of the requested KIND from TYPE's
- list of dynamic properties. */
-extern struct dynamic_prop *get_dyn_prop
- (enum dynamic_prop_node_kind kind, const struct type *type);
-
-/* * Given a dynamic property PROP of a given KIND, add this dynamic
- property to the given TYPE.
-
- This function assumes that TYPE is objfile-owned. */
-extern void add_dyn_prop
- (enum dynamic_prop_node_kind kind, struct dynamic_prop prop,
- struct type *type);
-
-extern void remove_dyn_prop (enum dynamic_prop_node_kind prop_kind,
- struct type *type);
-
extern struct type *check_typedef (struct type *);
extern void check_stub_method_group (struct type *, int);
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index 70558437f9c..83deed59657 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -1090,7 +1090,8 @@ gnuv3_get_typeid (struct value *value)
struct type *type;
struct gdbarch *gdbarch;
struct value *result;
- std::string type_name, canonical;
+ std::string type_name;
+ gdb::unique_xmalloc_ptr<char> canonical;
/* We have to handle values a bit trickily here, to allow this code
to work properly with non_lvalue values that are really just
@@ -1118,8 +1119,9 @@ gnuv3_get_typeid (struct value *value)
uses. E.g., GDB tends to use "const char *" as a type name, but
the demangler uses "char const *". */
canonical = cp_canonicalize_string (type_name.c_str ());
- if (!canonical.empty ())
- type_name = canonical;
+ const char *name = (canonical == nullptr
+ ? type_name.c_str ()
+ : canonical.get ());
typeinfo_type = gnuv3_get_typeid_type (gdbarch);
@@ -1135,19 +1137,19 @@ gnuv3_get_typeid (struct value *value)
vtable = gnuv3_get_vtable (gdbarch, type, address);
if (vtable == NULL)
error (_("cannot find typeinfo for object of type '%s'"),
- type_name.c_str ());
+ name);
typeinfo_value = value_field (vtable, vtable_field_type_info);
result = value_ind (value_cast (make_pointer_type (typeinfo_type, NULL),
typeinfo_value));
}
else
{
- std::string sym_name = std::string ("typeinfo for ") + type_name;
+ std::string sym_name = std::string ("typeinfo for ") + name;
bound_minimal_symbol minsym
= lookup_minimal_symbol (sym_name.c_str (), NULL, NULL);
if (minsym.minsym == NULL)
- error (_("could not find typeinfo symbol for '%s'"), type_name.c_str ());
+ error (_("could not find typeinfo symbol for '%s'"), name);
result = value_at_lazy (typeinfo_type, BMSYMBOL_VALUE_ADDRESS (minsym));
}
diff --git a/gdb/guile/scm-progspace.c b/gdb/guile/scm-progspace.c
index 5a39780dcbc..49c3e36227f 100644
--- a/gdb/guile/scm-progspace.c
+++ b/gdb/guile/scm-progspace.c
@@ -353,17 +353,16 @@ gdbscm_current_progspace (void)
static SCM
gdbscm_progspaces (void)
{
- struct program_space *ps;
SCM result;
result = SCM_EOL;
- ALL_PSPACES (ps)
- {
- SCM item = psscm_scm_from_pspace (ps);
+ for (struct program_space *ps : program_spaces)
+ {
+ SCM item = psscm_scm_from_pspace (ps);
- result = scm_cons (item, result);
- }
+ result = scm_cons (item, result);
+ }
return scm_reverse_x (result, SCM_EOL);
}
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 0e1ba6986b1..3c6b201a9fc 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -681,6 +681,8 @@ follow_fork ()
struct breakpoint *exception_resume_breakpoint = NULL;
CORE_ADDR step_range_start = 0;
CORE_ADDR step_range_end = 0;
+ int current_line = 0;
+ symtab *current_symtab = NULL;
struct frame_id step_frame_id = { 0 };
struct thread_fsm *thread_fsm = NULL;
@@ -734,6 +736,8 @@ follow_fork ()
(tp->control.step_resume_breakpoint);
step_range_start = tp->control.step_range_start;
step_range_end = tp->control.step_range_end;
+ current_line = tp->current_line;
+ current_symtab = tp->current_symtab;
step_frame_id = tp->control.step_frame_id;
exception_resume_breakpoint
= clone_momentary_breakpoint (tp->control.exception_resume_breakpoint);
@@ -794,6 +798,8 @@ follow_fork ()
= step_resume_breakpoint;
tp->control.step_range_start = step_range_start;
tp->control.step_range_end = step_range_end;
+ tp->current_line = current_line;
+ tp->current_symtab = current_symtab;
tp->control.step_frame_id = step_frame_id;
tp->control.exception_resume_breakpoint
= exception_resume_breakpoint;
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 6e4fe6cb771..1f289873f5e 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1133,58 +1133,56 @@ iterate_over_all_matching_symtabs
struct program_space *search_pspace, bool include_inline,
gdb::function_view<symbol_found_callback_ftype> callback)
{
- struct program_space *pspace;
-
- ALL_PSPACES (pspace)
- {
- if (search_pspace != NULL && search_pspace != pspace)
- continue;
- if (pspace->executing_startup)
- continue;
+ for (struct program_space *pspace : program_spaces)
+ {
+ if (search_pspace != NULL && search_pspace != pspace)
+ continue;
+ if (pspace->executing_startup)
+ continue;
- set_current_program_space (pspace);
+ set_current_program_space (pspace);
- for (objfile *objfile : current_program_space->objfiles ())
- {
- if (objfile->sf)
- objfile->sf->qf->expand_symtabs_matching (objfile,
- NULL,
- &lookup_name,
- NULL, NULL,
- search_domain);
-
- for (compunit_symtab *cu : objfile->compunits ())
- {
- struct symtab *symtab = COMPUNIT_FILETABS (cu);
+ for (objfile *objfile : current_program_space->objfiles ())
+ {
+ if (objfile->sf)
+ objfile->sf->qf->expand_symtabs_matching (objfile,
+ NULL,
+ &lookup_name,
+ NULL, NULL,
+ search_domain);
+
+ for (compunit_symtab *cu : objfile->compunits ())
+ {
+ struct symtab *symtab = COMPUNIT_FILETABS (cu);
- iterate_over_file_blocks (symtab, lookup_name, name_domain,
- callback);
+ iterate_over_file_blocks (symtab, lookup_name, name_domain,
+ callback);
- if (include_inline)
- {
- const struct block *block;
- int i;
+ if (include_inline)
+ {
+ const struct block *block;
+ int i;
- for (i = FIRST_LOCAL_BLOCK;
- i < BLOCKVECTOR_NBLOCKS (SYMTAB_BLOCKVECTOR (symtab));
- i++)
- {
- block = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symtab), i);
- state->language->la_iterate_over_symbols
- (block, lookup_name, name_domain,
- [&] (block_symbol *bsym)
- {
- /* Restrict calls to CALLBACK to symbols
- representing inline symbols only. */
- if (SYMBOL_INLINED (bsym->symbol))
- return callback (bsym);
- return true;
- });
- }
- }
- }
- }
- }
+ for (i = FIRST_LOCAL_BLOCK;
+ i < BLOCKVECTOR_NBLOCKS (SYMTAB_BLOCKVECTOR (symtab));
+ i++)
+ {
+ block = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symtab), i);
+ state->language->la_iterate_over_symbols
+ (block, lookup_name, name_domain,
+ [&] (block_symbol *bsym)
+ {
+ /* Restrict calls to CALLBACK to symbols
+ representing inline symbols only. */
+ if (SYMBOL_INLINED (bsym->symbol))
+ return callback (bsym);
+ return true;
+ });
+ }
+ }
+ }
+ }
+ }
}
/* Returns the block to be used for symbol searches from
@@ -3786,9 +3784,7 @@ collect_symtabs_from_filename (const char *file,
/* Find that file's data. */
if (search_pspace == NULL)
{
- struct program_space *pspace;
-
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
{
if (pspace->executing_startup)
continue;
@@ -3898,9 +3894,10 @@ find_linespec_symbols (struct linespec_state *state,
std::vector <block_symbol> *symbols,
std::vector<bound_minimal_symbol> *minsyms)
{
- std::string canon = cp_canonicalize_string_no_typedefs (lookup_name);
- if (!canon.empty ())
- lookup_name = canon.c_str ();
+ gdb::unique_xmalloc_ptr<char> canon
+ = cp_canonicalize_string_no_typedefs (lookup_name);
+ if (canon != nullptr)
+ lookup_name = canon.get ();
/* It's important to not call expand_symtabs_matching unnecessarily
as it can really slow things down (by unnecessarily expanding
@@ -4334,29 +4331,27 @@ search_minsyms_for_name (struct collect_info *info,
if (symtab == NULL)
{
- struct program_space *pspace;
-
- ALL_PSPACES (pspace)
- {
- if (search_pspace != NULL && search_pspace != pspace)
- continue;
- if (pspace->executing_startup)
- continue;
+ for (struct program_space *pspace : program_spaces)
+ {
+ if (search_pspace != NULL && search_pspace != pspace)
+ continue;
+ if (pspace->executing_startup)
+ continue;
- set_current_program_space (pspace);
+ set_current_program_space (pspace);
- for (objfile *objfile : current_program_space->objfiles ())
- {
- iterate_over_minimal_symbols (objfile, name,
- [&] (struct minimal_symbol *msym)
- {
- add_minsym (msym, objfile, nullptr,
- info->state->list_mode,
- &minsyms);
- return false;
- });
- }
- }
+ for (objfile *objfile : current_program_space->objfiles ())
+ {
+ iterate_over_minimal_symbols (objfile, name,
+ [&] (struct minimal_symbol *msym)
+ {
+ add_minsym (msym, objfile, nullptr,
+ info->state->list_mode,
+ &minsyms);
+ return false;
+ });
+ }
+ }
}
else
{
diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c
index b5835a52bf8..3b0261c6c9f 100644
--- a/gdb/mi/mi-cmd-file.c
+++ b/gdb/mi/mi-cmd-file.c
@@ -121,7 +121,6 @@ mi_cmd_file_list_shared_libraries (const char *command, char **argv, int argc)
{
struct ui_out *uiout = current_uiout;
const char *pattern;
- struct so_list *so = NULL;
switch (argc)
{
@@ -148,7 +147,7 @@ mi_cmd_file_list_shared_libraries (const char *command, char **argv, int argc)
/* Print the table header. */
ui_out_emit_list list_emitter (uiout, "shared-libraries");
- ALL_SO_LIBS (so)
+ for (struct so_list *so : current_program_space->solibs ())
{
if (so->so_name[0] == '\0')
continue;
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index de6d3d43bb4..00320d20898 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -116,13 +116,27 @@ show_print_symbol_filename (struct ui_file *file, int from_tty,
static int current_display_number;
+/* Last allocated display number. */
+
+static int display_number;
+
struct display
{
- /* Chain link to next auto-display item. */
- struct display *next;
+ display (const char *exp_string_, expression_up &&exp_,
+ const struct format_data &format_, struct program_space *pspace_,
+ const struct block *block_)
+ : exp_string (exp_string_),
+ exp (std::move (exp_)),
+ number (++display_number),
+ format (format_),
+ pspace (pspace_),
+ block (block_),
+ enabled_p (true)
+ {
+ }
/* The expression as the user typed it. */
- char *exp_string;
+ std::string exp_string;
/* Expression to be evaluated and displayed. */
expression_up exp;
@@ -140,27 +154,13 @@ struct display
const struct block *block;
/* Status of this display (enabled or disabled). */
- int enabled_p;
+ bool enabled_p;
};
-/* Chain of expressions whose values should be displayed
- automatically each time the program stops. */
-
-static struct display *display_chain;
+/* Expressions whose values should be displayed automatically each
+ time the program stops. */
-static int display_number;
-
-/* Walk the following statement or block through all displays.
- ALL_DISPLAYS_SAFE does so even if the statement deletes the current
- display. */
-
-#define ALL_DISPLAYS(B) \
- for (B = display_chain; B; B = B->next)
-
-#define ALL_DISPLAYS_SAFE(B,TMP) \
- for (B = display_chain; \
- B ? (TMP = B->next, 1): 0; \
- B = TMP)
+static std::vector<std::unique_ptr<struct display>> all_displays;
/* Prototypes for local functions. */
@@ -1763,27 +1763,9 @@ display_command (const char *arg, int from_tty)
innermost_block_tracker tracker;
expression_up expr = parse_expression (exp, &tracker);
- newobj = new display ();
-
- newobj->exp_string = xstrdup (exp);
- newobj->exp = std::move (expr);
- newobj->block = tracker.block ();
- newobj->pspace = current_program_space;
- newobj->number = ++display_number;
- newobj->format = fmt;
- newobj->enabled_p = 1;
- newobj->next = NULL;
-
- if (display_chain == NULL)
- display_chain = newobj;
- else
- {
- struct display *last;
-
- for (last = display_chain; last->next != NULL; last = last->next)
- ;
- last->next = newobj;
- }
+ newobj = new display (exp, std::move (expr), fmt,
+ current_program_space, tracker.block ());
+ all_displays.emplace_back (newobj);
if (from_tty)
do_one_display (newobj);
@@ -1791,26 +1773,13 @@ display_command (const char *arg, int from_tty)
dont_repeat ();
}
-static void
-free_display (struct display *d)
-{
- xfree (d->exp_string);
- delete d;
-}
-
/* Clear out the display_chain. Done when new symtabs are loaded,
since this invalidates the types stored in many expressions. */
void
-clear_displays (void)
+clear_displays ()
{
- struct display *d;
-
- while ((d = display_chain) != NULL)
- {
- display_chain = d->next;
- free_display (d);
- }
+ all_displays.clear ();
}
/* Delete the auto-display DISPLAY. */
@@ -1818,21 +1787,16 @@ clear_displays (void)
static void
delete_display (struct display *display)
{
- struct display *d;
-
gdb_assert (display != NULL);
- if (display_chain == display)
- display_chain = display->next;
-
- ALL_DISPLAYS (d)
- if (d->next == display)
- {
- d->next = display->next;
- break;
- }
-
- free_display (display);
+ auto iter = std::find_if (all_displays.begin (),
+ all_displays.end (),
+ [=] (const std::unique_ptr<struct display> &item)
+ {
+ return item.get () == display;
+ });
+ gdb_assert (iter != all_displays.end ());
+ all_displays.erase (iter);
}
/* Call FUNCTION on each of the displays whose numbers are given in
@@ -1840,9 +1804,7 @@ delete_display (struct display *display)
static void
map_display_numbers (const char *args,
- void (*function) (struct display *,
- void *),
- void *data)
+ gdb::function_view<void (struct display *)> function)
{
int num;
@@ -1860,27 +1822,20 @@ map_display_numbers (const char *args,
warning (_("bad display number at or near '%s'"), p);
else
{
- struct display *d, *tmp;
-
- ALL_DISPLAYS_SAFE (d, tmp)
- if (d->number == num)
- break;
- if (d == NULL)
+ auto iter = std::find_if (all_displays.begin (),
+ all_displays.end (),
+ [=] (const std::unique_ptr<display> &item)
+ {
+ return item->number == num;
+ });
+ if (iter == all_displays.end ())
printf_unfiltered (_("No display number %d.\n"), num);
else
- function (d, data);
+ function (iter->get ());
}
}
}
-/* Callback for map_display_numbers, that deletes a display. */
-
-static void
-do_delete_display (struct display *d, void *data)
-{
- delete_display (d);
-}
-
/* "undisplay" command. */
static void
@@ -1894,7 +1849,7 @@ undisplay_command (const char *args, int from_tty)
return;
}
- map_display_numbers (args, do_delete_display, NULL);
+ map_display_numbers (args, delete_display);
dont_repeat ();
}
@@ -1907,7 +1862,7 @@ do_one_display (struct display *d)
{
int within_current_scope;
- if (d->enabled_p == 0)
+ if (!d->enabled_p)
return;
/* The expression carries the architecture that was used at parse time.
@@ -1929,15 +1884,15 @@ do_one_display (struct display *d)
try
{
innermost_block_tracker tracker;
- d->exp = parse_expression (d->exp_string, &tracker);
+ d->exp = parse_expression (d->exp_string.c_str (), &tracker);
d->block = tracker.block ();
}
catch (const gdb_exception &ex)
{
/* Can't re-parse the expression. Disable this display item. */
- d->enabled_p = 0;
+ d->enabled_p = false;
warning (_("Unable to display \"%s\": %s"),
- d->exp_string, ex.what ());
+ d->exp_string.c_str (), ex.what ());
return;
}
}
@@ -1977,7 +1932,7 @@ do_one_display (struct display *d)
annotate_display_expression ();
- puts_filtered (d->exp_string);
+ puts_filtered (d->exp_string.c_str ());
annotate_display_expression_end ();
if (d->format.count != 1 || d->format.format == 'i')
@@ -2016,7 +1971,7 @@ do_one_display (struct display *d)
annotate_display_expression ();
- puts_filtered (d->exp_string);
+ puts_filtered (d->exp_string.c_str ());
annotate_display_expression_end ();
printf_filtered (" = ");
@@ -2053,10 +2008,8 @@ do_one_display (struct display *d)
void
do_displays (void)
{
- struct display *d;
-
- for (d = display_chain; d; d = d->next)
- do_one_display (d);
+ for (auto &d : all_displays)
+ do_one_display (d.get ());
}
/* Delete the auto-display which we were in the process of displaying.
@@ -2065,12 +2018,10 @@ do_displays (void)
void
disable_display (int num)
{
- struct display *d;
-
- for (d = display_chain; d; d = d->next)
+ for (auto &d : all_displays)
if (d->number == num)
{
- d->enabled_p = 0;
+ d->enabled_p = false;
return;
}
printf_unfiltered (_("No display number %d.\n"), num);
@@ -2093,15 +2044,13 @@ disable_current_display (void)
static void
info_display_command (const char *ignore, int from_tty)
{
- struct display *d;
-
- if (!display_chain)
+ if (all_displays.empty ())
printf_unfiltered (_("There are no auto-display expressions now.\n"));
else
printf_filtered (_("Auto-display expressions now in effect:\n\
Num Enb Expression\n"));
- for (d = display_chain; d; d = d->next)
+ for (auto &d : all_displays)
{
printf_filtered ("%d: %c ", d->number, "ny"[(int) d->enabled_p]);
if (d->format.size)
@@ -2109,38 +2058,31 @@ Num Enb Expression\n"));
d->format.format);
else if (d->format.format)
printf_filtered ("/%c ", d->format.format);
- puts_filtered (d->exp_string);
+ puts_filtered (d->exp_string.c_str ());
if (d->block && !contained_in (get_selected_block (0), d->block, true))
printf_filtered (_(" (cannot be evaluated in the current context)"));
printf_filtered ("\n");
}
}
-/* Callback fo map_display_numbers, that enables or disables the
- passed in display D. */
-
-static void
-do_enable_disable_display (struct display *d, void *data)
-{
- d->enabled_p = *(int *) data;
-}
-
/* Implementation of both the "disable display" and "enable display"
commands. ENABLE decides what to do. */
static void
-enable_disable_display_command (const char *args, int from_tty, int enable)
+enable_disable_display_command (const char *args, int from_tty, bool enable)
{
if (args == NULL)
{
- struct display *d;
-
- ALL_DISPLAYS (d)
+ for (auto &d : all_displays)
d->enabled_p = enable;
return;
}
- map_display_numbers (args, do_enable_disable_display, &enable);
+ map_display_numbers (args,
+ [=] (struct display *d)
+ {
+ d->enabled_p = enable;
+ });
}
/* The "enable display" command. */
@@ -2148,7 +2090,7 @@ enable_disable_display_command (const char *args, int from_tty, int enable)
static void
enable_display_command (const char *args, int from_tty)
{
- enable_disable_display_command (args, from_tty, 1);
+ enable_disable_display_command (args, from_tty, true);
}
/* The "disable display" command. */
@@ -2156,7 +2098,7 @@ enable_display_command (const char *args, int from_tty)
static void
disable_display_command (const char *args, int from_tty)
{
- enable_disable_display_command (args, from_tty, 0);
+ enable_disable_display_command (args, from_tty, false);
}
/* display_chain items point to blocks and expressions. Some expressions in
@@ -2170,7 +2112,6 @@ disable_display_command (const char *args, int from_tty)
static void
clear_dangling_display_expressions (struct objfile *objfile)
{
- struct display *d;
struct program_space *pspace;
/* With no symbol file we cannot have a block or expression from it. */
@@ -2183,7 +2124,7 @@ clear_dangling_display_expressions (struct objfile *objfile)
gdb_assert (objfile->pspace == pspace);
}
- for (d = display_chain; d != NULL; d = d->next)
+ for (auto &d : all_displays)
{
if (d->pspace != pspace)
continue;
diff --git a/gdb/probe.c b/gdb/probe.c
index a21df73d0ec..dca02f0780e 100644
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -185,9 +185,7 @@ parse_probes (const struct event_location *location,
}
else
{
- struct program_space *pspace;
-
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
parse_probes_in_pspace (spops, pspace, objfile_namestr,
provider, name, &result);
}
diff --git a/gdb/progspace.c b/gdb/progspace.c
index 6419f017704..a0b14a6d2eb 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -32,7 +32,7 @@
int last_program_space_num = 0;
/* The head of the program spaces list. */
-struct program_space *program_spaces;
+std::vector<struct program_space *> program_spaces;
/* Pointer to the current program space. */
struct program_space *current_program_space;
@@ -80,7 +80,7 @@ maybe_new_address_space (void)
if (shared_aspace)
{
/* Just return the first in the list. */
- return program_spaces->aspace;
+ return program_spaces[0]->aspace;
}
return new_address_space ();
@@ -109,44 +109,17 @@ init_address_spaces (void)
-/* Add a program space from the program spaces list. */
-
-static void
-add_program_space (program_space *pspace)
-{
- if (program_spaces == NULL)
- program_spaces = pspace;
- else
- {
- program_space *last;
-
- for (last = program_spaces; last->next != NULL; last = last->next)
- ;
- last->next = pspace;
- }
-}
-
/* Remove a program space from the program spaces list. */
static void
remove_program_space (program_space *pspace)
{
- program_space *ss, **ss_link;
gdb_assert (pspace != NULL);
- ss = program_spaces;
- ss_link = &program_spaces;
- while (ss != NULL)
- {
- if (ss == pspace)
- {
- *ss_link = ss->next;
- return;
- }
-
- ss_link = &ss->next;
- ss = *ss_link;
- }
+ auto iter = std::find (program_spaces.begin (), program_spaces.end (),
+ pspace);
+ gdb_assert (iter != program_spaces.end ());
+ program_spaces.erase (iter);
}
/* See progspace.h. */
@@ -157,7 +130,7 @@ program_space::program_space (address_space *aspace_)
{
program_space_alloc_data (this);
- add_program_space (this);
+ program_spaces.push_back (this);
}
/* See progspace.h. */
@@ -192,10 +165,8 @@ program_space::~program_space ()
void
program_space::free_all_objfiles ()
{
- struct so_list *so;
-
/* Any objfile reference would become stale. */
- for (so = master_so_list (); so; so = so->next)
+ for (struct so_list *so : current_program_space->solibs ())
gdb_assert (so->objfile == NULL);
while (!objfiles_list.empty ())
@@ -239,6 +210,14 @@ program_space::remove_objfile (struct objfile *objfile)
symfile_object_file = NULL;
}
+/* See progspace.h. */
+
+next_adapter<struct so_list>
+program_space::solibs () const
+{
+ return next_adapter<struct so_list> (this->so_list);
+}
+
/* Copies program space SRC to DEST. Copies the main executable file,
and the main symbol file. Returns DEST. */
@@ -295,11 +274,10 @@ program_space_empty_p (struct program_space *pspace)
static void
print_program_space (struct ui_out *uiout, int requested)
{
- struct program_space *pspace;
int count = 0;
/* Compute number of pspaces we will print. */
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
{
if (requested != -1 && pspace->num != requested)
continue;
@@ -316,7 +294,7 @@ print_program_space (struct ui_out *uiout, int requested)
uiout->table_header (17, ui_left, "exec", "Executable");
uiout->table_body ();
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
{
struct inferior *inf;
int printed_header;
@@ -369,9 +347,7 @@ print_program_space (struct ui_out *uiout, int requested)
static int
valid_program_space_id (int num)
{
- struct program_space *pspace;
-
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
if (pspace->num == num)
return 1;
@@ -397,20 +373,6 @@ maintenance_info_program_spaces_command (const char *args, int from_tty)
print_program_space (current_uiout, requested);
}
-/* Simply returns the count of program spaces. */
-
-int
-number_of_program_spaces (void)
-{
- struct program_space *pspace;
- int count = 0;
-
- ALL_PSPACES (pspace)
- count++;
-
- return count;
-}
-
/* Update all program spaces matching to address spaces. The user may
have created several program spaces, and loaded executables into
them before connecting to the target interface that will create the
@@ -426,7 +388,6 @@ void
update_address_spaces (void)
{
int shared_aspace = gdbarch_has_shared_address_space (target_gdbarch ());
- struct program_space *pspace;
struct inferior *inf;
init_address_spaces ();
@@ -436,11 +397,11 @@ update_address_spaces (void)
struct address_space *aspace = new_address_space ();
free_address_space (current_program_space->aspace);
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
pspace->aspace = aspace;
}
else
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
{
free_address_space (pspace->aspace);
pspace->aspace = new_address_space ();
diff --git a/gdb/progspace.h b/gdb/progspace.h
index 2b887847e17..099b4dc0b3a 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -28,6 +28,7 @@
#include "gdbsupport/next-iterator.h"
#include "gdbsupport/safe-iterator.h"
#include <list>
+#include <vector>
struct target_ops;
struct bfd;
@@ -37,6 +38,7 @@ struct exec;
struct address_space;
struct program_space_data;
struct address_space_data;
+struct so_list;
typedef std::list<std::shared_ptr<objfile>> objfile_list;
@@ -264,9 +266,12 @@ struct program_space
/* Free all the objfiles associated with this program space. */
void free_all_objfiles ();
+ /* Return a range adapter for iterating over all the solibs in this
+ program space. Use it like:
+
+ for (so_list *so : pspace->solibs ()) { ... } */
+ next_adapter<struct so_list> solibs () const;
- /* Pointer to next in linked list. */
- struct program_space *next = NULL;
/* Unique ID number. */
int num = 0;
@@ -362,17 +367,11 @@ struct address_space
#define current_target_sections (&current_program_space->target_sections)
/* The list of all program spaces. There's always at least one. */
-extern struct program_space *program_spaces;
+extern std::vector<struct program_space *>program_spaces;
/* The current program space. This is always non-null. */
extern struct program_space *current_program_space;
-#define ALL_PSPACES(pspace) \
- for ((pspace) = program_spaces; (pspace) != NULL; (pspace) = (pspace)->next)
-
-/* Returns the number of program spaces listed. */
-extern int number_of_program_spaces (void);
-
/* Returns true iff there's no inferior bound to PSPACE. */
extern int program_space_empty_p (struct program_space *pspace);
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 118dc570e7c..1fce7a39838 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1994,12 +1994,10 @@ maintenance_print_psymbols (const char *args, int from_tty)
static void
maintenance_info_psymtabs (const char *regexp, int from_tty)
{
- struct program_space *pspace;
-
if (regexp)
re_comp (regexp);
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
for (objfile *objfile : pspace->objfiles ())
{
struct gdbarch *gdbarch = objfile->arch ();
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 4875ffd2935..67f362b852d 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -1350,19 +1350,17 @@ gdbpy_print_stack_or_quit ()
static PyObject *
gdbpy_progspaces (PyObject *unused1, PyObject *unused2)
{
- struct program_space *ps;
-
gdbpy_ref<> list (PyList_New (0));
if (list == NULL)
return NULL;
- ALL_PSPACES (ps)
- {
- gdbpy_ref<> item = pspace_to_pspace_object (ps);
+ for (struct program_space *ps : program_spaces)
+ {
+ gdbpy_ref<> item = pspace_to_pspace_object (ps);
- if (item == NULL || PyList_Append (list.get (), item.get ()) == -1)
- return NULL;
- }
+ if (item == NULL || PyList_Append (list.get (), item.get ()) == -1)
+ return NULL;
+ }
return list.release ();
}
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 20661e48d96..f2fb0119b00 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -708,8 +708,7 @@ rust_print_struct_def (struct type *type, const char *varstring,
if (is_enum)
{
fputs_filtered ("enum ", stream);
- struct dynamic_prop *prop = get_dyn_prop (DYN_PROP_VARIANT_PARTS,
- type);
+ dynamic_prop *prop = type->dyn_prop (DYN_PROP_VARIANT_PARTS);
if (prop != nullptr && prop->kind == PROP_TYPE)
type = prop->data.original_type;
}
diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
index 582f2d5ede6..62e7b05b490 100644
--- a/gdb/solib-frv.c
+++ b/gdb/solib-frv.c
@@ -908,10 +908,7 @@ main_got (void)
CORE_ADDR
frv_fdpic_find_global_pointer (CORE_ADDR addr)
{
- struct so_list *so;
-
- so = master_so_list ();
- while (so)
+ for (struct so_list *so : current_program_space->solibs ())
{
int seg;
lm_info_frv *li = (lm_info_frv *) so->lm_info;
@@ -923,8 +920,6 @@ frv_fdpic_find_global_pointer (CORE_ADDR addr)
&& addr < map->segs[seg].addr + map->segs[seg].p_memsz)
return li->got_value;
}
-
- so = so->next;
}
/* Didn't find it in any of the shared objects. So assume it's in the
@@ -969,10 +964,7 @@ frv_fdpic_find_canonical_descriptor (CORE_ADDR entry_point)
in list of shared objects. */
if (addr == 0)
{
- struct so_list *so;
-
- so = master_so_list ();
- while (so)
+ for (struct so_list *so : current_program_space->solibs ())
{
lm_info_frv *li = (lm_info_frv *) so->lm_info;
@@ -981,8 +973,6 @@ frv_fdpic_find_canonical_descriptor (CORE_ADDR entry_point)
if (addr != 0)
break;
-
- so = so->next;
}
}
@@ -1116,8 +1106,6 @@ find_canonical_descriptor_in_load_object
CORE_ADDR
frv_fetch_objfile_link_map (struct objfile *objfile)
{
- struct so_list *so;
-
/* Cause frv_current_sos() to be run if it hasn't been already. */
if (main_lm_addr == 0)
solib_add (0, 0, 1);
@@ -1128,7 +1116,7 @@ frv_fetch_objfile_link_map (struct objfile *objfile)
/* The other link map addresses may be found by examining the list
of shared libraries. */
- for (so = master_so_list (); so; so = so->next)
+ for (struct so_list *so : current_program_space->solibs ())
{
lm_info_frv *li = (lm_info_frv *) so->lm_info;
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 38c832f8f5a..19d1105ae95 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1537,7 +1537,6 @@ svr4_current_sos (void)
CORE_ADDR
svr4_fetch_objfile_link_map (struct objfile *objfile)
{
- struct so_list *so;
struct svr4_info *info = get_svr4_info (objfile->pspace);
/* Cause svr4_current_sos() to be run if it hasn't been already. */
@@ -1555,7 +1554,7 @@ svr4_fetch_objfile_link_map (struct objfile *objfile)
/* The other link map addresses may be found by examining the list
of shared libraries. */
- for (so = master_so_list (); so; so = so->next)
+ for (struct so_list *so : current_program_space->solibs ())
if (so->objfile == objfile)
{
lm_info_svr4 *li = (lm_info_svr4 *) so->lm_info;
@@ -2307,7 +2306,6 @@ enable_break (struct svr4_info *info, int from_tty)
CORE_ADDR load_addr = 0;
int load_addr_found = 0;
int loader_found_in_list = 0;
- struct so_list *so;
struct target_ops *tmp_bfd_target;
sym_addr = 0;
@@ -2340,8 +2338,7 @@ enable_break (struct svr4_info *info, int from_tty)
/* On a running target, we can get the dynamic linker's base
address from the shared library table. */
- so = master_so_list ();
- while (so)
+ for (struct so_list *so : current_program_space->solibs ())
{
if (svr4_same_1 (interp_name, so->so_original_name))
{
@@ -2350,7 +2347,6 @@ enable_break (struct svr4_info *info, int from_tty)
load_addr = lm_addr_check (so, tmp_bfd.get ());
break;
}
- so = so->next;
}
/* If we were not able to find the base address of the loader
diff --git a/gdb/solib.c b/gdb/solib.c
index ba388d77e8d..cd410bb9e3e 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -647,13 +647,6 @@ free_so (struct so_list *so)
}
-/* Return address of first so_list entry in master shared object list. */
-struct so_list *
-master_so_list (void)
-{
- return so_list_head;
-}
-
/* Read in symbols for shared object SO. If SYMFILE_VERBOSE is set in FLAGS,
be chatty about it. Return true if any symbols were actually loaded. */
@@ -713,15 +706,13 @@ solib_read_symbols (struct so_list *so, symfile_add_flags flags)
return false;
}
-/* Return true if KNOWN->objfile is used by any other so_list object in the
- SO_LIST_HEAD list. Return false otherwise. */
+/* Return true if KNOWN->objfile is used by any other so_list object
+ in the list of shared libraries. Return false otherwise. */
static bool
solib_used (const struct so_list *const known)
{
- const struct so_list *pivot;
-
- for (pivot = so_list_head; pivot != NULL; pivot = pivot->next)
+ for (const struct so_list *pivot : current_program_space->solibs ())
if (pivot != known && pivot->objfile == known->objfile)
return true;
return false;
@@ -784,8 +775,8 @@ update_solib_list (int from_tty)
the time we're done walking GDB's list, the inferior's list
contains only the new shared objects, which we then add. */
- gdb = so_list_head;
- gdb_link = &so_list_head;
+ gdb = current_program_space->so_list;
+ gdb_link = &current_program_space->so_list;
while (gdb)
{
struct so_list *i = inferior;
@@ -943,8 +934,6 @@ libpthread_solib_p (struct so_list *so)
void
solib_add (const char *pattern, int from_tty, int readsyms)
{
- struct so_list *gdb;
-
if (print_symbol_loading_p (from_tty, 0, 0))
{
if (pattern != NULL)
@@ -979,7 +968,7 @@ solib_add (const char *pattern, int from_tty, int readsyms)
if (from_tty)
add_flags |= SYMFILE_VERBOSE;
- for (gdb = so_list_head; gdb; gdb = gdb->next)
+ for (struct so_list *gdb : current_program_space->solibs ())
if (! pattern || re_exec (gdb->so_name))
{
/* Normally, we would read the symbols from that library
@@ -1030,7 +1019,6 @@ solib_add (const char *pattern, int from_tty, int readsyms)
static void
info_sharedlibrary_command (const char *pattern, int from_tty)
{
- struct so_list *so = NULL; /* link map state variable */
bool so_missing_debug_info = false;
int addr_width;
int nr_libs;
@@ -1053,7 +1041,8 @@ info_sharedlibrary_command (const char *pattern, int from_tty)
/* ui_out_emit_table table_emitter needs to know the number of rows,
so we need to make two passes over the libs. */
- for (nr_libs = 0, so = so_list_head; so; so = so->next)
+ nr_libs = 0;
+ for (struct so_list *so : current_program_space->solibs ())
{
if (so->so_name[0])
{
@@ -1074,7 +1063,7 @@ info_sharedlibrary_command (const char *pattern, int from_tty)
uiout->table_body ();
- ALL_SO_LIBS (so)
+ for (struct so_list *so : current_program_space->solibs ())
{
if (! so->so_name[0])
continue;
@@ -1185,11 +1174,11 @@ clear_solib (void)
disable_breakpoints_in_shlibs ();
- while (so_list_head)
+ while (current_program_space->so_list)
{
- struct so_list *so = so_list_head;
+ struct so_list *so = current_program_space->so_list;
- so_list_head = so->next;
+ current_program_space->so_list = so->next;
gdb::observers::solib_unloaded.notify (so);
remove_target_sections (so);
free_so (so);
@@ -1284,12 +1273,10 @@ handle_solib_event (void)
static void
reload_shared_libraries_1 (int from_tty)
{
- struct so_list *so;
-
if (print_symbol_loading_p (from_tty, 0, 0))
printf_unfiltered (_("Loading symbols for shared libraries.\n"));
- for (so = so_list_head; so != NULL; so = so->next)
+ for (struct so_list *so : current_program_space->solibs ())
{
const char *found_pathname = NULL;
bool was_loaded = so->symbols_loaded != 0;
@@ -1552,18 +1539,17 @@ gdb_bfd_lookup_symbol (bfd *abfd,
return symaddr;
}
-/* SO_LIST_HEAD may contain user-loaded object files that can be removed
- out-of-band by the user. So upon notification of free_objfile remove
- all references to any user-loaded file that is about to be freed. */
+/* The shared library list may contain user-loaded object files that
+ can be removed out-of-band by the user. So upon notification of
+ free_objfile remove all references to any user-loaded file that is
+ about to be freed. */
static void
remove_user_added_objfile (struct objfile *objfile)
{
- struct so_list *so;
-
if (objfile != 0 && objfile->flags & OBJF_USERLOADED)
{
- for (so = so_list_head; so != NULL; so = so->next)
+ for (struct so_list *so : current_program_space->solibs ())
if (so->objfile == objfile)
so->objfile = NULL;
}
diff --git a/gdb/solib.h b/gdb/solib.h
index 2628ca0c2b7..801965fcd53 100644
--- a/gdb/solib.h
+++ b/gdb/solib.h
@@ -28,9 +28,6 @@ struct program_space;
#include "symfile-add-flags.h"
-/* List of known shared objects */
-#define so_list_head current_program_space->so_list
-
/* Called when we free all symtabs, to free the shared library information
as well. */
@@ -81,9 +78,9 @@ extern void set_solib_ops (struct gdbarch *gdbarch,
/* Synchronize GDB's shared object list with inferior's.
Extract the list of currently loaded shared objects from the
- inferior, and compare it with the list of shared objects currently
- in GDB's so_list_head list. Edit so_list_head to bring it in sync
- with the inferior's new list.
+ inferior, and compare it with the list of shared objects in the
+ current program space's list of shared libraries. Edit
+ so_list_head to bring it in sync with the inferior's new list.
If we notice that the inferior has unloaded some shared objects,
free any symbolic info GDB had read about those shared objects.
diff --git a/gdb/solist.h b/gdb/solist.h
index 068aeba2f0e..0360d342ae8 100644
--- a/gdb/solist.h
+++ b/gdb/solist.h
@@ -24,11 +24,6 @@
#include "symtab.h"
#include "gdb_bfd.h"
-#define ALL_SO_LIBS(so) \
- for (so = so_list_head; \
- so != NULL; \
- so = so->next)
-
/* Base class for target-specific link map information. */
struct lm_info_base
@@ -183,9 +178,6 @@ struct so_deleter
/* A unique pointer to a so_list. */
typedef std::unique_ptr<so_list, so_deleter> so_list_up;
-/* Return address of first so_list entry in master shared object list. */
-struct so_list *master_so_list (void);
-
/* Find main executable binary file. */
extern gdb::unique_xmalloc_ptr<char> exec_file_find (const char *in_pathname,
int *fd);
diff --git a/gdb/source.c b/gdb/source.c
index 7d22bbb5db3..b94c6af487d 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -421,9 +421,7 @@ forget_cached_source_info_for_objfile (struct objfile *objfile)
void
forget_cached_source_info (void)
{
- struct program_space *pspace;
-
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
for (objfile *objfile : pspace->objfiles ())
{
forget_cached_source_info_for_objfile (objfile);
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 5ef7748a9eb..eac47407105 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -738,7 +738,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
else
{
normal:
- std::string new_name;
+ gdb::unique_xmalloc_ptr<char> new_name;
if (sym->language () == language_cplus)
{
@@ -748,8 +748,8 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
name[p - string] = '\0';
new_name = cp_canonicalize_string (name);
}
- if (!new_name.empty ())
- sym->compute_and_set_names (new_name, true, objfile->per_bfd);
+ if (new_name != nullptr)
+ sym->compute_and_set_names (new_name.get (), true, objfile->per_bfd);
else
sym->compute_and_set_names (gdb::string_view (string, p - string), true,
objfile->per_bfd);
@@ -1637,10 +1637,10 @@ again:
memcpy (name, *pp, p - *pp);
name[p - *pp] = '\0';
- std::string new_name = cp_canonicalize_string (name);
- if (!new_name.empty ())
+ gdb::unique_xmalloc_ptr<char> new_name = cp_canonicalize_string (name);
+ if (new_name != nullptr)
type_name = obstack_strdup (&objfile->objfile_obstack,
- new_name);
+ new_name.get ());
}
if (type_name == NULL)
{
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 75e6f2d0d89..203609c326b 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -621,9 +621,7 @@ objfile_set_sym_fns (struct objfile *objfile, const struct sym_fns *sf)
static void
set_debug_symfile (const char *args, int from_tty, struct cmd_list_element *c)
{
- struct program_space *pspace;
-
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
for (objfile *objfile : pspace->objfiles ())
{
if (debug_symfile)
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index f45364a8832..a00009fc066 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -61,9 +61,7 @@ static void print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
void
print_symbol_bcache_statistics (void)
{
- struct program_space *pspace;
-
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
for (objfile *objfile : pspace->objfiles ())
{
QUIT;
@@ -78,64 +76,63 @@ print_symbol_bcache_statistics (void)
void
print_objfile_statistics (void)
{
- struct program_space *pspace;
int i, linetables, blockvectors;
- ALL_PSPACES (pspace)
- for (objfile *objfile : pspace->objfiles ())
- {
- QUIT;
- printf_filtered (_("Statistics for '%s':\n"), objfile_name (objfile));
- if (OBJSTAT (objfile, n_stabs) > 0)
- printf_filtered (_(" Number of \"stab\" symbols read: %d\n"),
- OBJSTAT (objfile, n_stabs));
- if (objfile->per_bfd->n_minsyms > 0)
- printf_filtered (_(" Number of \"minimal\" symbols read: %d\n"),
- objfile->per_bfd->n_minsyms);
- if (OBJSTAT (objfile, n_psyms) > 0)
- printf_filtered (_(" Number of \"partial\" symbols read: %d\n"),
- OBJSTAT (objfile, n_psyms));
- if (OBJSTAT (objfile, n_syms) > 0)
- printf_filtered (_(" Number of \"full\" symbols read: %d\n"),
- OBJSTAT (objfile, n_syms));
- if (OBJSTAT (objfile, n_types) > 0)
- printf_filtered (_(" Number of \"types\" defined: %d\n"),
- OBJSTAT (objfile, n_types));
- if (objfile->sf)
- objfile->sf->qf->print_stats (objfile);
- i = linetables = 0;
- for (compunit_symtab *cu : objfile->compunits ())
- {
- for (symtab *s : compunit_filetabs (cu))
- {
- i++;
- if (SYMTAB_LINETABLE (s) != NULL)
- linetables++;
- }
- }
- blockvectors = std::distance (objfile->compunits ().begin (),
- objfile->compunits ().end ());
- printf_filtered (_(" Number of symbol tables: %d\n"), i);
- printf_filtered (_(" Number of symbol tables with line tables: %d\n"),
- linetables);
- printf_filtered (_(" Number of symbol tables with blockvectors: %d\n"),
- blockvectors);
-
- if (OBJSTAT (objfile, sz_strtab) > 0)
- printf_filtered (_(" Space used by string tables: %d\n"),
- OBJSTAT (objfile, sz_strtab));
- printf_filtered (_(" Total memory used for objfile obstack: %s\n"),
- pulongest (obstack_memory_used (&objfile
- ->objfile_obstack)));
- printf_filtered (_(" Total memory used for BFD obstack: %s\n"),
- pulongest (obstack_memory_used (&objfile->per_bfd
- ->storage_obstack)));
- printf_filtered
- (_(" Total memory used for psymbol cache: %d\n"),
- objfile->partial_symtabs->psymbol_cache.memory_used ());
- printf_filtered (_(" Total memory used for string cache: %d\n"),
- objfile->per_bfd->string_cache.memory_used ());
- }
+ for (struct program_space *pspace : program_spaces)
+ for (objfile *objfile : pspace->objfiles ())
+ {
+ QUIT;
+ printf_filtered (_("Statistics for '%s':\n"), objfile_name (objfile));
+ if (OBJSTAT (objfile, n_stabs) > 0)
+ printf_filtered (_(" Number of \"stab\" symbols read: %d\n"),
+ OBJSTAT (objfile, n_stabs));
+ if (objfile->per_bfd->n_minsyms > 0)
+ printf_filtered (_(" Number of \"minimal\" symbols read: %d\n"),
+ objfile->per_bfd->n_minsyms);
+ if (OBJSTAT (objfile, n_psyms) > 0)
+ printf_filtered (_(" Number of \"partial\" symbols read: %d\n"),
+ OBJSTAT (objfile, n_psyms));
+ if (OBJSTAT (objfile, n_syms) > 0)
+ printf_filtered (_(" Number of \"full\" symbols read: %d\n"),
+ OBJSTAT (objfile, n_syms));
+ if (OBJSTAT (objfile, n_types) > 0)
+ printf_filtered (_(" Number of \"types\" defined: %d\n"),
+ OBJSTAT (objfile, n_types));
+ if (objfile->sf)
+ objfile->sf->qf->print_stats (objfile);
+ i = linetables = 0;
+ for (compunit_symtab *cu : objfile->compunits ())
+ {
+ for (symtab *s : compunit_filetabs (cu))
+ {
+ i++;
+ if (SYMTAB_LINETABLE (s) != NULL)
+ linetables++;
+ }
+ }
+ blockvectors = std::distance (objfile->compunits ().begin (),
+ objfile->compunits ().end ());
+ printf_filtered (_(" Number of symbol tables: %d\n"), i);
+ printf_filtered (_(" Number of symbol tables with line tables: %d\n"),
+ linetables);
+ printf_filtered (_(" Number of symbol tables with blockvectors: %d\n"),
+ blockvectors);
+
+ if (OBJSTAT (objfile, sz_strtab) > 0)
+ printf_filtered (_(" Space used by string tables: %d\n"),
+ OBJSTAT (objfile, sz_strtab));
+ printf_filtered (_(" Total memory used for objfile obstack: %s\n"),
+ pulongest (obstack_memory_used (&objfile
+ ->objfile_obstack)));
+ printf_filtered (_(" Total memory used for BFD obstack: %s\n"),
+ pulongest (obstack_memory_used (&objfile->per_bfd
+ ->storage_obstack)));
+ printf_filtered
+ (_(" Total memory used for psymbol cache: %d\n"),
+ objfile->partial_symtabs->psymbol_cache.memory_used ());
+ printf_filtered (_(" Total memory used for string cache: %d\n"),
+ objfile->per_bfd->string_cache.memory_used ());
+ }
}
static void
@@ -762,14 +759,12 @@ maintenance_print_msymbols (const char *args, int from_tty)
static void
maintenance_print_objfiles (const char *regexp, int from_tty)
{
- struct program_space *pspace;
-
dont_repeat ();
if (regexp)
re_comp (regexp);
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
for (objfile *objfile : pspace->objfiles ())
{
QUIT;
@@ -784,14 +779,12 @@ maintenance_print_objfiles (const char *regexp, int from_tty)
static void
maintenance_info_symtabs (const char *regexp, int from_tty)
{
- struct program_space *pspace;
-
dont_repeat ();
if (regexp)
re_comp (regexp);
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
for (objfile *objfile : pspace->objfiles ())
{
/* We don't want to print anything for this objfile until we
@@ -896,9 +889,7 @@ maintenance_info_symtabs (const char *regexp, int from_tty)
static void
maintenance_check_symtabs (const char *ignore, int from_tty)
{
- struct program_space *pspace;
-
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
for (objfile *objfile : pspace->objfiles ())
{
/* We don't want to print anything for this objfile until we
@@ -944,7 +935,6 @@ maintenance_check_symtabs (const char *ignore, int from_tty)
static void
maintenance_expand_symtabs (const char *args, int from_tty)
{
- struct program_space *pspace;
char *regexp = NULL;
/* We use buildargv here so that we handle spaces in the regexp
@@ -964,7 +954,7 @@ maintenance_expand_symtabs (const char *args, int from_tty)
if (regexp)
re_comp (regexp);
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
for (objfile *objfile : pspace->objfiles ())
{
if (objfile->sf)
@@ -1065,14 +1055,12 @@ maintenance_print_one_line_table (struct symtab *symtab, void *data)
static void
maintenance_info_line_tables (const char *regexp, int from_tty)
{
- struct program_space *pspace;
-
dont_repeat ();
if (regexp != NULL)
re_comp (regexp);
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
for (objfile *objfile : pspace->objfiles ())
{
for (compunit_symtab *cust : objfile->compunits ())
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 652384cd469..b765a583c42 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1276,9 +1276,7 @@ get_symbol_cache (struct program_space *pspace)
static void
set_symbol_cache_size (unsigned int new_size)
{
- struct program_space *pspace;
-
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
{
struct symbol_cache *cache = symbol_cache_key.get (pspace);
@@ -1526,9 +1524,7 @@ symbol_cache_dump (const struct symbol_cache *cache)
static void
maintenance_print_symbol_cache (const char *args, int from_tty)
{
- struct program_space *pspace;
-
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
{
struct symbol_cache *cache;
@@ -1552,9 +1548,7 @@ maintenance_print_symbol_cache (const char *args, int from_tty)
static void
maintenance_flush_symbol_cache (const char *args, int from_tty)
{
- struct program_space *pspace;
-
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
{
symbol_cache_flush (pspace);
}
@@ -1597,9 +1591,7 @@ symbol_cache_stats (struct symbol_cache *cache)
static void
maintenance_print_symbol_cache_statistics (const char *args, int from_tty)
{
- struct program_space *pspace;
-
- ALL_PSPACES (pspace)
+ for (struct program_space *pspace : program_spaces)
{
struct symbol_cache *cache;
@@ -1838,9 +1830,9 @@ demangle_for_lookup (const char *name, enum language lang,
/* If we were given a non-mangled name, canonicalize it
according to the language (so far only for C++). */
- std::string canon = cp_canonicalize_string (name);
- if (!canon.empty ())
- return storage.swap_string (canon);
+ gdb::unique_xmalloc_ptr<char> canon = cp_canonicalize_string (name);
+ if (canon != nullptr)
+ return storage.set_malloc_ptr (std::move (canon));
}
else if (lang == language_d)
{
@@ -5349,10 +5341,10 @@ completion_list_add_symbol (completion_tracker &tracker,
/* The call to canonicalize returns the empty string if the input
string is already in canonical form, thanks to this we don't
remove the symbol we just added above. */
- std::string str
+ gdb::unique_xmalloc_ptr<char> str
= cp_canonicalize_string_no_typedefs (sym->natural_name ());
- if (!str.empty ())
- tracker.remove_completion (str.c_str ());
+ if (str != nullptr)
+ tracker.remove_completion (str.get ());
}
}
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 5c5db0fabac..764c567a90b 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -2299,20 +2299,18 @@ bool iterate_over_symbols_terminated
/* 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. */
+ this way to avoid depending on the precise details of the storage
+ for the string. */
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)
+ /* Swap the malloc storage to STR, and return a pointer to the
+ beginning of the new string. */
+ const char *set_malloc_ptr (gdb::unique_xmalloc_ptr<char> &&str)
{
- std::swap (m_string, str);
- return m_string.c_str ();
+ m_malloc = std::move (str);
+ return m_malloc.get ();
}
/* Set the malloc storage to now point at PTR. Any previous malloc
@@ -2326,7 +2324,6 @@ public:
private:
/* The storage. */
- std::string m_string;
gdb::unique_xmalloc_ptr<char> m_malloc;
};
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index a2e0d87e89d..c13b651e90c 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,55 @@
+2020-05-10 Alok Kumar Sharma <alokkumar.sharma@amd.com>
+
+ * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
+ (fortran_runto_main): New Proc, fortran version of runto_main.
+ * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
+ * gdb.fortran/array-bounds.exp: Likewise.
+ * gdb.fortran/array-slices.exp: Likewise.
+ * gdb.fortran/block-data.exp: Likewise.
+ * gdb.fortran/charset.exp: Likewise.
+ * gdb.fortran/common-block.exp: Likewise.
+ * gdb.fortran/complex.exp: Likewise.
+ * gdb.fortran/derived-type-function.exp: Likewise.
+ * gdb.fortran/derived-type.exp: Likewise.
+ * gdb.fortran/info-modules.exp: Likewise.
+ * gdb.fortran/info-types.exp: Likewise.
+ * gdb.fortran/intrinsics.exp: Likewise.
+ * gdb.fortran/library-module.exp: Likewise.
+ * gdb.fortran/logical.exp: Likewise.
+ * gdb.fortran/max-depth.exp: Likewise.
+ * gdb.fortran/module.exp: Likewise.
+ * gdb.fortran/multi-dim.exp: Likewise.
+ * gdb.fortran/nested-funcs.exp: Likewise.
+ * gdb.fortran/print-formatted.exp: Likewise.
+ * gdb.fortran/print_type.exp: Likewise.
+ * gdb.fortran/printing-types.exp: Likewise.
+ * gdb.fortran/ptr-indentation.exp: Likewise.
+ * gdb.fortran/ptype-on-functions.exp: Likewise.
+ * gdb.fortran/subarray.exp: Likewise.
+ * gdb.fortran/vla-alloc-assoc.exp: Likewise.
+ * gdb.fortran/vla-datatypes.exp: Likewise.
+ * gdb.fortran/vla-history.exp: Likewise.
+ * gdb.fortran/vla-ptr-info.exp: Likewise.
+ * gdb.fortran/vla-ptype-sub.exp: Likewise.
+ * gdb.fortran/vla-ptype.exp: Likewise.
+ * gdb.fortran/vla-sizeof.exp: Likewise.
+ * gdb.fortran/vla-type.exp: Likewise.
+ * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
+ * gdb.fortran/vla-value-sub-finish.exp: Likewise.
+ * gdb.fortran/vla-value-sub.exp: Likewise.
+ * gdb.fortran/vla-value.exp: Likewise.
+ * gdb.fortran/whatis_type.exp: Likewise.
+ * gdb.mi/mi-var-child-f.exp: Likewise.
+
+2020-05-09 Tom de Vries <tdevries@suse.de>
+
+ * gdb.dwarf2/clang-debug-names.exp: Remove PR25952 kfail.
+
+2020-05-08 Tom de Vries <tdevries@suse.de>
+
+ * gdb.dwarf2/clang-debug-names.c: New test.
+ * gdb.dwarf2/clang-debug-names.exp: New file.
+
2020-05-06 Simon Marchi <simon.marchi@efficios.com>
* gdb.arch/amd64-prologue-skip-cf-protection.exp: New file.
diff --git a/gdb/testsuite/gdb.dwarf2/clang-debug-names.c b/gdb/testsuite/gdb.dwarf2/clang-debug-names.c
new file mode 100644
index 00000000000..d66c192dbf3
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/clang-debug-names.c
@@ -0,0 +1,25 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2020 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+main (void)
+{
+ asm ("main_label: .globl main_label");
+ int sum, a, b;
+ sum = a + b;
+ return sum;
+}
diff --git a/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp b/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp
new file mode 100644
index 00000000000..a6e33c1d899
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp
@@ -0,0 +1,145 @@
+# Copyright 2020 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+if {![dwarf2_support]} {
+ return 0
+}
+
+standard_testfile clang-debug-names.c clang-debug-names-debug.S
+
+# Set up the DWARF for the test.
+
+set main_str_label [Dwarf::_compute_label info_string3]
+set int_str_label [Dwarf::_compute_label info_string4]
+set main_die_label [Dwarf::_compute_label main_die_label]
+set int_die_label [Dwarf::_compute_label int_die_label]
+
+set debug_str \
+ [list \
+ "$main_str_label:" \
+ " .asciz \"main\"" \
+ "$int_str_label:" \
+ " .asciz \"int\""]
+
+set debug_names \
+ [list \
+ " .4byte .Ldebug_names_end - .Ldebug_names_start" \
+ ".Ldebug_names_start:" \
+ " .short 5 # Header: version" \
+ " .short 0 # Header: padding" \
+ " .long 1 # Header: compilation unit count" \
+ " .long 0 # Header: local type unit count" \
+ " .long 0 # Header: foreign type unit count" \
+ " .long 2 # Header: bucket count" \
+ " .long 2 # Header: name count" \
+ " .long .Lnames_abbrev_end0-.Lnames_abbrev_start0 " \
+ " # Header: abbreviation table size" \
+ " .long 8 # Header: augmentation string size" \
+ " .ascii \"LLVM0700\" # Header: augmentation string" \
+ " .long .Lcu1_begin # Compilation unit 0" \
+ " .long 1 # Bucket 0" \
+ " .long 0 # Bucket 1" \
+ " .long 193495088 # Hash in Bucket 0" \
+ " .long 2090499946 # Hash in Bucket 0" \
+ " .long $int_str_label # String in Bucket 0: int" \
+ " .long $main_str_label # String in Bucket 0: main" \
+ " .long .Lnames1-.Lnames_entries0 # Offset in Bucket 0" \
+ " .long .Lnames0-.Lnames_entries0 # Offset in Bucket 0" \
+ ".Lnames_abbrev_start0:" \
+ " .byte 46 # Abbrev code" \
+ " .byte 46 # DW_TAG_subprogram" \
+ " .byte 3 # DW_IDX_die_offset" \
+ " .byte 19 # DW_FORM_ref4" \
+ " .byte 0 # End of abbrev" \
+ " .byte 0 # End of abbrev" \
+ " .byte 36 # Abbrev code" \
+ " .byte 36 # DW_TAG_base_type" \
+ " .byte 3 # DW_IDX_die_offset" \
+ " .byte 19 # DW_FORM_ref4" \
+ " .byte 0 # End of abbrev" \
+ " .byte 0 # End of abbrev" \
+ " .byte 0 # End of abbrev list" \
+ ".Lnames_abbrev_end0:" \
+ ".Lnames_entries0:" \
+ ".Lnames1:" \
+ " .byte 36 # Abbreviation code" \
+ " .long $int_die_label - .Lcu1_begin # DW_IDX_die_offset" \
+ " .long 0 # End of list: int" \
+ ".Lnames0:" \
+ " .byte 46 # Abbreviation code" \
+ " .long $main_die_label - .Lcu1_begin # DW_IDX_die_offset" \
+ " .long 0 # End of list: main" \
+ " .p2align 2" \
+ ".Ldebug_names_end:"]
+
+set asm_file [standard_output_file $srcfile2]
+Dwarf::assemble $asm_file {
+ global srcdir subdir srcfile
+
+ lassign [function_range main ${srcdir}/${subdir}/${srcfile}] \
+ main_start main_length
+
+ cu {} {
+ DW_TAG_compile_unit {
+ {DW_AT_language @DW_LANG_C}
+ {DW_AT_name clang-debug-names.c}
+ {DW_AT_comp_dir /tmp}
+
+ } {
+ global int_die_label
+ global main_die_label
+
+ define_label $int_die_label
+ base_type {
+ {name "int"}
+ {encoding @DW_ATE_signed}
+ {byte_size 4 DW_FORM_sdata}
+ }
+
+ define_label $main_die_label
+ subprogram {
+ {name main}
+ {type :$int_die_label}
+ {low_pc $main_start addr}
+ {high_pc "$main_start + $main_length" addr}
+ }
+ }
+ }
+
+ _defer_output .debug_str {
+ global debug_str
+ _emit [join $debug_str "\n"]
+ }
+
+ _defer_output .debug_names {
+ global debug_names
+ _emit [join $debug_names "\n"]
+ }
+}
+
+if { [prepare_for_testing "failed to prepare" ${testfile} \
+ [list $srcfile $asm_file] {nodebug}] } {
+ return -1
+}
+
+set cmd "ptype main"
+set pass_re \
+ [multi_line \
+ $cmd \
+ "type = int \\(\\)"]
+gdb_test $cmd $pass_re
diff --git a/gdb/testsuite/gdb.fortran/array-bounds-high.exp b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
index 81e2f87b89f..ba34dbc23e2 100644
--- a/gdb/testsuite/gdb.fortran/array-bounds-high.exp
+++ b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
@@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
set testfile "array-bounds-high"
standard_testfile .f90
+load_lib fortran.exp
if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
return -1
}
-if {![runto MAIN__]} {
- perror "Could not run to breakpoint `MAIN__'."
+if {![fortran_runto_main]} {
+ perror "Could not run to main."
continue
}
diff --git a/gdb/testsuite/gdb.fortran/array-bounds.exp b/gdb/testsuite/gdb.fortran/array-bounds.exp
index 12bf5c2db3e..3f2527343b1 100644
--- a/gdb/testsuite/gdb.fortran/array-bounds.exp
+++ b/gdb/testsuite/gdb.fortran/array-bounds.exp
@@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
set testfile "array-bounds"
standard_testfile .f90
+load_lib fortran.exp
if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
return -1
}
-if {![runto MAIN__]} {
- perror "Could not run to breakpoint `MAIN__'."
+if {![fortran_runto_main]} {
+ perror "Could not run to main."
continue
}
diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp
index 11997f926ac..4ca1db90f7f 100644
--- a/gdb/testsuite/gdb.fortran/array-slices.exp
+++ b/gdb/testsuite/gdb.fortran/array-slices.exp
@@ -21,13 +21,14 @@
if {[skip_fortran_tests]} { return -1 }
standard_testfile ".f90"
+load_lib fortran.exp
if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
{debug f90}]} {
return -1
}
-if ![runto_main] {
+if ![fortran_runto_main] {
untested "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/block-data.exp b/gdb/testsuite/gdb.fortran/block-data.exp
index 292afe6c161..632c0141a34 100644
--- a/gdb/testsuite/gdb.fortran/block-data.exp
+++ b/gdb/testsuite/gdb.fortran/block-data.exp
@@ -30,8 +30,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
return -1
}
-if ![runto MAIN__] then {
- untested "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+ untested "couldn't run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/charset.exp b/gdb/testsuite/gdb.fortran/charset.exp
index f0f62f8490a..fc504ae0b08 100644
--- a/gdb/testsuite/gdb.fortran/charset.exp
+++ b/gdb/testsuite/gdb.fortran/charset.exp
@@ -19,12 +19,14 @@
if { [skip_fortran_tests] } { return -1 }
standard_testfile .f90
+load_lib fortran.exp
+
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug additional_flags=-fbackslash f90}] } {
return -1
}
-if ![runto MAIN__] {
- perror "Couldn't run to MAIN__"
+if ![fortran_runto_main] {
+ perror "Couldn't run to main"
continue
}
diff --git a/gdb/testsuite/gdb.fortran/common-block.exp b/gdb/testsuite/gdb.fortran/common-block.exp
index 19c1af0d81c..3dacfd32b24 100644
--- a/gdb/testsuite/gdb.fortran/common-block.exp
+++ b/gdb/testsuite/gdb.fortran/common-block.exp
@@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
return -1
}
-if ![runto MAIN__] then {
- perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+ perror "couldn't run to main"
continue
}
diff --git a/gdb/testsuite/gdb.fortran/complex.exp b/gdb/testsuite/gdb.fortran/complex.exp
index c092ab29f1f..a88e553e586 100644
--- a/gdb/testsuite/gdb.fortran/complex.exp
+++ b/gdb/testsuite/gdb.fortran/complex.exp
@@ -14,13 +14,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
standard_testfile .f90
+load_lib fortran.exp
if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
return -1
}
-if ![runto MAIN__] then {
- perror "Couldn't run to MAIN__"
+if ![fortran_runto_main] then {
+ perror "Couldn't run to main"
continue
}
diff --git a/gdb/testsuite/gdb.fortran/derived-type-function.exp b/gdb/testsuite/gdb.fortran/derived-type-function.exp
index 1f0f957317b..2ae6f46c1ec 100644
--- a/gdb/testsuite/gdb.fortran/derived-type-function.exp
+++ b/gdb/testsuite/gdb.fortran/derived-type-function.exp
@@ -21,13 +21,14 @@
if { [skip_fortran_tests] } { return -1 }
standard_testfile .f90
+load_lib fortran.exp
if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
return -1
}
-if ![runto MAIN__] then {
- perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+ perror "couldn't run to main"
continue
}
diff --git a/gdb/testsuite/gdb.fortran/derived-type.exp b/gdb/testsuite/gdb.fortran/derived-type.exp
index f1705bffd85..4b86ba97de6 100644
--- a/gdb/testsuite/gdb.fortran/derived-type.exp
+++ b/gdb/testsuite/gdb.fortran/derived-type.exp
@@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
return -1
}
-if ![runto MAIN__] then {
- perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+ perror "couldn't run to main"
continue
}
diff --git a/gdb/testsuite/gdb.fortran/info-modules.exp b/gdb/testsuite/gdb.fortran/info-modules.exp
index 0c3c6a58e12..a3a9b2cb185 100644
--- a/gdb/testsuite/gdb.fortran/info-modules.exp
+++ b/gdb/testsuite/gdb.fortran/info-modules.exp
@@ -28,8 +28,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
return -1
}
-if { ![runto MAIN__] } {
- perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+ perror "Could not run to main."
continue
}
diff --git a/gdb/testsuite/gdb.fortran/info-types.exp b/gdb/testsuite/gdb.fortran/info-types.exp
index 21389377826..e80c990a856 100644
--- a/gdb/testsuite/gdb.fortran/info-types.exp
+++ b/gdb/testsuite/gdb.fortran/info-types.exp
@@ -27,8 +27,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
return -1
}
-if { ![runto MAIN__] } {
- perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+ perror "Could not run to main."
continue
}
diff --git a/gdb/testsuite/gdb.fortran/intrinsics.exp b/gdb/testsuite/gdb.fortran/intrinsics.exp
index 504bce41388..2cb0237c955 100644
--- a/gdb/testsuite/gdb.fortran/intrinsics.exp
+++ b/gdb/testsuite/gdb.fortran/intrinsics.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
return -1
}
-if { ![runto MAIN__] } {
- perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+ perror "Could not run to main."
continue
}
diff --git a/gdb/testsuite/gdb.fortran/library-module.exp b/gdb/testsuite/gdb.fortran/library-module.exp
index f25988e32c8..8254fcf10a3 100644
--- a/gdb/testsuite/gdb.fortran/library-module.exp
+++ b/gdb/testsuite/gdb.fortran/library-module.exp
@@ -40,9 +40,10 @@ if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug f90
clean_restart $testfile
gdb_load_shlib $libfile
+load_lib fortran.exp
-if ![runto MAIN__] then {
- perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+ perror "couldn't run to main"
continue
}
diff --git a/gdb/testsuite/gdb.fortran/logical.exp b/gdb/testsuite/gdb.fortran/logical.exp
index 324714fa49e..161bbdd9081 100644
--- a/gdb/testsuite/gdb.fortran/logical.exp
+++ b/gdb/testsuite/gdb.fortran/logical.exp
@@ -16,13 +16,14 @@
# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
standard_testfile .f90
+load_lib fortran.exp
if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
return -1
}
-if { ![runto MAIN__] } {
- perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+ perror "Could not run to main."
continue
}
diff --git a/gdb/testsuite/gdb.fortran/max-depth.exp b/gdb/testsuite/gdb.fortran/max-depth.exp
index 262d0fdfa13..420b72539f8 100644
--- a/gdb/testsuite/gdb.fortran/max-depth.exp
+++ b/gdb/testsuite/gdb.fortran/max-depth.exp
@@ -26,8 +26,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
return -1
}
-if { ![runto MAIN__] } {
- perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+ perror "Could not run to main."
continue
}
diff --git a/gdb/testsuite/gdb.fortran/module.exp b/gdb/testsuite/gdb.fortran/module.exp
index 1c269e2fedf..4a8251c44c6 100644
--- a/gdb/testsuite/gdb.fortran/module.exp
+++ b/gdb/testsuite/gdb.fortran/module.exp
@@ -29,8 +29,8 @@ gdb_test "p modmany::var_i" " = 14" "stopped language detection"
gdb_test "print mod1::var_const" " = 20" "fully qualified name of DW_TAG_constant"
-if ![runto MAIN__] then {
- perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+ perror "couldn't run to main"
continue
}
@@ -123,7 +123,7 @@ complete "modmany::var" $modmany_list
# Breakpoint would work in language "c".
gdb_test "show language" {The current source language is "(auto; currently )?fortran".}
-# gcc-4.4.2: The main program is always MAIN__ in .symtab so "runto" above
+# gcc-4.4.2: The main program is always $fmain in .symtab so "runto" above
# works. But DWARF DW_TAG_subprogram contains the name specified by
# the "program" Fortran statement.
if [gdb_breakpoint "module"] {
diff --git a/gdb/testsuite/gdb.fortran/multi-dim.exp b/gdb/testsuite/gdb.fortran/multi-dim.exp
index 05590914df9..ef6c6da8bd5 100644
--- a/gdb/testsuite/gdb.fortran/multi-dim.exp
+++ b/gdb/testsuite/gdb.fortran/multi-dim.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug f90}
return -1
}
-if ![runto MAIN__] {
- perror "Couldn't run to MAIN__"
+if ![fortran_runto_main] {
+ perror "Couldn't run to main"
continue
}
diff --git a/gdb/testsuite/gdb.fortran/nested-funcs.exp b/gdb/testsuite/gdb.fortran/nested-funcs.exp
index e4fc02ffa55..9e0073d210e 100755
--- a/gdb/testsuite/gdb.fortran/nested-funcs.exp
+++ b/gdb/testsuite/gdb.fortran/nested-funcs.exp
@@ -25,8 +25,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
return -1
}
-if ![runto MAIN__] then {
- perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+ perror "couldn't run to main"
continue
}
diff --git a/gdb/testsuite/gdb.fortran/print-formatted.exp b/gdb/testsuite/gdb.fortran/print-formatted.exp
index 8c6529ce7f3..e71287724b1 100644
--- a/gdb/testsuite/gdb.fortran/print-formatted.exp
+++ b/gdb/testsuite/gdb.fortran/print-formatted.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
return -1
}
-if { ![runto MAIN__] } {
- fail "runto MAIN__"
+if { ![fortran_runto_main] } {
+ fail "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/print_type.exp b/gdb/testsuite/gdb.fortran/print_type.exp
index 7d5915390d5..fcedb9579a9 100755
--- a/gdb/testsuite/gdb.fortran/print_type.exp
+++ b/gdb/testsuite/gdb.fortran/print_type.exp
@@ -24,7 +24,7 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
return -1
}
-if ![runto_main] {
+if ![fortran_runto_main] {
untested "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp b/gdb/testsuite/gdb.fortran/printing-types.exp
index 2c88f9e003f..44fd93cc56a 100644
--- a/gdb/testsuite/gdb.fortran/printing-types.exp
+++ b/gdb/testsuite/gdb.fortran/printing-types.exp
@@ -16,13 +16,14 @@
if {[skip_fortran_tests]} { return -1 }
standard_testfile .f90
+load_lib fortran.exp
if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
return -1
}
-if {![runto MAIN__]} then {
- untested "could not run to breakpoint MAIN__"
+if {![fortran_runto_main]} then {
+ untested "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.exp b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
index 285e24e2cc7..209809a2922 100644
--- a/gdb/testsuite/gdb.fortran/ptr-indentation.exp
+++ b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
@@ -22,8 +22,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
return -1
}
-if {![runto MAIN__]} then {
- untested "couldn't run to breakpoint MAIN__"
+if {![fortran_runto_main]} then {
+ untested "couldn't run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
index d91e4bd48e6..8dc5f76d93a 100644
--- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
+++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
@@ -24,8 +24,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
return -1
}
-if ![runto MAIN__] then {
- perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+ perror "couldn't run to main"
continue
}
diff --git a/gdb/testsuite/gdb.fortran/subarray.exp b/gdb/testsuite/gdb.fortran/subarray.exp
index 5e3e8c38cb7..9ee5a9b3cb1 100644
--- a/gdb/testsuite/gdb.fortran/subarray.exp
+++ b/gdb/testsuite/gdb.fortran/subarray.exp
@@ -21,6 +21,7 @@
if { [skip_fortran_tests] } { return -1 }
standard_testfile .f
+load_lib fortran.exp
if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
return -1
@@ -31,8 +32,8 @@ gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
-if ![runto MAIN__] then {
- perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+ perror "couldn't run to main"
continue
}
diff --git a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
index 5d8585c2ee1..2ae0411cf12 100644
--- a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
+++ b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
@@ -14,13 +14,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
standard_testfile "vla.f90"
+load_lib fortran.exp
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
{debug f90 quiet}] } {
return -1
}
-if ![runto_main] {
+if ![fortran_runto_main] {
untested "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-datatypes.exp b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
index 2db9b3e1101..b69636f600c 100644
--- a/gdb/testsuite/gdb.fortran/vla-datatypes.exp
+++ b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
@@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
# check that all fortran standard datatypes will be
# handled correctly when using as VLA's
-if ![runto_main] {
+if ![fortran_runto_main] {
untested "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-history.exp b/gdb/testsuite/gdb.fortran/vla-history.exp
index 24bd945f4a2..3bf98db1970 100644
--- a/gdb/testsuite/gdb.fortran/vla-history.exp
+++ b/gdb/testsuite/gdb.fortran/vla-history.exp
@@ -14,13 +14,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
standard_testfile "vla.f90"
+load_lib fortran.exp
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
{debug f90 quiet}] } {
return -1
}
-if ![runto_main] {
+if ![fortran_runto_main] {
untested "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
index 24c7b458406..d3fa595bea5 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
@@ -14,13 +14,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
standard_testfile "vla.f90"
+load_lib fortran.exp
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
{debug f90 quiet}] } {
return -1
}
-if ![runto_main] {
+if ![fortran_runto_main] {
untested "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
index 09909e74b02..07a4a5fc2e9 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![runto_main] {
+if ![fortran_runto_main] {
untested "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp b/gdb/testsuite/gdb.fortran/vla-ptype.exp
index 22b2005317e..bbb81ea0c81 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![runto_main] {
+if ![fortran_runto_main] {
untested "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
index 8e7d36314e1..d26b8c60f80 100644
--- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
+++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
@@ -14,13 +14,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
standard_testfile "vla.f90"
+load_lib fortran.exp
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
{debug f90 quiet}] } {
return -1
}
-if ![runto_main] {
+if ![fortran_runto_main] {
untested "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp b/gdb/testsuite/gdb.fortran/vla-type.exp
index 6d885e78896..f007ea3a786 100755
--- a/gdb/testsuite/gdb.fortran/vla-type.exp
+++ b/gdb/testsuite/gdb.fortran/vla-type.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![runto_main] {
+if ![fortran_runto_main] {
untested "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
index ab61dde06fe..c3ed909a81e 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
@@ -14,13 +14,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
standard_testfile "vla-sub.f90"
+load_lib fortran.exp
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
{debug f90 quiet}] } {
return -1
}
-if ![runto_main] {
+if ![fortran_runto_main] {
untested "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
index afd992cee4e..403e411cc29 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
@@ -14,13 +14,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
standard_testfile "vla-sub.f90"
+load_lib fortran.exp
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
{debug f90 quiet}] } {
return -1
}
-if ![runto_main] {
+if ![fortran_runto_main] {
untested "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub.exp b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
index 3311f6befaa..fd923edf401 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
@@ -14,13 +14,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
standard_testfile "vla-sub.f90"
+load_lib fortran.exp
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
{debug f90 quiet}] } {
return -1
}
-if ![runto_main] {
+if ![fortran_runto_main] {
untested "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
index 5af17b570ce..9a727fc30a0 100644
--- a/gdb/testsuite/gdb.fortran/vla-value.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![runto_main] {
+if ![fortran_runto_main] {
untested "could not run to main"
return -1
}
@@ -129,8 +129,8 @@ gdb_test "print vla1(9, 9, 9)" "no such vector element \\\(vector not allocated\
# Try to assign VLA to user variable
clean_restart ${testfile}
-if ![runto MAIN__] then {
- perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+ perror "couldn't run to main"
continue
}
gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
diff --git a/gdb/testsuite/gdb.fortran/whatis_type.exp b/gdb/testsuite/gdb.fortran/whatis_type.exp
index 6a9cc0a81eb..4b0cbf9c28d 100644
--- a/gdb/testsuite/gdb.fortran/whatis_type.exp
+++ b/gdb/testsuite/gdb.fortran/whatis_type.exp
@@ -23,8 +23,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
return -1
}
-if ![runto MAIN__] {
- fail "run to MAIN__"
+if ![fortran_runto_main] {
+ fail "run to main"
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
index 8cfffa7c085..3af80a8e604 100644
--- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
@@ -36,7 +36,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
-mi_runto MAIN__
+mi_runto [fortran_main]
mi_create_varobj "array" "array" "create local variable array"
diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp
index 549ed657904..b9def7fa21e 100644
--- a/gdb/testsuite/lib/fortran.exp
+++ b/gdb/testsuite/lib/fortran.exp
@@ -126,3 +126,23 @@ proc fortran_character1 {} {
return "unknown"
}
}
+
+# Return name of the main procedure based on the compiler version.
+
+proc fortran_main {} {
+ if {[test_compiler_info {gcc-4-[012]-*}]
+ || [test_compiler_info {gcc-*}]
+ || [test_compiler_info {icc-*}]} {
+ return "MAIN__"
+ } elseif {[test_compiler_info {clang-*}]} {
+ return "MAIN_"
+ } else {
+ return "unknown"
+ }
+}
+
+# Fortran version of runto_main.
+
+proc fortran_runto_main { } {
+ return [runto [fortran_main]]
+}
diff --git a/gdb/top.c b/gdb/top.c
index 9fb9d5cb5c7..3589d6b6ce7 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -174,7 +174,7 @@ static const char *previous_repeat_arguments;
whatever) can issue its own commands and also send along commands
from the user, and have the user not notice that the user interface
is issuing commands too. */
-int server_command;
+bool server_command;
/* Timeout limit for response from target. */
diff --git a/gdb/top.h b/gdb/top.h
index 0cbb244c551..e98772a51e6 100644
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -281,7 +281,7 @@ extern void gdb_init (char *);
extern int source_line_number;
extern std::string source_file_name;
extern bool history_expansion_p;
-extern int server_command;
+extern bool server_command;
extern char *lim_at_start;
extern void gdb_add_history (const char *);
diff --git a/gdb/value.c b/gdb/value.c
index 7ea39af5551..aafbf0fc06b 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -2291,7 +2291,7 @@ set_internalvar (struct internalvar *var, struct value *val)
when accessing the value.
If we keep it, we would still refer to the origin value.
Remove the location property in case it exist. */
- remove_dyn_prop (DYN_PROP_DATA_LOCATION, value_type (new_data.value));
+ value_type (new_data.value)->remove_dyn_prop (DYN_PROP_DATA_LOCATION);
break;
}