aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r--gdb/breakpoint.c124
1 files changed, 71 insertions, 53 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 23e5051..bfcfc24 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -18,7 +18,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "arch-utils.h"
-#include <ctype.h>
#include "event-top.h"
#include "exceptions.h"
#include "gdbsupport/gdb_vecs.h"
@@ -50,7 +49,6 @@
#include "cli/cli-script.h"
#include "block.h"
#include "solib.h"
-#include "solist.h"
#include "observable.h"
#include "memattr.h"
#include "ada-lang.h"
@@ -255,14 +253,22 @@ DIAGNOSTIC_POP
static std::string
breakpoint_location_address_str (const bp_location *bl)
{
- std::string str = string_printf ("Breakpoint %d (%s) at address %s",
+ std::string str = string_printf ("Breakpoint %d (%s) ",
bl->owner->number,
- host_address_to_string (bl),
- paddress (bl->gdbarch, bl->address));
+ host_address_to_string (bl));
- std::string loc_string = bl->to_string ();
- if (!loc_string.empty ())
- str += string_printf (" %s", loc_string.c_str ());
+ if (bl_address_is_meaningful (bl))
+ {
+ gdb_assert (bl->gdbarch != nullptr);
+ str += string_printf ("at address %s",
+ paddress (bl->gdbarch, bl->address));
+
+ std::string loc_string = bl->to_string ();
+ if (!loc_string.empty ())
+ str += string_printf (" %s", loc_string.c_str ());
+ }
+ else
+ str += "with dummy location";
return str;
}
@@ -618,8 +624,8 @@ breakpoints_should_be_inserted_now (void)
/* Don't remove breakpoints yet if, even though all threads are
stopped, we still have events to process. */
- for (thread_info *tp : all_non_exited_threads ())
- if (tp->resumed () && tp->has_pending_waitstatus ())
+ for (thread_info &tp : all_non_exited_threads ())
+ if (tp.resumed () && tp.has_pending_waitstatus ())
return 1;
}
return 0;
@@ -717,11 +723,17 @@ all_breakpoints_safe ()
tracepoint_range
all_tracepoints ()
{
- return tracepoint_range (tracepoint_iterator (breakpoint_chain.begin ()),
- tracepoint_iterator (breakpoint_chain.end ()));
+ breakpoint_iterator begin (breakpoint_chain.begin ());
+ breakpoint_iterator end (breakpoint_chain.end ());
+ tracepoint_iterator tracepoint_begin (std::move (begin), end);
+ tracepoint_iterator tracepoint_end (end, end);
+
+ return tracepoint_range (std::move (tracepoint_begin),
+ std::move (tracepoint_end));
}
-/* Array is sorted by bp_location_is_less_than - primarily by the ADDRESS. */
+/* Array is sorted by bp_location_ptr_is_less_than - primarily by the
+ ADDRESS. */
static std::vector<bp_location *> bp_locations;
@@ -1280,7 +1292,7 @@ condition_completer (struct cmd_list_element *cmd,
{
tracker.advance_custom_word_point_by (1);
/* We don't support completion of history indices. */
- if (!isdigit (text[1]))
+ if (!c_isdigit (text[1]))
complete_internalvar (tracker, &text[1]);
return;
}
@@ -3657,13 +3669,13 @@ create_overlay_event_breakpoint (void)
{
const char *const func_name = "_ovly_debug_event";
- for (objfile *objfile : current_program_space->objfiles ())
+ for (objfile &objfile : current_program_space->objfiles ())
{
struct breakpoint *b;
struct breakpoint_objfile_data *bp_objfile_data;
CORE_ADDR addr;
- bp_objfile_data = get_breakpoint_objfile_data (objfile);
+ bp_objfile_data = get_breakpoint_objfile_data (&objfile);
if (msym_not_found_p (bp_objfile_data->overlay_msym.minsym))
continue;
@@ -3672,7 +3684,7 @@ create_overlay_event_breakpoint (void)
{
bound_minimal_symbol m
= lookup_minimal_symbol_text (current_program_space, func_name,
- objfile);
+ &objfile);
if (m.minsym == NULL)
{
/* Avoid future lookups in this objfile. */
@@ -3683,7 +3695,7 @@ create_overlay_event_breakpoint (void)
}
addr = bp_objfile_data->overlay_msym.value_address ();
- b = create_internal_breakpoint (objfile->arch (), addr,
+ b = create_internal_breakpoint (objfile.arch (), addr,
bp_overlay_event);
b->locspec = new_explicit_location_spec_function (func_name);
@@ -3808,19 +3820,19 @@ create_longjmp_master_breakpoint (void)
{
set_current_program_space (pspace);
- for (objfile *obj : pspace->objfiles ())
+ for (objfile &obj : pspace->objfiles ())
{
/* Skip separate debug object, it's handled in the loop below. */
- if (obj->separate_debug_objfile_backlink != nullptr)
+ if (obj.separate_debug_objfile_backlink != nullptr)
continue;
/* Try a probe kind breakpoint on main objfile. */
- if (create_longjmp_master_breakpoint_probe (obj))
+ if (create_longjmp_master_breakpoint_probe (&obj))
continue;
/* Try longjmp_names kind breakpoints on main and separate_debug
objfiles. */
- for (objfile *debug_objfile : obj->separate_debug_objfiles ())
+ for (objfile *debug_objfile : obj.separate_debug_objfiles ())
if (create_longjmp_master_breakpoint_names (debug_objfile))
break;
}
@@ -3840,12 +3852,12 @@ create_std_terminate_master_breakpoint (void)
{
set_current_program_space (pspace);
- for (objfile *objfile : pspace->objfiles ())
+ for (objfile &objfile : pspace->objfiles ())
{
struct breakpoint *b;
struct breakpoint_objfile_data *bp_objfile_data;
- 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;
@@ -3854,7 +3866,7 @@ create_std_terminate_master_breakpoint (void)
{
bound_minimal_symbol m
= lookup_minimal_symbol (current_program_space, func_name,
- objfile);
+ &objfile);
if (m.minsym == NULL || (m.minsym->type () != mst_text
&& m.minsym->type () != mst_file_text))
{
@@ -3865,7 +3877,7 @@ create_std_terminate_master_breakpoint (void)
bp_objfile_data->terminate_msym = m;
}
- b = create_internal_breakpoint (objfile->arch (),
+ b = create_internal_breakpoint (objfile.arch (),
bp_objfile_data->terminate_msym,
bp_std_terminate_master);
b->locspec = new_explicit_location_spec_function (func_name);
@@ -3969,19 +3981,19 @@ create_exception_master_breakpoint_hook (objfile *objfile)
static void
create_exception_master_breakpoint (void)
{
- for (objfile *obj : current_program_space->objfiles ())
+ for (objfile &obj : current_program_space->objfiles ())
{
/* Skip separate debug object. */
- if (obj->separate_debug_objfile_backlink)
+ if (obj.separate_debug_objfile_backlink)
continue;
/* Try a probe kind breakpoint. */
- if (create_exception_master_breakpoint_probe (obj))
+ if (create_exception_master_breakpoint_probe (&obj))
continue;
/* Iterate over main and separate debug objects and try an
_Unwind_DebugHook kind breakpoint. */
- for (objfile *debug_objfile : obj->separate_debug_objfiles ())
+ for (objfile *debug_objfile : obj.separate_debug_objfiles ())
if (create_exception_master_breakpoint_hook (debug_objfile))
break;
}
@@ -5136,7 +5148,7 @@ print_solib_event (bool is_catchpoint)
if (!first)
current_uiout->text (" ");
first = false;
- current_uiout->field_string ("library", iter->so_name);
+ current_uiout->field_string ("library", iter->name);
current_uiout->text ("\n");
}
}
@@ -7504,7 +7516,7 @@ breakpoint_locations_match (const struct bp_location *loc1,
else
/* We compare bp_location.length in order to cover ranged
breakpoints. Keep this in sync with
- bp_location_is_less_than. */
+ bp_location_ptr_is_less_than. */
return (breakpoint_address_match (loc1->pspace->aspace.get (),
loc1->address,
loc2->pspace->aspace.get (),
@@ -8144,7 +8156,7 @@ disable_breakpoints_in_unloaded_shlib (program_space *pspace, const solib &solib
target_terminal::ours_for_output ();
warning (_("Temporarily disabling breakpoints "
"for unloaded shared library \"%s\""),
- solib.so_name.c_str ());
+ solib.name.c_str ());
disabled_shlib_breaks = true;
}
}
@@ -10289,7 +10301,7 @@ masked_watchpoint::print_recreate (struct ui_file *fp) const
}
gdb_printf (fp, " %s mask 0x%s", exp_string.get (),
- phex (hw_wp_mask, sizeof (CORE_ADDR)));
+ phex (hw_wp_mask));
print_recreate_thread (fp);
}
@@ -10457,7 +10469,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
int len;
len = exp_end - exp_start;
- while (len > 0 && isspace (exp_start[len - 1]))
+ while (len > 0 && c_isspace (exp_start[len - 1]))
len--;
error (_("Cannot watch constant value `%.*s'."), len, exp_start);
}
@@ -11205,14 +11217,17 @@ breakpoint_auto_delete (bpstat *bs)
delete_breakpoint (&b);
}
-/* A comparison function for bp_location AP and BP being interfaced to
- std::sort. Sort elements primarily by their ADDRESS (no matter what
- bl_address_is_meaningful says), secondarily by ordering first
- permanent elements and tertiarily just ensuring the array is sorted
- stable way despite std::sort being an unstable algorithm. */
+/* A comparison function for bp_location pointers A and B being interfaced to
+ std::sort, for instance to sort an std::vector<bp_location *>. Sort
+ elements:
+ - primarily by their ADDRESS (no matter what bl_address_is_meaningful
+ says),
+ - secondarily by ordering first permanent elements, and
+ - tertiarily just ensuring the array is sorted in a stable way despite
+ std::sort being an unstable algorithm. */
-static int
-bp_location_is_less_than (const bp_location *a, const bp_location *b)
+static bool
+bp_location_ptr_is_less_than (const bp_location *a, const bp_location *b)
{
if (a->address != b->address)
return a->address < b->address;
@@ -11250,6 +11265,15 @@ bp_location_is_less_than (const bp_location *a, const bp_location *b)
return a < b;
}
+/* A comparison function for bp_locations A and B being interfaced to
+ std::sort, for instance to sort an std::vector<bp_location>. */
+
+static bool
+bp_location_is_less_than (const bp_location &a, const bp_location &b)
+{
+ return bp_location_ptr_is_less_than (&a, &b);
+}
+
/* Set bp_locations_placed_address_before_address_max and
bp_locations_shadow_len_after_address_max according to the current
content of the bp_locations array. */
@@ -11455,7 +11479,7 @@ update_global_location_list (enum ugll_insert_mode insert_mode)
handle_automatic_hardware_breakpoints (loc);
std::sort (bp_locations.begin (), bp_locations.end (),
- bp_location_is_less_than);
+ bp_location_ptr_is_less_than);
bp_locations_target_extensions_update ();
@@ -11903,9 +11927,7 @@ breakpoint::add_location (bp_location &loc)
auto ub = std::upper_bound (m_locations.begin (), m_locations.end (),
loc,
- [] (const bp_location &left,
- const bp_location &right)
- { return left.address < right.address; });
+ bp_location_is_less_than);
m_locations.insert (ub, loc);
}
@@ -13986,9 +14008,7 @@ int
insert_single_step_breakpoints (struct gdbarch *gdbarch)
{
regcache *regcache = get_thread_regcache (inferior_thread ());
- std::vector<CORE_ADDR> next_pcs;
-
- next_pcs = gdbarch_software_single_step (gdbarch, regcache);
+ std::vector<CORE_ADDR> next_pcs = gdbarch_get_next_pcs (gdbarch, regcache);
if (!next_pcs.empty ())
{
@@ -14095,7 +14115,7 @@ strace_command (const char *arg, int from_tty)
/* Decide if we are dealing with a static tracepoint marker (`-m'),
or with a normal static tracepoint. */
- if (arg && startswith (arg, "-m") && isspace (arg[2]))
+ if (arg && startswith (arg, "-m") && c_isspace (arg[2]))
{
ops = &strace_marker_breakpoint_ops;
locspec = new_linespec_location_spec (&arg,
@@ -14747,9 +14767,7 @@ static struct cmd_list_element *enablebreaklist = NULL;
cmd_list_element *commands_cmd_element = nullptr;
-void _initialize_breakpoint ();
-void
-_initialize_breakpoint ()
+INIT_GDB_FILE (breakpoint)
{
struct cmd_list_element *c;