Optionally print source code to gdb console window

Robert Rossi bob@brasko.net
Mon May 6 22:18:59 GMT 2024


I got an automated email saying I broke a test.

This updated patch fixes the test and updates the code to the GNU standard,
hopefully.

Thanks,
Bob Rossi


On Sun, May 5, 2024 at 4:57 PM Robert Rossi <bob@brasko.net> wrote:

> A little history. When using --annotations, gdb did not print the source
> code to the gdb console window. When using mi with new-ui it does. When I
> reported this in the past, several people said it was a feature that gdb
> printed the source code lines to the console.
>
> I've had several users of cgdb say they do not want gdb to print the
> source code to the gdb console window as they can see the code in the code
> view.
>
> I've created and attached a patch that I hope makes it optional to have
> gdb print the source code to the gdb console window. Could I have some
> feedback?
>
> I've added a new print source option to control printing source code to
> the gdb console.
>
> (gdb) show print source
> Printing of source code to gdb console is on.
>
> You can turn the printing of the source code off as follows.
> (gdb) set print source off
> (gdb)
>
> When the printing of source code is on,
> (gdb) r
> Starting program: /home/bob/rcs/git/gdb/gdb-build/main
> ....
> Breakpoint 1, main (argc=1, argv=0x7fffffffe0c8) at test_main.cpp:42
> 42      {
> (gdb) n
> 43          int i = 3;
> (gdb) n
> 44          int j = 4;
> (gdb) n
> 47          long_func();
>
> When the printing of source code is off,
> (gdb) r
> Starting program: /home/bob/rcs/git/gdb/gdb-build/main
> ...
> Breakpoint 1, main (argc=1, argv=0x7fffffffe098) at test_main.cpp:42
> (gdb) n
> (gdb) n
> (gdb) n
> (gdb)
>
> I don't know gdb code well enough to understand if i've disabled
> functionality
> beyond what i was hoping to.
>
> I'm not sure how to control this from cgdb when using old versions of gdb.
> I get the following error when i run --ex "set print source off" when
> starting gdb.
> Undefined set print command: "source off".  Try "help set print".
>
> Thanks,
> Bob Rossi
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/gdb-patches/attachments/20240506/56ece823/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sourceprint-round2.diff
Type: text/x-patch
Size: 2735 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/gdb-patches/attachments/20240506/56ece823/attachment.bin>


More information about the Gdb-patches mailing list