X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fsource.c;h=ae94addb6135f99e240cb197d12be94582f567eb;hb=430329a943352cb440b1075a1b753483985f74bf;hp=d2e47fee8ad0107ca0ede05c531be29d89fad01b;hpb=c214a6fd4d4e7d6d8bfd1dc355442070a63ca61a;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/source.c b/gdb/source.c index d2e47fee8a..ae94addb61 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1,6 +1,6 @@ /* List lines of source files for GDB, the GNU debugger. Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, - 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 + 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of GDB. @@ -44,6 +44,7 @@ #include "filenames.h" /* for DOSish file names */ #include "completer.h" #include "ui-out.h" +#include #ifdef CRLF_SOURCE_FILES @@ -152,21 +153,22 @@ get_current_source_symtab_and_line (void) cursal.symtab = current_source_symtab; cursal.line = current_source_line; + cursal.pc = 0; + cursal.end = 0; return cursal; } -/* Return the current source file for listing and next line to list. - If a file is not set, try and get a default. +/* If the current source file for listing is not set, try and get a default. + Usually called before get_current_source_symtab_and_line() is called. It may err out if a default cannot be determined. - Depending on where it is called, it can recurse as the process of - determining a new default may call the caler! - Use get_current_source_symtab_and_line instead to get whatever - we have without erroring out or trying to get a default. - NOTE: The returned sal pc and end fields are not valid. */ + We must be cautious about where it is called, as it can recurse as the + process of determining a new default may call the caller! + Use get_current_source_symtab_and_line only to get whatever + we have without erroring out or trying to get a default. */ -struct symtab_and_line -get_current_or_default_source_symtab_and_line (void) +void +set_default_source_symtab_and_line (void) { struct symtab_and_line cursal; @@ -176,21 +178,15 @@ get_current_or_default_source_symtab_and_line (void) /* Pull in a current source symtab if necessary */ if (current_source_symtab == 0) select_source_symtab (0); - - cursal.symtab = current_source_symtab; - cursal.line = current_source_line; - cursal.pc = 0; - cursal.end = 0; - - return cursal; } /* Return the current default file for listing and next line to list (the returned sal pc and end fields are not valid.) - and set the surrent default to whatever is in SAL */ + and set the current default to whatever is in SAL. + NOTE: The returned sal pc and end fields are not valid. */ struct symtab_and_line -set_current_source_symtab_and_line (struct symtab_and_line *sal) +set_current_source_symtab_and_line (const struct symtab_and_line *sal) { struct symtab_and_line cursal; @@ -243,7 +239,7 @@ select_source_symtab (register struct symtab *s) /* Make the default place to list be the function `main' if one exists. */ - if (lookup_symbol (main_name (), 0, VAR_NAMESPACE, 0, NULL)) + if (lookup_symbol (main_name (), 0, VAR_DOMAIN, 0, NULL)) { sals = decode_line_spec (main_name (), 1); sal = sals.sals[0]; @@ -362,6 +358,12 @@ init_source_path (void) forget_cached_source_info (); } +void +init_last_source_visited (void) +{ + last_source_visited = NULL; +} + /* Add zero or more directories to the front of the source path. */ void @@ -391,6 +393,18 @@ directory_command (char *dirname, int from_tty) void mod_path (char *dirname, char **which_path) +{ + add_path (dirname, which_path, 1); +} + +/* Workhorse of mod_path. Takes an extra argument to determine + if dirname should be parsed for separators that indicate multiple + directories. This allows for interfaces that pre-parse the dirname + and allow specification of traditional separator characters such + as space or tab. */ + +void +add_path (char *dirname, char **which_path, int parse_separators) { char *old = *which_path; int prefix = 0; @@ -408,9 +422,16 @@ mod_path (char *dirname, char **which_path) struct stat st; { - char *separator = strchr (name, DIRNAME_SEPARATOR); - char *space = strchr (name, ' '); - char *tab = strchr (name, '\t'); + char *separator = NULL; + char *space = NULL; + char *tab = NULL; + + if (parse_separators) + { + separator = strchr (name, DIRNAME_SEPARATOR); + space = strchr (name, ' '); + tab = strchr (name, '\t'); + } if (separator == 0 && space == 0 && tab == 0) p = dirname = name + strlen (name); @@ -541,7 +562,8 @@ mod_path (char *dirname, char **which_path) tinybuf[0] = DIRNAME_SEPARATOR; tinybuf[1] = '\0'; - /* If we have already tacked on a name(s) in this command, be sure they stay on the front as we tack on some more. */ + /* If we have already tacked on a name(s) in this command, be sure they stay + on the front as we tack on some more. */ if (prefix) { char *temp, c; @@ -652,14 +674,24 @@ openp (const char *path, int try_cwd_first, const char *string, mode |= O_BINARY; #endif - if ((try_cwd_first || IS_ABSOLUTE_PATH (string)) && is_regular_file (string)) + if (try_cwd_first || IS_ABSOLUTE_PATH (string)) { int i; - filename = alloca (strlen (string) + 1); - strcpy (filename, string); - fd = open (filename, mode, prot); - if (fd >= 0) - goto done; + + if (is_regular_file (string)) + { + filename = alloca (strlen (string) + 1); + strcpy (filename, string); + fd = open (filename, mode, prot); + if (fd >= 0) + goto done; + } + else + { + filename = NULL; + fd = -1; + } + for (i = 0; string[i]; i++) if (IS_DIR_SEPARATOR (string[i])) goto done; @@ -1202,8 +1234,9 @@ print_source_lines (struct symtab *s, int line, int stopline, int noerror) /* Print a list of files and line numbers which a user may choose from in order to list a function which was specified ambiguously (as with - `list classname::overloadedfuncname', for example). The vector in - SALS provides the filenames and line numbers. */ + `list classname::overloadedfuncname', or 'list objectiveCSelector:). + The vector in SALS provides the filenames and line numbers. + NOTE: some of the SALS may have no filename or line information! */ static void ambiguous_line_spec (struct symtabs_and_lines *sals) @@ -1225,7 +1258,7 @@ line_info (char *arg, int from_tty) CORE_ADDR start_pc, end_pc; int i; - INIT_SAL (&sal); /* initialize to zeroes */ + init_sal (&sal); /* initialize to zeroes */ if (arg == 0) {