From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6595 invoked by alias); 22 Jan 2015 00:36:49 -0000 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 Received: (qmail 6585 invoked by uid 89); 22 Jan 2015 00:36:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-ob0-f201.google.com Received: from mail-ob0-f201.google.com (HELO mail-ob0-f201.google.com) (209.85.214.201) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 22 Jan 2015 00:36:45 +0000 Received: by mail-ob0-f201.google.com with SMTP id wp4so2706460obc.0 for ; Wed, 21 Jan 2015 16:36:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:mime-version:content-type :content-transfer-encoding:message-id:date:to:cc:subject:in-reply-to :references; bh=pyEeX2D1ok7UDyfaIg6FRV/OkpSiLVbJ9086TM9cTqo=; b=gND1S182s7B6P/qhS9FtsQDna4JdjGtrtWAqlpDZZbvWBJHfiTBJLEzd3t5dzI85RI ptLJqW8XdUZHDti/mnMZZImna1wC417TmHnYpk2wUcxeVaCekX3nSOu8fNhXuu9plKY6 Dy5Crd2aMvyaelmwCUd5HsKfCC2g2qelTg6EhxFM/fQCiK4bqttCU359Tz1Ee/63AyZ9 uGkyH2bMwS98GL4kMiQu817OsylU7hJvMzR7m31oHgEccG41fc0z+RTLBlOnIScUfLC7 4c6xyfs7+cUcj6tnM5WNPotefpkejEER+vUQGqvovBCwpqMbaNZWPFP2lHRBQbgdnrz9 +gZw== X-Gm-Message-State: ALoCoQky+2/sLhS1iLqJLhFndT5sUn/fi80AAp9kdftGWKFYbgREXS+JBQgkaFnV0v4xjPqPF3elPp3qZnU9f4Vtg+b2ItiZb7bhFlAj0LkPLDywy3stczLdv56zgZLa2rAPqKnDn6vNqacbjqld7NS/fQ1qbO4669kBpsLp/h+EJ/PmpVNbVLI= X-Received: by 10.182.130.132 with SMTP id oe4mr8351850obb.37.1421887003424; Wed, 21 Jan 2015 16:36:43 -0800 (PST) Received: from corpmail-nozzle1-2.hot.corp.google.com ([100.108.1.103]) by gmr-mx.google.com with ESMTPS id v10si881753qcf.3.2015.01.21.16.36.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jan 2015 16:36:43 -0800 (PST) Received: from ruffy2.mtv.corp.google.com ([172.17.128.107]) by corpmail-nozzle1-2.hot.corp.google.com with ESMTP id RudIdrUP.1; Wed, 21 Jan 2015 16:36:43 -0800 From: Doug Evans MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <21696.17946.241321.820985@ruffy2.mtv.corp.google.com> Date: Thu, 22 Jan 2015 00:36:00 -0000 To: Jan Kratochvil Cc: gdb-patches Subject: Re: [patch] Print current thread after loading a core file [Re: [patch] Sort threads for thread apply all (bt)] In-Reply-To: <20150117205934.GA31682@host2.jankratochvil.net> References: <20150115183316.GA16405@host2.jankratochvil.net> <20150117205934.GA31682@host2.jankratochvil.net> X-IsSubscribed: yes X-SW-Source: 2015-01/txt/msg00580.txt.bz2 Jan Kratochvil writes: > On Thu, 15 Jan 2015 20:29:07 +0100, Doug Evans wrote: > > On Thu, Jan 15, 2015 at 10:33 AM, Jan Kratochvil wrote: > > > Should GDB always print after loading a core file what "thread" command would > > > print? > > > [Current thread is 1 (Thread 0x7fcbe28fe700 (LWP 15453))] > > > > Sounds reasonable to me. > > Though there is the concern to not even talk about threads if there are "none". > > So maybe only print that if there is more than one thread? > > Attached. > > BTW I think it will print the thread even when loading single/non-threaded > core file when other inferior(s) exist. But that currently crashes > [Bug threads/12074] multi-inferior internal error > https://sourceware.org/bugzilla/show_bug.cgi?id=12074 > plus I think that would be a correct behavior anyway. > > No regressions on {x86_64,x86_64-m32}-fedora22pre-linux-gnu. > > > Jan > gdb/ChangeLog > 2015-01-17 Jan Kratochvil > > * corelow.c (core_open): Call also thread_command. > * gdbthread.h (thread_command): New prototype moved from ... > * thread.c (thread_command): ... here. > (thread_command): Make it global. Hi. LGTM with one nit. > > diff --git a/gdb/corelow.c b/gdb/corelow.c > index a9eadd5..c168d1a 100644 > --- a/gdb/corelow.c > +++ b/gdb/corelow.c > @@ -456,6 +456,17 @@ core_open (const char *arg, int from_tty) > /* Now, set up the frame cache, and print the top of stack. */ > reinit_frame_cache (); > print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1); > + > + /* Current thread should be NUM 1 but the user does not know that. */ > + if (thread_count () >= 2) Can you add a comment explaining why the test is >= 2 here? E.g., something like /* Current thread should be NUM 1 but the user does not know that. If a program is single threaded gdb in general does not mention anything about threads. That is why the test is >= 2. */ > + { > + TRY_CATCH (except, RETURN_MASK_ERROR) > + { > + thread_command (NULL, from_tty); > + } > + if (except.reason < 0) > + exception_print (gdb_stderr, except); > + } > } > > static void > diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h > index 15a979b..a2f378a 100644 > --- a/gdb/gdbthread.h > +++ b/gdb/gdbthread.h > @@ -455,6 +455,8 @@ extern void finish_thread_state_cleanup (void *ptid_p); > /* Commands with a prefix of `thread'. */ > extern struct cmd_list_element *thread_cmd_list; > > +extern void thread_command (char *tidstr, int from_tty); > + > /* Print notices on thread events (attach, detach, etc.), set with > `set print thread-events'. */ > extern int print_thread_events; > diff --git a/gdb/thread.c b/gdb/thread.c > index ed20fbe..4bce212 100644 > --- a/gdb/thread.c > +++ b/gdb/thread.c > @@ -62,7 +62,6 @@ static int highest_thread_num; > spawned new threads we haven't heard of yet. */ > static int threads_executing; > > -static void thread_command (char *tidstr, int from_tty); > static void thread_apply_all_command (char *, int); > static int thread_alive (struct thread_info *); > static void info_threads_command (char *, int); > @@ -1506,7 +1505,7 @@ thread_apply_command (char *tidlist, int from_tty) > /* Switch to the specified thread. Will dispatch off to thread_apply_command > if prefix of arg is `apply'. */ > > -static void > +void > thread_command (char *tidstr, int from_tty) > { > if (!tidstr)