+2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
+
+ Turn process_stratum_target's breakpoint_kind_from_pc,
+ sw_breakpoint_from_kind, and breakpoint_kind_from_current_state
+ ops into methods of process_target.
+
+ * target.h (struct process_stratum_target): Remove the target op.
+ (class process_target): Add the target op.
+ (target_breakpoint_kind_from_pc): Update the macro.
+ (target_breakpoint_kind_from_current_state): Update the macro.
+ (default_breakpoint_kind_from_pc): Remove declaration.
+ * target.cc (default_breakpoint_kind_from_pc): Turn into ...
+ (process_target::breakpoint_kind_from_pc): ... this.
+ (process_target::breakpoint_kind_from_current_state): Define.
+
+ Update the derived classes and callers below.
+
+ * mem-break.cc (bp_size): Update.
+ (bp_opcode): Update.
+ * linux-low.cc (linux_target_ops): Update.
+ (linux_wait_1): Update.
+ (linux_breakpoint_kind_from_pc): Turn into ...
+ (linux_process_target::breakpoint_kind_from_pc): ... this.
+ (linux_sw_breakpoint_from_kind): Turn into ...
+ (linux_process_target::sw_breakpoint_from_kind): ... this.
+ (linux_breakpoint_kind_from_current_state): Turn into ...
+ (linux_process_target::breakpoint_kind_from_current_state): ... this.
+ * linux-low.h (class linux_process_target): Update.
+ * lynx-low.cc (lynx_target_ops): Update.
+ (lynx_process_target::sw_breakpoint_from_kind): Define.
+ * lynx-low.h (class lynx_process_target): Update.
+ * nto-low.cc (nto_target_ops): Update.
+ (nto_sw_breakpoint_from_kind): Turn into ...
+ (nto_process_target::sw_breakpoint_from_kind): ... this.
+ * nto-low.h (class nto_process_target): Update.
+ * win32-low.cc (win32_target_ops): Update.
+ (win32_sw_breakpoint_from_kind): Turn into ...
+ (win32_process_target::sw_breakpoint_from_kind): ... this.
+ * win32-low.h (class win32_process_target): Update.
+
2020-02-20 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Turn process_stratum_target's multifs_open, multifs_readlink,
CORE_ADDR stop_pc = event_child->stop_pc;
breakpoint_kind =
- the_target->breakpoint_kind_from_current_state (&stop_pc);
- the_target->sw_breakpoint_from_kind (breakpoint_kind, &increment_pc);
+ the_target->pt->breakpoint_kind_from_current_state (&stop_pc);
+ the_target->pt->sw_breakpoint_from_kind (breakpoint_kind, &increment_pc);
if (debug_threads)
{
/* Implementation of the target_ops method "breakpoint_kind_from_pc". */
-static int
-linux_breakpoint_kind_from_pc (CORE_ADDR *pcptr)
+int
+linux_process_target::breakpoint_kind_from_pc (CORE_ADDR *pcptr)
{
if (the_low_target.breakpoint_kind_from_pc != NULL)
return (*the_low_target.breakpoint_kind_from_pc) (pcptr);
else
- return default_breakpoint_kind_from_pc (pcptr);
+ return process_target::breakpoint_kind_from_pc (pcptr);
}
/* Implementation of the target_ops method "sw_breakpoint_from_kind". */
-static const gdb_byte *
-linux_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+linux_process_target::sw_breakpoint_from_kind (int kind, int *size)
{
gdb_assert (the_low_target.sw_breakpoint_from_kind != NULL);
/* Implementation of the target_ops method
"breakpoint_kind_from_current_state". */
-static int
-linux_breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
+int
+linux_process_target::breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
{
if (the_low_target.breakpoint_kind_from_current_state != NULL)
return (*the_low_target.breakpoint_kind_from_current_state) (pcptr);
else
- return linux_breakpoint_kind_from_pc (pcptr);
+ return breakpoint_kind_from_pc (pcptr);
}
/* Default implementation of linux_target_ops method "set_pc" for
static linux_process_target the_linux_target;
static process_stratum_target linux_target_ops = {
- linux_breakpoint_kind_from_pc,
- linux_sw_breakpoint_from_kind,
linux_proc_tid_get_name,
- linux_breakpoint_kind_from_current_state,
linux_supports_software_single_step,
linux_supports_catch_syscall,
linux_get_ipa_tdesc_idx,
ssize_t multifs_readlink (int pid, const char *filename, char *buf,
size_t bufsiz) override;
+
+ int breakpoint_kind_from_pc (CORE_ADDR *pcptr) override;
+
+ const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
+ int breakpoint_kind_from_current_state (CORE_ADDR *pcptr) override;
};
#define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
return true;
}
+const gdb_byte *
+lynx_process_target::sw_breakpoint_from_kind (int kind, int *size)
+{
+ error (_("Target does not implement the sw_breakpoint_from_kind op"));
+}
+
/* The LynxOS target ops object. */
static lynx_process_target the_lynx_target;
/* The LynxOS target_ops vector. */
static process_stratum_target lynx_target_ops = {
- NULL, /* breakpoint_kind_from_pc */
- NULL, /* sw_breakpoint_from_kind */
NULL, /* thread_name */
- NULL, /* breakpoint_kind_from_current_state */
NULL, /* supports_software_single_step */
NULL, /* supports_catch_syscall */
NULL, /* get_ipa_tdesc_idx */
void request_interrupt () override;
bool supports_hardware_single_step () override;
+
+ const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
};
/* The inferior's target description. This is a global because the
{
int size = 0;
- the_target->sw_breakpoint_from_kind (bp->kind, &size);
+ the_target->pt->sw_breakpoint_from_kind (bp->kind, &size);
return size;
}
{
int size = 0;
- return the_target->sw_breakpoint_from_kind (bp->kind, &size);
+ return the_target->pt->sw_breakpoint_from_kind (bp->kind, &size);
}
/* See mem-break.h. */
/* Implementation of the target_ops method "sw_breakpoint_from_kind". */
-static const gdb_byte *
-nto_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+nto_process_target::sw_breakpoint_from_kind (int kind, int *size)
{
*size = the_low_target.breakpoint_len;
return the_low_target.breakpoint;
static nto_process_target the_nto_target;
static process_stratum_target nto_target_ops = {
- NULL, /* breakpoint_kind_from_pc */
- nto_sw_breakpoint_from_kind,
NULL, /* thread_name */
- NULL, /* breakpoint_kind_from_current_state */
NULL, /* supports_software_single_step */
NULL, /* supports_catch_syscall */
NULL, /* get_ipa_tdesc_idx */
bool stopped_by_watchpoint () override;
CORE_ADDR stopped_data_address () override;
+
+ const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
};
/* The inferior's target description. This is a global because the
return the_target->pt->kill (proc);
}
-/* Default implementation for breakpoint_kind_for_pc.
-
- The default behavior for targets that don't implement breakpoint_kind_for_pc
- is to use the size of a breakpoint as the kind. */
-
-int
-default_breakpoint_kind_from_pc (CORE_ADDR *pcptr)
-{
- int size = 0;
-
- gdb_assert (the_target->sw_breakpoint_from_kind != NULL);
-
- (*the_target->sw_breakpoint_from_kind) (0, &size);
- return size;
-}
-
/* Define it. */
target_terminal_state target_terminal::m_terminal_state
{
return readlink (filename, buf, bufsiz);
}
+
+int
+process_target::breakpoint_kind_from_pc (CORE_ADDR *pcptr)
+{
+ /* The default behavior is to use the size of a breakpoint as the
+ kind. */
+ int size = 0;
+ sw_breakpoint_from_kind (0, &size);
+ return size;
+}
+
+int
+process_target::breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
+{
+ return breakpoint_kind_from_pc (pcptr);
+}
shared code. */
struct process_stratum_target
{
- /* Return the breakpoint kind for this target based on PC. The PCPTR is
- adjusted to the real memory location in case a flag (e.g., the Thumb bit on
- ARM) was present in the PC. */
- int (*breakpoint_kind_from_pc) (CORE_ADDR *pcptr);
-
- /* Return the software breakpoint from KIND. KIND can have target
- specific meaning like the Z0 kind parameter.
- SIZE is set to the software breakpoint's length in memory. */
- const gdb_byte *(*sw_breakpoint_from_kind) (int kind, int *size);
-
/* Return the thread's name, or NULL if the target is unable to determine it.
The returned value must not be freed by the caller. */
const char *(*thread_name) (ptid_t thread);
- /* Return the breakpoint kind for this target based on the current
- processor state (e.g. the current instruction mode on ARM) and the
- PC. The PCPTR is adjusted to the real memory location in case a flag
- (e.g., the Thumb bit on ARM) is present in the PC. */
- int (*breakpoint_kind_from_current_state) (CORE_ADDR *pcptr);
-
/* Returns true if the target can software single step. */
int (*supports_software_single_step) (void);
not override this. The default behavior is to use readlink(2). */
virtual ssize_t multifs_readlink (int pid, const char *filename,
char *buf, size_t bufsiz);
+
+ /* Return the breakpoint kind for this target based on PC. The
+ PCPTR is adjusted to the real memory location in case a flag
+ (e.g., the Thumb bit on ARM) was present in the PC. */
+ virtual int breakpoint_kind_from_pc (CORE_ADDR *pcptr);
+
+ /* Return the software breakpoint from KIND. KIND can have target
+ specific meaning like the Z0 kind parameter.
+ SIZE is set to the software breakpoint's length in memory. */
+ virtual const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) = 0;
+
+ /* Return the breakpoint kind for this target based on the current
+ processor state (e.g. the current instruction mode on ARM) and the
+ PC. The PCPTR is adjusted to the real memory location in case a
+ flag (e.g., the Thumb bit on ARM) is present in the PC. */
+ virtual int breakpoint_kind_from_current_state (CORE_ADDR *pcptr);
};
extern process_stratum_target *the_target;
the_target->pt->stopped_by_hw_breakpoint ()
#define target_breakpoint_kind_from_pc(pcptr) \
- (the_target->breakpoint_kind_from_pc \
- ? (*the_target->breakpoint_kind_from_pc) (pcptr) \
- : default_breakpoint_kind_from_pc (pcptr))
+ the_target->pt->breakpoint_kind_from_pc (pcptr)
#define target_breakpoint_kind_from_current_state(pcptr) \
- (the_target->breakpoint_kind_from_current_state \
- ? (*the_target->breakpoint_kind_from_current_state) (pcptr) \
- : target_breakpoint_kind_from_pc (pcptr))
+ the_target->pt->breakpoint_kind_from_current_state (pcptr)
#define target_supports_software_single_step() \
(the_target->supports_software_single_step ? \
const char *target_pid_to_str (ptid_t);
-int default_breakpoint_kind_from_pc (CORE_ADDR *pcptr);
-
#endif /* GDBSERVER_TARGET_H */
/* Implementation of the target_ops method "sw_breakpoint_from_kind". */
-static const gdb_byte *
-win32_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+win32_process_target::sw_breakpoint_from_kind (int kind, int *size)
{
*size = the_low_target.breakpoint_len;
return the_low_target.breakpoint;
static win32_process_target the_win32_target;
static process_stratum_target win32_target_ops = {
- NULL, /* breakpoint_kind_from_pc */
- win32_sw_breakpoint_from_kind,
NULL, /* thread_name */
- NULL, /* breakpoint_kind_from_current_state */
NULL, /* supports_software_single_step */
NULL, /* supports_catch_syscall */
NULL, /* get_ipa_tdesc_idx */
bool supports_get_tib_address () override;
int get_tib_address (ptid_t ptid, CORE_ADDR *addr) override;
+
+ const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
};
/* Retrieve the context for this thread, if not already retrieved. */