From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31972 invoked by alias); 20 Jul 2009 02:31:50 -0000 Received: (qmail 31960 invoked by uid 22791); 20 Jul 2009 02:31:49 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from smtp-outbound-1.vmware.com (HELO smtp-outbound-1.vmware.com) (65.115.85.69) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 20 Jul 2009 02:31:42 +0000 Received: from mailhost4.vmware.com (mailhost4.vmware.com [10.16.67.124]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id A6B7513011 for ; Sun, 19 Jul 2009 19:31:39 -0700 (PDT) Received: from [10.20.94.141] (msnyder-server.eng.vmware.com [10.20.94.141]) by mailhost4.vmware.com (Postfix) with ESMTP id 9A603C9DE4 for ; Sun, 19 Jul 2009 19:31:39 -0700 (PDT) Message-ID: <4A63D5B4.8090505@vmware.com> Date: Mon, 20 Jul 2009 06:13:00 -0000 From: Michael Snyder User-Agent: Thunderbird 1.5.0.12 (X11/20080411) MIME-Version: 1.0 To: "gdb-patches@sourceware.org" Subject: [RFA] clean up temp sals in handle_inferior_event Content-Type: multipart/mixed; boundary="------------070804010308050100030507" X-IsSubscribed: yes 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: 2009-07/txt/msg00463.txt.bz2 This is a multi-part message in MIME format. --------------070804010308050100030507 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 477 Almost obvious, but I'll play it conservative. ;-) There were seven, and now eight, places in handle_inferior_event where a local struct symtab_and_line is declared and used briefly. One of them even opens and closes a block just for this purpose. This patch merges those all into a single local temp variable. They all initialize it, and all but one of them returns after using it, so they can't interact. Plus I ran the testsuites with no regressions. OK to check in? --------------070804010308050100030507 Content-Type: text/plain; name="tmp-sal.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="tmp-sal.txt" Content-length: 6943 2009-07-19 Michael Snyder * infrun.c (handle_inferior_event): Clean up local tmp variables. Index: infrun.c =================================================================== RCS file: /cvs/src/src/gdb/infrun.c,v retrieving revision 1.401 diff -u -p -r1.401 infrun.c --- infrun.c 18 Jul 2009 23:35:31 -0000 1.401 +++ infrun.c 20 Jul 2009 02:21:49 -0000 @@ -2383,7 +2383,7 @@ handle_inferior_event (struct execution_ int sw_single_step_trap_p = 0; int stopped_by_watchpoint; int stepped_after_stopped_by_watchpoint = 0; - struct symtab_and_line stop_pc_sal; + struct symtab_and_line stop_pc_sal, tmp_sal; enum stop_kind stop_soon; if (ecs->ws.kind != TARGET_WAITKIND_EXITED @@ -3738,12 +3738,11 @@ infrun: not switching back to stepped th { /* Set up a step-resume breakpoint at the address indicated by SKIP_SOLIB_RESOLVER. */ - struct symtab_and_line sr_sal; - init_sal (&sr_sal); - sr_sal.pc = pc_after_resolver; + init_sal (&tmp_sal); + tmp_sal.pc = pc_after_resolver; insert_step_resume_breakpoint_at_sal (gdbarch, - sr_sal, null_frame_id); + tmp_sal, null_frame_id); } keep_going (ecs); @@ -3834,13 +3833,11 @@ infrun: not switching back to stepped th if (execution_direction == EXEC_REVERSE) { - struct symtab_and_line sr_sal; - /* Normal function call return (static or dynamic). */ - init_sal (&sr_sal); - sr_sal.pc = ecs->stop_func_start; - insert_step_resume_breakpoint_at_sal (gdbarch, - sr_sal, null_frame_id); + init_sal (&tmp_sal); + tmp_sal.pc = ecs->stop_func_start; + insert_step_resume_breakpoint_at_sal (gdbarch, + tmp_sal, null_frame_id); } else insert_step_resume_breakpoint_at_caller (frame); @@ -3862,12 +3859,11 @@ infrun: not switching back to stepped th if (real_stop_pc != 0 && in_solib_dynsym_resolve_code (real_stop_pc)) { - struct symtab_and_line sr_sal; - init_sal (&sr_sal); - sr_sal.pc = ecs->stop_func_start; + init_sal (&tmp_sal); + tmp_sal.pc = ecs->stop_func_start; insert_step_resume_breakpoint_at_sal (gdbarch, - sr_sal, null_frame_id); + tmp_sal, null_frame_id); keep_going (ecs); return; } @@ -3878,19 +3874,15 @@ infrun: not switching back to stepped th If there are several symtabs at that PC (e.g. with include files), just want to know whether *any* of them have line numbers. find_pc_line handles this. */ - { - struct symtab_and_line tmp_sal; - - tmp_sal = find_pc_line (ecs->stop_func_start, 0); - if (tmp_sal.line != 0) - { - if (execution_direction == EXEC_REVERSE) - handle_step_into_function_backward (gdbarch, ecs); - else - handle_step_into_function (gdbarch, ecs); - return; - } - } + tmp_sal = find_pc_line (ecs->stop_func_start, 0); + if (tmp_sal.line != 0) + { + if (execution_direction == EXEC_REVERSE) + handle_step_into_function_backward (gdbarch, ecs); + else + handle_step_into_function (gdbarch, ecs); + return; + } /* If we have no line number and the step-stop-if-no-debug is set, we stop the step so that the user has a chance to switch @@ -3908,11 +3900,10 @@ infrun: not switching back to stepped th { /* Set a breakpoint at callee's start address. From there we can step once and be back in the caller. */ - struct symtab_and_line sr_sal; - init_sal (&sr_sal); - sr_sal.pc = ecs->stop_func_start; + init_sal (&tmp_sal); + tmp_sal.pc = ecs->stop_func_start; insert_step_resume_breakpoint_at_sal (gdbarch, - sr_sal, null_frame_id); + tmp_sal, null_frame_id); } else /* Set a breakpoint at callee's return address (the address @@ -3945,11 +3936,10 @@ infrun: not switching back to stepped th /* Stepped backward into the solib dynsym resolver. Set a breakpoint at its start and continue, then one more step will take us out. */ - struct symtab_and_line sr_sal; - init_sal (&sr_sal); - sr_sal.pc = ecs->stop_func_start; + init_sal (&tmp_sal); + tmp_sal.pc = ecs->stop_func_start; insert_step_resume_breakpoint_at_sal (gdbarch, - sr_sal, null_frame_id); + tmp_sal, null_frame_id); keep_going (ecs); return; } @@ -3971,17 +3961,15 @@ infrun: not switching back to stepped th if (real_stop_pc) { /* And put the step-breakpoint there and go until there. */ - struct symtab_and_line sr_sal; - - init_sal (&sr_sal); /* initialize to zeroes */ - sr_sal.pc = real_stop_pc; - sr_sal.section = find_pc_overlay (sr_sal.pc); + init_sal (&tmp_sal); /* initialize to zeroes */ + tmp_sal.pc = real_stop_pc; + tmp_sal.section = find_pc_overlay (tmp_sal.pc); /* Do not specify what the fp should be when we stop since on some machines the prologue is where the new fp value is established. */ insert_step_resume_breakpoint_at_sal (gdbarch, - sr_sal, null_frame_id); + tmp_sal, null_frame_id); /* Restart without fiddling with the step ranges or other state. */ @@ -4065,13 +4053,11 @@ infrun: not switching back to stepped th ecs->event_thread->step_frame_id) && inline_skipped_frames (ecs->ptid)) { - struct symtab_and_line call_sal; - if (debug_infrun) fprintf_unfiltered (gdb_stdlog, "infrun: stepped into inlined function\n"); - find_frame_sal (get_current_frame (), &call_sal); + find_frame_sal (get_current_frame (), &tmp_sal); if (ecs->event_thread->step_over_calls != STEP_OVER_ALL) { @@ -4080,22 +4066,21 @@ infrun: not switching back to stepped th we were previously stepping, go down into the function first. Otherwise stop at the call site. */ - if (call_sal.line == ecs->event_thread->current_line - && call_sal.symtab == ecs->event_thread->current_symtab) + if (tmp_sal.line == ecs->event_thread->current_line + && tmp_sal.symtab == ecs->event_thread->current_symtab) step_into_inline_frame (ecs->ptid); ecs->event_thread->stop_step = 1; print_stop_reason (END_STEPPING_RANGE, 0); stop_stepping (ecs); - return; } else { /* For "next", we should stop at the call site if it is on a different source line. Otherwise continue through the inlined function. */ - if (call_sal.line == ecs->event_thread->current_line - && call_sal.symtab == ecs->event_thread->current_symtab) + if (tmp_sal.line == ecs->event_thread->current_line + && tmp_sal.symtab == ecs->event_thread->current_symtab) keep_going (ecs); else { @@ -4103,8 +4088,8 @@ infrun: not switching back to stepped th print_stop_reason (END_STEPPING_RANGE, 0); stop_stepping (ecs); } - return; } + return; } /* Look for "calls" to inlined functions, part two. If we are still --------------070804010308050100030507--