From patchwork Fri Mar 6 22:04:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Durigan Junior X-Patchwork-Id: 5508 Received: (qmail 90575 invoked by alias); 6 Mar 2015 22:04:41 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 90564 invoked by uid 89); 6 Mar 2015 22:04:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 06 Mar 2015 22:04:39 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t26M4aVa032284 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 6 Mar 2015 17:04:36 -0500 Received: from localhost (dhcp-10-15-16-169.yyz.redhat.com [10.15.16.169]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t26M4ZMp023350 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Fri, 6 Mar 2015 17:04:36 -0500 From: Sergio Durigan Junior To: Yao Qi Cc: Pedro Alves , gdb-patches@sourceware.org Subject: Re: [RFC] Support command "catch syscall" properly on different targets References: <1425047015-1906-1-git-send-email-qiyaoltc@gmail.com> <877fv3kqx1.fsf@redhat.com> <86lhjei8md.fsf@gmail.com> <54F5A90E.8050704@redhat.com> <87bnkaklbe.fsf@redhat.com> <868ufahylt.fsf@gmail.com> X-URL: http://blog.sergiodj.net Date: Fri, 06 Mar 2015 17:04:35 -0500 Message-ID: <87lhj9zsss.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes On Friday, March 06 2015, Yao Qi wrote: > In my patch, "catch syscall" command is allowed on the target which > supports catch syscall. On exec target, GDB will error on command > "catch syscall", so it causes regressions in catch-syscall.exp. Hey Yao, So, as I said in my previous messages, I don't think that making the "catch syscall" command to fail on the exec target. What do you think of the attached patch (applies on top of your patch, rebased to the current HEAD)? It implements what I proposed, but in a different way. If the target is "None" (no binary loaded) or "exec" (inferior loaded but never started), then it displays a warning but still creates the catchpoint. The actual check for these targets happens in the insert_catch_syscall function, which is called when we already know if the target actually supports the syscall catchpoint. Maybe I forgot to cover some corner case, but I still think we should support "catch syscall" when no inferior has been started. > The proc test_catch_syscall_multi_arch in catch-syscall.exp tests > syscall number is mapped to different syscall number on different > gdbarch, but it has: > > # We are not interested in loading any binary here, and in > # some systems (PowerPC, for example), if we load a binary > # there is no way to set other architecture. > > As you mentioned in > https://sourceware.org/bugzilla/show_bug.cgi?id=10737#c4 , when GDB > starts an inferior, the arch is set correspondingly, so it is unable > reproduce the bug. test_catch_syscall_multi_arch is the simpler > reproducer, IMO. How about 'upgrade' test_catch_syscall_multi_arch like > this? > > - file 32-bit program > - run to main > - catch syscall 5 > - kill > - file 64-bit program > - run to main > - catch syscall 5 It would work (though, by testing this on PPC64, I still see the strange warnings about changing to an unknown architecture, even after compiling with targets=all). With the attached patch, we would only need to expect the message saying that the syscall catchpoint may not be supported in the target, and still would not need a binary to perform the test. WDYT? Index: binutils-gdb/gdb/breakpoint.c =================================================================== --- binutils-gdb.orig/gdb/breakpoint.c +++ binutils-gdb/gdb/breakpoint.c @@ -8517,6 +8517,15 @@ insert_catch_syscall (struct bp_location struct catch_syscall_inferior_data *inf_data = get_catch_syscall_inferior_data (inf); + /* Checking if the target supports 'catch syscall'. Here we should + already know the definitive answer. */ + if (!target_supports_syscall_catchpoint (get_current_arch ())) + { + warning (_("The feature 'catch syscall' is not supported on \ +this target.")); + return 1; + } + ++inf_data->total_syscalls_count; if (!c->syscalls_to_be_caught) ++inf_data->any_syscall_count; @@ -12168,8 +12177,20 @@ catch_syscall_command_1 (char *arg, int /* Checking if the feature if supported. */ if (!target_supports_syscall_catchpoint (gdbarch)) - error (_("The feature 'catch syscall' is not supported on \ + { + /* If our target is "None" (i.e., no binary loaded), or "exec" + (i.e., binary has been loaded, but the inferior has not been + started yet), then we still have no way to know if our target + supports syscall catchpoints. Therefore, we just warn the + user, but keep going. */ + if (strcmp (target_shortname, "None") == 0 + || strcmp (target_shortname, "exec") == 0) + warning (_("The feature 'catch syscall' may not be supported \ +on this target.")); + else + error (_("The feature 'catch syscall' is not supported on \ this target yet.")); + } tempflag = get_cmd_context (command) == CATCH_TEMPORARY;