aboutsummaryrefslogtreecommitdiff
path: root/gdb/doc
diff options
context:
space:
mode:
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2022-02-07 08:26:56 +0100
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2022-02-07 08:26:56 +0100
commit61fb73769a0168afa466bb2245a1a233942203bb (patch)
treed8f1ca94d686cfca7fbc7cff14c1d54bc0ebecdd /gdb/doc
parent2b826f759256b77b447da9831b079e32a7bb0cdb (diff)
downloadgdb-61fb73769a0168afa466bb2245a1a233942203bb.zip
gdb-61fb73769a0168afa466bb2245a1a233942203bb.tar.gz
gdb-61fb73769a0168afa466bb2245a1a233942203bb.tar.bz2
gdb: add the 'set/show suppress-cli-notifications' command
GDB already has a flag to suppress printing notification events, such as thread and inferior context switches, on the CLI. This is used internally when executing commands. Make the flag available to the user via a new command. This is expected to be useful in scripts. For instance, suppose that when Inferior 1 gets to a certain state, you want to add and set up a new inferior using the commands below, but you also want to have a reduced/clean output. define do-setup printf "Setting up Inferior 2...\n" add-inferior -exec a.out inferior 2 break file.c:3 run inferior 1 printf "Done\n" end Currently, GDB prints (gdb) do-setup Setting up Inferior 2... [New inferior 2] Added inferior 2 on connection 1 (native) [Switching to inferior 2 [<null>] (/tmp/a.out)] Breakpoint 2 at 0x1155: file file.c, line 3. Thread 2.1 "a.out" hit Breakpoint 2, main () at file.c:3 3 return 0; [Switching to inferior 1 [process 7670] (/tmp/test)] [Switching to thread 1.1 (process 7670)] #0 main () at test.c:2 2 int a = 1; Done GDB's Python API make it possible to capture and return GDB's output, but this does not work for all the streams. In particular, CLI notification events are not captured: (gdb) python gdb.execute("do-setup", False, True) [Switching to inferior 2 [<null>] (/tmp/a.out)] Thread 2.1 "a.out" hit Breakpoint 2, main () at file.c:3 3 return 0; [Switching to inferior 1 [process 8263] (/tmp/test)] [Switching to thread 1.1 (process 8263)] #0 main () at test.c:2 2 int a = 1; You can use the new "set suppress-cli-notifications" command to suppress the output: (gdb) set suppress-cli-notifications on (gdb) do-setup Setting up Inferior 2... [New inferior 2] Added inferior 2 on connection 1 (native) Breakpoint 2 at 0x1155: file file.c, line 3. Done
Diffstat (limited to 'gdb/doc')
-rw-r--r--gdb/doc/gdb.texinfo69
1 files changed, 69 insertions, 0 deletions
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 2073d92..8e7fb2d 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -27211,6 +27211,75 @@ inside a cygwin window.
Displays whether the debugger is operating in interactive mode or not.
@end table
+@table @code
+@kindex set suppress-cli-notifications
+@item set suppress-cli-notifications
+If @code{on}, command-line-interface (CLI) notifications that are
+printed by @value{GDBN} are suppressed. If @code{off}, the
+notifications are printed as usual. The default value is @code{off}.
+CLI notifications occur when you change the selected context or when
+the program being debugged stops, as detailed below.
+
+@table @emph
+@item User-selected context changes:
+When you change the selected context (i.e.@: the current inferior,
+thread and/or the frame), @value{GDBN} prints information about the
+new context. For example, the default behavior is below:
+
+@smallexample
+(gdb) inferior 1
+[Switching to inferior 1 [process 634] (/tmp/test)]
+[Switching to thread 1 (process 634)]
+#0 main () at test.c:3
+3 return 0;
+(gdb)
+@end smallexample
+
+When the notifications are suppressed, the new context is not printed:
+
+@smallexample
+(gdb) set suppress-cli-notifications on
+(gdb) inferior 1
+(gdb)
+@end smallexample
+
+@item The program being debugged stops:
+When the program you are debugging stops (e.g.@: because of hitting a
+breakpoint, completing source-stepping, an interrupt, etc.),
+@value{GDBN} prints information about the stop event. For example,
+below is a breakpoint hit:
+
+@smallexample
+(gdb) break test.c:3
+Breakpoint 2 at 0x555555555155: file test.c, line 3.
+(gdb) continue
+Continuing.
+
+Breakpoint 2, main () at test.c:3
+3 return 0;
+(gdb)
+@end smallexample
+
+When the notifications are suppressed, the output becomes:
+
+@smallexample
+(gdb) break test.c:3
+Breakpoint 2 at 0x555555555155: file test.c, line 3.
+(gdb) set suppress-cli-notifications on
+(gdb) continue
+Continuing.
+(gdb)
+@end smallexample
+
+Suppressing CLI notifications may be useful in scripts to obtain a
+reduced output from a list of commands.
+@end table
+
+@kindex show suppress-cli-notifications
+@item show suppress-cli-notifications
+Displays whether printing CLI notifications is suppressed or not.
+@end table
+
@node Extending GDB
@chapter Extending @value{GDBN}
@cindex extending GDB