1 /* List lines of source files for GDB, the GNU debugger.
2 Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
3 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 #include "expression.h"
30 #include "gdb_assert.h"
32 #include <sys/types.h>
33 #include "gdb_string.h"
37 #include "gdb_regex.h"
43 #include "filenames.h" /* for DOSish file names */
44 #include "completer.h"
46 #include "readline/readline.h"
49 #define OPEN_MODE (O_RDONLY | O_BINARY)
50 #define FDOPEN_MODE FOPEN_RB
52 /* Prototypes for exported functions. */
54 void _initialize_source (void);
56 /* Prototypes for local functions. */
58 static int get_filename_and_charpos (struct symtab
*, char **);
60 static void reverse_search_command (char *, int);
62 static void forward_search_command (char *, int);
64 static void line_info (char *, int);
66 static void source_info (char *, int);
68 static void show_directories (char *, int);
70 /* Path of directories to search for source files.
71 Same format as the PATH environment variable's value. */
75 /* Support for source path substitution commands. */
77 struct substitute_path_rule
81 struct substitute_path_rule
*next
;
84 static struct substitute_path_rule
*substitute_path_rules
= NULL
;
86 /* Symtab of default file for listing lines of. */
88 static struct symtab
*current_source_symtab
;
90 /* Default next line to list. */
92 static int current_source_line
;
94 /* Default number of lines to print with commands like "list".
95 This is based on guessing how many long (i.e. more than chars_per_line
96 characters) lines there will be. To be completely correct, "list"
97 and friends should be rewritten to count characters and see where
98 things are wrapping, but that would be a fair amount of work. */
100 int lines_to_list
= 10;
102 show_lines_to_list (struct ui_file
*file
, int from_tty
,
103 struct cmd_list_element
*c
, const char *value
)
105 fprintf_filtered (file
, _("\
106 Number of source lines gdb will list by default is %s.\n"),
110 /* Line number of last line printed. Default for various commands.
111 current_source_line is usually, but not always, the same as this. */
113 static int last_line_listed
;
115 /* First line number listed by last listing command. */
117 static int first_line_listed
;
119 /* Saves the name of the last source file visited and a possible error code.
120 Used to prevent repeating annoying "No such file or directories" msgs */
122 static struct symtab
*last_source_visited
= NULL
;
123 static int last_source_error
= 0;
125 /* Return the first line listed by print_source_lines.
126 Used by command interpreters to request listing from
130 get_first_line_listed (void)
132 return first_line_listed
;
135 /* Return the default number of lines to print with commands like the
136 cli "list". The caller of print_source_lines must use this to
137 calculate the end line and use it in the call to print_source_lines
138 as it does not automatically use this value. */
141 get_lines_to_list (void)
143 return lines_to_list
;
146 /* Return the current source file for listing and next line to list.
147 NOTE: The returned sal pc and end fields are not valid. */
149 struct symtab_and_line
150 get_current_source_symtab_and_line (void)
152 struct symtab_and_line cursal
= { 0 };
154 cursal
.symtab
= current_source_symtab
;
155 cursal
.line
= current_source_line
;
162 /* If the current source file for listing is not set, try and get a default.
163 Usually called before get_current_source_symtab_and_line() is called.
164 It may err out if a default cannot be determined.
165 We must be cautious about where it is called, as it can recurse as the
166 process of determining a new default may call the caller!
167 Use get_current_source_symtab_and_line only to get whatever
168 we have without erroring out or trying to get a default. */
171 set_default_source_symtab_and_line (void)
173 struct symtab_and_line cursal
;
175 if (!have_full_symbols () && !have_partial_symbols ())
176 error (_("No symbol table is loaded. Use the \"file\" command."));
178 /* Pull in a current source symtab if necessary */
179 if (current_source_symtab
== 0)
180 select_source_symtab (0);
183 /* Return the current default file for listing and next line to list
184 (the returned sal pc and end fields are not valid.)
185 and set the current default to whatever is in SAL.
186 NOTE: The returned sal pc and end fields are not valid. */
188 struct symtab_and_line
189 set_current_source_symtab_and_line (const struct symtab_and_line
*sal
)
191 struct symtab_and_line cursal
= { 0 };
193 cursal
.symtab
= current_source_symtab
;
194 cursal
.line
= current_source_line
;
196 current_source_symtab
= sal
->symtab
;
197 current_source_line
= sal
->line
;
204 /* Reset any information stored about a default file and line to print. */
207 clear_current_source_symtab_and_line (void)
209 current_source_symtab
= 0;
210 current_source_line
= 0;
213 /* Set the source file default for the "list" command to be S.
215 If S is NULL, and we don't have a default, find one. This
216 should only be called when the user actually tries to use the
217 default, since we produce an error if we can't find a reasonable
218 default. Also, since this can cause symbols to be read, doing it
219 before we need to would make things slower than necessary. */
222 select_source_symtab (struct symtab
*s
)
224 struct symtabs_and_lines sals
;
225 struct symtab_and_line sal
;
226 struct partial_symtab
*ps
;
227 struct partial_symtab
*cs_pst
= 0;
232 current_source_symtab
= s
;
233 current_source_line
= 1;
237 if (current_source_symtab
)
240 /* Make the default place to list be the function `main'
242 if (lookup_symbol (main_name (), 0, VAR_DOMAIN
, 0, NULL
))
244 sals
= decode_line_spec (main_name (), 1);
247 current_source_symtab
= sal
.symtab
;
248 current_source_line
= max (sal
.line
- (lines_to_list
- 1), 1);
249 if (current_source_symtab
)
253 /* All right; find the last file in the symtab list (ignoring .h's). */
255 current_source_line
= 1;
257 for (ofp
= object_files
; ofp
!= NULL
; ofp
= ofp
->next
)
259 for (s
= ofp
->symtabs
; s
; s
= s
->next
)
261 const char *name
= s
->filename
;
262 int len
= strlen (name
);
263 if (!(len
> 2 && strcmp(&name
[len
- 2], ".h") == 0))
264 current_source_symtab
= s
;
267 if (current_source_symtab
)
270 /* Howabout the partial symbol tables? */
272 for (ofp
= object_files
; ofp
!= NULL
; ofp
= ofp
->next
)
274 for (ps
= ofp
->psymtabs
; ps
!= NULL
; ps
= ps
->next
)
276 const char *name
= ps
->filename
;
277 int len
= strlen (name
);
278 if (!(len
> 2 && strcmp (&name
[len
- 2], ".h") == 0))
286 internal_error (__FILE__
, __LINE__
,
287 _("select_source_symtab: "
288 "readin pst found and no symtabs."));
292 current_source_symtab
= PSYMTAB_TO_SYMTAB (cs_pst
);
295 if (current_source_symtab
)
298 error (_("Can't find a default source file"));
302 show_directories (char *ignore
, int from_tty
)
304 puts_filtered ("Source directories searched: ");
305 puts_filtered (source_path
);
306 puts_filtered ("\n");
309 /* Forget what we learned about line positions in source files, and
310 which directories contain them; must check again now since files
311 may be found in a different directory now. */
314 forget_cached_source_info (void)
317 struct objfile
*objfile
;
318 struct partial_symtab
*pst
;
320 for (objfile
= object_files
; objfile
!= NULL
; objfile
= objfile
->next
)
322 for (s
= objfile
->symtabs
; s
!= NULL
; s
= s
->next
)
324 if (s
->line_charpos
!= NULL
)
326 xfree (s
->line_charpos
);
327 s
->line_charpos
= NULL
;
329 if (s
->fullname
!= NULL
)
336 ALL_OBJFILE_PSYMTABS (objfile
, pst
)
338 if (pst
->fullname
!= NULL
)
340 xfree (pst
->fullname
);
341 pst
->fullname
= NULL
;
348 init_source_path (void)
352 sprintf (buf
, "$cdir%c$cwd", DIRNAME_SEPARATOR
);
353 source_path
= xstrdup (buf
);
354 forget_cached_source_info ();
358 init_last_source_visited (void)
360 last_source_visited
= NULL
;
363 /* Add zero or more directories to the front of the source path. */
366 directory_command (char *dirname
, int from_tty
)
369 /* FIXME, this goes to "delete dir"... */
372 if (!from_tty
|| query (_("Reinitialize source path to empty? ")))
380 mod_path (dirname
, &source_path
);
381 last_source_visited
= NULL
;
384 show_directories ((char *) 0, from_tty
);
385 forget_cached_source_info ();
388 /* Add a path given with the -d command line switch.
389 This will not be quoted so we must not treat spaces as separators. */
392 directory_switch (char *dirname
, int from_tty
)
394 add_path (dirname
, &source_path
, 0);
397 /* Add zero or more directories to the front of an arbitrary path. */
400 mod_path (char *dirname
, char **which_path
)
402 add_path (dirname
, which_path
, 1);
405 /* Workhorse of mod_path. Takes an extra argument to determine
406 if dirname should be parsed for separators that indicate multiple
407 directories. This allows for interfaces that pre-parse the dirname
408 and allow specification of traditional separator characters such
412 add_path (char *dirname
, char **which_path
, int parse_separators
)
414 char *old
= *which_path
;
423 if (parse_separators
)
425 /* This will properly parse the space and tab separators
426 and any quotes that may exist. DIRNAME_SEPARATOR will
427 be dealt with later. */
428 argv
= buildargv (dirname
);
429 make_cleanup_freeargv (argv
);
438 arg
= xstrdup (dirname
);
439 make_cleanup (xfree
, arg
);
449 char *separator
= NULL
;
451 /* Spaces and tabs will have been removed by buildargv().
452 The directories will there be split into a list but
453 each entry may still contain DIRNAME_SEPARATOR. */
454 if (parse_separators
)
455 separator
= strchr (name
, DIRNAME_SEPARATOR
);
458 p
= arg
= name
+ strlen (name
);
463 while (*arg
== DIRNAME_SEPARATOR
)
467 /* If there are no more directories in this argument then start
468 on the next argument next time round the loop (if any). */
470 arg
= parse_separators
? argv
[++argv_index
] : NULL
;
473 /* name is the start of the directory.
474 p is the separator (or null) following the end. */
476 while (!(IS_DIR_SEPARATOR (*name
) && p
<= name
+ 1) /* "/" */
477 #ifdef HAVE_DOS_BASED_FILE_SYSTEM
478 /* On MS-DOS and MS-Windows, h:\ is different from h: */
479 && !(p
== name
+ 3 && name
[1] == ':') /* "d:/" */
481 && IS_DIR_SEPARATOR (p
[-1]))
482 /* Sigh. "foo/" => "foo" */
486 while (p
> name
&& p
[-1] == '.')
490 /* "." => getwd (). */
491 name
= current_directory
;
494 else if (p
> name
+ 1 && IS_DIR_SEPARATOR (p
[-2]))
504 /* "...foo/." => "...foo". */
515 name
= tilde_expand (name
);
516 #ifdef HAVE_DOS_BASED_FILE_SYSTEM
517 else if (IS_ABSOLUTE_PATH (name
) && p
== name
+ 2) /* "d:" => "d:." */
518 name
= concat (name
, ".", (char *)NULL
);
520 else if (!IS_ABSOLUTE_PATH (name
) && name
[0] != '$')
521 name
= concat (current_directory
, SLASH_STRING
, name
, (char *)NULL
);
523 name
= savestring (name
, p
- name
);
524 make_cleanup (xfree
, name
);
526 /* Unless it's a variable, check existence. */
529 /* These are warnings, not errors, since we don't want a
530 non-existent directory in a .gdbinit file to stop processing
531 of the .gdbinit file.
533 Whether they get added to the path is more debatable. Current
534 answer is yes, in case the user wants to go make the directory
535 or whatever. If the directory continues to not exist/not be
536 a directory/etc, then having them in the path should be
538 if (stat (name
, &st
) < 0)
540 int save_errno
= errno
;
541 fprintf_unfiltered (gdb_stderr
, "Warning: ");
542 print_sys_errmsg (name
, save_errno
);
544 else if ((st
.st_mode
& S_IFMT
) != S_IFDIR
)
545 warning (_("%s is not a directory."), name
);
550 unsigned int len
= strlen (name
);
555 /* FIXME: strncmp loses in interesting ways on MS-DOS and
556 MS-Windows because of case-insensitivity and two different
557 but functionally identical slash characters. We need a
558 special filesystem-dependent file-name comparison function.
560 Actually, even on Unix I would use realpath() or its work-
561 alike before comparing. Then all the code above which
562 removes excess slashes and dots could simply go away. */
563 if (!strncmp (p
, name
, len
)
564 && (p
[len
] == '\0' || p
[len
] == DIRNAME_SEPARATOR
))
566 /* Found it in the search path, remove old copy */
568 p
--; /* Back over leading separator */
569 if (prefix
> p
- *which_path
)
570 goto skip_dup
; /* Same dir twice in one cmd */
571 strcpy (p
, &p
[len
+ 1]); /* Copy from next \0 or : */
573 p
= strchr (p
, DIRNAME_SEPARATOR
);
583 tinybuf
[0] = DIRNAME_SEPARATOR
;
586 /* If we have already tacked on a name(s) in this command, be sure they stay
587 on the front as we tack on some more. */
594 temp
= concat (old
, tinybuf
, name
, (char *)NULL
);
596 *which_path
= concat (temp
, "", &old
[prefix
], (char *)NULL
);
597 prefix
= strlen (temp
);
602 *which_path
= concat (name
, (old
[0] ? tinybuf
: old
),
604 prefix
= strlen (name
);
617 source_info (char *ignore
, int from_tty
)
619 struct symtab
*s
= current_source_symtab
;
623 printf_filtered (_("No current source file.\n"));
626 printf_filtered (_("Current source file is %s\n"), s
->filename
);
628 printf_filtered (_("Compilation directory is %s\n"), s
->dirname
);
630 printf_filtered (_("Located in %s\n"), s
->fullname
);
632 printf_filtered (_("Contains %d line%s.\n"), s
->nlines
,
633 s
->nlines
== 1 ? "" : "s");
635 printf_filtered (_("Source language is %s.\n"), language_str (s
->language
));
636 printf_filtered (_("Compiled with %s debugging format.\n"), s
->debugformat
);
637 printf_filtered (_("%s preprocessor macro info.\n"),
638 s
->macro_table
? "Includes" : "Does not include");
642 /* Return True if the file NAME exists and is a regular file */
644 is_regular_file (const char *name
)
647 const int status
= stat (name
, &st
);
649 /* Stat should never fail except when the file does not exist.
650 If stat fails, analyze the source of error and return True
651 unless the file does not exist, to avoid returning false results
652 on obscure systems where stat does not work as expected.
655 return (errno
!= ENOENT
);
657 return S_ISREG (st
.st_mode
);
660 /* Open a file named STRING, searching path PATH (dir names sep by some char)
661 using mode MODE and protection bits PROT in the calls to open.
663 OPTS specifies the function behaviour in specific cases.
665 If OPF_TRY_CWD_FIRST, try to open ./STRING before searching PATH.
666 (ie pretend the first element of PATH is "."). This also indicates
667 that a slash in STRING disables searching of the path (this is
668 so that "exec-file ./foo" or "symbol-file ./foo" insures that you
669 get that particular version of foo or an error message).
671 If OPTS has OPF_SEARCH_IN_PATH set, absolute names will also be
672 searched in path (we usually want this for source files but not for
675 If FILENAME_OPENED is non-null, set it to a newly allocated string naming
676 the actual file opened (this string will always start with a "/"). We
677 have to take special pains to avoid doubling the "/" between the directory
678 and the file, sigh! Emacs gets confuzzed by this when we print the
681 If a file is found, return the descriptor.
682 Otherwise, return -1, with errno set for the last name we tried to open. */
684 /* >>>> This should only allow files of certain types,
685 >>>> eg executable, non-directory */
687 openp (const char *path
, int opts
, const char *string
,
689 char **filename_opened
)
703 if ((opts
& OPF_TRY_CWD_FIRST
) || IS_ABSOLUTE_PATH (string
))
707 if (is_regular_file (string
))
709 filename
= alloca (strlen (string
) + 1);
710 strcpy (filename
, string
);
711 fd
= open (filename
, mode
, prot
);
721 if (!(opts
& OPF_SEARCH_IN_PATH
))
722 for (i
= 0; string
[i
]; i
++)
723 if (IS_DIR_SEPARATOR (string
[i
]))
727 /* /foo => foo, to avoid multiple slashes that Emacs doesn't like. */
728 while (IS_DIR_SEPARATOR(string
[0]))
732 while (string
[0] == '.' && IS_DIR_SEPARATOR (string
[1]))
735 alloclen
= strlen (path
) + strlen (string
) + 2;
736 filename
= alloca (alloclen
);
738 for (p
= path
; p
; p
= p1
? p1
+ 1 : 0)
740 p1
= strchr (p
, DIRNAME_SEPARATOR
);
746 if (len
== 4 && p
[0] == '$' && p
[1] == 'c'
747 && p
[2] == 'w' && p
[3] == 'd')
749 /* Name is $cwd -- insert current directory name instead. */
752 /* First, realloc the filename buffer if too short. */
753 len
= strlen (current_directory
);
754 newlen
= len
+ strlen (string
) + 2;
755 if (newlen
> alloclen
)
758 filename
= alloca (alloclen
);
760 strcpy (filename
, current_directory
);
764 /* Normal file name in path -- just use it. */
765 strncpy (filename
, p
, len
);
769 /* Remove trailing slashes */
770 while (len
> 0 && IS_DIR_SEPARATOR (filename
[len
- 1]))
773 strcat (filename
+ len
, SLASH_STRING
);
774 strcat (filename
, string
);
776 if (is_regular_file (filename
))
778 fd
= open (filename
, mode
);
787 /* If a file was opened, canonicalize its filename. Use xfullpath
788 rather than gdb_realpath to avoid resolving the basename part
789 of filenames when the associated file is a symbolic link. This
790 fixes a potential inconsistency between the filenames known to
791 GDB and the filenames it prints in the annotations. */
793 *filename_opened
= NULL
;
794 else if (IS_ABSOLUTE_PATH (filename
))
795 *filename_opened
= xfullpath (filename
);
798 /* Beware the // my son, the Emacs barfs, the botch that catch... */
800 char *f
= concat (current_directory
,
801 IS_DIR_SEPARATOR (current_directory
[strlen (current_directory
) - 1])
803 filename
, (char *)NULL
);
804 *filename_opened
= xfullpath (f
);
813 /* This is essentially a convenience, for clients that want the behaviour
814 of openp, using source_path, but that really don't want the file to be
815 opened but want instead just to know what the full pathname is (as
816 qualified against source_path).
818 The current working directory is searched first.
820 If the file was found, this function returns 1, and FULL_PATHNAME is
821 set to the fully-qualified pathname.
823 Else, this functions returns 0, and FULL_PATHNAME is set to NULL. */
825 source_full_path_of (char *filename
, char **full_pathname
)
829 fd
= openp (source_path
, OPF_TRY_CWD_FIRST
| OPF_SEARCH_IN_PATH
, filename
,
830 O_RDONLY
, 0, full_pathname
);
833 *full_pathname
= NULL
;
841 /* Return non-zero if RULE matches PATH, that is if the rule can be
845 substitute_path_rule_matches (const struct substitute_path_rule
*rule
,
848 const int from_len
= strlen (rule
->from
);
849 const int path_len
= strlen (path
);
852 if (path_len
< from_len
)
855 /* The substitution rules are anchored at the start of the path,
856 so the path should start with rule->from. There is no filename
857 comparison routine, so we need to extract the first FROM_LEN
858 characters from PATH first and use that to do the comparison. */
860 path_start
= alloca (from_len
+ 1);
861 strncpy (path_start
, path
, from_len
);
862 path_start
[from_len
] = '\0';
864 if (FILENAME_CMP (path_start
, rule
->from
) != 0)
867 /* Make sure that the region in the path that matches the substitution
868 rule is immediately followed by a directory separator (or the end of
869 string character). */
871 if (path
[from_len
] != '\0' && !IS_DIR_SEPARATOR (path
[from_len
]))
877 /* Find the substitute-path rule that applies to PATH and return it.
878 Return NULL if no rule applies. */
880 static struct substitute_path_rule
*
881 get_substitute_path_rule (const char *path
)
883 struct substitute_path_rule
*rule
= substitute_path_rules
;
885 while (rule
!= NULL
&& !substitute_path_rule_matches (rule
, path
))
891 /* If the user specified a source path substitution rule that applies
892 to PATH, then apply it and return the new path. This new path must
893 be deallocated afterwards.
895 Return NULL if no substitution rule was specified by the user,
896 or if no rule applied to the given PATH. */
899 rewrite_source_path (const char *path
)
901 const struct substitute_path_rule
*rule
= get_substitute_path_rule (path
);
908 from_len
= strlen (rule
->from
);
910 /* Compute the rewritten path and return it. */
913 (char *) xmalloc (strlen (path
) + 1 + strlen (rule
->to
) - from_len
);
914 strcpy (new_path
, rule
->to
);
915 strcat (new_path
, path
+ from_len
);
920 /* This function is capable of finding the absolute path to a
921 source file, and opening it, provided you give it an
922 OBJFILE and FILENAME. Both the DIRNAME and FULLNAME are only
923 added suggestions on where to find the file.
925 OBJFILE should be the objfile associated with a psymtab or symtab.
926 FILENAME should be the filename to open.
927 DIRNAME is the compilation directory of a particular source file.
928 Only some debug formats provide this info.
929 FULLNAME can be the last known absolute path to the file in question.
932 A valid file descriptor is returned. ( the return value is positive )
933 FULLNAME is set to the absolute path to the file just opened.
936 An invalid file descriptor is returned. ( the return value is negative )
937 FULLNAME is set to NULL. */
939 find_and_open_source (struct objfile
*objfile
,
940 const char *filename
,
944 char *path
= source_path
;
948 /* Quick way out if we already know its full name */
952 /* The user may have requested that source paths be rewritten
953 according to substitution rules he provided. If a substitution
954 rule applies to this path, then apply it. */
955 char *rewritten_fullname
= rewrite_source_path (*fullname
);
957 if (rewritten_fullname
!= NULL
)
960 *fullname
= rewritten_fullname
;
963 result
= open (*fullname
, OPEN_MODE
);
966 /* Didn't work -- free old one, try again. */
973 /* If necessary, rewrite the compilation directory name according
974 to the source path substitution rules specified by the user. */
976 char *rewritten_dirname
= rewrite_source_path (dirname
);
978 if (rewritten_dirname
!= NULL
)
980 make_cleanup (xfree
, rewritten_dirname
);
981 dirname
= rewritten_dirname
;
984 /* Replace a path entry of $cdir with the compilation directory name */
986 /* We cast strstr's result in case an ANSIhole has made it const,
987 which produces a "required warning" when assigned to a nonconst. */
988 p
= (char *) strstr (source_path
, "$cdir");
989 if (p
&& (p
== path
|| p
[-1] == DIRNAME_SEPARATOR
)
990 && (p
[cdir_len
] == DIRNAME_SEPARATOR
|| p
[cdir_len
] == '\0'))
995 alloca (strlen (source_path
) + 1 + strlen (dirname
) + 1);
996 len
= p
- source_path
;
997 strncpy (path
, source_path
, len
); /* Before $cdir */
998 strcpy (path
+ len
, dirname
); /* new stuff */
999 strcat (path
+ len
, source_path
+ len
+ cdir_len
); /* After $cdir */
1003 if (IS_ABSOLUTE_PATH (filename
))
1005 /* If filename is absolute path, try the source path
1006 substitution on it. */
1007 char *rewritten_filename
= rewrite_source_path (filename
);
1009 if (rewritten_filename
!= NULL
)
1011 make_cleanup (xfree
, rewritten_filename
);
1012 filename
= rewritten_filename
;
1016 result
= openp (path
, OPF_SEARCH_IN_PATH
, filename
, OPEN_MODE
, 0, fullname
);
1019 /* Didn't work. Try using just the basename. */
1020 p
= lbasename (filename
);
1022 result
= openp (path
, OPF_SEARCH_IN_PATH
, p
, OPEN_MODE
, 0, fullname
);
1028 tmp_fullname
= *fullname
;
1029 *fullname
= xstrdup (tmp_fullname
);
1030 xfree (tmp_fullname
);
1035 /* Open a source file given a symtab S. Returns a file descriptor or
1036 negative number for error.
1038 This function is a convience function to find_and_open_source. */
1041 open_source_file (struct symtab
*s
)
1046 return find_and_open_source (s
->objfile
, s
->filename
, s
->dirname
,
1050 /* Finds the fullname that a symtab represents.
1052 If this functions finds the fullname, it will save it in ps->fullname
1053 and it will also return the value.
1055 If this function fails to find the file that this symtab represents,
1056 NULL will be returned and ps->fullname will be set to NULL. */
1058 symtab_to_fullname (struct symtab
*s
)
1065 /* Don't check s->fullname here, the file could have been
1066 deleted/moved/..., look for it again */
1067 r
= find_and_open_source (s
->objfile
, s
->filename
, s
->dirname
,
1079 /* Finds the fullname that a partial_symtab represents.
1081 If this functions finds the fullname, it will save it in ps->fullname
1082 and it will also return the value.
1084 If this function fails to find the file that this partial_symtab represents,
1085 NULL will be returned and ps->fullname will be set to NULL. */
1087 psymtab_to_fullname (struct partial_symtab
*ps
)
1094 /* Don't check ps->fullname here, the file could have been
1095 deleted/moved/..., look for it again */
1096 r
= find_and_open_source (ps
->objfile
, ps
->filename
, ps
->dirname
,
1102 return ps
->fullname
;
1108 /* Create and initialize the table S->line_charpos that records
1109 the positions of the lines in the source file, which is assumed
1110 to be open on descriptor DESC.
1111 All set S->nlines to the number of such lines. */
1114 find_source_lines (struct symtab
*s
, int desc
)
1117 char *data
, *p
, *end
;
1119 int lines_allocated
= 1000;
1125 line_charpos
= (int *) xmalloc (lines_allocated
* sizeof (int));
1126 if (fstat (desc
, &st
) < 0)
1127 perror_with_name (s
->filename
);
1129 if (s
->objfile
&& s
->objfile
->obfd
)
1130 mtime
= s
->objfile
->mtime
;
1132 mtime
= exec_bfd_mtime
;
1134 if (mtime
&& mtime
< st
.st_mtime
)
1135 warning (_("Source file is more recent than executable."));
1137 #ifdef LSEEK_NOT_LINEAR
1141 /* Have to read it byte by byte to find out where the chars live */
1143 line_charpos
[0] = lseek (desc
, 0, SEEK_CUR
);
1145 while (myread (desc
, &c
, 1) > 0)
1149 if (nlines
== lines_allocated
)
1151 lines_allocated
*= 2;
1153 (int *) xrealloc ((char *) line_charpos
,
1154 sizeof (int) * lines_allocated
);
1156 line_charpos
[nlines
++] = lseek (desc
, 0, SEEK_CUR
);
1160 #else /* lseek linear. */
1162 struct cleanup
*old_cleanups
;
1164 /* st_size might be a large type, but we only support source files whose
1165 size fits in an int. */
1166 size
= (int) st
.st_size
;
1168 /* Use malloc, not alloca, because this may be pretty large, and we may
1169 run into various kinds of limits on stack size. */
1170 data
= (char *) xmalloc (size
);
1171 old_cleanups
= make_cleanup (xfree
, data
);
1173 /* Reassign `size' to result of read for systems where \r\n -> \n. */
1174 size
= myread (desc
, data
, size
);
1176 perror_with_name (s
->filename
);
1179 line_charpos
[0] = 0;
1184 /* A newline at the end does not start a new line. */
1187 if (nlines
== lines_allocated
)
1189 lines_allocated
*= 2;
1191 (int *) xrealloc ((char *) line_charpos
,
1192 sizeof (int) * lines_allocated
);
1194 line_charpos
[nlines
++] = p
- data
;
1197 do_cleanups (old_cleanups
);
1199 #endif /* lseek linear. */
1202 (int *) xrealloc ((char *) line_charpos
, nlines
* sizeof (int));
1206 /* Return the character position of a line LINE in symtab S.
1207 Return 0 if anything is invalid. */
1209 #if 0 /* Currently unused */
1212 source_line_charpos (struct symtab
*s
, int line
)
1216 if (!s
->line_charpos
|| line
<= 0)
1218 if (line
> s
->nlines
)
1220 return s
->line_charpos
[line
- 1];
1223 /* Return the line number of character position POS in symtab S. */
1226 source_charpos_line (struct symtab
*s
, int chr
)
1231 if (s
== 0 || s
->line_charpos
== 0)
1233 lnp
= s
->line_charpos
;
1234 /* Files are usually short, so sequential search is Ok */
1235 while (line
< s
->nlines
&& *lnp
<= chr
)
1240 if (line
>= s
->nlines
)
1248 /* Get full pathname and line number positions for a symtab.
1249 Return nonzero if line numbers may have changed.
1250 Set *FULLNAME to actual name of the file as found by `openp',
1251 or to 0 if the file is not found. */
1254 get_filename_and_charpos (struct symtab
*s
, char **fullname
)
1256 int desc
, linenums_changed
= 0;
1258 desc
= open_source_file (s
);
1266 *fullname
= s
->fullname
;
1267 if (s
->line_charpos
== 0)
1268 linenums_changed
= 1;
1269 if (linenums_changed
)
1270 find_source_lines (s
, desc
);
1272 return linenums_changed
;
1275 /* Print text describing the full name of the source file S
1276 and the line number LINE and its corresponding character position.
1277 The text starts with two Ctrl-z so that the Emacs-GDB interface
1280 MID_STATEMENT is nonzero if the PC is not at the beginning of that line.
1282 Return 1 if successful, 0 if could not find the file. */
1285 identify_source_line (struct symtab
*s
, int line
, int mid_statement
,
1288 if (s
->line_charpos
== 0)
1289 get_filename_and_charpos (s
, (char **) NULL
);
1290 if (s
->fullname
== 0)
1292 if (line
> s
->nlines
)
1293 /* Don't index off the end of the line_charpos array. */
1295 annotate_source (s
->fullname
, line
, s
->line_charpos
[line
- 1],
1298 current_source_line
= line
;
1299 first_line_listed
= line
;
1300 last_line_listed
= line
;
1301 current_source_symtab
= s
;
1306 /* Print source lines from the file of symtab S,
1307 starting with line number LINE and stopping before line number STOPLINE. */
1309 static void print_source_lines_base (struct symtab
*s
, int line
, int stopline
,
1312 print_source_lines_base (struct symtab
*s
, int line
, int stopline
, int noerror
)
1317 int nlines
= stopline
- line
;
1319 /* Regardless of whether we can open the file, set current_source_symtab. */
1320 current_source_symtab
= s
;
1321 current_source_line
= line
;
1322 first_line_listed
= line
;
1324 /* If printing of source lines is disabled, just print file and line number */
1325 if (ui_out_test_flags (uiout
, ui_source_list
))
1327 /* Only prints "No such file or directory" once */
1328 if ((s
!= last_source_visited
) || (!last_source_error
))
1330 last_source_visited
= s
;
1331 desc
= open_source_file (s
);
1335 desc
= last_source_error
;
1347 last_source_error
= desc
;
1351 char *name
= alloca (strlen (s
->filename
) + 100);
1352 sprintf (name
, "%d\t%s", line
, s
->filename
);
1353 print_sys_errmsg (name
, errno
);
1356 ui_out_field_int (uiout
, "line", line
);
1357 ui_out_text (uiout
, "\tin ");
1358 ui_out_field_string (uiout
, "file", s
->filename
);
1359 ui_out_text (uiout
, "\n");
1364 last_source_error
= 0;
1366 if (s
->line_charpos
== 0)
1367 find_source_lines (s
, desc
);
1369 if (line
< 1 || line
> s
->nlines
)
1372 error (_("Line number %d out of range; %s has %d lines."),
1373 line
, s
->filename
, s
->nlines
);
1376 if (lseek (desc
, s
->line_charpos
[line
- 1], 0) < 0)
1379 perror_with_name (s
->filename
);
1382 stream
= fdopen (desc
, FDOPEN_MODE
);
1385 while (nlines
-- > 0)
1392 last_line_listed
= current_source_line
;
1393 sprintf (buf
, "%d\t", current_source_line
++);
1394 ui_out_text (uiout
, buf
);
1397 if (c
< 040 && c
!= '\t' && c
!= '\n' && c
!= '\r')
1399 sprintf (buf
, "^%c", c
+ 0100);
1400 ui_out_text (uiout
, buf
);
1403 ui_out_text (uiout
, "^?");
1406 /* Skip a \r character, but only before a \n. */
1407 int c1
= fgetc (stream
);
1410 printf_filtered ("^%c", c
+ 0100);
1412 ungetc (c1
, stream
);
1416 sprintf (buf
, "%c", c
);
1417 ui_out_text (uiout
, buf
);
1420 while (c
!= '\n' && (c
= fgetc (stream
)) >= 0);
1426 /* Show source lines from the file of symtab S, starting with line
1427 number LINE and stopping before line number STOPLINE. If this is the
1428 not the command line version, then the source is shown in the source
1429 window otherwise it is simply printed */
1432 print_source_lines (struct symtab
*s
, int line
, int stopline
, int noerror
)
1434 print_source_lines_base (s
, line
, stopline
, noerror
);
1437 /* Print info on range of pc's in a specified line. */
1440 line_info (char *arg
, int from_tty
)
1442 struct symtabs_and_lines sals
;
1443 struct symtab_and_line sal
;
1444 CORE_ADDR start_pc
, end_pc
;
1447 init_sal (&sal
); /* initialize to zeroes */
1451 sal
.symtab
= current_source_symtab
;
1452 sal
.line
= last_line_listed
;
1454 sals
.sals
= (struct symtab_and_line
*)
1455 xmalloc (sizeof (struct symtab_and_line
));
1460 sals
= decode_line_spec_1 (arg
, 0);
1465 /* C++ More than one line may have been specified, as when the user
1466 specifies an overloaded function name. Print info on them all. */
1467 for (i
= 0; i
< sals
.nelts
; i
++)
1471 if (sal
.symtab
== 0)
1473 printf_filtered (_("No line number information available"));
1476 /* This is useful for "info line *0x7f34". If we can't tell the
1477 user about a source line, at least let them have the symbolic
1479 printf_filtered (" for address ");
1481 print_address (sal
.pc
, gdb_stdout
);
1484 printf_filtered (".");
1485 printf_filtered ("\n");
1487 else if (sal
.line
> 0
1488 && find_line_pc_range (sal
, &start_pc
, &end_pc
))
1490 if (start_pc
== end_pc
)
1492 printf_filtered ("Line %d of \"%s\"",
1493 sal
.line
, sal
.symtab
->filename
);
1495 printf_filtered (" is at address ");
1496 print_address (start_pc
, gdb_stdout
);
1498 printf_filtered (" but contains no code.\n");
1502 printf_filtered ("Line %d of \"%s\"",
1503 sal
.line
, sal
.symtab
->filename
);
1505 printf_filtered (" starts at address ");
1506 print_address (start_pc
, gdb_stdout
);
1508 printf_filtered (" and ends at ");
1509 print_address (end_pc
, gdb_stdout
);
1510 printf_filtered (".\n");
1513 /* x/i should display this line's code. */
1514 set_next_address (start_pc
);
1516 /* Repeating "info line" should do the following line. */
1517 last_line_listed
= sal
.line
+ 1;
1519 /* If this is the only line, show the source code. If it could
1520 not find the file, don't do anything special. */
1521 if (annotation_level
&& sals
.nelts
== 1)
1522 identify_source_line (sal
.symtab
, sal
.line
, 0, start_pc
);
1525 /* Is there any case in which we get here, and have an address
1526 which the user would want to see? If we have debugging symbols
1527 and no line numbers? */
1528 printf_filtered (_("Line number %d is out of range for \"%s\".\n"),
1529 sal
.line
, sal
.symtab
->filename
);
1534 /* Commands to search the source file for a regexp. */
1537 forward_search_command (char *regex
, int from_tty
)
1545 line
= last_line_listed
+ 1;
1547 msg
= (char *) re_comp (regex
);
1549 error (("%s"), msg
);
1551 if (current_source_symtab
== 0)
1552 select_source_symtab (0);
1554 desc
= open_source_file (current_source_symtab
);
1556 perror_with_name (current_source_symtab
->filename
);
1558 if (current_source_symtab
->line_charpos
== 0)
1559 find_source_lines (current_source_symtab
, desc
);
1561 if (line
< 1 || line
> current_source_symtab
->nlines
)
1564 error (_("Expression not found"));
1567 if (lseek (desc
, current_source_symtab
->line_charpos
[line
- 1], 0) < 0)
1570 perror_with_name (current_source_symtab
->filename
);
1573 stream
= fdopen (desc
, FDOPEN_MODE
);
1577 static char *buf
= NULL
;
1579 int cursize
, newsize
;
1582 buf
= xmalloc (cursize
);
1591 if (p
- buf
== cursize
)
1593 newsize
= cursize
+ cursize
/ 2;
1594 buf
= xrealloc (buf
, newsize
);
1599 while (c
!= '\n' && (c
= getc (stream
)) >= 0);
1601 /* Remove the \r, if any, at the end of the line, otherwise
1602 regular expressions that end with $ or \n won't work. */
1603 if (p
- buf
> 1 && p
[-2] == '\r')
1609 /* we now have a source line in buf, null terminate and match */
1611 if (re_exec (buf
) > 0)
1615 print_source_lines (current_source_symtab
, line
, line
+ 1, 0);
1616 set_internalvar (lookup_internalvar ("_"),
1617 value_from_longest (builtin_type_int
,
1619 current_source_line
= max (line
- lines_to_list
/ 2, 1);
1625 printf_filtered (_("Expression not found\n"));
1630 reverse_search_command (char *regex
, int from_tty
)
1638 line
= last_line_listed
- 1;
1640 msg
= (char *) re_comp (regex
);
1642 error (("%s"), msg
);
1644 if (current_source_symtab
== 0)
1645 select_source_symtab (0);
1647 desc
= open_source_file (current_source_symtab
);
1649 perror_with_name (current_source_symtab
->filename
);
1651 if (current_source_symtab
->line_charpos
== 0)
1652 find_source_lines (current_source_symtab
, desc
);
1654 if (line
< 1 || line
> current_source_symtab
->nlines
)
1657 error (_("Expression not found"));
1660 if (lseek (desc
, current_source_symtab
->line_charpos
[line
- 1], 0) < 0)
1663 perror_with_name (current_source_symtab
->filename
);
1666 stream
= fdopen (desc
, FDOPEN_MODE
);
1670 /* FIXME!!! We walk right off the end of buf if we get a long line!!! */
1671 char buf
[4096]; /* Should be reasonable??? */
1681 while (c
!= '\n' && (c
= getc (stream
)) >= 0);
1683 /* Remove the \r, if any, at the end of the line, otherwise
1684 regular expressions that end with $ or \n won't work. */
1685 if (p
- buf
> 1 && p
[-2] == '\r')
1691 /* We now have a source line in buf; null terminate and match. */
1693 if (re_exec (buf
) > 0)
1697 print_source_lines (current_source_symtab
, line
, line
+ 1, 0);
1698 set_internalvar (lookup_internalvar ("_"),
1699 value_from_longest (builtin_type_int
,
1701 current_source_line
= max (line
- lines_to_list
/ 2, 1);
1705 if (fseek (stream
, current_source_symtab
->line_charpos
[line
- 1], 0) < 0)
1708 perror_with_name (current_source_symtab
->filename
);
1712 printf_filtered (_("Expression not found\n"));
1717 /* If the last character of PATH is a directory separator, then strip it. */
1720 strip_trailing_directory_separator (char *path
)
1722 const int last
= strlen (path
) - 1;
1725 return; /* No stripping is needed if PATH is the empty string. */
1727 if (IS_DIR_SEPARATOR (path
[last
]))
1731 /* Return the path substitution rule that matches FROM.
1732 Return NULL if no rule matches. */
1734 static struct substitute_path_rule
*
1735 find_substitute_path_rule (const char *from
)
1737 struct substitute_path_rule
*rule
= substitute_path_rules
;
1739 while (rule
!= NULL
)
1741 if (FILENAME_CMP (rule
->from
, from
) == 0)
1749 /* Add a new substitute-path rule at the end of the current list of rules.
1750 The new rule will replace FROM into TO. */
1753 add_substitute_path_rule (char *from
, char *to
)
1755 struct substitute_path_rule
*rule
;
1756 struct substitute_path_rule
*new_rule
;
1758 new_rule
= xmalloc (sizeof (struct substitute_path_rule
));
1759 new_rule
->from
= xstrdup (from
);
1760 new_rule
->to
= xstrdup (to
);
1761 new_rule
->next
= NULL
;
1763 /* If the list of rules are empty, then insert the new rule
1764 at the head of the list. */
1766 if (substitute_path_rules
== NULL
)
1768 substitute_path_rules
= new_rule
;
1772 /* Otherwise, skip to the last rule in our list and then append
1775 rule
= substitute_path_rules
;
1776 while (rule
->next
!= NULL
)
1779 rule
->next
= new_rule
;
1782 /* Remove the given source path substitution rule from the current list
1783 of rules. The memory allocated for that rule is also deallocated. */
1786 delete_substitute_path_rule (struct substitute_path_rule
*rule
)
1788 if (rule
== substitute_path_rules
)
1789 substitute_path_rules
= rule
->next
;
1792 struct substitute_path_rule
*prev
= substitute_path_rules
;
1794 while (prev
!= NULL
&& prev
->next
!= rule
)
1797 gdb_assert (prev
!= NULL
);
1799 prev
->next
= rule
->next
;
1807 /* Implement the "show substitute-path" command. */
1810 show_substitute_path_command (char *args
, int from_tty
)
1812 struct substitute_path_rule
*rule
= substitute_path_rules
;
1816 argv
= buildargv (args
);
1817 make_cleanup_freeargv (argv
);
1819 /* We expect zero or one argument. */
1821 if (argv
!= NULL
&& argv
[0] != NULL
&& argv
[1] != NULL
)
1822 error (_("Too many arguments in command"));
1824 if (argv
!= NULL
&& argv
[0] != NULL
)
1827 /* Print the substitution rules. */
1831 (_("Source path substitution rule matching `%s':\n"), from
);
1833 printf_filtered (_("List of all source path substitution rules:\n"));
1835 while (rule
!= NULL
)
1837 if (from
== NULL
|| FILENAME_CMP (rule
->from
, from
) == 0)
1838 printf_filtered (" `%s' -> `%s'.\n", rule
->from
, rule
->to
);
1843 /* Implement the "unset substitute-path" command. */
1846 unset_substitute_path_command (char *args
, int from_tty
)
1848 struct substitute_path_rule
*rule
= substitute_path_rules
;
1849 char **argv
= buildargv (args
);
1853 /* This function takes either 0 or 1 argument. */
1855 make_cleanup_freeargv (argv
);
1856 if (argv
!= NULL
&& argv
[0] != NULL
&& argv
[1] != NULL
)
1857 error (_("Incorrect usage, too many arguments in command"));
1859 if (argv
!= NULL
&& argv
[0] != NULL
)
1862 /* If the user asked for all the rules to be deleted, ask him
1863 to confirm and give him a chance to abort before the action
1867 && !query (_("Delete all source path substitution rules? ")))
1868 error (_("Canceled"));
1870 /* Delete the rule matching the argument. No argument means that
1871 all rules should be deleted. */
1873 while (rule
!= NULL
)
1875 struct substitute_path_rule
*next
= rule
->next
;
1877 if (from
== NULL
|| FILENAME_CMP (from
, rule
->from
) == 0)
1879 delete_substitute_path_rule (rule
);
1886 /* If the user asked for a specific rule to be deleted but
1887 we could not find it, then report an error. */
1889 if (from
!= NULL
&& !rule_found
)
1890 error (_("No substitution rule defined for `%s'"), from
);
1893 /* Add a new source path substitution rule. */
1896 set_substitute_path_command (char *args
, int from_tty
)
1898 char *from_path
, *to_path
;
1900 struct substitute_path_rule
*rule
;
1902 argv
= buildargv (args
);
1903 make_cleanup_freeargv (argv
);
1905 if (argv
== NULL
|| argv
[0] == NULL
|| argv
[1] == NULL
)
1906 error (_("Incorrect usage, too few arguments in command"));
1908 if (argv
[2] != NULL
)
1909 error (_("Incorrect usage, too many arguments in command"));
1911 if (*(argv
[0]) == '\0')
1912 error (_("First argument must be at least one character long"));
1914 /* Strip any trailing directory separator character in either FROM
1915 or TO. The substitution rule already implicitly contains them. */
1916 strip_trailing_directory_separator (argv
[0]);
1917 strip_trailing_directory_separator (argv
[1]);
1919 /* If a rule with the same "from" was previously defined, then
1920 delete it. This new rule replaces it. */
1922 rule
= find_substitute_path_rule (argv
[0]);
1924 delete_substitute_path_rule (rule
);
1926 /* Insert the new substitution rule. */
1928 add_substitute_path_rule (argv
[0], argv
[1]);
1933 _initialize_source (void)
1935 struct cmd_list_element
*c
;
1936 current_source_symtab
= 0;
1937 init_source_path ();
1939 /* The intention is to use POSIX Basic Regular Expressions.
1940 Always use the GNU regex routine for consistency across all hosts.
1941 Our current GNU regex.c does not have all the POSIX features, so this is
1942 just an approximation. */
1943 re_set_syntax (RE_SYNTAX_GREP
);
1945 c
= add_cmd ("directory", class_files
, directory_command
, _("\
1946 Add directory DIR to beginning of search path for source files.\n\
1947 Forget cached info on source file locations and line positions.\n\
1948 DIR can also be $cwd for the current working directory, or $cdir for the\n\
1949 directory in which the source file was compiled into object code.\n\
1950 With no argument, reset the search path to $cdir:$cwd, the default."),
1954 add_com_alias ("use", "directory", class_files
, 0);
1956 set_cmd_completer (c
, filename_completer
);
1958 add_cmd ("directories", no_class
, show_directories
, _("\
1959 Current search path for finding source files.\n\
1960 $cwd in the path means the current working directory.\n\
1961 $cdir in the path means the compilation directory of the source file."),
1966 add_com_alias ("D", "directory", class_files
, 0);
1967 add_cmd ("ld", no_class
, show_directories
, _("\
1968 Current search path for finding source files.\n\
1969 $cwd in the path means the current working directory.\n\
1970 $cdir in the path means the compilation directory of the source file."),
1974 add_info ("source", source_info
,
1975 _("Information about the current source file."));
1977 add_info ("line", line_info
, _("\
1978 Core addresses of the code for a source line.\n\
1979 Line can be specified as\n\
1980 LINENUM, to list around that line in current file,\n\
1981 FILE:LINENUM, to list around that line in that file,\n\
1982 FUNCTION, to list around beginning of that function,\n\
1983 FILE:FUNCTION, to distinguish among like-named static functions.\n\
1984 Default is to describe the last source line that was listed.\n\n\
1985 This sets the default address for \"x\" to the line's first instruction\n\
1986 so that \"x/i\" suffices to start examining the machine code.\n\
1987 The address is also stored as the value of \"$_\"."));
1989 add_com ("forward-search", class_files
, forward_search_command
, _("\
1990 Search for regular expression (see regex(3)) from last line listed.\n\
1991 The matching line number is also stored as the value of \"$_\"."));
1992 add_com_alias ("search", "forward-search", class_files
, 0);
1994 add_com ("reverse-search", class_files
, reverse_search_command
, _("\
1995 Search backward for regular expression (see regex(3)) from last line listed.\n\
1996 The matching line number is also stored as the value of \"$_\"."));
2000 add_com_alias ("/", "forward-search", class_files
, 0);
2001 add_com_alias ("?", "reverse-search", class_files
, 0);
2004 add_setshow_integer_cmd ("listsize", class_support
, &lines_to_list
, _("\
2005 Set number of source lines gdb will list by default."), _("\
2006 Show number of source lines gdb will list by default."), NULL
,
2009 &setlist
, &showlist
);
2011 add_cmd ("substitute-path", class_files
, set_substitute_path_command
,
2013 Usage: set substitute-path FROM TO\n\
2014 Add a substitution rule replacing FROM into TO in source file names.\n\
2015 If a substitution rule was previously set for FROM, the old rule\n\
2016 is replaced by the new one."),
2019 add_cmd ("substitute-path", class_files
, unset_substitute_path_command
,
2021 Usage: unset substitute-path [FROM]\n\
2022 Delete the rule for substituting FROM in source file names. If FROM\n\
2023 is not specified, all substituting rules are deleted.\n\
2024 If the debugger cannot find a rule for FROM, it will display a warning."),
2027 add_cmd ("substitute-path", class_files
, show_substitute_path_command
,
2029 Usage: show substitute-path [FROM]\n\
2030 Print the rule for substituting FROM in source file names. If FROM\n\
2031 is not specified, print all substitution rules."),