From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 7/9] infrun.c: add for_each_just_stopped_thread
Date: Fri, 26 Sep 2014 01:36:00 -0000 [thread overview]
Message-ID: <1411691982-10744-8-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1411691982-10744-1-git-send-email-palves@redhat.com>
This is a preparatory/cleanup patch that does two things:
- Renames 'delete_step_thread_step_resume_breakpoint'. The
"step_resume" part is misnomer these days, as the function deletes
other kinds of breakpoints, not just the step-resume breakpoint. A
following patch will want to make it delete yet another kind of
breakpoint, even.
- Splits out the logic of which threads get those breakpoints deleted
to a separate "for_each"-style function, so that the same following
patch may use it with a different callback.
Tested on x86_64 Fedora 20.
gdb/
2014-09-25 Pedro Alves <palves@redhat.com>
* infrun.c (delete_step_resume_breakpoint_callback): Delete.
(delete_thread_infrun_breakpoints): New function, with parts
salvaged from delete_step_resume_breakpoint_callback.
(delete_step_thread_step_resume_breakpoint): Delete.
(for_each_just_stopped_thread_callback_func): New typedef.
(for_each_just_stopped_thread): New function.
(delete_just_stopped_threads_infrun_breakpoints): New function.
(delete_step_thread_step_resume_breakpoint_cleanup): Rename to ...
(delete_just_stopped_threads_infrun_breakpoints_cleanup):
... this. Adjust.
(wait_for_inferior, fetch_inferior_event): Adjust to renames.
---
gdb/infrun.c | 72 +++++++++++++++++++++++++++++++++---------------------------
1 file changed, 40 insertions(+), 32 deletions(-)
diff --git a/gdb/infrun.c b/gdb/infrun.c
index e0df9bf..d6d0948 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -2606,54 +2606,61 @@ infrun_thread_thread_exit (struct thread_info *tp, int silent)
nullify_last_target_wait_ptid ();
}
-/* Callback for iterate_over_threads. */
+/* Delete the step resume, single-step and longjmp/exception resume
+ breakpoints of TP. */
-static int
-delete_step_resume_breakpoint_callback (struct thread_info *info, void *data)
+static void
+delete_thread_infrun_breakpoints (struct thread_info *tp)
{
- if (is_exited (info->ptid))
- return 0;
-
- delete_step_resume_breakpoint (info);
- delete_exception_resume_breakpoint (info);
- return 0;
+ delete_step_resume_breakpoint (tp);
+ delete_exception_resume_breakpoint (tp);
}
-/* In all-stop, delete the step resume breakpoint of any thread that
- had one. In non-stop, delete the step resume breakpoint of the
- thread that just stopped. */
+/* If the target still has execution, call FUNC for each thread that
+ just stopped. In all-stop, that's all the non-exited threads; in
+ non-stop, that's the current thread, only. */
+
+typedef void (*for_each_just_stopped_thread_callback_func)
+ (struct thread_info *tp);
static void
-delete_step_thread_step_resume_breakpoint (void)
+for_each_just_stopped_thread (for_each_just_stopped_thread_callback_func func)
{
- if (!target_has_execution
- || ptid_equal (inferior_ptid, null_ptid))
- /* If the inferior has exited, we have already deleted the step
- resume breakpoints out of GDB's lists. */
+ if (!target_has_execution || ptid_equal (inferior_ptid, null_ptid))
return;
if (non_stop)
{
- /* If in non-stop mode, only delete the step-resume or
- longjmp-resume breakpoint of the thread that just stopped
- stepping. */
- struct thread_info *tp = inferior_thread ();
-
- delete_step_resume_breakpoint (tp);
- delete_exception_resume_breakpoint (tp);
+ /* If in non-stop mode, only the current thread stopped. */
+ func (inferior_thread ());
}
else
- /* In all-stop mode, delete all step-resume and longjmp-resume
- breakpoints of any thread that had them. */
- iterate_over_threads (delete_step_resume_breakpoint_callback, NULL);
+ {
+ struct thread_info *tp;
+
+ /* In all-stop mode, all threads have stopped. */
+ ALL_NON_EXITED_THREADS (tp)
+ {
+ func (tp);
+ }
+ }
+}
+
+/* Delete the step resume and longjmp/exception resume breakpoints of
+ the threads that just stopped. */
+
+static void
+delete_just_stopped_threads_infrun_breakpoints (void)
+{
+ for_each_just_stopped_thread (delete_thread_infrun_breakpoints);
}
/* A cleanup wrapper. */
static void
-delete_step_thread_step_resume_breakpoint_cleanup (void *arg)
+delete_just_stopped_threads_infrun_breakpoints_cleanup (void *arg)
{
- delete_step_thread_step_resume_breakpoint ();
+ delete_just_stopped_threads_infrun_breakpoints ();
}
/* Pretty print the results of target_wait, for debugging purposes. */
@@ -2788,8 +2795,9 @@ wait_for_inferior (void)
fprintf_unfiltered
(gdb_stdlog, "infrun: wait_for_inferior ()\n");
- old_cleanups =
- make_cleanup (delete_step_thread_step_resume_breakpoint_cleanup, NULL);
+ old_cleanups
+ = make_cleanup (delete_just_stopped_threads_infrun_breakpoints_cleanup,
+ NULL);
while (1)
{
@@ -2911,7 +2919,7 @@ fetch_inferior_event (void *client_data)
{
struct inferior *inf = find_inferior_pid (ptid_get_pid (ecs->ptid));
- delete_step_thread_step_resume_breakpoint ();
+ delete_just_stopped_threads_infrun_breakpoints ();
/* We may not find an inferior if this was a process exit. */
if (inf == NULL || inf->control.stop_soon == NO_STOP_QUIETLY)
--
1.9.3
prev parent reply other threads:[~2014-09-26 1:36 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-26 0:39 [PATCH 0/9] software single-step support rework, fix limitations Pedro Alves
2014-09-26 0:39 ` [PATCH 1/9] Decide whether we may have removed breakpoints based on step_over_info Pedro Alves
2014-09-28 12:52 ` Yao Qi
2014-10-02 18:05 ` Pedro Alves
2014-10-06 1:06 ` Yao Qi
2014-10-06 8:42 ` Pedro Alves
2014-09-26 0:39 ` [PATCH 2/9] Rewrite non-continuable watchpoints handling Pedro Alves
2014-09-26 0:40 ` [PATCH 4/9] Remove deprecated_insert_raw_breakpoint and friends Pedro Alves
2014-09-26 0:40 ` [PATCH 9/9] Non-stop + software single-step archs: don't force displaced-stepping for all single-steps Pedro Alves
2014-09-26 0:40 ` [PATCH 8/9] Make single-step breakpoints be per-thread Pedro Alves
2014-09-26 0:40 ` [PATCH 3/9] Put single-step breakpoints on the bp_location chain Pedro Alves
2014-09-28 12:36 ` Yao Qi
2014-09-30 13:01 ` Pedro Alves
2014-09-30 13:15 ` Pedro Alves
2014-09-29 6:33 ` Yao Qi
2014-10-02 17:55 ` Pedro Alves
2014-09-26 0:40 ` [PATCH 5/9] Switch back to stepped thread: clear step-over info Pedro Alves
2014-09-30 16:33 ` Pedro Alves
2014-09-26 1:18 ` [PATCH 6/9] thread.c: cleanup breakpoint deletion Pedro Alves
2014-09-26 1:36 ` Pedro Alves [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1411691982-10744-8-git-send-email-palves@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).