From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 109E33858410 for ; Mon, 20 Nov 2023 15:35:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 109E33858410 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 109E33858410 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:67c:2178:6::1d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700494558; cv=none; b=JQr4Mp+vEOrmg6rREdaDbDzmZYY19/HhTJI5dDWV0nxOcxqVxtHbN9E7qU7ueLcU6RghTOWQwxKm4Eqpa3ArmOsmjbYs8370NreZr3CeQQ4AO+NbuKgWECTdZU4XTnw8Nv863If9SgIIzqHrKC8kn/EE9IX5nByLJOIp77Ev4A0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700494558; c=relaxed/simple; bh=6QDcN5EwjhIz7tWPgcnQ0tTbDy55ocrf3AROxjhx4gM=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=DsYnzJ32F6iCW4Crnisd8XYRxMJC+WejEwTsFKTwjw/NpzR8neQcGBRmP3aTP9tW2EeWwf+HZ7O8zz5tPI4VT26aubuH33kb83X+U7HzZLyizDjmvqM+q2RcV2cyLbm75GgYndk4mh3qYcgM31K1Ty/bqRaKTPPy8g4R90W7l10= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E6C0A1F895 for ; Mon, 20 Nov 2023 15:35:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1700494556; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YIOYsqlf/333kIXVb+q2RKvtXfbvZuBenfXZ62irn2U=; b=xHsf0dAcmVkqVI5SFaBccTSpiPyoCn7E1Uu1gEx2YbChG9rHoQTIzufs1QBD0ShLrXUblm Ycf3dfP76PKYlWfE1CBclw7Xudk8jfAqctAt2PX/exhXZ0jxGOgUERqfCjVczwMsAz2UVA 6ytKVM1esxx90NfkR7YjkZX1SJmefkA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1700494556; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YIOYsqlf/333kIXVb+q2RKvtXfbvZuBenfXZ62irn2U=; b=NiYPp92A4EK4dRfxF7MPhzLVHVpUXiNdZs4a5girLrxo9jZA514URtLylUEmNtU72m7WOK 8HBuHY8TTwTsLUDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D9FD413912 for ; Mon, 20 Nov 2023 15:35:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UJoxNNt8W2WDTQAAMHmgww (envelope-from ) for ; Mon, 20 Nov 2023 15:35:55 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [RFC 2/3] [gdb/tdep] Add gdbarch_extended_event_to_syscall Date: Mon, 20 Nov 2023 16:37:48 +0100 Message-Id: <20231120153749.11072-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231120153749.11072-1-tdevries@suse.de> References: <20231120153749.11072-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: 0.70 X-Spamd-Result: default: False [0.70 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000]; TO_DN_NONE(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MID_CONTAINS_FROM(1.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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(+) diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index c64584c5760..27ed580b265 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -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 () diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h index e53950c4408..e41d31321a5 100644 --- a/gdb/arch-utils.h +++ b/gdb/arch-utils.h @@ -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 */ diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h index 9f468bd1f61..62ad52f5da8 100644 --- a/gdb/gdbarch-gen.h +++ b/gdb/gdbarch-gen.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); diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index ea6e4c647b1..f4661b8b4cd 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -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) { diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py index 694ac366023..0292c91d29f 100644 --- a/gdb/gdbarch_components.py +++ b/gdb/gdbarch_components.py @@ -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. -- 2.35.3