From patchwork Fri Aug 1 06:38:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 2269 Received: (qmail 30251 invoked by alias); 1 Aug 2014 06:42:25 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 30236 invoked by uid 89); 1 Aug 2014 06:42:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 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, 01 Aug 2014 06:42:22 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1XD6Xj-0005ok-H5 from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Thu, 31 Jul 2014 23:42:19 -0700 Received: from SVR-ORW-FEM-06.mgc.mentorg.com ([147.34.97.120]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 31 Jul 2014 23:42:19 -0700 Received: from qiyao.dyndns.org.com (147.34.91.1) by SVR-ORW-FEM-06.mgc.mentorg.com (147.34.97.120) with Microsoft SMTP Server id 14.2.247.3; Thu, 31 Jul 2014 23:42:18 -0700 From: Yao Qi To: Subject: [PATCH] use in_infcall instead of proceed_to_finish Date: Fri, 1 Aug 2014 14:38:24 +0800 Message-ID: <1406875104-13501-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes Hi, When I read this line below in run_inferior_call, call_thread->control.proceed_to_finish = 1; I am confused, and wonder why this flag (about command finish) should be set for inferior call. Looks it is used as a flag to save stop_registers. However, it is still confusing, IMO. When GDB does inferior call, flag in_infcall is set, so we can save stop_registers when either proceed_to_finish or in_infcall is true, which is easy to understand. That is what this patch does. Regression tested on x86_64-linux and arm-none-eabi. OK to apply? gdb: 2014-08-01 Yao Qi * gdbthread.h (struct thread_control_state) : Update comments. * infcall.c (run_inferior_call): Don't set proceed_to_finish. * infrun.c: Update comments to stop_registers. (normal_stop): Save stop_registers when in_infcall is true. --- gdb/gdbthread.h | 3 +-- gdb/infcall.c | 3 --- gdb/infrun.c | 11 ++++++----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 522b674..794f4d2 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -106,8 +106,7 @@ struct thread_control_state by keep_going. */ int trap_expected; - /* Nonzero if the thread is being proceeded for a "finish" command - or a similar situation when stop_registers should be saved. */ + /* Nonzero if the thread is being proceeded for a "finish" command. */ int proceed_to_finish; /* Nonzero if the thread is being proceeded for an inferior function diff --git a/gdb/infcall.c b/gdb/infcall.c index 5c65bb5..da09585 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -400,9 +400,6 @@ run_inferior_call (struct thread_info *call_thread, CORE_ADDR real_pc) disable_watchpoints_before_interactive_call_start (); - /* We want stop_registers, please... */ - call_thread->control.proceed_to_finish = 1; - TRY_CATCH (e, RETURN_MASK_ALL) { int was_sync = sync_execution; diff --git a/gdb/infrun.c b/gdb/infrun.c index 33aa674..57464c5 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -355,9 +355,9 @@ show_stop_on_solib_events (struct ui_file *file, int from_tty, int stop_after_trap; /* Save register contents here when executing a "finish" command or are - about to pop a stack dummy frame, if-and-only-if proceed_to_finish is set. - Thus this contains the return value from the called function (assuming - values are returned in a register). */ + about to pop a stack dummy frame, if-and-only-if proceed_to_finish + or in_infcall is set. Thus this contains the return value from the + called function (assuming values are returned in a register). */ struct regcache *stop_registers; @@ -6191,8 +6191,9 @@ normal_stop (void) /* Save the function value return registers, if we care. We might be about to restore their previous contents. */ - if (inferior_thread ()->control.proceed_to_finish - && execution_direction != EXEC_REVERSE) + if ((inferior_thread ()->control.proceed_to_finish + && execution_direction != EXEC_REVERSE) + || inferior_thread ()->control.in_infcall) { /* This should not be necessary. */ if (stop_registers)