From patchwork Fri Oct 10 17:14:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 3189 Received: (qmail 28901 invoked by alias); 10 Oct 2014 17:14:48 -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 28890 invoked by uid 89); 10 Oct 2014 17:14:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS 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, 10 Oct 2014 17:14:47 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9AHEjE5029573 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 10 Oct 2014 13:14:45 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9AHEh16021346; Fri, 10 Oct 2014 13:14:44 -0400 Message-ID: <54381402.1070301@redhat.com> Date: Fri, 10 Oct 2014 18:14:42 +0100 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 MIME-Version: 1.0 To: Ajit Kumar Agarwal , "gdb-patches@sourceware.org" CC: Vinod Kathail , Vidhumouli Hunsigida , Nagaraju Mekala Subject: Re: [PATCH] Microblaze: Reject invalid target descriptions. References: In-Reply-To: On 10/08/2014 12:36 PM, Ajit Kumar Agarwal wrote: > Hello Pedro: > > Please find the updated patch with the feedback incorporated. > > [Pedro]: Sure you do. Just hack your target or gdbserver to send a bogus description. > > Tested . Thank you. I've added a sentence to the commit log saying that then, and pushed the patch in, as below. From cc3afae25a4e37ed7a864a8f4eea1dc11b20d5fb Mon Sep 17 00:00:00 2001 From: Ajit Kumar Agarwal Date: Fri, 10 Oct 2014 18:07:06 +0100 Subject: [PATCH] Microblaze: Reject invalid target descriptions We currently validate the target description, but then forget to reject it if found invalid. Tested that incorrect descriptions are rejected and GDB warns about them. Tested the Microblaze Design with and without stack-protect registers. The gdb command "info registers" displayed the register correctly. If a stack protect design is not selected, only core registers are displayed. When the stack-protect registers are selected in the design, the core registers along with stack-protect registers are displayed. gdb/ 2014-10-10 Ajit Agarwal * microblaze-tdep.c (microblaze_gdbarch_init): If the description isn't valid, release the tdesc arch data and return NULL. --- gdb/ChangeLog | 5 +++++ gdb/microblaze-tdep.c | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f64bcc9..047413c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-10-10 Ajit Agarwal + + * microblaze-tdep.c (microblaze_gdbarch_init): If the description + isn't valid, release the tdesc arch data and return NULL. + 2014-10-10 Pedro Alves * linux-tdep.c: Include observer.h. diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c index 6a9f11f..f257b96 100644 --- a/gdb/microblaze-tdep.c +++ b/gdb/microblaze-tdep.c @@ -722,7 +722,13 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) MICROBLAZE_SHR_REGNUM, "rshr"); } - } + + if (!valid_p) + { + tdesc_data_cleanup (tdesc_data); + return NULL; + } + } /* Allocate space for the new architecture. */ tdep = XNEW (struct gdbarch_tdep);