diff options
author | John Gilmore <gnu@cygnus> | 1992-11-06 09:21:13 +0000 |
---|---|---|
committer | John Gilmore <gnu@cygnus> | 1992-11-06 09:21:13 +0000 |
commit | 8a96d79b70cca5e535ed5f83df0063b8a6d081da (patch) | |
tree | 57213106eece9eb8cbdb0e69cb59bd238b0dbea4 /gdb/source.c | |
parent | a644baaa037aa4b0a1ffeda7371b40c32595f620 (diff) | |
download | gdb-8a96d79b70cca5e535ed5f83df0063b8a6d081da.zip gdb-8a96d79b70cca5e535ed5f83df0063b8a6d081da.tar.gz gdb-8a96d79b70cca5e535ed5f83df0063b8a6d081da.tar.bz2 |
* 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,
<Lee_Cooprider@vos.stratus.com>.
Diffstat (limited to 'gdb/source.c')
-rw-r--r-- | gdb/source.c | 68 |
1 files changed, 47 insertions, 21 deletions
diff --git a/gdb/source.c b/gdb/source.c index e59079d..3869e1a 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, |