From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14660 invoked by alias); 6 Mar 2011 14:56:20 -0000 Received: (qmail 14652 invoked by uid 22791); 6 Mar 2011 14:56:20 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO glazunov.sibelius.xs4all.nl) (83.163.83.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 06 Mar 2011 14:56:15 +0000 Received: from glazunov.sibelius.xs4all.nl (kettenis@localhost [127.0.0.1]) by glazunov.sibelius.xs4all.nl (8.14.3/8.14.3) with ESMTP id p26Etrtl026200; Sun, 6 Mar 2011 15:55:53 +0100 (CET) Received: (from kettenis@localhost) by glazunov.sibelius.xs4all.nl (8.14.3/8.14.3/Submit) id p26Etppr028003; Sun, 6 Mar 2011 15:55:51 +0100 (CET) Date: Sun, 06 Mar 2011 17:00:00 -0000 Message-Id: <201103061455.p26Etppr028003@glazunov.sibelius.xs4all.nl> From: Mark Kettenis To: jan.kratochvil@redhat.com CC: msnyder@vmware.com, gdb-patches@sourceware.org In-reply-to: <20110306141515.GA1895@host1.jankratochvil.net> (message from Jan Kratochvil on Sun, 6 Mar 2011 15:15:16 +0100) Subject: Re: [RFA] i386-tdep.c, check target_read_memory for error. References: <4D715BB0.8030506@vmware.com> <20110306141515.GA1895@host1.jankratochvil.net> 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 X-SW-Source: 2011-03/txt/msg00395.txt.bz2 > Date: Sun, 6 Mar 2011 15:15:16 +0100 > From: Jan Kratochvil > > On Fri, 04 Mar 2011 22:37:52 +0100, Michael Snyder wrote: > > Call error if target_read_memory fails. > [...] > > - target_read_memory (pc, &op, 1); > > + if (target_read_memory (pc, &op, 1)) > > + error (_("Couldn't read memory at pc (%s)"), > > + paddress (gdbarch, pc)); > > There is the function `read_memory' for such purpose. But read_memory() will throw an exception if reading fails. That is not necessarily what we want here. In fact, most of these reads should silently fail. They are part of the prologue analysis code, which to some of extent is based on heuristics. And one of the heristics here is that if we fail to read an instruction at a certain address, we're no longer looking at a function prologue. Higher level code will try an alternative strategy or issue an error message. Spamming the user with more error messages isn't going to be terribly helpful. But Michael is right that there is an issue here. The code is relying on uninitialized stack variables not matching the specific opcodes we check against. I think most of the: target_read_memory(pc, &op, 1); statements, should be replaced with if (target_read_memory(pc, &op, 1)) return pc; Cheers, Mark