aboutsummaryrefslogtreecommitdiff
path: root/gdb/infrun.h
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2019-01-02 17:31:08 -0500
committerSimon Marchi <simon.marchi@ericsson.com>2019-01-02 17:31:08 -0500
commitd20172fc53017cef12d64b21aa2fdac72072558c (patch)
tree405b1ffd879db4b7a5681b885a9f14e1683a405f /gdb/infrun.h
parente3319240732bc9543af8ced9d80ec89d0b629b2e (diff)
downloadgdb-d20172fc53017cef12d64b21aa2fdac72072558c.zip
gdb-d20172fc53017cef12d64b21aa2fdac72072558c.tar.gz
gdb-d20172fc53017cef12d64b21aa2fdac72072558c.tar.bz2
Place displaced step data directly in inferior structure
This patch moves the per-inferior data related to displaced stepping to be directly in the inferior structure, rather than in a container on the side. On notable difference is that previously, we deleted the state on inferior exit, which guaranteed a clean state if re-using the inferior for a new run or attach. We now need to reset the state manually. At the same time, I changed step_saved_copy to be a gdb::byte_vector, so it is automatically freed on destruction (which should plug the leak reported here [1]). [1] https://sourceware.org/ml/gdb-patches/2018-11/msg00202.html gdb/ChangeLog: * inferior.h (class inferior) <displaced_step_state>: New field. * infrun.h (struct displaced_step_state): Move here from infrun.c. Initialize fields, add constructor. <inf>: Remove field. <reset>: New method. * infrun.c (struct displaced_step_inferior_state): Move to infrun.h. (displaced_step_inferior_states): Remove. (get_displaced_stepping_state): Adust. (displaced_step_in_progress_any_inferior): Adjust. (displaced_step_in_progress_thread): Adjust. (displaced_step_in_progress): Adjust. (add_displaced_stepping_state): Remove. (get_displaced_step_closure_by_addr): Adjust. (remove_displaced_stepping_state): Remove. (infrun_inferior_exit): Call displaced_step_state.reset. (use_displaced_stepping): Don't check for NULL. (displaced_step_prepare_throw): Call get_displaced_stepping_state. (displaced_step_fixup): Don't check for NULL. (prepare_for_detach): Don't check for NULL.
Diffstat (limited to 'gdb/infrun.h')
-rw-r--r--gdb/infrun.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/gdb/infrun.h b/gdb/infrun.h
index 0d1309b..8f61b75 100644
--- a/gdb/infrun.h
+++ b/gdb/infrun.h
@@ -258,4 +258,48 @@ struct buf_displaced_step_closure : displaced_step_closure
gdb::byte_vector buf;
};
+/* Per-inferior displaced stepping state. */
+struct displaced_step_inferior_state
+{
+ displaced_step_inferior_state ()
+ {
+ reset ();
+ }
+
+ /* Put this object back in its original state. */
+ void reset ()
+ {
+ failed_before = 0;
+ step_thread = nullptr;
+ step_gdbarch = nullptr;
+ step_closure = nullptr;
+ step_original = 0;
+ step_copy = 0;
+ step_saved_copy.clear ();
+ }
+
+ /* True if preparing a displaced step ever failed. If so, we won't
+ try displaced stepping for this inferior again. */
+ int failed_before;
+
+ /* If this is not nullptr, this is the thread carrying out a
+ displaced single-step in process PID. This thread's state will
+ require fixing up once it has completed its step. */
+ thread_info *step_thread;
+
+ /* The architecture the thread had when we stepped it. */
+ gdbarch *step_gdbarch;
+
+ /* The closure provided gdbarch_displaced_step_copy_insn, to be used
+ for post-step cleanup. */
+ displaced_step_closure *step_closure;
+
+ /* The address of the original instruction, and the copy we
+ made. */
+ CORE_ADDR step_original, step_copy;
+
+ /* Saved contents of copy area. */
+ gdb::byte_vector step_saved_copy;
+};
+
#endif /* INFRUN_H */