Refactor clone_all_breakpoints
authorYao Qi <yao.qi@linaro.org>
Thu, 21 Jul 2016 11:12:18 +0000 (12:12 +0100)
committerYao Qi <yao.qi@linaro.org>
Thu, 21 Jul 2016 11:12:18 +0000 (12:12 +0100)
This patch is to change the interface of clone_all_breakpoints, from
lists of breakpoints and raw_breakpoints to child thread and parent
thread.  I choose child thread to pass because we need the ptid of
the child thread in the following patch.

gdb/gdbserver:

2016-07-21  Yao Qi  <yao.qi@linaro.org>

* inferiors.c (get_thread_process): Make parameter const.
* inferiors.h (get_thread_process): Update declaration.
* mem-break.c (clone_all_breakpoints): Remove all parameters.
Add new parameters child_thread and parent_thread.  Callers
updated.
* mem-break.h (clone_all_breakpoints): Update declaration.

gdb/gdbserver/ChangeLog
gdb/gdbserver/inferiors.c
gdb/gdbserver/inferiors.h
gdb/gdbserver/linux-low.c
gdb/gdbserver/mem-break.c
gdb/gdbserver/mem-break.h

index 7fae552d229faf220d87b337f132786e079c2231..c440d6686f71c375ee4201e5280adf3c7d222522 100644 (file)
@@ -1,3 +1,12 @@
+2016-07-21  Yao Qi  <yao.qi@linaro.org>
+
+       * inferiors.c (get_thread_process): Make parameter const.
+       * inferiors.h (get_thread_process): Update declaration.
+       * mem-break.c (clone_all_breakpoints): Remove all parameters.
+       Add new parameters child_thread and parent_thread.  Callers
+       updated.
+       * mem-break.h (clone_all_breakpoints): Update declaration.
+
 2016-07-21  Yao Qi  <yao.qi@linaro.org>
 
        * mem-break.c (struct breakpoint) <cond_list>: Remove.
index 4bea4fd7a91bc948322c604c6368506bdb7ff938..1f5149ff4867a49b469b0e67bea6fa7173ce1afa 100644 (file)
@@ -399,7 +399,7 @@ have_attached_inferiors_p (void)
 }
 
 struct process_info *
-get_thread_process (struct thread_info *thread)
+get_thread_process (const struct thread_info *thread)
 {
   int pid = ptid_get_pid (thread->entry.id);
   return find_process_pid (pid);
index 00dfe60e0c5f88ed0f36bb2d1c1eeefa8d7e8895..65ab1c6fc60828b05fdae47ba4b67b2452088d24 100644 (file)
@@ -88,7 +88,7 @@ struct process_info
    no current thread selected.  */
 
 struct process_info *current_process (void);
-struct process_info *get_thread_process (struct thread_info *);
+struct process_info *get_thread_process (const struct thread_info *);
 
 extern struct inferior_list all_processes;
 
index 46c5a38c1a3a89ee4a68d450dee406c8e3152e70..39718c65502cbf641a59e67743ebe786e8ac262d 100644 (file)
@@ -560,9 +560,7 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
              current_thread = saved_thread;
            }
 
-         clone_all_breakpoints (&child_proc->breakpoints,
-                                &child_proc->raw_breakpoints,
-                                parent_proc->breakpoints);
+         clone_all_breakpoints (child_thr, event_thr);
 
          tdesc = XNEW (struct target_desc);
          copy_target_description (tdesc, parent_proc->tdesc);
index 353942223cd5f16b8c466f4773f1705810648f5a..c14219e07952e0e8ee9b6501bcda195106ea95f3 100644 (file)
@@ -2184,21 +2184,22 @@ clone_one_breakpoint (const struct breakpoint *src)
   return dest;
 }
 
-/* Create a new breakpoint list NEW_LIST that is a copy of the
-   list starting at SRC_LIST.  Create the corresponding new
-   raw_breakpoint list NEW_RAW_LIST as well.  */
+/* See mem-break.h.  */
 
 void
-clone_all_breakpoints (struct breakpoint **new_list,
-                      struct raw_breakpoint **new_raw_list,
-                      const struct breakpoint *src_list)
+clone_all_breakpoints (struct thread_info *child_thread,
+                      const struct thread_info *parent_thread)
 {
   const struct breakpoint *bp;
   struct breakpoint *new_bkpt;
   struct breakpoint *bkpt_tail = NULL;
   struct raw_breakpoint *raw_bkpt_tail = NULL;
+  struct process_info *child_proc = get_thread_process (child_thread);
+  struct process_info *parent_proc = get_thread_process (parent_thread);
+  struct breakpoint **new_list = &child_proc->breakpoints;
+  struct raw_breakpoint **new_raw_list = &child_proc->raw_breakpoints;
 
-  for (bp = src_list; bp != NULL; bp = bp->next)
+  for (bp = parent_proc->breakpoints; bp != NULL; bp = bp->next)
     {
       new_bkpt = clone_one_breakpoint (bp);
       APPEND_TO_LIST (new_list, new_bkpt, bkpt_tail);
index 321de1220ccd5943c6b5d99a5843ab7872e74250..d6330035e7ab3ddc0ef74db9ca6c28336c85a448 100644 (file)
@@ -267,10 +267,10 @@ int insert_memory_breakpoint (struct raw_breakpoint *bp);
 
 int remove_memory_breakpoint (struct raw_breakpoint *bp);
 
-/* Create a new breakpoint list NEW_BKPT_LIST that is a copy of SRC.  */
+/* Create a new breakpoint list in CHILD_THREAD's process that is a
+   copy of breakpoint list in PARENT_THREAD's process.  */
 
-void clone_all_breakpoints (struct breakpoint **new_bkpt_list,
-                           struct raw_breakpoint **new_raw_bkpt_list,
-                           const struct breakpoint *src);
+void clone_all_breakpoints (struct thread_info *child_thread,
+                           const struct thread_info *parent_thread);
 
 #endif /* MEM_BREAK_H */