From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6187 invoked by alias); 3 Jan 2004 15:01:14 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 6179 invoked from network); 3 Jan 2004 15:01:11 -0000 Received: from unknown (HELO mwinf0402.wanadoo.fr) (193.252.22.27) by sources.redhat.com with SMTP; 3 Jan 2004 15:01:11 -0000 Received: from takamaka.act-europe.fr (AStDenis-103-1-2-242.w81-249.abo.wanadoo.fr [81.249.112.242]) by mwinf0402.wanadoo.fr (SMTP Server) with ESMTP id A95BB8000B4; Sat, 3 Jan 2004 16:01:10 +0100 (CET) Received: by takamaka.act-europe.fr (Postfix, from userid 507) id 8DA6A47D62; Sat, 3 Jan 2004 19:01:07 +0400 (RET) Date: Sat, 03 Jan 2004 15:01:00 -0000 From: Joel Brobecker To: Mark Kettenis Cc: ac131313@redhat.com, gdb-patches@sources.redhat.com Subject: [RFA] infrun.c:handle_inferior_event() tiny simplification (was "Re: [RFA/patch] handle_inferior_event() extract some code into a separate function") Message-ID: <20040103150107.GY820@gnat.com> References: <20031219144323.GL826@gnat.com> <3FF59C76.3000902@gnu.org> <20040103115203.GU820@gnat.com> <200401031251.i03CpAwn025849@elgar.kettenis.dyndns.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="iVCmgExH7+hIHJ1A" Content-Disposition: inline In-Reply-To: <200401031251.i03CpAwn025849@elgar.kettenis.dyndns.org> User-Agent: Mutt/1.4i X-SW-Source: 2004-01/txt/msg00052.txt.bz2 --iVCmgExH7+hIHJ1A Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 2134 > gcc -c -g -O2 ... -Werror /home/kettenis/sandbox/virgin-gdb/src/gdb/infrun.c > cc1: warnings being treated as errors > /home/kettenis/sandbox/virgin-gdb/src/gdb/infrun.c: In function `handle_inferior_event': > /home/kettenis/sandbox/virgin-gdb/src/gdb/infrun.c:1337: warning: `real_stop_pc' might be used uninitialized in this function Thanks to Mark, I looked closer to this variable. It turns out that this variable is very locally used in two blocks of the function, vis: void handle_inferior_event (struct execution_control_state *ecs) { [...] if ([test for subroutine call])\ { [...] real_stop_pc = skip_language_trampoline (stop_pc); if (real_stop_pc == 0) real_stop_pc = SKIP_TRAMPOLINE_CODE (stop_pc); if (real_stop_pc != 0) ecs->stop_func_start = real_stop_pc; [...] return; } [...] if (IN_SOLIB_RETURN_TRAMPOLINE (stop_pc, ecs->stop_func_name)) { /* Determine where this trampoline returns. */ real_stop_pc = SKIP_TRAMPOLINE_CODE (stop_pc); /* Only proceed through if we know where it's going. */ if (real_stop_pc) { [...] sr_sal.pc = real_stop_pc; [...] return; } } [...] } So the real mistake I made was to make real_stop_pc a parameter of the new function I introduced. It should have been a local variable to that function. Here is what I suggest: 1. A patch to makes it more obvious that this variable is only locally used by defining it only inside these if blocks. Patch attached. 2. Send an updated version of the patch I backed out where real_stop_pc is local variable to the new function, rather than a parameter (that was completely foolish since we don't even use the value that was passed and was not set in any case) Here is the first patch: 2004-01-03 J. Brobecker * infrun.c (handle_inferior_event): Move the declaration of real_stop_pc inside the if blocks where it is used. OK to apply? Tested on x86-linux with GCC 3.2.3, no warning, and no regression. -- Joel --iVCmgExH7+hIHJ1A Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="infrun.c.diff" Content-length: 1237 Index: infrun.c =================================================================== RCS file: /cvs/src/src/gdb/infrun.c,v retrieving revision 1.124 diff -u -p -r1.124 infrun.c --- infrun.c 3 Jan 2004 13:02:00 -0000 1.124 +++ infrun.c 3 Jan 2004 14:47:01 -0000 @@ -1244,7 +1244,6 @@ pc_in_sigtramp (CORE_ADDR pc) void handle_inferior_event (struct execution_control_state *ecs) { - CORE_ADDR real_stop_pc; /* NOTE: cagney/2003-03-28: If you're looking at this code and thinking that the variable stepped_after_stopped_by_watchpoint isn't used, then you're wrong! The macro STOPPED_BY_WATCHPOINT, @@ -2479,6 +2478,7 @@ process_event_stop_test: || ecs->stop_func_name == 0) { /* It's a subroutine call. */ + CORE_ADDR real_stop_pc; if ((step_over_calls == STEP_OVER_NONE) || ((step_range_end == 1) @@ -2582,7 +2582,7 @@ process_event_stop_test: if (IN_SOLIB_RETURN_TRAMPOLINE (stop_pc, ecs->stop_func_name)) { /* Determine where this trampoline returns. */ - real_stop_pc = SKIP_TRAMPOLINE_CODE (stop_pc); + CORE_ADDR real_stop_pc = SKIP_TRAMPOLINE_CODE (stop_pc); /* Only proceed through if we know where it's going. */ if (real_stop_pc) --iVCmgExH7+hIHJ1A--