From patchwork Thu Aug 21 00:29:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Breazeal X-Patchwork-Id: 2473 Received: (qmail 6077 invoked by alias); 21 Aug 2014 00:35:27 -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 6053 invoked by uid 89); 21 Aug 2014 00:35:24 -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 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; Thu, 21 Aug 2014 00:35:23 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1XKGLY-0001jw-1Y from donb@codesourcery.com for gdb-patches@sourceware.org; Wed, 20 Aug 2014 17:35:20 -0700 Received: from SVR-ORW-FEM-04.mgc.mentorg.com ([147.34.97.41]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 20 Aug 2014 17:35:19 -0700 Received: from build4-lucid-cs (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.2.247.3; Wed, 20 Aug 2014 17:35:19 -0700 Received: by build4-lucid-cs (Postfix, from userid 1905) id 4C33240D74; Wed, 20 Aug 2014 17:35:18 -0700 (PDT) From: Don Breazeal To: Subject: [PATCH 14/16 v2] Suppress spurious warnings with extended-remote follow exec Date: Wed, 20 Aug 2014 17:29:22 -0700 Message-ID: <1408580964-27916-15-git-send-email-donb@codesourcery.com> In-Reply-To: <1407434395-19089-1-git-send-email-donb@codesourcery.com> References: <1407434395-19089-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 on an extended-remote Linux target. When gdbserver on Linux sets up the hook for shared library load detection, an initial step is to read the version number from the r_debug structure in memory. In the current implementation, if the version number is not equal to one, a warning was printed by gdbserver. However, the number can be zero if the structure has not been initialized yet. 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 x64 Ubuntu, both GDB tests and manual testing of following an exec, then debugging 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 gdb/gdbserver/ 2014-08-20 Don Breazeal * linux-low.c (linux_qxfer_libraries_svr4): Change handling of r_debug version mismatch. --- gdb/gdbserver/linux-low.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index f8bab6c..6be78a7 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -6226,10 +6226,15 @@ 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 read it in a subsequent pass + through here. */ + return -1; } else if (read_one_ptr (priv->r_debug + lmo->r_map_offset, &lm_addr, ptr_size) != 0)