From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/4] Eliminate fork_info::clobber_regs
Date: Tue, 05 Mar 2019 18:43:00 -0000 [thread overview]
Message-ID: <20190305184340.26768-5-palves@redhat.com> (raw)
In-Reply-To: <20190305184340.26768-1-palves@redhat.com>
All fork_save_infrun_state callers pass '1' as CLOBBER_REGS nowadays.
The larger hunk in fork_save_infrun_state is just a reindentation.
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* linux-fork.c (fork_info::clobber_regs): Delete.
(fork_load_infrun_state): Remove reference to 'clobber_regs'.
(fork_save_infrun_state): Remove 'clobber_regs' parameter. Update
comment. Adjust.
(scoped_switch_fork_info::scoped_switch_fork_info)
(checkpoint_command, linux_fork_context): Adjust
fork_save_infrun_state calls.
---
gdb/linux-fork.c | 79 +++++++++++++++++++++++++-------------------------------
1 file changed, 35 insertions(+), 44 deletions(-)
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 4bc454ba6d..51e8fddbc2 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -77,9 +77,6 @@ struct fork_info
CORE_ADDR pc = 0;
- /* True if we should restore saved regs. */
- int clobber_regs = 0;
-
/* Set of open file descriptors' offsets. */
off_t *filepos = nullptr;
@@ -223,7 +220,7 @@ fork_load_infrun_state (struct fork_info *fp)
linux_nat_switch_fork (fp->ptid);
- if (fp->savedregs && fp->clobber_regs)
+ if (fp->savedregs)
get_current_regcache ()->restore (fp->savedregs);
registers_changed ();
@@ -245,11 +242,10 @@ fork_load_infrun_state (struct fork_info *fp)
}
}
-/* Save infrun state for the fork PTID.
- Exported for use by linux child_follow_fork. */
+/* Save infrun state for the fork FP. */
static void
-fork_save_infrun_state (struct fork_info *fp, int clobber_regs)
+fork_save_infrun_state (struct fork_info *fp)
{
char path[PATH_MAX];
struct dirent *de;
@@ -260,44 +256,39 @@ fork_save_infrun_state (struct fork_info *fp, int clobber_regs)
fp->savedregs = new readonly_detached_regcache (*get_current_regcache ());
fp->pc = regcache_read_pc (get_current_regcache ());
- fp->clobber_regs = clobber_regs;
- if (clobber_regs)
+ /* Now save the 'state' (file position) of all open file descriptors.
+ Unfortunately fork does not take care of that for us... */
+ snprintf (path, PATH_MAX, "/proc/%ld/fd", (long) fp->ptid.pid ());
+ if ((d = opendir (path)) != NULL)
{
- /* Now save the 'state' (file position) of all open file descriptors.
- Unfortunately fork does not take care of that for us... */
- snprintf (path, PATH_MAX, "/proc/%ld/fd",
- (long) fp->ptid.pid ());
- if ((d = opendir (path)) != NULL)
+ long tmp;
+
+ fp->maxfd = 0;
+ while ((de = readdir (d)) != NULL)
{
- long tmp;
-
- fp->maxfd = 0;
- while ((de = readdir (d)) != NULL)
- {
- /* Count open file descriptors (actually find highest
- numbered). */
- tmp = strtol (&de->d_name[0], NULL, 10);
- if (fp->maxfd < tmp)
- fp->maxfd = tmp;
- }
- /* Allocate array of file positions. */
- fp->filepos = XRESIZEVEC (off_t, fp->filepos, fp->maxfd + 1);
-
- /* Initialize to -1 (invalid). */
- for (tmp = 0; tmp <= fp->maxfd; tmp++)
- fp->filepos[tmp] = -1;
-
- /* Now find actual file positions. */
- rewinddir (d);
- while ((de = readdir (d)) != NULL)
- if (isdigit (de->d_name[0]))
- {
- tmp = strtol (&de->d_name[0], NULL, 10);
- fp->filepos[tmp] = call_lseek (tmp, 0, SEEK_CUR);
- }
- closedir (d);
+ /* Count open file descriptors (actually find highest
+ numbered). */
+ tmp = strtol (&de->d_name[0], NULL, 10);
+ if (fp->maxfd < tmp)
+ fp->maxfd = tmp;
}
+ /* Allocate array of file positions. */
+ fp->filepos = XRESIZEVEC (off_t, fp->filepos, fp->maxfd + 1);
+
+ /* Initialize to -1 (invalid). */
+ for (tmp = 0; tmp <= fp->maxfd; tmp++)
+ fp->filepos[tmp] = -1;
+
+ /* Now find actual file positions. */
+ rewinddir (d);
+ while ((de = readdir (d)) != NULL)
+ if (isdigit (de->d_name[0]))
+ {
+ tmp = strtol (&de->d_name[0], NULL, 10);
+ fp->filepos[tmp] = call_lseek (tmp, 0, SEEK_CUR);
+ }
+ closedir (d);
}
}
@@ -421,7 +412,7 @@ public:
gdb_assert (m_oldfp != nullptr);
newfp = find_fork_ptid (pptid);
gdb_assert (newfp != nullptr);
- fork_save_infrun_state (m_oldfp, 1);
+ fork_save_infrun_state (m_oldfp);
remove_breakpoints ();
fork_load_infrun_state (newfp);
insert_breakpoints ();
@@ -718,7 +709,7 @@ checkpoint_command (const char *args, int from_tty)
fork_list.emplace_front (inferior_ptid.pid ());
}
- fork_save_infrun_state (fp, 1);
+ fork_save_infrun_state (fp);
fp->parent_ptid = last_target_ptid;
}
@@ -733,7 +724,7 @@ linux_fork_context (struct fork_info *newfp, int from_tty)
oldfp = find_fork_ptid (inferior_ptid);
gdb_assert (oldfp != NULL);
- fork_save_infrun_state (oldfp, 1);
+ fork_save_infrun_state (oldfp);
remove_breakpoints ();
fork_load_infrun_state (newfp);
insert_breakpoints ();
--
2.14.4
next prev parent reply other threads:[~2019-03-05 18:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-05 18:43 [PATCH 0/4] Make "checkpoint" not rely on inferior_ptid Pedro Alves
2019-03-05 18:43 ` [PATCH 1/4] " Pedro Alves
2019-03-05 19:32 ` Tom Tromey
2019-03-05 19:46 ` Pedro Alves
2019-03-05 18:43 ` Pedro Alves [this message]
2019-03-05 18:43 ` [PATCH 2/4] C++ify fork_info, use std::list Pedro Alves
2019-03-05 18:43 ` [PATCH 3/4] linux-fork.c: rewrite inf_has_multiple_threads Pedro Alves
2019-03-05 19:46 ` [PATCH 0/4] Make "checkpoint" not rely on inferior_ptid Tom Tromey
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=20190305184340.26768-5-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