From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 313 invoked by alias); 4 Jun 2012 16:26:26 -0000 Received: (qmail 32726 invoked by uid 22791); 4 Jun 2012 16:26:16 -0000 X-SWARE-Spam-Status: No, hits=-7.4 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,TW_EG,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 04 Jun 2012 16:25:59 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q54GPxei022172 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 4 Jun 2012 12:25:59 -0400 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q54GPvMb007059 for ; Mon, 4 Jun 2012 12:25:58 -0400 Subject: [PATCH 2/2] Make gdbarch_gdb_signal_from_target a method with predicate. To: gdb-patches@sourceware.org From: Pedro Alves Date: Mon, 04 Jun 2012 16:26:00 -0000 Message-ID: <20120604162557.11635.12396.stgit@brno.lan> In-Reply-To: <4FCCD900.3040102@redhat.com> References: <4FCCD900.3040102@redhat.com> User-Agent: StGit/0.16 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-06/txt/msg00085.txt.bz2 This makes gdb_signal_from_target a method with a predicate, with the intent being to remove the host signal translation fallback from the hook itself, and instead do it at the caller, which actually is already doing the fallback. This reinforces the "must be host independent" comment. Tested on x86_64 Fedora 16, and applied. 2012-06-04 Pedro Alves gdb/ * arch-utils.c (default_gdb_signal_from_target): Delete. * arch-utils.h (default_gdb_signal_from_target): Delete. * corelow.c (core_open) : Extended comment. Check gdbarch_gdb_signal_from_target_p. * gdbarch.sh (gdb_signal_from_target): Make it an M method (with predicate). * gdbarch.h: Regenerate. * gdbarch.c: Regenerate. --- gdb/arch-utils.c | 9 --------- gdb/arch-utils.h | 3 --- gdb/corelow.c | 13 +++++++++---- gdb/gdbarch.c | 15 ++++++++++++--- gdb/gdbarch.h | 5 +++-- gdb/gdbarch.sh | 5 ++--- 6 files changed, 26 insertions(+), 24 deletions(-) diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 98cf4b8..e683a2d 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -793,15 +793,6 @@ default_gen_return_address (struct gdbarch *gdbarch, error (_("This architecture has no method to collect a return address.")); } -enum gdb_signal -default_gdb_signal_from_target (struct gdbarch *gdbarch, int signo) -{ - /* Lacking a better mapping, assume host signal numbers. If - debugging a cross-core, most likely this translation will be - incorrect. */ - return gdb_signal_from_host (signo); -} - /* */ /* -Wmissing-prototypes */ diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h index ba71ec3..7c398b3 100644 --- a/gdb/arch-utils.h +++ b/gdb/arch-utils.h @@ -172,7 +172,4 @@ extern void default_gen_return_address (struct gdbarch *gdbarch, extern const char *default_auto_charset (void); extern const char *default_auto_wide_charset (void); -extern enum gdb_signal default_gdb_signal_from_target (struct gdbarch *, - int); - #endif diff --git a/gdb/corelow.c b/gdb/corelow.c index 8c3cd5c..dd62560 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -441,11 +441,16 @@ core_open (char *filename, int from_tty) if (siggy > 0) { /* If we don't have a CORE_GDBARCH to work with, assume a native - core. */ + core (map gdb_signal from host signals). If we do have + CORE_GDBARCH to work with, but no gdb_signal_from_target + implementation for that gdbarch, as a fallback measure, + assume the host signal mapping. It'll be correct for native + cores, but most likely incorrect for cross-cores. */ enum gdb_signal sig = (core_gdbarch != NULL - ? gdbarch_gdb_signal_from_target (core_gdbarch, - siggy) - : gdb_signal_from_host (siggy)); + && gdbarch_gdb_signal_from_target_p (core_gdbarch) + ? gdbarch_gdb_signal_from_target (core_gdbarch, + siggy) + : gdb_signal_from_host (siggy)); printf_filtered (_("Program terminated with signal %d, %s.\n"), siggy, gdb_signal_to_string (sig)); diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 3ebe835..9d7b67a 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -427,7 +427,7 @@ struct gdbarch startup_gdbarch = 0, /* sofun_address_maybe_missing */ 0, /* process_record */ 0, /* process_record_signal */ - default_gdb_signal_from_target, /* gdb_signal_from_target */ + 0, /* gdb_signal_from_target */ 0, /* get_siginfo_type */ 0, /* record_special_symbol */ 0, /* get_syscall_number */ @@ -536,7 +536,6 @@ gdbarch_alloc (const struct gdbarch_info *info, gdbarch->displaced_step_free_closure = NULL; gdbarch->displaced_step_location = NULL; gdbarch->relocate_instruction = NULL; - gdbarch->gdb_signal_from_target = default_gdb_signal_from_target; gdbarch->has_shared_address_space = default_has_shared_address_space; gdbarch->fast_tracepoint_valid_at = default_fast_tracepoint_valid_at; gdbarch->auto_charset = default_auto_charset; @@ -727,7 +726,7 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of sofun_address_maybe_missing, invalid_p == 0 */ /* Skip verify of process_record, has predicate. */ /* Skip verify of process_record_signal, has predicate. */ - /* Skip verify of gdb_signal_from_target, invalid_p == 0 */ + /* Skip verify of gdb_signal_from_target, has predicate. */ /* Skip verify of get_siginfo_type, has predicate. */ /* Skip verify of record_special_symbol, has predicate. */ /* Skip verify of get_syscall_number, has predicate. */ @@ -996,6 +995,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) "gdbarch_dump: gcore_bfd_target = %s\n", pstring (gdbarch->gcore_bfd_target)); fprintf_unfiltered (file, + "gdbarch_dump: gdbarch_gdb_signal_from_target_p() = %d\n", + gdbarch_gdb_signal_from_target_p (gdbarch)); + fprintf_unfiltered (file, "gdbarch_dump: gdb_signal_from_target = <%s>\n", host_address_to_string (gdbarch->gdb_signal_from_target)); fprintf_unfiltered (file, @@ -3787,6 +3789,13 @@ set_gdbarch_process_record_signal (struct gdbarch *gdbarch, gdbarch->process_record_signal = process_record_signal; } +int +gdbarch_gdb_signal_from_target_p (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + return gdbarch->gdb_signal_from_target != NULL; +} + enum gdb_signal gdbarch_gdb_signal_from_target (struct gdbarch *gdbarch, int signo) { diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index da449c2..e4e7abf 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -945,8 +945,9 @@ extern void set_gdbarch_process_record_signal (struct gdbarch *gdbarch, gdbarch_ header (the nm-*.h files), the host header, or similar headers. This is mainly used when cross-debugging core files --- "Live" targets hide the translation behind the target interface - (target_wait, target_resume, etc.). The default is to do the - translation using host signal numbers. */ + (target_wait, target_resume, etc.). */ + +extern int gdbarch_gdb_signal_from_target_p (struct gdbarch *gdbarch); typedef enum gdb_signal (gdbarch_gdb_signal_from_target_ftype) (struct gdbarch *gdbarch, int signo); extern enum gdb_signal gdbarch_gdb_signal_from_target (struct gdbarch *gdbarch, int signo); diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 5cefdab..0f58def 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -778,9 +778,8 @@ M:int:process_record_signal:struct regcache *regcache, enum gdb_signal signal:re # header (the nm-*.h files), the host header, or similar # headers. This is mainly used when cross-debugging core files --- # "Live" targets hide the translation behind the target interface -# (target_wait, target_resume, etc.). The default is to do the -# translation using host signal numbers. -m:enum gdb_signal:gdb_signal_from_target:int signo:signo::default_gdb_signal_from_target::0 +# (target_wait, target_resume, etc.). +M:enum gdb_signal:gdb_signal_from_target:int signo:signo # Extra signal info inspection. #