* [PATCH] GDB checkpoint can't/shouldn't be possible with multiple threads on Linux
@ 2011-04-12 7:44 Kevin Pouget
2011-04-12 10:59 ` Pedro Alves
0 siblings, 1 reply; 11+ messages in thread
From: Kevin Pouget @ 2011-04-12 7:44 UTC (permalink / raw)
To: gdb-patches
Hello,
as I reported in http://sourceware.org/bugzilla/show_bug.cgi?id=12628
and discussed in http://sourceware.org/ml/gdb/2011-04/msg00018.html,
GDB can't handle properly the checkpointing of an application
currently running several threads without a dedicated support.
This patch updates the thread-list and check the thread count before
doing the actual checkpoint.
(does such a patch require a test case?)
Cordially,
Kevin
-----------
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 880781a..611aa7e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2011-04-12 Kevin Pouget <kevin.pouget@st.com>
+
+ PR threads/12628
+ * linux-fork.c (checkpoint_command): Disallow checkpointing of
+ processes with multiple threads.
+
2011-03-29 Kevin Pouget <kevin.pouget@st.com>
Allow Python notification of new object-file loadings.
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 7f654af..c137604 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -628,6 +628,11 @@ checkpoint_command (char *args, int from_tty)
pid_t retpid;
struct cleanup *old_chain;
+ /* Ensure that the inferior is not multithreaded. */
+ update_thread_list () ;
+ if (thread_count () > 1)
+ error (_("checkpoint: can't checkpoint multiple threads.")) ;
+
/* Make the inferior fork, record its (and gdb's) state. */
if (lookup_minimal_symbol ("fork", NULL, NULL) != NULL)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] GDB checkpoint can't/shouldn't be possible with multiple threads on Linux
2011-04-12 7:44 [PATCH] GDB checkpoint can't/shouldn't be possible with multiple threads on Linux Kevin Pouget
@ 2011-04-12 10:59 ` Pedro Alves
2011-04-12 11:55 ` Kevin Pouget
0 siblings, 1 reply; 11+ messages in thread
From: Pedro Alves @ 2011-04-12 10:59 UTC (permalink / raw)
To: gdb-patches; +Cc: Kevin Pouget
On Tuesday 12 April 2011 08:44:14, Kevin Pouget wrote:
> as I reported in http://sourceware.org/bugzilla/show_bug.cgi?id=12628
> and discussed in http://sourceware.org/ml/gdb/2011-04/msg00018.html,
> (does such a patch require a test case?)
Tests are always good, tough I'd approve this without one.
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index 880781a..611aa7e 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,9 @@
> +2011-04-12 Kevin Pouget <kevin.pouget@st.com>
> +
> + PR threads/12628
> + * linux-fork.c (checkpoint_command): Disallow checkpointing of
> + processes with multiple threads.
> +
Next time please post ChangeLog entries as plaintext,
separate from the patch.
> diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
> index 7f654af..c137604 100644
> --- a/gdb/linux-fork.c
> +++ b/gdb/linux-fork.c
> @@ -628,6 +628,11 @@ checkpoint_command (char *args, int from_tty)
> pid_t retpid;
> struct cleanup *old_chain;
>
> + /* Ensure that the inferior is not multithreaded. */
Double space after periods.
> + update_thread_list () ;
> + if (thread_count () > 1)
> + error (_("checkpoint: can't checkpoint multiple threads.")) ;
You have spurious spaces before `;'.
thread_count() returns the sum total number of threads of all
inferiors/process. You want the number of threads of the
current process only. AFAIR, there's no function handy that
returns you that. (Since you're interested in checking for multiple
threads, you could use iterate_over_threads with a
callback that returns true if it sees a second thread for a
given process, so you don't really need to count all
the threads.)
--
Pedro Alves
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] GDB checkpoint can't/shouldn't be possible with multiple threads on Linux
2011-04-12 10:59 ` Pedro Alves
@ 2011-04-12 11:55 ` Kevin Pouget
2011-04-12 12:55 ` Pedro Alves
0 siblings, 1 reply; 11+ messages in thread
From: Kevin Pouget @ 2011-04-12 11:55 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1403 bytes --]
> Next time please post ChangeLog entries as plaintext,
> separate from the patch.
2011-04-12 Kevin Pouget <kevin.pouget@st.com>
PR threads/12628
* linux-fork.c (checkpoint_command): Disallow checkpointing of
processes with multiple threads.
(inf_has_multiple_thread_cb): New function.
> > diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
> > index 7f654af..c137604 100644
> > --- a/gdb/linux-fork.c
> > +++ b/gdb/linux-fork.c
> > @@ -628,6 +628,11 @@ checkpoint_command (char *args, int from_tty)
> > pid_t retpid;
> > struct cleanup *old_chain;
> >
> > + /* Ensure that the inferior is not multithreaded. */
>
> Double space after periods.
fixed
> > + update_thread_list () ;
> > + if (thread_count () > 1)
> > + error (_("checkpoint: can't checkpoint multiple threads.")) ;
>
> You have spurious spaces before `;'.
fixed
> thread_count() returns the sum total number of threads of all
> inferiors/process. You want the number of threads of the
> current process only. AFAIR, there's no function handy that
> returns you that. (Since you're interested in checking for multiple
> threads, you could use iterate_over_threads with a
> callback that returns true if it sees a second thread for a
> given process, so you don't really need to count all
> the threads.)
you're right, I updated the patch as suggested
thanks,
Kevin
[-- Attachment #2: checkpoint.diff --]
[-- Type: application/octet-stream, Size: 1304 bytes --]
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 7f654af..8a18d42 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -616,6 +616,20 @@ linux_fork_checkpointing_p (int pid)
return (checkpointing_pid == pid);
}
+static int
+inf_has_multiple_thread_cb (struct thread_info *tp, void *data)
+{
+ int *has_multiple_threads = (int *) data;
+
+ gdb_assert(current_inferior() != NULL);
+
+ if (current_inferior()->pid == GET_PID(tp->ptid))
+ (*has_multiple_threads)++;
+
+ /* Stop the iteration if multiple threads have been detected. */
+ return *has_multiple_threads > 1;
+}
+
static void
checkpoint_command (char *args, int from_tty)
{
@@ -627,7 +641,16 @@ checkpoint_command (char *args, int from_tty)
struct fork_info *fp;
pid_t retpid;
struct cleanup *old_chain;
+ int has_multiple_threads = 0 ;
+
+ if (!target_has_execution) error (_("The program is not being run."));
+ /* Ensure that the inferior is not multithreaded. */
+ update_thread_list () ;
+ iterate_over_threads(inf_has_multiple_thread_cb, &has_multiple_threads);
+ if (has_multiple_threads > 1)
+ error (_("checkpoint: can't checkpoint multiple threads."));
+
/* Make the inferior fork, record its (and gdb's) state. */
if (lookup_minimal_symbol ("fork", NULL, NULL) != NULL)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] GDB checkpoint can't/shouldn't be possible with multiple threads on Linux
2011-04-12 11:55 ` Kevin Pouget
@ 2011-04-12 12:55 ` Pedro Alves
2011-04-12 13:28 ` Kevin Pouget
0 siblings, 1 reply; 11+ messages in thread
From: Pedro Alves @ 2011-04-12 12:55 UTC (permalink / raw)
To: gdb-patches; +Cc: Kevin Pouget
On Tuesday 12 April 2011 12:55:05, Kevin Pouget wrote:
> > Next time please post ChangeLog entries as plaintext,
> > separate from the patch.
>
> 2011-04-12 Kevin Pouget <kevin.pouget@st.com>
>
> PR threads/12628
>
> * linux-fork.c (checkpoint_command): Disallow checkpointing of
> processes with multiple threads.
> (inf_has_multiple_thread_cb): New function.
>
> > > diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
> > > index 7f654af..c137604 100644
> > > --- a/gdb/linux-fork.c
> > > +++ b/gdb/linux-fork.c
> > > @@ -628,6 +628,11 @@ checkpoint_command (char *args, int from_tty)
> > > pid_t retpid;
> > > struct cleanup *old_chain;
> > >
> > > + /* Ensure that the inferior is not multithreaded. */
> >
> > Double space after periods.
>
> fixed
>
> > > + update_thread_list () ;
> > > + if (thread_count () > 1)
> > > + error (_("checkpoint: can't checkpoint multiple threads.")) ;
> >
> > You have spurious spaces before `;'.
>
> fixed
>
> > thread_count() returns the sum total number of threads of all
> > inferiors/process. You want the number of threads of the
> > current process only. AFAIR, there's no function handy that
> > returns you that. (Since you're interested in checking for multiple
> > threads, you could use iterate_over_threads with a
> > callback that returns true if it sees a second thread for a
> > given process, so you don't really need to count all
> > the threads.)
>
> you're right, I updated the patch as suggested
Can you have a dialogue with your mailer, convincing it
to attach text files as Content-Type: text/$SOMETHING
rather than application/octet-stream + base64 ?
It's more steps to to read and harder to quote-for-review
binary attachments than should be necessary. Thanks.
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 7f654af..8a18d42 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -616,6 +616,20 @@ linux_fork_checkpointing_p (int pid)
return (checkpointing_pid == pid);
}
> +static int
> +inf_has_multiple_thread_cb (struct thread_info *tp, void *data)
Misses a short describing comment. Something like
/* Callback for iterate over threads. Used to check whether
the current inferior is multi-threaded. Returns true as soon
as it sees the second thread of the current inferior. */
> +{
> + int *has_multiple_threads = (int *) data;
> +
> + gdb_assert(current_inferior() != NULL);
(Many other things would break if this wasn't true.)
Missing spaces before `('.
> + if (current_inferior()->pid == GET_PID(tp->ptid))
Missing spaces before `('. Please use ptid_get_pid.
if (current_inferior ()->pid == ptid_get_pid (tp->ptid))
> + (*has_multiple_threads)++;
> +
> + /* Stop the iteration if multiple threads have been detected. */
> + return *has_multiple_threads > 1;
> +}
> +
> static void
> checkpoint_command (char *args, int from_tty)
> {
> @@ -627,7 +641,16 @@ checkpoint_command (char *args, int from_tty)
> struct fork_info *fp;
> pid_t retpid;
> struct cleanup *old_chain;
> + int has_multiple_threads = 0 ;
Space before `;' again. Let's reserve variables named
`has_FOO' for booleans. Otherwise, the code is harder
to read (the "if (has_multiple_threads > 1)" check below
made me go "hmm?"). You could encapsulate the magic count
in a predicate function:
static int
inf_has_multiple_threads (void)
{
int count = 0;
iterate_over_threads (inf_has_multiple_thread_cb, &count);
return (count > 1);
}
> + iterate_over_threads(inf_has_multiple_thread_cb, &has_multiple_threads);
> + if (has_multiple_threads > 1)
> + error (_("checkpoint: can't checkpoint multiple threads."));
> +
> + if (!target_has_execution) error (_("The program is not being run."));
Each statement goes on its own line.
> + /* Ensure that the inferior is not multithreaded. */
> + update_thread_list () ;
Space before `;' again.
> + iterate_over_threads(inf_has_multiple_thread_cb, &has_multiple_threads);
> + if (has_multiple_threads > 1)
> + error (_("checkpoint: can't checkpoint multiple threads."));
> +
Missing spaces again.
--
Pedro Alves
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] GDB checkpoint can't/shouldn't be possible with multiple threads on Linux
2011-04-12 12:55 ` Pedro Alves
@ 2011-04-12 13:28 ` Kevin Pouget
2011-04-12 13:36 ` Pedro Alves
2011-04-12 13:42 ` Pedro Alves
0 siblings, 2 replies; 11+ messages in thread
From: Kevin Pouget @ 2011-04-12 13:28 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
everything should have been fixed now,
> Can you have a dialogue with your mailer, convincing it
> to attach text files as Content-Type: text/$SOMETHING
> rather than application/octet-stream + base64 ?
> It's more steps to to read and harder to quote-for-review
> binary attachments than should be necessary. Thanks.
gmail is my provider, not easy to talk to them; copy-and-paste should be better
> > + gdb_assert(current_inferior() != NULL);
>
> (Many other things would break if this wasn't true.)
that was a redundant verification before checking
> > + if (!target_has_execution) error (_("The program is not being run."));
so it's now removed
> Space before `;' again. Let's reserve variables named
> `has_FOO' for booleans. Otherwise, the code is harder
> to read (the "if (has_multiple_threads > 1)" check below
> made me go "hmm?"). You could encapsulate the magic count
> in a predicate function:
>
> static int
> inf_has_multiple_threads (void)
> {
> int count = 0;
>
> iterate_over_threads (inf_has_multiple_thread_cb, &count);
> return (count > 1);
> }
right, I was afraid of adding to many new functions for a 'simple' bug
fix, but it does look better.
> Space before `;' again.
> ...
> Missing spaces again.
I'll take an extra care with all these spaces, sorry :)
Thanks,
Kevin
------
2011-04-12 Kevin Pouget <kevin.pouget@st.com>
PR threads/12628
* linux-fork.c (checkpoint_command): Disallow checkpointing of
processes with multiple threads.
(inf_has_multiple_thread_cb): New function.
(inf_has_multiple_threads): New function.
-------
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 7f654af..e733cde 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -616,6 +616,33 @@ linux_fork_checkpointing_p (int pid)
return (checkpointing_pid == pid);
}
+/* Callback for iterate over threads. Used to check whether
+ the current inferior is multi-threaded. Returns true as soon
+ as it sees the second thread of the current inferior. */
+
+static int
+inf_has_multiple_thread_cb (struct thread_info *tp, void *data)
+{
+ int *has_multiple_threads = (int *) data;
+
+ if (current_inferior ()->pid == ptid_get_pid (tp->ptid))
+ (*has_multiple_threads)++;
+
+ /* Stop the iteration if multiple threads have been detected. */
+ return *has_multiple_threads > 1;
+}
+
+/* Return true if the current inferior is multi-threaded. */
+
+static int
+inf_has_multiple_threads (void)
+{
+ int count = 0;
+
+ iterate_over_threads (inf_has_multiple_thread_cb, &count);
+ return (count > 1);
+}
+
static void
checkpoint_command (char *args, int from_tty)
{
@@ -628,6 +655,14 @@ checkpoint_command (char *args, int from_tty)
pid_t retpid;
struct cleanup *old_chain;
+ if (!target_has_execution)
+ error (_("The program is not being run."));
+
+ /* Ensure that the inferior is not multithreaded. */
+ update_thread_list ();
+ if (inf_has_multiple_threads ())
+ error (_("checkpoint: can't checkpoint multiple threads."));
+
/* Make the inferior fork, record its (and gdb's) state. */
if (lookup_minimal_symbol ("fork", NULL, NULL) != NULL)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] GDB checkpoint can't/shouldn't be possible with multiple threads on Linux
2011-04-12 13:28 ` Kevin Pouget
@ 2011-04-12 13:36 ` Pedro Alves
2011-04-12 13:42 ` Pedro Alves
1 sibling, 0 replies; 11+ messages in thread
From: Pedro Alves @ 2011-04-12 13:36 UTC (permalink / raw)
To: gdb-patches; +Cc: Kevin Pouget
On Tuesday 12 April 2011 14:27:49, Kevin Pouget wrote:
> everything should have been fixed now,
>
>
> > Can you have a dialogue with your mailer, convincing it
> > to attach text files as Content-Type: text/$SOMETHING
> > rather than application/octet-stream + base64 ?
> > It's more steps to to read and harder to quote-for-review
> > binary attachments than should be necessary. Thanks.
>
> gmail is my provider, not easy to talk to them; copy-and-paste should be better
gmail + smtp (and imap) is what I use with my private gmail address.
Works fine. I think there's a way to trick gmail's web client
to send text as text. ISTR you only need to name your files .txt,
rather that .diff or something else. I might me wrong.
> I'll take an extra care with all these spaces, sorry :)
No worries. :-)
> 2011-04-12 Kevin Pouget <kevin.pouget@st.com>
Double spaces before and after your name:
2011-04-12 Kevin Pouget <kevin.pouget@st.com>
>
> PR threads/12628
>
> * linux-fork.c (checkpoint_command): Disallow checkpointing of
> processes with multiple threads.
> (inf_has_multiple_thread_cb): New function.
> (inf_has_multiple_threads): New function.
Thanks, this revision looks great.
Is your copyright assigment sorted out?
--
Pedro Alves
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] GDB checkpoint can't/shouldn't be possible with multiple threads on Linux
2011-04-12 13:28 ` Kevin Pouget
2011-04-12 13:36 ` Pedro Alves
@ 2011-04-12 13:42 ` Pedro Alves
2011-04-12 13:55 ` Kevin Pouget
1 sibling, 1 reply; 11+ messages in thread
From: Pedro Alves @ 2011-04-12 13:42 UTC (permalink / raw)
To: gdb-patches; +Cc: Kevin Pouget
Small nit I should have caught before:
On Tuesday 12 April 2011 14:27:49, Kevin Pouget wrote:
> +static int
> +inf_has_multiple_thread_cb (struct thread_info *tp, void *data)
> +{
> + int *has_multiple_threads = (int *) data;
can you rename this local as well, in line with the other
local in the other function? To "count", or "count_p", or something
like that. Thanks. (pre-approved)
> + if (current_inferior ()->pid == ptid_get_pid (tp->ptid))
> + (*has_multiple_threads)++;
> +
> + /* Stop the iteration if multiple threads have been detected. */
> + return *has_multiple_threads > 1;
> +}
> +
> +/* Return true if the current inferior is multi-threaded. */
> +
> +static int
> +inf_has_multiple_threads (void)
> +{
> + int count = 0;
> +
> + iterate_over_threads (inf_has_multiple_thread_cb, &count);
--
Pedro Alves
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] GDB checkpoint can't/shouldn't be possible with multiple threads on Linux
2011-04-12 13:42 ` Pedro Alves
@ 2011-04-12 13:55 ` Kevin Pouget
2011-08-31 12:45 ` Kevin Pouget
0 siblings, 1 reply; 11+ messages in thread
From: Kevin Pouget @ 2011-04-12 13:55 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On Tue, Apr 12, 2011 at 9:41 AM, Pedro Alves <pedro@codesourcery.com> wrote:
> Small nit I should have caught before:
>
> On Tuesday 12 April 2011 14:27:49, Kevin Pouget wrote:
>> +static int
>> +inf_has_multiple_thread_cb (struct thread_info *tp, void *data)
>> +{
>> + int *has_multiple_threads = (int *) data;
>
> can you rename this local as well, in line with the other
> local in the other function? To "count", or "count_p", or something
> like that. Thanks. (pre-approved)
fixed with count_p, thanks
Kevin
--
2011-04-12 Kevin Pouget <kevin.pouget@st.com>
PR threads/12628
* linux-fork.c (checkpoint_command): Disallow checkpointing of
processes with multiple threads.
(inf_has_multiple_thread_cb): New function.
(inf_has_multiple_threads): New function.
--
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 7f654af..de512c3 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -616,6 +616,33 @@ linux_fork_checkpointing_p (int pid)
return (checkpointing_pid == pid);
}
+/* Callback for iterate over threads. Used to check whether
+ the current inferior is multi-threaded. Returns true as soon
+ as it sees the second thread of the current inferior. */
+
+static int
+inf_has_multiple_thread_cb (struct thread_info *tp, void *data)
+{
+ int *count_p = (int *) data;
+
+ if (current_inferior ()->pid == ptid_get_pid (tp->ptid))
+ (*count_p)++;
+
+ /* Stop the iteration if multiple threads have been detected. */
+ return *count_p > 1;
+}
+
+/* Return true if the current inferior is multi-threaded. */
+
+static int
+inf_has_multiple_threads (void)
+{
+ int count = 0;
+
+ iterate_over_threads (inf_has_multiple_thread_cb, &count);
+ return (count > 1);
+}
+
static void
checkpoint_command (char *args, int from_tty)
{
@@ -628,6 +655,14 @@ checkpoint_command (char *args, int from_tty)
pid_t retpid;
struct cleanup *old_chain;
+ if (!target_has_execution)
+ error (_("The program is not being run."));
+
+ /* Ensure that the inferior is not multithreaded. */
+ update_thread_list ();
+ if (inf_has_multiple_threads ())
+ error (_("checkpoint: can't checkpoint multiple threads."));
+
/* Make the inferior fork, record its (and gdb's) state. */
if (lookup_minimal_symbol ("fork", NULL, NULL) != NULL)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] GDB checkpoint can't/shouldn't be possible with multiple threads on Linux
2011-04-12 13:55 ` Kevin Pouget
@ 2011-08-31 12:45 ` Kevin Pouget
2011-09-06 14:42 ` Pedro Alves
0 siblings, 1 reply; 11+ messages in thread
From: Kevin Pouget @ 2011-08-31 12:45 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1032 bytes --]
On Tue, Apr 12, 2011 at 3:54 PM, Kevin Pouget <kevin.pouget@gmail.com> wrote:
>
> On Tue, Apr 12, 2011 at 9:41 AM, Pedro Alves <pedro@codesourcery.com> wrote:
> > Small nit I should have caught before:
> >
> > On Tuesday 12 April 2011 14:27:49, Kevin Pouget wrote:
> >> +static int
> >> +inf_has_multiple_thread_cb (struct thread_info *tp, void *data)
> >> +{
> >> + int *has_multiple_threads = (int *) data;
> >
> > can you rename this local as well, in line with the other
> > local in the other function? To "count", or "count_p", or something
> > like that. Thanks. (pre-approved)
>
> fixed with count_p, thanks
Hello,
my copyright assignment is now ready, so I regenerated the patch
against the up-to-date trunk
Cordially,
Kevin
--
2011-08-31 Kevin Pouget <kevin.pouget@st.com>
PR threads/12628
* linux-fork.c (checkpoint_command): Disallow checkpointing of
processes with multiple threads.
(inf_has_multiple_thread_cb): New function.
(inf_has_multiple_threads): New function.
[-- Attachment #2: 0001-Disallow-checkpointing-of-multiple-threads.patch --]
[-- Type: text/x-patch, Size: 1902 bytes --]
From aaf0bedfe6aa61ba06761dbe381770ba86bddf6a Mon Sep 17 00:00:00 2001
From: Kevin Pouget <kevin.pouget@st.com>
Date: Tue, 12 Apr 2011 10:31:40 -0400
Subject: [PATCH] Disallow checkpointing of multiple threads
Signed-off-by: Kevin Pouget <kevin.pouget@st.com>
---
gdb/linux-fork.c | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 7f654af..de512c3 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -616,6 +616,33 @@ linux_fork_checkpointing_p (int pid)
return (checkpointing_pid == pid);
}
+/* Callback for iterate over threads. Used to check whether
+ the current inferior is multi-threaded. Returns true as soon
+ as it sees the second thread of the current inferior. */
+
+static int
+inf_has_multiple_thread_cb (struct thread_info *tp, void *data)
+{
+ int *count_p = (int *) data;
+
+ if (current_inferior ()->pid == ptid_get_pid (tp->ptid))
+ (*count_p)++;
+
+ /* Stop the iteration if multiple threads have been detected. */
+ return *count_p > 1;
+}
+
+/* Return true if the current inferior is multi-threaded. */
+
+static int
+inf_has_multiple_threads (void)
+{
+ int count = 0;
+
+ iterate_over_threads (inf_has_multiple_thread_cb, &count);
+ return (count > 1);
+}
+
static void
checkpoint_command (char *args, int from_tty)
{
@@ -628,6 +655,14 @@ checkpoint_command (char *args, int from_tty)
pid_t retpid;
struct cleanup *old_chain;
+ if (!target_has_execution)
+ error (_("The program is not being run."));
+
+ /* Ensure that the inferior is not multithreaded. */
+ update_thread_list ();
+ if (inf_has_multiple_threads ())
+ error (_("checkpoint: can't checkpoint multiple threads."));
+
/* Make the inferior fork, record its (and gdb's) state. */
if (lookup_minimal_symbol ("fork", NULL, NULL) != NULL)
--
1.7.6
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] GDB checkpoint can't/shouldn't be possible with multiple threads on Linux
2011-08-31 12:45 ` Kevin Pouget
@ 2011-09-06 14:42 ` Pedro Alves
2011-09-15 13:32 ` Kevin Pouget
0 siblings, 1 reply; 11+ messages in thread
From: Pedro Alves @ 2011-09-06 14:42 UTC (permalink / raw)
To: Kevin Pouget; +Cc: gdb-patches
Hi Kevin,
On Wednesday 31 August 2011 13:44:43, Kevin Pouget wrote:
> On Tue, Apr 12, 2011 at 3:54 PM, Kevin Pouget <kevin.pouget@gmail.com> wrote:
> >
> > On Tue, Apr 12, 2011 at 9:41 AM, Pedro Alves <pedro@codesourcery.com> wrote:
>
> > > can you rename this local as well, in line with the other
> > > local in the other function? To "count", or "count_p", or something
> > > like that. Thanks. (pre-approved)
> >
> > fixed with count_p, thanks
>
> my copyright assignment is now ready, so I regenerated the patch
> against the up-to-date trunk
This was pre-approved, so you can just check it in once you have a chance.
Thanks,
--
Pedro Alves
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] GDB checkpoint can't/shouldn't be possible with multiple threads on Linux
2011-09-06 14:42 ` Pedro Alves
@ 2011-09-15 13:32 ` Kevin Pouget
0 siblings, 0 replies; 11+ messages in thread
From: Kevin Pouget @ 2011-09-15 13:32 UTC (permalink / raw)
To: gdb-patches
check-in:
http://sourceware.org/ml/gdb-cvs/2011-09/msg00087.html
Thanks,
Kevin
On Tue, Sep 6, 2011 at 3:49 PM, Pedro Alves <pedro@codesourcery.com> wrote:
> Hi Kevin,
>
> On Wednesday 31 August 2011 13:44:43, Kevin Pouget wrote:
>> On Tue, Apr 12, 2011 at 3:54 PM, Kevin Pouget <kevin.pouget@gmail.com> wrote:
>> >
>> > On Tue, Apr 12, 2011 at 9:41 AM, Pedro Alves <pedro@codesourcery.com> wrote:
>>
>> > > can you rename this local as well, in line with the other
>> > > local in the other function? To "count", or "count_p", or something
>> > > like that. Thanks. (pre-approved)
>> >
>> > fixed with count_p, thanks
>>
>> my copyright assignment is now ready, so I regenerated the patch
>> against the up-to-date trunk
>
> This was pre-approved, so you can just check it in once you have a chance.
>
> Thanks,
> --
> Pedro Alves
>
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2011-09-15 12:49 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-12 7:44 [PATCH] GDB checkpoint can't/shouldn't be possible with multiple threads on Linux Kevin Pouget
2011-04-12 10:59 ` Pedro Alves
2011-04-12 11:55 ` Kevin Pouget
2011-04-12 12:55 ` Pedro Alves
2011-04-12 13:28 ` Kevin Pouget
2011-04-12 13:36 ` Pedro Alves
2011-04-12 13:42 ` Pedro Alves
2011-04-12 13:55 ` Kevin Pouget
2011-08-31 12:45 ` Kevin Pouget
2011-09-06 14:42 ` Pedro Alves
2011-09-15 13:32 ` Kevin Pouget
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox