diff -urNp gdb-14.2.orig/gdb/stack.c gdb-14.2/gdb/stack.c --- gdb-14.2.orig/gdb/stack.c 2024-03-03 00:55:00.000000000 -0500 +++ gdb-14.2/gdb/stack.c 2024-05-05 11:27:07.735576624 -0400 @@ -1161,7 +1161,9 @@ print_frame_info (const frame_print_opti uiout->text ("\t"); } - print_source_lines (sal.symtab, sal.line, sal.line + 1, 0); + + if (opts.sourceprint) + print_source_lines (sal.symtab, sal.line, sal.line + 1, 0); } /* If disassemble-next-line is set to on and there is line debug diff -urNp gdb-14.2.orig/gdb/valprint.c gdb-14.2/gdb/valprint.c --- gdb-14.2.orig/gdb/valprint.c 2024-03-03 00:55:00.000000000 -0500 +++ gdb-14.2/gdb/valprint.c 2024-05-05 11:24:32.447511834 -0400 @@ -113,6 +113,7 @@ struct value_print_options user_print_op true, /* addressprint */ false, /* nibblesprint */ false, /* objectprint */ + true, /* sourceprint */ PRINT_MAX_DEFAULT, /* print_max */ PRINT_MAX_CHARS_DEFAULT, /* print_max_chars */ 10, /* repeat_count_threshold */ @@ -2878,6 +2879,16 @@ Printing of C++ virtual function tables value); } +/* Controls printing of source code. */ +static void +show_sourceprint (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + gdb_printf (file, _("\ +Printing of source code to gdb console is %s.\n"), + value); +} + /* Controls looking up an object's derived type using what we find in its vtables. */ static void @@ -3088,6 +3099,14 @@ pretty-printers for that value.") N_("Show printing of C++ virtual function tables."), NULL, /* help_doc */ }, + boolean_option_def { + "source", + [] (value_print_options *opt) { return &opt->sourceprint; }, + show_sourceprint, /* show_cmd_cb */ + N_("Set printing of source code to gdb console."), + N_("Show printing of source code to gdb console."), + NULL, /* help_doc */ + }, }; /* See valprint.h. */ diff -urNp gdb-14.2.orig/gdb/valprint.h gdb-14.2/gdb/valprint.h --- gdb-14.2.orig/gdb/valprint.h 2024-03-03 00:55:00.000000000 -0500 +++ gdb-14.2/gdb/valprint.h 2024-05-05 11:16:22.418856087 -0400 @@ -62,6 +62,9 @@ struct value_print_options in its vtables. */ bool objectprint; + /* Controls printing of source to console. */ + bool sourceprint; + /* Maximum number of elements to print for vector contents, or UINT_MAX for no limit. Note that "set print elements 0" stores UINT_MAX in print_max, which displays in a show command as "unlimited". */