From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2180 invoked by alias); 27 Apr 2013 07:59:42 -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 2171 invoked by uid 89); 27 Apr 2013 07:59:41 -0000 X-Spam-SWARE-Status: No, score=-4.3 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_NO,SPF_SOFTFAIL autolearn=no version=3.3.1 Received: from mtaout20.012.net.il (HELO mtaout20.012.net.il) (80.179.55.166) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sat, 27 Apr 2013 07:59:39 +0000 Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0MLW00E00M1GMC00@a-mtaout20.012.net.il> for gdb-patches@sourceware.org; Sat, 27 Apr 2013 10:58:49 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MLW00C35M61ZCC0@a-mtaout20.012.net.il> for gdb-patches@sourceware.org; Sat, 27 Apr 2013 10:58:49 +0300 (IDT) Date: Sun, 28 Apr 2013 16:24:00 -0000 From: Eli Zaretskii Subject: Re: [RFA] Thread exit messages on MS-Windows In-reply-to: <83obd1tyi7.fsf@gnu.org> To: gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <838v44tnf8.fsf@gnu.org> References: <83obd1tyi7.fsf@gnu.org> X-SW-Source: 2013-04/txt/msg00841.txt.bz2 > Date: Fri, 26 Apr 2013 12:46:56 +0300 > From: Eli Zaretskii > > This is from the node "Threads" of the manual: > > `set print thread-events' > `set print thread-events on' > `set print thread-events off' > The `set print thread-events' command allows you to enable or > disable printing of messages when GDB notices that new threads have > started or that threads have exited. By default, these messages > will be printed if detection of these events is supported by the > target. Note that these messages cannot be disabled on all > targets. > > However, debugging MinGW programs on MS-Windows, I see only messages > about new threads, like this: > > [New Thread 6184.0x1bbc] > [New Thread 6184.0x13c8] > [New Thread 6184.0x1a3c] > > I never see any messages about threads that exited, although examining > the details of the program being debugged, I clearly see that most of > them did. > > Does that mean that GDB doesn't support thread exit messages on > Windows? What feature(s) are missing for this support to be > available? > > I can get thread exit messages from windows-nat.c such as > > [Deleting Thread 8112.0x1494] > [Deleting Thread 8112.0x11d0] > > if I "set verbose on", but that mode causes GDB to become much more > talkative than I'd like. > > In thread.c, I see that add_thread_with_info will announce new threads > if print_thread_events is non-zero, but I see no similar announcement > in delete_thread or its subroutines. Is this supposed to be handled > by target-specific back ends? I see something like that in, e.g., > linux-nat.c and in inf-ttrace.c, but I'm unsure whether that is a > conclusive evidence. > > If indeed thread deletion should be announced by the target, why this > asymmetry with thread creation? > > TIA for any help or info. No one replied, so I'm now converting this into an RFA. The patch below causes GDB on Windows to display thread exit messages like this: [Thread 5920.0x13e4 exited with code 0] [Thread 5920.0x12d0 exited with code 0] [Thread 5920.0x1cbc exited with code 0] OK to commit this (on the trunk)? 2013-04-27 Eli Zaretskii * windows-nat.c (windows_delete_thread): Accept an additional argument, the thread's exit code, and announce thread death when print_thread_events is non-zero and we are deleting a thread that is not the main thread. (get_windows_debug_event): Pass thread exit code to windows_delete_thread. --- gdb/windows-nat.c~0 2013-02-27 21:42:26.000000000 +0200 +++ gdb/windows-nat.c 2013-04-27 10:46:32.937875000 +0300 @@ -386,7 +386,7 @@ windows_init_thread_list (void) /* Delete a thread from the list of threads. */ static void -windows_delete_thread (ptid_t ptid) +windows_delete_thread (ptid_t ptid, DWORD exit_code) { thread_info *th; DWORD id; @@ -397,6 +397,9 @@ windows_delete_thread (ptid_t ptid) if (info_verbose) printf_unfiltered ("[Deleting %s]\n", target_pid_to_str (ptid)); + else if (print_thread_events && id != main_thread_id) + printf_unfiltered (_("[%s exited with code %d]\n"), + target_pid_to_str (ptid), exit_code); delete_thread (ptid); for (th = &thread_head; @@ -1496,7 +1499,8 @@ get_windows_debug_event (struct target_o if (current_event.dwThreadId != main_thread_id) { windows_delete_thread (ptid_build (current_event.dwProcessId, 0, - current_event.dwThreadId)); + current_event.dwThreadId), + current_event.u.ExitThread.dwExitCode); th = &dummy_thread_info; } break; @@ -1513,7 +1517,7 @@ get_windows_debug_event (struct target_o current_process_handle = current_event.u.CreateProcessInfo.hProcess; if (main_thread_id) windows_delete_thread (ptid_build (current_event.dwProcessId, 0, - main_thread_id)); + main_thread_id), 0); main_thread_id = current_event.dwThreadId; /* Add the main thread. */ th = windows_add_thread (ptid_build (current_event.dwProcessId, 0,