[PATCH 2/2] Replace address and aspace with thread in struct step_over_info

Yao Qi
2016-04-15T13:29:53Z

This patch replaces the fields aspace and address in
'struct step_over_info' with 'thread', because aspace and thread can
be got from thread.

gdb:

2016-04-15 Yao Qi <yao.qi@linaro.org>

* infrun.c (struct step_over_info) <aspace>: Remove
: Remove.
<thread>: New field.
(set_step_over_info): Update.
(clear_step_over_info): Update.
(stepping_past_nonsteppable_watchpoint): Update.
---
gdb/infrun.c | 47 +++++++++++++++++++++--------------------------
1 file changed, 21 insertions(+), 26 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index 9017b0a..72f7fe4 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1282,16 +1282,12 @@ enum step_over_what_flag
};
DEF_ENUM_FLAGS_TYPE (enum step_over_what_flag, step_over_what);

-/* Info about an instruction that is being stepped over. */
+/* Info about a thread that is being stepped over. */

struct step_over_info
{
- /* If we're stepping past a breakpoint, this is the address space
- and address of the instruction the breakpoint is set at. We'll
- skip inserting all breakpoints here. Valid iff ASPACE is
- non-NULL. */
- struct address_space *aspace;
- CORE_ADDR address;
+ /* We're stepping over the thread to pass a breakpoint. */
+ struct thread_info *thread;

/* The instruction being stepped over triggers a nonsteppable
watchpoint. If true, we'll skip inserting watchpoints. */
@@ -1331,18 +1327,7 @@ static void
set_step_over_info (struct thread_info *thread,
int nonsteppable_watchpoint_p)
{
- if (thread != NULL)
- {
- struct regcache *regcache = get_thread_regcache (thread->ptid);
-
- step_over_info.aspace = get_regcache_aspace (regcache);
- step_over_info.address = regcache_read_pc (regcache);
- }
- else
- {
- step_over_info.aspace = NULL;
- step_over_info.address = 0;
- }
+ step_over_info.thread = thread;
step_over_info.nonsteppable_watchpoint_p = nonsteppable_watchpoint_p;
}

@@ -1355,8 +1340,7 @@ clear_step_over_info (void)
if (debug_infrun)
fprintf_unfiltered (gdb_stdlog,
"infrun: clear_step_over_info\n");
- step_over_info.aspace = NULL;
- step_over_info.address = 0;
+ step_over_info.thread = NULL;
step_over_info.nonsteppable_watchpoint_p = 0;
}

@@ -1366,10 +1350,21 @@ int
stepping_past_instruction_at (struct address_space *aspace,
CORE_ADDR address)
{
- return (step_over_info.aspace != NULL
- && breakpoint_address_match (aspace, address,
- step_over_info.aspace,
- step_over_info.address));
+ if (step_over_info.thread != NULL)
+ {
+ struct regcache *regcache;
+
+ regcache = get_thread_regcache (step_over_info.thread->ptid);
+
+ /* The step-over isn't finished or is still valid, so the PC got
+ from regcache is the value when thread stops, rather than the
+ value after step-over. */
+ return breakpoint_address_match (aspace, address,
+ get_regcache_aspace (regcache) ,
+ regcache_read_pc (regcache));
+ }
+ else
+ return 0;
}

/* See infrun.h. */
@@ -1385,7 +1380,7 @@ stepping_past_nonsteppable_watchpoint (void)
static int
step_over_info_valid_p (void)
{
- return (step_over_info.aspace != NULL
+ return (step_over_info.thread != NULL
|| stepping_past_nonsteppable_watchpoint ());
}

--
1.9.1