Subject: bug#65007: [PATCH] Allow displaying program IO in the GDB buffer.

From: StrawberryTea <[email-masked]>
Date: Sat, 26 Aug 2023 14:37:06 -0400

Hi Po Lu,

I’m not sure whether I should reply or always send the edited patch in as a separate email and have been emailing several times but no longer getting responses. I made the changes you requested:

lisp/progmodes/gdb-mi.el (gdb-use-io-buffer): Don’t create IO
═════════════════════════════════════════════════════════════

buffer if `gdb-use-io-buffer’.
(gdb-use-io-buffer): New user option.
—
 lisp/progmodes/gdb-mi.el | 16 +++++++++++++—
 1 file changed, 13 insertions(+), 3 deletions(-)

diff –git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index a1091de43e9..00cb1013f7b 100644
— a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -1098,9 +1098,10 @@ detailed description of this mode.
                      (if gdb-debuginfod-enable “on” “off”))
              ’gdb-debuginfod-message)

• (gdb-get-buffer-create ’gdb-inferior-io)
• (gdb-clear-inferior-io)
• (gdb-inferior-io–init-proc (get-process “gdb-inferior”))
⁃ (when gdb-use-io-buffer
⁃ (gdb-get-buffer-create ’gdb-inferior-io)
⁃ (gdb-clear-inferior-io)
⁃ (gdb-inferior-io–init-proc (get-process “gdb-inferior”)))

  (when (eq system-type ’windows-nt)
    ;; Don’t create a separate console window for the debuggee.
@@ -1828,6 +1829,15 @@ this trigger is subscribed to `gdb-buf-publisher’ and called with
   :group ’gdb
   :version “25.1”)

+(defcustom gdb-use-io-buffer t
⁃ “Non-nil means to split the program’s I/O from the GDB buffer.
⁃ 
+If t, create the `gdb-inferior-io’ buffer and redirect the
+program’s I/O to it.“
⁃ :type ’boolean
⁃ :group ’gdb
⁃ :version “30.1”)
⁃ (defun gdb-inferior-filter (proc string)
    (unless (string-equal string “”)
      (let (buf)
–
2.41.0

Po Lu <[email-masked]> writes:

> StrawberryTea <[email-masked]> writes:
>
>> * gdb-mi.el: Add new customizable variable `gdb-split-io-flag’.
>>
>> This change allows the user to control whether program IO is displayed
>> in the GDB buffer or in a separate buffer.  The default is to display it
>> in the the `gdb-inferior-io’ buffer.
>> —
>>  lisp/progmodes/gdb-mi.el | 16 +++++++++++++—
>>  1 file changed, 13 insertions(+), 3 deletions(-)
>>
>> diff –git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
>> index a1091de43e9..8f4f06abb9a 100644
>> — a/lisp/progmodes/gdb-mi.el
>> +++ b/lisp/progmodes/gdb-mi.el
>> @@ -1098,9 +1098,10 @@ detailed description of this mode.
>>                       (if gdb-debuginfod-enable “on” “off”))
>>               ’gdb-debuginfod-message)
>>
>> -  (gdb-get-buffer-create ’gdb-inferior-io)
>> -  (gdb-clear-inferior-io)
>> -  (gdb-inferior-io–init-proc (get-process “gdb-inferior”))
>> +  (when gdb-split-io-flag
>> +    (gdb-get-buffer-create ’gdb-inferior-io)
>> +    (gdb-clear-inferior-io)
>> +    (gdb-inferior-io–init-proc (get-process “gdb-inferior”)))
>>
>>    (when (eq system-type ’windows-nt)
>>      ;; Don’t create a separate console window for the debuggee.
>> @@ -1828,6 +1829,15 @@ this trigger is subscribed to `gdb-buf-publisher’ and called with
>>    :group ’gdb
>>    :version “25.1”)
>>
>> +(defcustom gdb-split-io-flag t
>> +  “Non-nil means to split the program’s I/O from the GDB buffer.
>> +
>> +If t, create the `gdb-inferior-io’ buffer and redirect the
>> +program’s I/O to it.”
>> +  :type ’boolean
>> +  :group ’gdb
>> +  :version “30.1”)
>> +
>>  (defun gdb-inferior-filter (proc string)
>>    (unless (string-equal string “”)
>>      (let (buf)
>
> Please append a ChangeLog entry to your commit messages,
> formatted in adherence with GNU standards.  In particular, it
> should contain one entry for each function changed or variable
> introduced:
>
> Add new customizable variable `gdb-split-io-flag’.
>
> * lisp/progmodes/gdb-mi.el (gdb-split-io-flag): Don’t create IO
> buffer if `gdb-split-io-flag’.
> (gdb-split-io-flag): New user option.
>
> Moreover, wouldn’t `gdb-use-io-buffer’ make a better name for
> this option?  We don’t typically name variables or user options
> ``flags’’ in Emacs.