event_location_up string_to_event_location_basic (const char **stringp, const struct language_defn *language, symbol_name_match_type match_type) { event_location_up location; const char *cs; /* Try the input as a probe spec. */ cs = *stringp; if (cs != NULL && probe_linespec_to_static_ops (&cs) != NULL) { location = new_probe_location (*stringp); *stringp += strlen (*stringp); } else { /* Try an address location. */ if (*stringp != NULL && **stringp == '*') { const char *arg, *orig; CORE_ADDR addr; orig = arg = *stringp; addr = linespec_expression_to_pc (&arg); location = new_address_location (addr, orig, arg - orig); *stringp += arg - orig; } else { /* Everything else is a linespec. */ location = new_linespec_location (stringp, match_type); } } return location; }
static SCM gdbscm_register_breakpoint_x (SCM self) { breakpoint_smob *bp_smob = bpscm_get_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct gdb_exception except = exception_none; char *location, *copy; struct event_location *eloc; struct cleanup *cleanup; /* We only support registering breakpoints created with make-breakpoint. */ if (!bp_smob->is_scheme_bkpt) scm_misc_error (FUNC_NAME, _("not a Scheme breakpoint"), SCM_EOL); if (bpscm_is_valid (bp_smob)) scm_misc_error (FUNC_NAME, _("breakpoint is already registered"), SCM_EOL); pending_breakpoint_scm = self; location = bp_smob->spec.location; copy = location; eloc = new_linespec_location (©); cleanup = make_cleanup_delete_event_location (eloc); TRY { int internal = bp_smob->spec.is_internal; switch (bp_smob->spec.type) { case bp_breakpoint: { create_breakpoint (get_current_arch (), eloc, NULL, -1, NULL, 0, 0, bp_breakpoint, 0, AUTO_BOOLEAN_TRUE, &bkpt_breakpoint_ops, 0, 1, internal, 0); break; } case bp_watchpoint: { enum target_hw_bp_type access_type = bp_smob->spec.access_type; if (access_type == hw_write) watch_command_wrapper (location, 0, internal); else if (access_type == hw_access) awatch_command_wrapper (location, 0, internal); else if (access_type == hw_read) rwatch_command_wrapper (location, 0, internal); else gdb_assert_not_reached ("invalid access type"); break; } default: gdb_assert_not_reached ("invalid breakpoint type"); } } CATCH (ex, RETURN_MASK_ALL) { except = ex; } END_CATCH /* Ensure this gets reset, even if there's an error. */ pending_breakpoint_scm = SCM_BOOL_F; GDBSCM_HANDLE_GDB_EXCEPTION (except); do_cleanups (cleanup); return SCM_UNSPECIFIED; }