From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 56374 invoked by alias); 25 Aug 2019 22:40:10 -0000 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 Received: (qmail 56363 invoked by uid 89); 25 Aug 2019 22:40:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=equally 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 ESMTP; Sun, 25 Aug 2019 22:40:08 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 74E0AC057E9A for ; Sun, 25 Aug 2019 22:40:07 +0000 (UTC) Received: from localhost (unused-10-15-17-196.yyz.redhat.com [10.15.17.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 480EC60920; Sun, 25 Aug 2019 22:40:05 +0000 (UTC) From: Sergio Durigan Junior To: Pedro Alves Cc: GDB Patches Subject: Re: [PATCH] Improve ptrace-error detection on Linux targets References: <20190819032918.3536-1-sergiodj@redhat.com> Date: Sun, 25 Aug 2019 22:40:00 -0000 In-Reply-To: (Pedro Alves's message of "Mon, 19 Aug 2019 19:26:21 +0100") Message-ID: <874l2450oq.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg00573.txt.bz2 On Monday, August 19 2019, Pedro Alves wrote: > Two comments on implementation, that I think apply > equally to the new version you're working on as well: Thanks for the review. I didn't reply before, but I used your suggestions in the next version. > #1 - A target method (target_ptrace_me_fail_reason) looks like the > wrong place to put this, to me. As I understand it, the core of > gdb isn't ever calling the target_ptrace_me_fail_reason. This is > all code that is implementation detail of the Linux target > implementation. > > I'd prefer some other way to address this. An idea would be to have > a function pointer in inf-ptrace.c that defaults to an implementation > that returns the empty string: > > // in inf-ptrace.c > > static std::string > default_inf_ptrace_me_fail_reason (int err) > { > return {}; > } > > std::string (*inf_ptrace_me_fail_reason) (int err) = default_inf_ptrace_me_fail_reason; > > // in inf-ptrace.h > > extern std::string (*inf_ptrace_me_fail_reason) (int err); > > And then in linux-nat.c:_initialize_linux_nat, you'd override the > implementation, like: > > std::string > linux_ptrace_me_fail_reason (int err) > { > ... > } > > void > _initialize_linux_nat () > { > ... > inf_ptrace_me_fail_reason = linux_ptrace_me_fail_reason; > } > > > Note I'm not suggesting anything with virtual methods before > of the next point. > > #2 - What about gdbserver? Don't we want the same nice error > messages in gdbserver? > > See gdbserver/linux-low.c:linux_ptrace_fun. > > This would suggest putting that linux_ptrace_me_fail_reason > function in gdb/nat/ so that it would be used by gdbserver too. Thanks. I followed both of your suggestions, and will submit a v2 soon. -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/