This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] use in_infcall instead of proceed_to_finish
- From: Yao Qi <yao at codesourcery dot com>
- To: <gdb-patches at sourceware dot org>
- Date: Fri, 1 Aug 2014 14:38:24 +0800
- Subject: [PATCH] use in_infcall instead of proceed_to_finish
- Authentication-results: sourceware.org; auth=none
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 <yao@codesourcery.com>
* gdbthread.h (struct thread_control_state) <proceed_to_finish>:
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)
--
1.9.0