From 8a96d79b70cca5e535ed5f83df0063b8a6d081da Mon Sep 17 00:00:00 2001 From: John Gilmore Date: Fri, 6 Nov 1992 09:21:13 +0000 Subject: [PATCH] * m68k-stub.c: Remove ansidecl.h and the few uses of it. Stubs should stand alone as much as possible. * source.c (show_directories): Avoid printf_filtered length prob pointed out by Jonathan Stone. * i960-pinsn.c (MEM_MAX, MEM_SIZ): Set upper limit properly to avoid accesses beyond end of table. Fix by Lee W. Cooprider, . --- gdb/ChangeLog | 12 +++++++++ gdb/i960-pinsn.c | 8 +++--- gdb/source.c | 68 +++++++++++++++++++++++++++++++++--------------- 3 files changed, 64 insertions(+), 24 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6eb2743456..7b5ce02ee9 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +Fri Nov 6 00:14:38 1992 John Gilmore (gnu@cygnus.com) + + * m68k-stub.c: Remove ansidecl.h and the few uses of it. + Stubs should stand alone as much as possible. + + * source.c (show_directories): Avoid printf_filtered length prob + pointed out by Jonathan Stone. + + * i960-pinsn.c (MEM_MAX, MEM_SIZ): Set upper limit properly to + avoid accesses beyond end of table. Fix by Lee W. Cooprider, + . + Thu Nov 5 17:33:08 1992 Fred Fish (fnf@cygnus.com) * {ser-bsd.c, ser-termios.c} (serial_close): Pass address of diff --git a/gdb/i960-pinsn.c b/gdb/i960-pinsn.c index 4fee194c45..85dc5bc267 100644 --- a/gdb/i960-pinsn.c +++ b/gdb/i960-pinsn.c @@ -341,8 +341,12 @@ mem( memaddr, word1, word2, noprint ) * -2: 2 operands, store instruction */ static struct tabent *mem_tab = NULL; - static struct { int opcode; char *name; char numops; } mem_init[] = { +/* Opcodes of 0x8X, 9X, aX, bX, and cX must be in the table. */ #define MEM_MIN 0x80 +#define MEM_MAX 0xcf +#define MEM_SIZ ((MEM_MAX-MEM_MIN+1) * sizeof(struct tabent)) + + static struct { int opcode; char *name; char numops; } mem_init[] = { 0x80, "ldob", 2, 0x82, "stob", -2, 0x84, "bx", 1, @@ -363,8 +367,6 @@ mem( memaddr, word1, word2, noprint ) 0xc2, "stib", -2, 0xc8, "ldis", 2, 0xca, "stis", -2, -#define MEM_MAX 0xca -#define MEM_SIZ ((MEM_MAX-MEM_MIN+1) * sizeof(struct tabent)) 0, NULL, 0 }; diff --git a/gdb/source.c b/gdb/source.c index e59079d410..3869e1a169 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -200,7 +200,9 @@ show_directories (ignore, from_tty) char *ignore; int from_tty; { - printf_filtered ("Source directories searched: %s\n", source_path); + puts_filtered ("Source directories searched: "); + puts_filtered (source_path); + puts_filtered ("\n"); } /* Forget what we learned about line positions in source files, @@ -608,6 +610,7 @@ find_source_lines (s, desc) int desc; { struct stat st; + char c; register char *data, *p, *end; int nlines = 0; int lines_allocated = 1000; @@ -618,14 +621,35 @@ find_source_lines (s, desc) line_charpos = (int *) xmmalloc (s -> objfile -> md, lines_allocated * sizeof (int)); if (fstat (desc, &st) < 0) - perror_with_name (s->filename); + perror_with_name (s->filename); if (exec_bfd) { exec_mtime = bfd_get_mtime(exec_bfd); if (exec_mtime && exec_mtime < st.st_mtime) - printf_filtered ("Source file is more recent than executable.\n"); + printf_filtered ("Source file is more recent than executable.\n"); } +#ifdef LSEEK_NOT_LINEAR + /* Have to read it byte by byte to find out where the chars live */ + + line_charpos[0] = tell(desc); + nlines = 1; + while (myread(desc, &c, 1)>0) + { + if (c == '\n') + { + if (nlines == lines_allocated) + { + lines_allocated *= 2; + line_charpos = + (int *) xmrealloc (s -> objfile -> md, (char *) line_charpos, + sizeof (int) * lines_allocated); + } + line_charpos[nlines++] = tell(desc); + } + } + +#else /* st_size might be a large type, but we only support source files whose size fits in an int. FIXME. */ size = (int) st.st_size; @@ -637,31 +661,33 @@ find_source_lines (s, desc) data = (char *) alloca (size); #endif if (myread (desc, data, size) < 0) - perror_with_name (s->filename); + perror_with_name (s->filename); end = data + size; p = data; line_charpos[0] = 0; nlines = 1; while (p != end) + { + if (*p++ == '\n' + /* A newline at the end does not start a new line. */ + && p != end) { - if (*p++ == '\n' - /* A newline at the end does not start a new line. */ - && p != end) - { - if (nlines == lines_allocated) - { - lines_allocated *= 2; - line_charpos = - (int *) xmrealloc (s -> objfile -> md, (char *) line_charpos, - sizeof (int) * lines_allocated); - } - line_charpos[nlines++] = p - data; - } + if (nlines == lines_allocated) + { + lines_allocated *= 2; + line_charpos = + (int *) xmrealloc (s -> objfile -> md, (char *) line_charpos, + sizeof (int) * lines_allocated); + } + line_charpos[nlines++] = p - data; } + } +#endif s->nlines = nlines; s->line_charpos = - (int *) xmrealloc (s -> objfile -> md, (char *) line_charpos, - nlines * sizeof (int)); + (int *) xmrealloc (s -> objfile -> md, (char *) line_charpos, + nlines * sizeof (int)); + } /* Return the character position of a line LINE in symtab S. @@ -821,7 +847,7 @@ print_source_lines (s, line, stopline, noerror) printf_filtered ("%d\t", current_source_line++); do { - if (c < 040 && c != '\t' && c != '\n') + if (c < 040 && c != '\t' && c != '\n' && c != '\r') printf_filtered ("^%c", c + 0100); else if (c == 0177) printf_filtered ("^?"); @@ -1293,7 +1319,7 @@ Lines can be specified in these ways:\n\ FILE:FUNCTION, to distinguish among like-named static functions.\n\ *ADDRESS, to list around the line containing that address.\n\ With two args if one is empty it stands for ten lines away from the other arg."); - add_com_alias ("l", "list", class_files, 0); + add_com_alias ("l", "list", class_files, 1); add_show_from_set (add_set_cmd ("listsize", class_support, var_uinteger,