From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17479 invoked by alias); 10 Oct 2013 13:34:44 -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 17469 invoked by uid 89); 10 Oct 2013 13:34:44 -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,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_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 ESMTP; Thu, 10 Oct 2013 13:34:43 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9ADYdjc012603 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 10 Oct 2013 09:34:39 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r9ADYbte013420; Thu, 10 Oct 2013 09:34:38 -0400 Message-ID: <5256ACED.7040402@redhat.com> Date: Thu, 10 Oct 2013 13:34:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: "Abid, Hafiz" CC: "gdb-patches@sourceware.org" , "Mirza, Taimoor" Subject: Re: [patch] Disassembly improvements References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-10/txt/msg00343.txt.bz2 On 10/10/2013 02:14 PM, Abid, Hafiz wrote: > Hi Pedro, > I am attaching the patch that was mentioned in the following thread. I resurrected it from our internal repo, did a bit of manual testing and run the regression suite without any problem. It basically reads memory from the target in a buffer in gdb_disassembly and tries to use this buffer in dis_asm_read_memory instead of reading from the target. This saves us on repeated memory read calls. The problem was noted when eclipse was trying to fill its disassembly view. > https://sourceware.org/ml/gdb-patches/2013-10/msg00221.html Thanks. > + /* Assume the disassembler always read memory forwards. If we "always reads" > + failed to read a buffer line in a previous call, assume we're > + reading close to the end of a mapped page or section, and so it's > + useless to keep retrying reading that buffer line. Simply > + fallback to reading directly from target memory. */ Should be "retrying to read", I think. > + if (info->buffer_length > 0) > + { > + while (len) > + { > + if (memaddr >= info->buffer_vma > + && memaddr < info->buffer_vma + info->buffer_length) > + { > + unsigned int offset = (memaddr - info->buffer_vma); > + unsigned int l = min (len, info->buffer_length - offset); > + > + memcpy (myaddr, info->buffer + offset, l); > + > + memaddr += l; > + myaddr += l; > + len -= l; > + > + if (len == 0) > + return 0; > + } > + else > + { > + int rval; > + unsigned int len = info->buffer_length; > + > + /* Try fetching a new buffer line from the target. */ Hmm, this seems to miss making sure LEN doesn't read beyond the original requested memory range. It'd be good to add that. That "unsigned int len" variable shadows the function's "len" parameter. It'd be good to rename it. > + > + /* If we fail reading memory halfway, we'll have clobbered > + the buffer, so don't trust it anymore, even on fail. */ > + info->buffer_length = 0; > + rval = target_read_memory (memaddr, info->buffer, len); > + if (rval == 0) > + { > + info->buffer_vma = memaddr; > + info->buffer_length = len; > + } > + else > + { > + /* Read from target memory directly from now on. */ > + break; > + } > + } > + } > + } > return target_read_memory (memaddr, myaddr, len); > } -- Pedro Alves