From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 124607 invoked by alias); 13 Jun 2017 21:31:33 -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 123395 invoked by uid 89); 13 Jun 2017 21:31:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=HTo:D*synopsys.com X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 13 Jun 2017 21:31:30 +0000 Received: by simark.ca (Postfix, from userid 33) id D6CD21E4E8; Tue, 13 Jun 2017 17:31:33 -0400 (EDT) To: Anton Kolesov Subject: Re: [PATCH] arc: Select CPU model properly before disassembling X-PHP-Originating-Script: 33:rcube.php MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 13 Jun 2017 21:31:00 -0000 From: Simon Marchi Cc: gdb-patches@sourceware.org, Francois Bedard In-Reply-To: <39A54937CC95F24AA2F794E2D2B66B135874F238@DE02WEMBXB.internal.synopsys.com> References: <20170601160213.16092-1-Anton.Kolesov@synopsys.com> <64a77ae925bca53fed60b579642f07f8@polymtl.ca> <39A54937CC95F24AA2F794E2D2B66B135874F238@DE02WEMBXB.internal.synopsys.com> Message-ID: <85d6db352b9a796f92bb97af8cf32037@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.2.5 X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg00409.txt.bz2 On 2017-06-06 15:51, Anton Kolesov wrote: >> Could gdb_disassembler set the section field of disassemble_info >> itself? >> What you are doing to set the section field here is not >> ARC-specific, >> it looks like it could potentially help other architectures to have >> that >> field set. >> >> Other places that use the disassembler would have to set it too, for >> example in the object prepared by the arc_disassemble_info function. > > I think this info->section initialization code can be moved to > arch-utils.c:default_print_insn, however I'm not sure if that wouldn't > cause > any troubles with other architectures. I don't see why setting the section would cause a problem. If it does, I'd say it's more likely a bug in these other architectures code. You could argue that for architectures that don't have disassembler options, it would be some wasted cycles though... > Doing initialization in gdb_disassembler > constructor is complicated, because we don't really know what would be > the > disassembled address at this stage, hence what would be the section. > Gdb_dissassembler construction can use .text section as a default, but > then > might now work with some multi-arch ELFs, I presume (unlikely to be a > problem for ARC, though). That might be a good default behavior, to be overridden by the few architectures that have some more corner cases. > Another option is, of course, to partially revert [2] for ARC - make > arc_delayed_print_insn a printer for ARC, but change it, so it will > only > set info->section and then call default_print_insn. I believe that same > change > is needed in mep-tdep.c. At least for ARC we would need to use > print_insn > anyway to disassemble, because opcodes/arc-dis.c:arc_insn_decode relies > on it. That's fine with me. Simon