From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8AFC238582B0; Thu, 17 Aug 2023 07:20:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8AFC238582B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1692256806; bh=oDLXhifgAdKz3weg/xJ0WJ89gLNZTNw6H1vCE68YpGk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Wa66Vqt8VOsy85XL58IqoLu/oJoXgC/jKh4Pi/YLBfq1L9/9I+5hSvRb2PPmw2DWQ 0UxbfS2oeGqIXF3Dbx0VKyvw9/mHD5qznei7LPMk8rELPP2lT7NWcZjmFEJqs+WBvA nugGnCSuPtJKRPr8NJNS0Y6+w+hphubfVuWKS3Lo= From: "moshe.rubin at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug cli/30771] GDB needs a silent thread-selecting command akin to "select-frame" Date: Thu, 17 Aug 2023 07:20:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: cli X-Bugzilla-Version: 8.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: moshe.rubin at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30771 --- Comment #4 from Moshe Rubin --- Hi Tom, Your intriguing suggestion about using "pipe" (albeit in later versions of = gdb) got me thinking. Checking two versions of gdb 8.2 my organization uses: GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1 GNU gdb (GDB) 8.2.1 it turns out that they support an earlier version of "pipe": (gdb) help pipe Pipe gdb output via a shell command (gdb) pipe cmd1 cmd2 is equivalent to $ cmd1 | cmd2 Examples: pipe "p Vehicles::g_cliquer._members" "grep rectRaw" pipe "p g_invlut" "tail -10|sort -n" (This differs from what I found in gdb 13.1: (gdb) help pipe pipe, | Send the output of a gdb command to a shell command. Usage: | [COMMAND] | SHELL_COMMAND Usage: | -d DELIM COMMAND DELIM SHELL_COMMAND Usage: pipe [COMMAND] | SHELL_COMMAND Usage: pipe -d DELIM COMMAND DELIM SHELL_COMMAND Executes COMMAND and sends its output to SHELL_COMMAND. The -d option indicates to use the string DELIM to separate COMMAND from SHELL_COMMAND, in alternative to |. This is useful in case COMMAND contains a | character. With no COMMAND, repeat the last executed command and send its output to SHELL_COMMAND.) I figured I'd give the older "pipe" a try, and found some intriguing but le= ss than satisfactory results. Here is a session I had in 8.2.1 (the results in 8.1.1 are identical) with my comments based on the line numbers: 1 (gdb) info thread 1 2 3 2 Id Target Id Frame 3 * 1 Thread 0x155538844700 (LWP 8876) __GI_raise (sig=3Dsig@entry=3D6= ) at ../sysdeps/unix/sysv/linux/raise.c:51 4 2 Thread 0x155538885700 (LWP 8875) 0x0000155552be3aa8 in hack_digit (p=3D0x155538882480) at printf_fp.c:175 5 3 Thread 0x155555354b00 (LWP 16327) 0x0000155554019ad3 in futex_wait_cancelable (...) at ../sysdeps/unix/sysv/linux/futex-internal.h:= 88 7 8 (gdb) pipe "thread 2" "cat > /dev/null" 9 [Switching to thread 2 (Thread 0x155538885700 (LWP 8875))] 10 #0 0x0000155552be3aa8 in hack_digit (p=3D0x155538882480) at printf_fp.= c:175 11 12 (gdb) pipe "thread 2" "cat > /dev/null" 13 14 (gdb) pipe "thread 3" "cat > /dev/null" 15 [Switching to thread 3 (Thread 0x155555354b00 (LWP 16327))] 16 #0 0x0000155554019ad3 in futex_wait_cancelable (...) at=20=20=20=20 ../sysdeps/unix/sysv/linux/futex-internal.h:88 17 18 (gdb) pipe "thread 3" "cat > /dev/null" 19 20 (gdb) pipe "thread 2" "cat > /dev/null" 21 [Switching to thread 2 (Thread 0x155538885700 (LWP 8875))] 22 #0 0x0000155552be3aa8 in hack_digit (p=3D0x155538882480) at printf_fp.= c:175 23 24 (gdb) pipe "thread 2" "cat > /dev/null" 25 26 (gdb) thread 1 27 [Switching to thread 1 (Thread 0x155538844700 (LWP 8876))] 28 #0 __GI_raise (sig=3Dsig@entry=3D6) at ../sysdeps/unix/sysv/linux/rais= e.c:51 29 51 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory. 30 (gdb) thread 1 31 [Switching to thread 1 (Thread 0x155538844700 (LWP 8876))] 32 #0 __GI_raise (sig=3Dsig@entry=3D6) at ../sysdeps/unix/sysv/linux/rais= e.c:51 33 51 in ../sysdeps/unix/sysv/linux/raise.c 34 (gdb) thread 1 35 [Switching to thread 1 (Thread 0x155538844700 (LWP 8876))] 36 #0 __GI_raise (sig=3Dsig@entry=3D6) at ../sysdeps/unix/sysv/linux/rais= e.c:51 37 51 in ../sysdeps/unix/sysv/linux/raise.c 38 (gdb) 39 To simplify things, I only show the first three threads. Here are the findings: +-------+---------+------------------+----------+--------------------------= ------------------+ | Lines | Mode | Thread Selection | Visible? | Comment=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | +-------+---------+------------------+----------+--------------------------= ------------------+ | 3 | | | | gdb session opens with th= read #1 selected | | 8-10 | pipe | #1 -> #2 | yes |=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | | 12 | pipe | #2 -> #2 | NO | see lines 26-29 for VISIB= LE case (regular) | | 14-16 | pipe | #2 -> #3 | yes |=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | | 18 | pipe | #3 -> #3 | NO |=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | | 20-22 | pipe | #3 -> #2 | yes |=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | | 24 | pipe | #2 -> #2 | NO |=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | | 26-29 | regular | #1 -> #1 | yes |=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | +-------+---------+------------------+----------+--------------------------= ------------------+ Using ">&" instead of ">" to pipe cat's output doesn't make a difference: (gdb) pipe "thread 3" "cat >& /dev/null" [Switching to thread 3 (Thread 0x155555354b00 (LWP 16327))] #0 0x0000155554019ad3 in futex_wait_cancelable (...) at ../sysdeps/unix/sysv/linux/futex-internal.h:88 When I left out the pipe character ">" I expected to see two identical outp= uts, but it does not: (gdb) pipe "thread 3" "cat" [Switching to thread 3 (Thread 0x155555354b00 (LWP 16327))] #0 0x0000155554019ad3 in futex_wait_cancelable (...) at ../sysdeps/unix/sysv/linux/futex-internal.h:88 88 in ../sysdeps/unix/sysv/linux/futex-internal.h (gdb) ----------------------------------- Questions re gdb 8.2 "pipe" command: ----------------------------------- (1) Why is it not silent when selecting between non-identical threads, but silent with identical threads? (2) Is there a way to get the 8.2 "pipe" to work correctly and silence the output completely? --=20 You are receiving this mail because: You are on the CC list for the bug.=