From patchwork Wed Jul 15 21:49:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Breazeal X-Patchwork-Id: 7710 Received: (qmail 21181 invoked by alias); 15 Jul 2015 21:51:08 -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 21169 invoked by uid 89); 15 Jul 2015 21:51:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 15 Jul 2015 21:51:06 +0000 Received: from svr-orw-fem-06.mgc.mentorg.com ([147.34.97.120]) by relay1.mentorg.com with esmtp id 1ZFUZz-0000oB-K7 from Don_Breazeal@mentor.com ; Wed, 15 Jul 2015 14:51:03 -0700 Received: from build4-lucid-cs (147.34.91.1) by SVR-ORW-FEM-06.mgc.mentorg.com (147.34.97.120) with Microsoft SMTP Server id 14.3.224.2; Wed, 15 Jul 2015 14:51:03 -0700 Received: by build4-lucid-cs (Postfix, from userid 1905) id E932A40F0A; Wed, 15 Jul 2015 14:51:03 -0700 (PDT) From: Don Breazeal To: , Subject: [PATCH 4/5] Eliminate spurious warnings from remote exec Date: Wed, 15 Jul 2015 14:49:38 -0700 Message-ID: <1436996979-32350-5-git-send-email-donb@codesourcery.com> In-Reply-To: <1436996979-32350-1-git-send-email-donb@codesourcery.com> References: <1436996979-32350-1-git-send-email-donb@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes This patch eliminates some spurious gdbserver warnings that occur when following an exec event on extended-remote Linux targets. When gdbserver on Linux sets up the hook for shared library load detection, an initial step is to read the version number field of the r_debug structure from memory. In the current implementation, if the version number is not equal to one, a warning is printed by gdbserver. However, the number can be zero if the structure has not been initialized yet. This seems to happen most of the time after an exec. To suppress the warnings the error check was changed so that if the version number is not equal to one the function silently returns -1. Subsequent calls to the routine find an initialized r_debug structure. Tested on x86_64 GNU/Linux, both GDB tests and manual testing which followed an exec, then debugged a shared library loaded by the exec'd program to ensure that there were no warnings and that debugging shared libs was not adversely affected. Thanks --Don 2015-07-15 Don Breazeal * gdb/gdbserver/linux-low.c (linux_qxfer_libraries_svr4): Return silently on r_debug version error instead of printing a warning. --- gdb/gdbserver/linux-low.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 47d8bc3..37eceb5 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -6421,10 +6421,16 @@ linux_qxfer_libraries_svr4 (const char *annex, unsigned char *readbuf, { if (linux_read_memory (priv->r_debug + lmo->r_version_offset, (unsigned char *) &r_version, - sizeof (r_version)) != 0 - || r_version != 1) + sizeof (r_version)) != 0) + warning ("error reading r_debug version from memory"); + else if (r_version != 1) { - warning ("unexpected r_debug version %d", r_version); + /* If the version is incorrect, it probably means that + r_debug hasn't been initialized yet. Just silently + return an error. We will try again in a subsequent + pass through here, e.g. at the next library load + event. */ + return -1; } else if (read_one_ptr (priv->r_debug + lmo->r_map_offset, &lm_addr, ptr_size) != 0)