From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31357 invoked by alias); 11 Oct 2013 16:45:17 -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 31341 invoked by uid 89); 11 Oct 2013 16:45:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 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; Fri, 11 Oct 2013 16:45:14 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1VUfpu-00076r-Ut from Hafiz_Abid@mentor.com ; Fri, 11 Oct 2013 09:45:10 -0700 Received: from SVR-IES-FEM-03.mgc.mentorg.com ([137.202.0.108]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 11 Oct 2013 09:45:11 -0700 Received: from EU-MBX-03.mgc.mentorg.com ([169.254.2.112]) by SVR-IES-FEM-03.mgc.mentorg.com ([137.202.0.108]) with mapi id 14.02.0247.003; Fri, 11 Oct 2013 17:45:09 +0100 From: "Abid, Hafiz" To: Pedro Alves CC: "gdb-patches@sourceware.org" , "Mirza, Taimoor" Subject: RE: [patch] Disassembly improvements Date: Fri, 11 Oct 2013 16:45:00 -0000 Message-ID: References: <5256ACED.7040402@redhat.com> <5256BF1B.9010202@redhat.com> <5256C41A.8020403@redhat.com> In-Reply-To: <5256C41A.8020403@redhat.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-SW-Source: 2013-10/txt/msg00390.txt.bz2 > > But it seems to me that will just disable the optimization for buffer > > line > 1. > > > > LEN here I think will the disassembler considers to be the maximum > > length of an instruction for the arquitecture it is disassembling. > > We want to read _more_ than that from memory in one go, otherwise, > > we'll not be buffering anything. What we do not want, is for that > > over fetching to read beyond the range that was passed to > gdb_disassembly. We come in the else case only if we have exhausted the initial buffer alloc= ated in gdb_disassembly. You are right that current code will read LEN bytes in = that case instead of reading the larger buffer but I think that should not be very co= mmon and we don't lose the optimization gained from the buffering for the first ' DI= S_BUF_SIZE' bytes. So I think this patch is useful on its own and the other enhancement= can be built on top of it. Also if user provides a range of address to the disassembly command then it= is possible that end address is in the middle of the instruction and gdb will end up reading= beyond the end address given in the command. So we probably cannot forbid that here anyway. (gdb) disassemble /r $pc,$pc+12 Dump of assembler code from 0x40292c to 0x402938: =3D> 0x000000000040292c : c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rb= p) 0x0000000000402933 : eb 78 jmp 0x4029ad 0x0000000000402935 : 8b 15 f5 18 20 00 mov 0x2018f5(%rip),%e= dx # 0x604230 As you can see gdb reading beyond 0x402938 here. > > I think we'll need to derive from "struct disassemble_info", and add > > the original range to that new struct, or record that info directly in > > "struct disassemble_info", which is in include/dis-asm.h. >=20 > I now noticed there's a struct disassemble_info->application_data field, > which GDB currently uses to put the gdbarch in. We could put a disasm.c > specific structure there instead. I noticed that this field is already being used in spu-tdep.c. Any changes to it will break that code. We can add new fields but as I described above, we may not want to check for the high address of the request. Thanks, Abid