+#undef INHERIT
+
+ /* Clean up a target struct so it no longer has any zero pointers in
+ it. Some entries are defaulted to a method that print an error,
+ others are hard-wired to a standard recursive default. */
+
+#define de_fault(field, value) \
+ if (!current_target.field) \
+ current_target.field = value
+
+ de_fault (to_open,
+ (void (*) (char *, int))
+ tcomplain);
+ de_fault (to_close,
+ (void (*) (int))
+ target_ignore);
+ de_fault (to_attach,
+ maybe_kill_then_attach);
+ de_fault (to_post_attach,
+ (void (*) (int))
+ target_ignore);
+ de_fault (to_detach,
+ (void (*) (char *, int))
+ target_ignore);
+ de_fault (to_resume,
+ (void (*) (ptid_t, int, enum target_signal))
+ noprocess);
+ de_fault (to_wait,
+ (ptid_t (*) (ptid_t, struct target_waitstatus *))
+ noprocess);
+ de_fault (to_fetch_registers,
+ (void (*) (int))
+ target_ignore);
+ de_fault (to_store_registers,
+ (void (*) (int))
+ noprocess);
+ de_fault (to_prepare_to_store,
+ (void (*) (void))
+ noprocess);
+ de_fault (deprecated_xfer_memory,
+ (int (*) (CORE_ADDR, gdb_byte *, int, int, struct mem_attrib *, struct target_ops *))
+ nomemory);
+ de_fault (to_files_info,
+ (void (*) (struct target_ops *))
+ target_ignore);
+ de_fault (to_insert_breakpoint,
+ memory_insert_breakpoint);
+ de_fault (to_remove_breakpoint,
+ memory_remove_breakpoint);
+ de_fault (to_can_use_hw_breakpoint,
+ (int (*) (int, int, int))
+ return_zero);
+ de_fault (to_insert_hw_breakpoint,
+ (int (*) (struct bp_target_info *))
+ return_minus_one);
+ de_fault (to_remove_hw_breakpoint,
+ (int (*) (struct bp_target_info *))
+ return_minus_one);
+ de_fault (to_insert_watchpoint,
+ (int (*) (CORE_ADDR, int, int))
+ return_minus_one);
+ de_fault (to_remove_watchpoint,
+ (int (*) (CORE_ADDR, int, int))
+ return_minus_one);
+ de_fault (to_stopped_by_watchpoint,
+ (int (*) (void))
+ return_zero);
+ de_fault (to_stopped_data_address,
+ (int (*) (struct target_ops *, CORE_ADDR *))
+ return_zero);
+ de_fault (to_region_ok_for_hw_watchpoint,
+ default_region_ok_for_hw_watchpoint);
+ de_fault (to_terminal_init,
+ (void (*) (void))
+ target_ignore);
+ de_fault (to_terminal_inferior,
+ (void (*) (void))
+ target_ignore);
+ de_fault (to_terminal_ours_for_output,
+ (void (*) (void))
+ target_ignore);
+ de_fault (to_terminal_ours,
+ (void (*) (void))
+ target_ignore);
+ de_fault (to_terminal_save_ours,
+ (void (*) (void))
+ target_ignore);
+ de_fault (to_terminal_info,
+ default_terminal_info);
+ de_fault (to_kill,
+ (void (*) (void))
+ noprocess);
+ de_fault (to_load,
+ (void (*) (char *, int))
+ tcomplain);
+ de_fault (to_lookup_symbol,
+ (int (*) (char *, CORE_ADDR *))
+ nosymbol);
+ de_fault (to_create_inferior,
+ maybe_kill_then_create_inferior);
+ de_fault (to_post_startup_inferior,
+ (void (*) (ptid_t))
+ target_ignore);
+ de_fault (to_acknowledge_created_inferior,
+ (void (*) (int))
+ target_ignore);
+ de_fault (to_insert_fork_catchpoint,
+ (void (*) (int))
+ tcomplain);
+ de_fault (to_remove_fork_catchpoint,
+ (int (*) (int))
+ tcomplain);
+ de_fault (to_insert_vfork_catchpoint,
+ (void (*) (int))
+ tcomplain);
+ de_fault (to_remove_vfork_catchpoint,
+ (int (*) (int))
+ tcomplain);
+ de_fault (to_insert_exec_catchpoint,
+ (void (*) (int))
+ tcomplain);
+ de_fault (to_remove_exec_catchpoint,
+ (int (*) (int))
+ tcomplain);
+ de_fault (to_reported_exec_events_per_exec_call,
+ (int (*) (void))
+ return_one);
+ de_fault (to_has_exited,
+ (int (*) (int, int, int *))
+ return_zero);
+ de_fault (to_mourn_inferior,
+ (void (*) (void))
+ noprocess);
+ de_fault (to_can_run,
+ return_zero);
+ de_fault (to_notice_signals,
+ (void (*) (ptid_t))
+ target_ignore);
+ de_fault (to_thread_alive,
+ (int (*) (ptid_t))
+ return_zero);
+ de_fault (to_find_new_threads,
+ (void (*) (void))
+ target_ignore);
+ de_fault (to_extra_thread_info,
+ (char *(*) (struct thread_info *))
+ return_zero);
+ de_fault (to_stop,
+ (void (*) (void))
+ target_ignore);
+ current_target.to_xfer_partial = current_xfer_partial;
+ de_fault (to_rcmd,
+ (void (*) (char *, struct ui_file *))
+ tcomplain);
+ de_fault (to_enable_exception_callback,
+ (struct symtab_and_line * (*) (enum exception_event_kind, int))
+ nosupport_runtime);
+ de_fault (to_get_current_exception_event,
+ (struct exception_event_record * (*) (void))
+ nosupport_runtime);
+ de_fault (to_pid_to_exec_file,
+ (char *(*) (int))
+ return_zero);
+ de_fault (to_can_async_p,
+ (int (*) (void))
+ return_zero);
+ de_fault (to_is_async_p,
+ (int (*) (void))
+ return_zero);
+ de_fault (to_async,
+ (void (*) (void (*) (enum inferior_event_type, void*), void*))
+ tcomplain);
+ current_target.to_read_description = NULL;
+#undef de_fault
+
+ /* Finally, position the target-stack beneath the squashed
+ "current_target". That way code looking for a non-inherited
+ target method can quickly and simply find it. */
+ current_target.beneath = target_stack;
+}
+
+/* Mark OPS as a running target. This reverses the effect
+ of target_mark_exited. */
+
+void
+target_mark_running (struct target_ops *ops)
+{
+ struct target_ops *t;
+
+ for (t = target_stack; t != NULL; t = t->beneath)
+ if (t == ops)
+ break;
+ if (t == NULL)
+ internal_error (__FILE__, __LINE__,
+ "Attempted to mark unpushed target \"%s\" as running",
+ ops->to_shortname);
+
+ ops->to_has_execution = 1;
+ ops->to_has_all_memory = 1;
+ ops->to_has_memory = 1;
+ ops->to_has_stack = 1;
+ ops->to_has_registers = 1;
+
+ update_current_target ();
+}
+
+/* Mark OPS as a non-running target. This reverses the effect
+ of target_mark_running. */
+
+void
+target_mark_exited (struct target_ops *ops)
+{
+ struct target_ops *t;
+
+ for (t = target_stack; t != NULL; t = t->beneath)
+ if (t == ops)
+ break;
+ if (t == NULL)
+ internal_error (__FILE__, __LINE__,
+ "Attempted to mark unpushed target \"%s\" as running",
+ ops->to_shortname);
+
+ ops->to_has_execution = 0;
+ ops->to_has_all_memory = 0;
+ ops->to_has_memory = 0;
+ ops->to_has_stack = 0;
+ ops->to_has_registers = 0;
+
+ update_current_target ();