From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119711 invoked by alias); 13 Feb 2017 18:33:04 -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 119702 invoked by uid 89); 13 Feb 2017 18:33:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=start_pc 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; Mon, 13 Feb 2017 18:33:02 +0000 Received: from svr-orw-mbx-03.mgc.mentorg.com ([147.34.90.203]) by relay1.mentorg.com with esmtp id 1cdLQr-0006lJ-25 from Luis_Gustavo@mentor.com ; Mon, 13 Feb 2017 10:33:01 -0800 Received: from [172.30.12.49] (147.34.91.1) by svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 13 Feb 2017 10:32:57 -0800 Subject: Re: [PATCH 1/3] gdb: xtensa: initialize isa in call0_ret References: <1484783438-13780-1-git-send-email-jcmvbkbc@gmail.com> <1484783438-13780-2-git-send-email-jcmvbkbc@gmail.com> To: Max Filippov , CC: Maxim Grigoriev , Woody LaRue , Marc Gauthier Reply-To: Luis Machado From: Luis Machado Message-ID: <771fb557-5364-2844-43c5-cec009d75e53@codesourcery.com> Date: Mon, 13 Feb 2017 18:33:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <1484783438-13780-2-git-send-email-jcmvbkbc@gmail.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) To svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) X-IsSubscribed: yes X-SW-Source: 2017-02/txt/msg00355.txt.bz2 On 01/18/2017 05:50 PM, Max Filippov wrote: > This fixes segfault in native gdb because isa is not initialized at the > point of call to xtensa_isa_maxlength. > > 2017-01-18 Max Filippov > gdb/ Drop gdb/ > diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c > index 978b13a..797e728 100644 > --- a/gdb/xtensa-tdep.c > +++ b/gdb/xtensa-tdep.c > @@ -2027,6 +2027,8 @@ call0_ret (CORE_ADDR start_pc, CORE_ADDR finish_pc) > const char *opcname; > int found_ret = 0; > > + if (!xtensa_default_isa) > + xtensa_default_isa = xtensa_isa_init (0, 0); > isa = xtensa_default_isa; > gdb_assert (XTENSA_ISA_BSZ >= xtensa_isa_maxlength (isa)); > ins = xtensa_insnbuf_alloc (isa); > I see a couple other uses of this construct for checking if a default isa is set or not. How about moving this check to a function that takes care of setting the default isa and returns this information to assign to "isa"?