Article View: gnu.gdb.bug
Article #10166Patches for new "set listsize" command
From: Peter Schauer
Date: Mon, 02 Apr 1990 17:48
Date: Mon, 02 Apr 1990 17:48
286 lines
8677 bytes
8677 bytes
The following patches implement a new command
set list size
to allow the setting of the size of the source file listing. This is useful
if you have terminals with long screens.
(It also fixes a minor bug if you do a reverse search and the pattern
is not found).
Peter Schauer pes@tumuc.e-technik.tu-muenchen.dbp.de
*** ./source.c.orig Tue Feb 27 10:19:39 1990
--- ./source.c Fri Mar 23 17:46:45 1990
***************
*** 87,93 ****
sal = sals.sals[0];
free (sals.sals);
current_source_symtab = sal.symtab;
! current_source_line = max (sal.line - 9, 1);
return;
}
--- 87,93 ----
sal = sals.sals[0];
free (sals.sals);
current_source_symtab = sal.symtab;
! current_source_line = max (sal.line - (get_list_size() - 1), 1);
return;
}
***************
*** 599,604 ****
--- 609,615 ----
int dummy_beg = 0;
int linenum_beg = 0;
char *p;
+ int list_count = get_list_size();
if (symtab_list == 0 && partial_symtab_list == 0)
error ("No symbol table is loaded. Use the \"symbol-file\" command.");
***************
*** 615,621 ****
if (current_source_symtab == 0)
error ("No default source file yet. Do \"help list\".");
print_source_lines (current_source_symtab, current_source_line,
! current_source_line + 10, 0);
return;
}
--- 626,632 ----
if (current_source_symtab == 0)
error ("No default source file yet. Do \"help list\".");
print_source_lines (current_source_symtab, current_source_line,
! current_source_line + list_count, 0);
return;
}
***************
*** 625,631 ****
if (current_source_symtab == 0)
error ("No default source file yet. Do \"help list\".");
print_source_lines (current_source_symtab,
! max (first_line_listed - 10, 1),
first_line_listed, 0);
return;
}
--- 636,642 ----
if (current_source_symtab == 0)
error ("No default source file yet. Do \"help list\".");
print_source_lines (current_source_symtab,
! max (first_line_listed - list_count, 1),
first_line_listed, 0);
return;
}
***************
*** 731,745 ****
if (dummy_beg && sal_end.symtab == 0)
error ("No default source file yet. Do \"help list\".");
if (dummy_beg)
! print_source_lines (sal_end.symtab, max (sal_end.line - 9, 1),
sal_end.line + 1, 0);
else if (sal.symtab == 0)
error ("No default source file yet. Do \"help list\".");
else if (no_end)
! print_source_lines (sal.symtab, max (sal.line - 5, 1), sal.line + 5, 0);
else
print_source_lines (sal.symtab, sal.line,
! dummy_end ? sal.line + 10 : sal_end.line + 1,
0);
}
--- 742,756 ----
if (dummy_beg && sal_end.symtab == 0)
error ("No default source file yet. Do \"help list\".");
if (dummy_beg)
! print_source_lines (sal_end.symtab, max (sal_end.line - (list_count - 1), 1),
sal_end.line + 1, 0);
else if (sal.symtab == 0)
error ("No default source file yet. Do \"help list\".");
else if (no_end)
! print_source_lines (sal.symtab, max (sal.line - list_count/2, 1), sal.line + list_count/2, 0);
else
print_source_lines (sal.symtab, sal.line,
! dummy_end ? sal.line + list_count : sal_end.line + 1,
0);
}
***************
*** 814,819 ****
--- 825,831 ----
register FILE *stream;
int line = last_line_listed + 1;
char *msg;
+ int list_count = get_list_size();
msg = (char *) re_comp (regex);
if (msg)
***************
*** 865,871 ****
fclose (stream);
print_source_lines (current_source_symtab,
line, line+1, 0);
! current_source_line = max (line - 5, 1);
return;
}
line++;
--- 877,883 ----
fclose (stream);
print_source_lines (current_source_symtab,
line, line+1, 0);
! current_source_line = max (line - list_count/2, 1);
return;
}
line++;
***************
*** 884,889 ****
--- 896,902 ----
register FILE *stream;
int line = last_line_listed - 1;
char *msg;
+ int list_count = get_list_size();
msg = (char *) re_comp (regex);
if (msg)
***************
*** 916,922 ****
stream = fdopen (desc, "r");
clearerr (stream);
! while (1)
{
char buf[4096]; /* Should be reasonable??? */
register char *p = buf;
--- 929,935 ----
stream = fdopen (desc, "r");
clearerr (stream);
! while (line > 1)
{
char buf[4096]; /* Should be reasonable??? */
register char *p = buf;
***************
*** 936,942 ****
fclose (stream);
print_source_lines (current_source_symtab,
line, line+1, 0);
! current_source_line = max (line - 5, 1);
return;
}
line--;
--- 949,955 ----
fclose (stream);
print_source_lines (current_source_symtab,
line, line+1, 0);
! current_source_line = max (line - list_count/2, 1);
return;
}
line--;
*** ./stack.c.orig Fri Oct 20 15:56:08 1989
--- ./stack.c Fri Mar 23 17:46:47 1990
***************
*** 176,182 ****
printf_filtered ("0x%x\t", fi->pc);
print_source_lines (sal.symtab, sal.line, sal.line + 1, 1);
}
! current_source_line = max (sal.line - 5, 1);
}
frame_changed = 0;
if (source != 0)
--- 176,182 ----
printf_filtered ("0x%x\t", fi->pc);
print_source_lines (sal.symtab, sal.line, sal.line + 1, 1);
}
! current_source_line = max (sal.line - get_list_size()/2, 1);
}
frame_changed = 0;
if (source != 0)
*** ./utils.c.orig Mon Apr 2 18:36:40 1990
--- ./utils.c Mon Apr 2 18:38:57 1990
***************
*** 495,502 ****
}
}
! static int lines_per_page, lines_printed, chars_per_line, chars_printed;
/* Set values of page and line size. */
static void
set_screensize_command (arg, from_tty)
--- 495,547 ----
}
}
! static int lines_per_page, list_size;
+ /* Set value of list size. */
+ static void
+ set_listsize_command (arg, from_tty)
+ char *arg;
+ int from_tty;
+ {
+ char *p = arg;
+ char *p1;
+ int tolistsize = list_size;
+
+ if (!*p)
+ error_no_arg ("set listsize");
+
+ while (*p >= '0' && *p <= '9')
+ p++;
+
+ if (*p && *p != ' ' && *p != '\t')
+ error ("Non-integral argument given to \"set listsize\".");
+
+ tolistsize = atoi (arg);
+ if(tolistsize < 3 || tolistsize > lines_per_page)
+ error ("Illegal argument given to \"set listsize\".");
+
+ list_size = tolistsize;
+ }
+
+ int
+ get_list_size()
+ {
+ return(list_size);
+ }
+
+ static void
+ listsize_info (arg, from_tty)
+ char *arg;
+ int from_tty;
+ {
+ if (arg)
+ error ("\"info listsize\" does not take any arguments.");
+
+ printf ("%d lines listed from source file.\n", list_size);
+ }
+
+ static lines_printed, chars_per_line, chars_printed;
+
/* Set values of page and line size. */
static void
set_screensize_command (arg, from_tty)
***************
*** 846,851 ****
--- 891,902 ----
&setlist);
add_info ("screensize", screensize_info,
"Show gdb's current notion of the size of the output screen.");
+ add_cmd ("listsize", class_support, set_listsize_command,
+ "Change line count of source file listing.\n\
+ The argument is the number of lines used for listing source files.",
+ &setlist);
+ add_info ("listsize", listsize_info,
+ "Show line count of source file listing.");
/* These defaults will be used if we are unable to get the correct
values from termcap. */
***************
*** 885,890 ****
--- 936,942 ----
}
}
}
+ list_size = (lines_per_page/2 + 1) & ~1;;
#ifdef USG
/* Initialize signal names. */
Technical Details
Message-ID:
<982@tumuc.UUCP>Path:
arc1-ca.pugleaf.net!gmdzi!unido!fauern!tumuc!pesShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f5053,3a9390a51b3ae401,start X-Google-Attributes: gidf5053,public X-Google-ArrivalTime: 1990-04-02 21:31:01 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!tumuc!pes From: pes@tumuc.e-technik.tu-muenchen.dbp.de (Peter Schauer) Newsgroups: gnu.gdb.bug Subject: Patches for new "set listsize" command Message-ID: <982@tumuc.UUCP> Date: 2 Apr 90 17:48:36 GMT Sender: news@tumuc.UUCP Reply-To: pesrem@tumuc.UUCP (Peter Schauer) Distribution: gnu Organization: Technical University of Munich, West-Germany Lines: 286 Posted: Mon Apr 2 18:48:36 1990