From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14872 invoked by alias); 12 Apr 2011 11:55:31 -0000 Received: (qmail 14864 invoked by uid 22791); 12 Apr 2011 11:55:30 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-vw0-f41.google.com (HELO mail-vw0-f41.google.com) (209.85.212.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 12 Apr 2011 11:55:26 +0000 Received: by vws4 with SMTP id 4so6511182vws.0 for ; Tue, 12 Apr 2011 04:55:25 -0700 (PDT) Received: by 10.220.164.136 with SMTP id e8mr1765619vcy.79.1302609325124; Tue, 12 Apr 2011 04:55:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.175.197 with HTTP; Tue, 12 Apr 2011 04:55:04 -0700 (PDT) In-Reply-To: <201104121159.06026.pedro@codesourcery.com> References: <201104121159.06026.pedro@codesourcery.com> From: Kevin Pouget Date: Tue, 12 Apr 2011 11:55:00 -0000 Message-ID: Subject: Re: [PATCH] GDB checkpoint can't/shouldn't be possible with multiple threads on Linux To: Pedro Alves Cc: gdb-patches@sourceware.org Content-Type: multipart/mixed; boundary=0016e68971021aed6304a0b75e67 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-04/txt/msg00165.txt.bz2 --0016e68971021aed6304a0b75e67 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-length: 1380 > Next time please post ChangeLog entries as plaintext, > separate from the patch. 2011-04-12 Kevin Pouget 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) > > =A0 =A0pid_t retpid; > > =A0 =A0struct cleanup *old_chain; > > > > + =A0/* Ensure that the inferior is not multithreaded. */ > > Double space after periods. fixed > > + =A0update_thread_list () ; > > + =A0if (thread_count () > 1) > > + =A0 =A0error (_("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. =A0You want the number of threads of the > current process only. =A0AFAIR, there's no function handy that > returns you that. =A0(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 --0016e68971021aed6304a0b75e67 Content-Type: application/octet-stream; name="checkpoint.diff" Content-Disposition: attachment; filename="checkpoint.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gmf4w8q10 Content-length: 1769 ZGlmZiAtLWdpdCBhL2dkYi9saW51eC1mb3JrLmMgYi9nZGIvbGludXgtZm9y ay5jCmluZGV4IDdmNjU0YWYuLjhhMThkNDIgMTAwNjQ0Ci0tLSBhL2dkYi9s aW51eC1mb3JrLmMKKysrIGIvZ2RiL2xpbnV4LWZvcmsuYwpAQCAtNjE2LDYg KzYxNiwyMCBAQCBsaW51eF9mb3JrX2NoZWNrcG9pbnRpbmdfcCAoaW50IHBp ZCkKICAgcmV0dXJuIChjaGVja3BvaW50aW5nX3BpZCA9PSBwaWQpOwogfQog CitzdGF0aWMgaW50CitpbmZfaGFzX211bHRpcGxlX3RocmVhZF9jYiAoc3Ry dWN0IHRocmVhZF9pbmZvICp0cCwgdm9pZCAqZGF0YSkKK3sKKyAgaW50ICpo YXNfbXVsdGlwbGVfdGhyZWFkcyA9IChpbnQgKikgZGF0YTsKKyAgCisgIGdk Yl9hc3NlcnQoY3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