Add a new gdbarch hook, that translates ptrace events like PTRACE_EVENT_EXEC
into the system call number that triggers the event.
No implementation and no use of the hook yet, this will be added in the
following patch.
---
gdb/arch-utils.c | 8 ++++++++
gdb/arch-utils.h | 3 +++
gdb/gdbarch-gen.h | 7 +++++++
gdb/gdbarch.c | 22 ++++++++++++++++++++++
gdb/gdbarch_components.py | 12 ++++++++++++
5 files changed, 52 insertions(+)
@@ -1492,6 +1492,14 @@ gdbarch_initialized_p (gdbarch *arch)
return arch->initialized_p;
}
+/* See arch-utils.h. */
+
+int
+default_extended_event_to_syscall (struct gdbarch *, int)
+{
+ return -1;
+}
+
void _initialize_gdbarch_utils ();
void
_initialize_gdbarch_utils ()
@@ -325,4 +325,7 @@ extern enum return_value_convention default_gdbarch_return_value
struct regcache *regcache, struct value **read_value,
const gdb_byte *writebuf);
+/* Default implementation of gdbarch extended_event_to_syscall method. */
+extern int default_extended_event_to_syscall (struct gdbarch *, int);
+
#endif /* ARCH_UTILS_H */
@@ -1283,6 +1283,13 @@ typedef LONGEST (gdbarch_get_syscall_number_ftype) (struct gdbarch *gdbarch, thr
extern LONGEST gdbarch_get_syscall_number (struct gdbarch *gdbarch, thread_info *thread);
extern void set_gdbarch_get_syscall_number (struct gdbarch *gdbarch, gdbarch_get_syscall_number_ftype *get_syscall_number);
+/* Function for the 'catch syscall' feature.
+ Translate extended wait event to architecture-specific system call number. */
+
+typedef int (gdbarch_extended_event_to_syscall_ftype) (struct gdbarch *gdbarch, int event);
+extern int gdbarch_extended_event_to_syscall (struct gdbarch *gdbarch, int event);
+extern void set_gdbarch_extended_event_to_syscall (struct gdbarch *gdbarch, gdbarch_extended_event_to_syscall_ftype *extended_event_to_syscall);
+
/* The filename of the XML syscall for this architecture. */
extern const char * gdbarch_xml_syscall_file (struct gdbarch *gdbarch);
@@ -207,6 +207,7 @@ struct gdbarch
gdbarch_get_siginfo_type_ftype *get_siginfo_type = nullptr;
gdbarch_record_special_symbol_ftype *record_special_symbol = nullptr;
gdbarch_get_syscall_number_ftype *get_syscall_number = nullptr;
+ gdbarch_extended_event_to_syscall_ftype *extended_event_to_syscall = default_extended_event_to_syscall;
const char * xml_syscall_file = 0;
struct syscalls_info * syscalls_info = 0;
const char *const * stap_integer_prefixes = 0;
@@ -475,6 +476,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of get_siginfo_type, has predicate. */
/* Skip verify of record_special_symbol, has predicate. */
/* Skip verify of get_syscall_number, has predicate. */
+ /* Skip verify of extended_event_to_syscall, invalid_p == 0 */
/* Skip verify of xml_syscall_file, invalid_p == 0 */
/* Skip verify of syscalls_info, invalid_p == 0 */
/* Skip verify of stap_integer_prefixes, invalid_p == 0 */
@@ -1198,6 +1200,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
gdb_printf (file,
"gdbarch_dump: get_syscall_number = <%s>\n",
host_address_to_string (gdbarch->get_syscall_number));
+ gdb_printf (file,
+ "gdbarch_dump: extended_event_to_syscall = <%s>\n",
+ host_address_to_string (gdbarch->extended_event_to_syscall));
gdb_printf (file,
"gdbarch_dump: xml_syscall_file = %s\n",
pstring (gdbarch->xml_syscall_file));
@@ -4512,6 +4517,23 @@ set_gdbarch_get_syscall_number (struct gdbarch *gdbarch,
gdbarch->get_syscall_number = get_syscall_number;
}
+int
+gdbarch_extended_event_to_syscall (struct gdbarch *gdbarch, int event)
+{
+ gdb_assert (gdbarch != NULL);
+ gdb_assert (gdbarch->extended_event_to_syscall != NULL);
+ if (gdbarch_debug >= 2)
+ gdb_printf (gdb_stdlog, "gdbarch_extended_event_to_syscall called\n");
+ return gdbarch->extended_event_to_syscall (gdbarch, event);
+}
+
+void
+set_gdbarch_extended_event_to_syscall (struct gdbarch *gdbarch,
+ gdbarch_extended_event_to_syscall_ftype extended_event_to_syscall)
+{
+ gdbarch->extended_event_to_syscall = extended_event_to_syscall;
+}
+
const char *
gdbarch_xml_syscall_file (struct gdbarch *gdbarch)
{
@@ -2064,6 +2064,18 @@ Get architecture-specific system calls information from registers.
predicate=True,
)
+Method(
+ comment="""
+Function for the 'catch syscall' feature.
+Translate extended wait event to architecture-specific system call number.
+""",
+ type="int",
+ name="extended_event_to_syscall",
+ params=[("int", "event")],
+ predefault="default_extended_event_to_syscall",
+ invalid=False,
+)
+
Value(
comment="""
The filename of the XML syscall for this architecture.