* filenames.h (HAS_DRIVE_SPEC, STRIP_DRIVE_SPEC): New macros.
[deliverable/binutils-gdb.git] / gdb / source.c
CommitLineData
c906108c 1/* List lines of source files for GDB, the GNU debugger.
6aba47ca 2 Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
0fb0cc75 3 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008,
4c38e0a4 4 2009, 2010 Free Software Foundation, Inc.
c906108c 5
c5aa993b 6 This file is part of GDB.
c906108c 7
c5aa993b
JM
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
a9762ec7 10 the Free Software Foundation; either version 3 of the License, or
c5aa993b 11 (at your option) any later version.
c906108c 12
c5aa993b
JM
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.
c906108c 17
c5aa993b 18 You should have received a copy of the GNU General Public License
a9762ec7 19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
20
21#include "defs.h"
5af949e3 22#include "arch-utils.h"
c906108c
SS
23#include "symtab.h"
24#include "expression.h"
25#include "language.h"
26#include "command.h"
c2c6d25f 27#include "source.h"
c906108c
SS
28#include "gdbcmd.h"
29#include "frame.h"
30#include "value.h"
2f61ca93 31#include "gdb_assert.h"
c906108c
SS
32
33#include <sys/types.h>
34#include "gdb_string.h"
35#include "gdb_stat.h"
36#include <fcntl.h>
c906108c 37#include "gdbcore.h"
88987551 38#include "gdb_regex.h"
c906108c
SS
39#include "symfile.h"
40#include "objfiles.h"
41#include "annotate.h"
42#include "gdbtypes.h"
c5f0f3d0 43#include "linespec.h"
fe4e3eb8 44#include "filenames.h" /* for DOSish file names */
d75b5104 45#include "completer.h"
8b93c638 46#include "ui-out.h"
dbda9972 47#include "readline/readline.h"
c906108c 48
ccefe4c4
TT
49#include "psymtab.h"
50
3e3a28f1 51
c906108c
SS
52#define OPEN_MODE (O_RDONLY | O_BINARY)
53#define FDOPEN_MODE FOPEN_RB
54
c906108c
SS
55/* Prototypes for exported functions. */
56
a14ed312 57void _initialize_source (void);
c906108c
SS
58
59/* Prototypes for local functions. */
60
a14ed312 61static int get_filename_and_charpos (struct symtab *, char **);
c906108c 62
a14ed312 63static void reverse_search_command (char *, int);
c906108c 64
a14ed312 65static void forward_search_command (char *, int);
c906108c 66
a14ed312 67static void line_info (char *, int);
c906108c 68
a14ed312 69static void source_info (char *, int);
c906108c 70
a14ed312 71static void show_directories (char *, int);
c906108c
SS
72
73/* Path of directories to search for source files.
74 Same format as the PATH environment variable's value. */
75
76char *source_path;
77
2f61ca93
JB
78/* Support for source path substitution commands. */
79
80struct substitute_path_rule
81{
82 char *from;
83 char *to;
84 struct substitute_path_rule *next;
85};
86
87static struct substitute_path_rule *substitute_path_rules = NULL;
88
c906108c
SS
89/* Symtab of default file for listing lines of. */
90
0378c332 91static struct symtab *current_source_symtab;
c906108c
SS
92
93/* Default next line to list. */
94
0378c332 95static int current_source_line;
c906108c 96
6c95b8df
PA
97static struct program_space *current_source_pspace;
98
c906108c
SS
99/* Default number of lines to print with commands like "list".
100 This is based on guessing how many long (i.e. more than chars_per_line
101 characters) lines there will be. To be completely correct, "list"
102 and friends should be rewritten to count characters and see where
103 things are wrapping, but that would be a fair amount of work. */
104
105int lines_to_list = 10;
920d2a44
AC
106static void
107show_lines_to_list (struct ui_file *file, int from_tty,
108 struct cmd_list_element *c, const char *value)
109{
110 fprintf_filtered (file, _("\
111Number of source lines gdb will list by default is %s.\n"),
112 value);
113}
c906108c
SS
114
115/* Line number of last line printed. Default for various commands.
116 current_source_line is usually, but not always, the same as this. */
117
118static int last_line_listed;
119
120/* First line number listed by last listing command. */
121
122static int first_line_listed;
123
124/* Saves the name of the last source file visited and a possible error code.
125 Used to prevent repeating annoying "No such file or directories" msgs */
126
127static struct symtab *last_source_visited = NULL;
128static int last_source_error = 0;
c906108c 129\f
0378c332
FN
130/* Return the first line listed by print_source_lines.
131 Used by command interpreters to request listing from
132 a previous point. */
133
134int
135get_first_line_listed (void)
136{
137 return first_line_listed;
138}
139
140/* Return the default number of lines to print with commands like the
141 cli "list". The caller of print_source_lines must use this to
142 calculate the end line and use it in the call to print_source_lines
143 as it does not automatically use this value. */
144
145int
146get_lines_to_list (void)
147{
148 return lines_to_list;
149}
150
151/* Return the current source file for listing and next line to list.
152 NOTE: The returned sal pc and end fields are not valid. */
153
154struct symtab_and_line
155get_current_source_symtab_and_line (void)
156{
245c7f48 157 struct symtab_and_line cursal = { 0 };
0378c332 158
6c95b8df 159 cursal.pspace = current_source_pspace;
0378c332
FN
160 cursal.symtab = current_source_symtab;
161 cursal.line = current_source_line;
53cb0458
FN
162 cursal.pc = 0;
163 cursal.end = 0;
0378c332
FN
164
165 return cursal;
166}
167
53cb0458
FN
168/* If the current source file for listing is not set, try and get a default.
169 Usually called before get_current_source_symtab_and_line() is called.
0378c332 170 It may err out if a default cannot be determined.
53cb0458
FN
171 We must be cautious about where it is called, as it can recurse as the
172 process of determining a new default may call the caller!
173 Use get_current_source_symtab_and_line only to get whatever
174 we have without erroring out or trying to get a default. */
0378c332 175
53cb0458
FN
176void
177set_default_source_symtab_and_line (void)
0378c332
FN
178{
179 struct symtab_and_line cursal;
180
181 if (!have_full_symbols () && !have_partial_symbols ())
8a3fe4f8 182 error (_("No symbol table is loaded. Use the \"file\" command."));
0378c332
FN
183
184 /* Pull in a current source symtab if necessary */
185 if (current_source_symtab == 0)
186 select_source_symtab (0);
0378c332
FN
187}
188
189/* Return the current default file for listing and next line to list
190 (the returned sal pc and end fields are not valid.)
53cb0458
FN
191 and set the current default to whatever is in SAL.
192 NOTE: The returned sal pc and end fields are not valid. */
0378c332
FN
193
194struct symtab_and_line
53cb0458 195set_current_source_symtab_and_line (const struct symtab_and_line *sal)
0378c332 196{
245c7f48 197 struct symtab_and_line cursal = { 0 };
6c95b8df
PA
198
199 cursal.pspace = current_source_pspace;
0378c332
FN
200 cursal.symtab = current_source_symtab;
201 cursal.line = current_source_line;
6c95b8df
PA
202 cursal.pc = 0;
203 cursal.end = 0;
0378c332 204
6c95b8df 205 current_source_pspace = sal->pspace;
0378c332
FN
206 current_source_symtab = sal->symtab;
207 current_source_line = sal->line;
6c95b8df 208
0378c332
FN
209 return cursal;
210}
211
212/* Reset any information stored about a default file and line to print. */
213
214void
215clear_current_source_symtab_and_line (void)
216{
217 current_source_symtab = 0;
218 current_source_line = 0;
219}
c5aa993b 220
c906108c
SS
221/* Set the source file default for the "list" command to be S.
222
223 If S is NULL, and we don't have a default, find one. This
224 should only be called when the user actually tries to use the
225 default, since we produce an error if we can't find a reasonable
226 default. Also, since this can cause symbols to be read, doing it
227 before we need to would make things slower than necessary. */
228
229void
aa1ee363 230select_source_symtab (struct symtab *s)
c906108c
SS
231{
232 struct symtabs_and_lines sals;
233 struct symtab_and_line sal;
c906108c 234 struct objfile *ofp;
c5aa993b 235
c906108c
SS
236 if (s)
237 {
238 current_source_symtab = s;
239 current_source_line = 1;
6c95b8df 240 current_source_pspace = SYMTAB_PSPACE (s);
c906108c
SS
241 return;
242 }
243
244 if (current_source_symtab)
245 return;
246
247 /* Make the default place to list be the function `main'
248 if one exists. */
2570f2b7 249 if (lookup_symbol (main_name (), 0, VAR_DOMAIN, 0))
c906108c 250 {
51cc5b07 251 sals = decode_line_spec (main_name (), 1);
c906108c 252 sal = sals.sals[0];
b8c9b27d 253 xfree (sals.sals);
6c95b8df 254 current_source_pspace = sal.pspace;
c906108c
SS
255 current_source_symtab = sal.symtab;
256 current_source_line = max (sal.line - (lines_to_list - 1), 1);
257 if (current_source_symtab)
c5aa993b 258 return;
c906108c 259 }
c5aa993b 260
8340a3fb
LM
261 /* Alright; find the last file in the symtab list (ignoring .h's
262 and namespace symtabs). */
c906108c
SS
263
264 current_source_line = 1;
265
6c95b8df 266 ALL_OBJFILES (ofp)
c906108c 267 {
c5aa993b 268 for (s = ofp->symtabs; s; s = s->next)
c906108c 269 {
591e78ff 270 const char *name = s->filename;
c906108c 271 int len = strlen (name);
8340a3fb
LM
272 if (!(len > 2 && (strcmp (&name[len - 2], ".h") == 0
273 || strcmp (name, "<<C++-namespaces>>") == 0)))
6c95b8df
PA
274 {
275 current_source_pspace = current_program_space;
276 current_source_symtab = s;
277 }
c906108c
SS
278 }
279 }
6c95b8df 280
c906108c
SS
281 if (current_source_symtab)
282 return;
283
6c95b8df 284 ALL_OBJFILES (ofp)
ccefe4c4
TT
285 {
286 if (ofp->sf)
287 s = ofp->sf->qf->find_last_source_symtab (ofp);
288 if (s)
289 current_source_symtab = s;
290 }
c906108c
SS
291 if (current_source_symtab)
292 return;
293
8a3fe4f8 294 error (_("Can't find a default source file"));
c906108c
SS
295}
296\f
297static void
fba45db2 298show_directories (char *ignore, int from_tty)
c906108c
SS
299{
300 puts_filtered ("Source directories searched: ");
301 puts_filtered (source_path);
302 puts_filtered ("\n");
303}
304
305/* Forget what we learned about line positions in source files, and
306 which directories contain them; must check again now since files
307 may be found in a different directory now. */
308
309void
fba45db2 310forget_cached_source_info (void)
c906108c 311{
6c95b8df 312 struct program_space *pspace;
52f0bd74
AC
313 struct symtab *s;
314 struct objfile *objfile;
c906108c 315
6c95b8df
PA
316 ALL_PSPACES (pspace)
317 ALL_PSPACE_OBJFILES (pspace, objfile)
c906108c 318 {
c5aa993b 319 for (s = objfile->symtabs; s != NULL; s = s->next)
c906108c 320 {
c5aa993b 321 if (s->line_charpos != NULL)
c906108c 322 {
2dc74dc1 323 xfree (s->line_charpos);
c5aa993b 324 s->line_charpos = NULL;
c906108c 325 }
c5aa993b 326 if (s->fullname != NULL)
c906108c 327 {
2dc74dc1 328 xfree (s->fullname);
c5aa993b 329 s->fullname = NULL;
c906108c
SS
330 }
331 }
58d370e0 332
ccefe4c4
TT
333 if (objfile->sf)
334 objfile->sf->qf->forget_cached_source_info (objfile);
c906108c 335 }
c4e86dd4
DJ
336
337 last_source_visited = NULL;
c906108c
SS
338}
339
340void
fba45db2 341init_source_path (void)
c906108c
SS
342{
343 char buf[20];
344
345 sprintf (buf, "$cdir%c$cwd", DIRNAME_SEPARATOR);
4fcf66da 346 source_path = xstrdup (buf);
c906108c
SS
347 forget_cached_source_info ();
348}
349
350/* Add zero or more directories to the front of the source path. */
c5aa993b 351
c906108c 352void
fba45db2 353directory_command (char *dirname, int from_tty)
c906108c
SS
354{
355 dont_repeat ();
356 /* FIXME, this goes to "delete dir"... */
357 if (dirname == 0)
358 {
80618b99 359 if (!from_tty || query (_("Reinitialize source path to empty? ")))
c906108c 360 {
b8c9b27d 361 xfree (source_path);
c906108c
SS
362 init_source_path ();
363 }
364 }
365 else
366 {
367 mod_path (dirname, &source_path);
c4e86dd4 368 forget_cached_source_info ();
c906108c
SS
369 }
370 if (from_tty)
c5aa993b 371 show_directories ((char *) 0, from_tty);
c906108c
SS
372}
373
13d35ae5
AS
374/* Add a path given with the -d command line switch.
375 This will not be quoted so we must not treat spaces as separators. */
376
377void
378directory_switch (char *dirname, int from_tty)
379{
380 add_path (dirname, &source_path, 0);
381}
382
c906108c
SS
383/* Add zero or more directories to the front of an arbitrary path. */
384
385void
fba45db2 386mod_path (char *dirname, char **which_path)
c04e0a08
JJ
387{
388 add_path (dirname, which_path, 1);
389}
390
391/* Workhorse of mod_path. Takes an extra argument to determine
392 if dirname should be parsed for separators that indicate multiple
393 directories. This allows for interfaces that pre-parse the dirname
394 and allow specification of traditional separator characters such
395 as space or tab. */
396
397void
398add_path (char *dirname, char **which_path, int parse_separators)
c906108c
SS
399{
400 char *old = *which_path;
401 int prefix = 0;
13d35ae5
AS
402 char **argv = NULL;
403 char *arg;
404 int argv_index = 0;
c906108c
SS
405
406 if (dirname == 0)
407 return;
408
13d35ae5
AS
409 if (parse_separators)
410 {
411 /* This will properly parse the space and tab separators
412 and any quotes that may exist. DIRNAME_SEPARATOR will
413 be dealt with later. */
d1a41061 414 argv = gdb_buildargv (dirname);
13d35ae5
AS
415 make_cleanup_freeargv (argv);
416
13d35ae5
AS
417 arg = argv[0];
418 }
419 else
420 {
421 arg = xstrdup (dirname);
422 make_cleanup (xfree, arg);
423 }
c906108c
SS
424
425 do
426 {
13d35ae5 427 char *name = arg;
aa1ee363 428 char *p;
c906108c
SS
429 struct stat st;
430
431 {
c04e0a08 432 char *separator = NULL;
c04e0a08 433
13d35ae5
AS
434 /* Spaces and tabs will have been removed by buildargv().
435 The directories will there be split into a list but
436 each entry may still contain DIRNAME_SEPARATOR. */
c04e0a08 437 if (parse_separators)
13d35ae5 438 separator = strchr (name, DIRNAME_SEPARATOR);
c906108c 439
13d35ae5
AS
440 if (separator == 0)
441 p = arg = name + strlen (name);
c906108c
SS
442 else
443 {
13d35ae5
AS
444 p = separator;
445 arg = p + 1;
446 while (*arg == DIRNAME_SEPARATOR)
447 ++arg;
c906108c 448 }
13d35ae5
AS
449
450 /* If there are no more directories in this argument then start
451 on the next argument next time round the loop (if any). */
452 if (*arg == '\0')
453 arg = parse_separators ? argv[++argv_index] : NULL;
c906108c
SS
454 }
455
13d35ae5
AS
456 /* name is the start of the directory.
457 p is the separator (or null) following the end. */
458
459 while (!(IS_DIR_SEPARATOR (*name) && p <= name + 1) /* "/" */
c3690141 460#ifdef HAVE_DOS_BASED_FILE_SYSTEM
7be570e7 461 /* On MS-DOS and MS-Windows, h:\ is different from h: */
13d35ae5 462 && !(p == name + 3 && name[1] == ':') /* "d:/" */
7be570e7 463#endif
13d35ae5 464 && IS_DIR_SEPARATOR (p[-1]))
c906108c
SS
465 /* Sigh. "foo/" => "foo" */
466 --p;
c906108c
SS
467 *p = '\0';
468
7be570e7 469 while (p > name && p[-1] == '.')
c906108c
SS
470 {
471 if (p - name == 1)
472 {
473 /* "." => getwd (). */
474 name = current_directory;
475 goto append;
476 }
fe4e3eb8 477 else if (p > name + 1 && IS_DIR_SEPARATOR (p[-2]))
c906108c
SS
478 {
479 if (p - name == 2)
480 {
481 /* "/." => "/". */
482 *--p = '\0';
483 goto append;
484 }
485 else
486 {
487 /* "...foo/." => "...foo". */
488 p -= 2;
489 *p = '\0';
490 continue;
491 }
492 }
493 else
494 break;
495 }
496
497 if (name[0] == '~')
498 name = tilde_expand (name);
c3690141 499#ifdef HAVE_DOS_BASED_FILE_SYSTEM
fe4e3eb8 500 else if (IS_ABSOLUTE_PATH (name) && p == name + 2) /* "d:" => "d:." */
1754f103 501 name = concat (name, ".", (char *)NULL);
7be570e7 502#endif
fe4e3eb8 503 else if (!IS_ABSOLUTE_PATH (name) && name[0] != '$')
1754f103 504 name = concat (current_directory, SLASH_STRING, name, (char *)NULL);
c906108c
SS
505 else
506 name = savestring (name, p - name);
b8c9b27d 507 make_cleanup (xfree, name);
c906108c
SS
508
509 /* Unless it's a variable, check existence. */
c5aa993b
JM
510 if (name[0] != '$')
511 {
512 /* These are warnings, not errors, since we don't want a
513 non-existent directory in a .gdbinit file to stop processing
514 of the .gdbinit file.
515
516 Whether they get added to the path is more debatable. Current
517 answer is yes, in case the user wants to go make the directory
518 or whatever. If the directory continues to not exist/not be
519 a directory/etc, then having them in the path should be
520 harmless. */
521 if (stat (name, &st) < 0)
522 {
523 int save_errno = errno;
524 fprintf_unfiltered (gdb_stderr, "Warning: ");
525 print_sys_errmsg (name, save_errno);
526 }
527 else if ((st.st_mode & S_IFMT) != S_IFDIR)
8a3fe4f8 528 warning (_("%s is not a directory."), name);
c5aa993b 529 }
c906108c
SS
530
531 append:
532 {
aa1ee363 533 unsigned int len = strlen (name);
c906108c
SS
534
535 p = *which_path;
536 while (1)
537 {
7be570e7
JM
538 /* FIXME: strncmp loses in interesting ways on MS-DOS and
539 MS-Windows because of case-insensitivity and two different
540 but functionally identical slash characters. We need a
541 special filesystem-dependent file-name comparison function.
542
543 Actually, even on Unix I would use realpath() or its work-
544 alike before comparing. Then all the code above which
545 removes excess slashes and dots could simply go away. */
c906108c
SS
546 if (!strncmp (p, name, len)
547 && (p[len] == '\0' || p[len] == DIRNAME_SEPARATOR))
548 {
549 /* Found it in the search path, remove old copy */
550 if (p > *which_path)
c5aa993b 551 p--; /* Back over leading separator */
c906108c
SS
552 if (prefix > p - *which_path)
553 goto skip_dup; /* Same dir twice in one cmd */
c5aa993b 554 strcpy (p, &p[len + 1]); /* Copy from next \0 or : */
c906108c
SS
555 }
556 p = strchr (p, DIRNAME_SEPARATOR);
557 if (p != 0)
558 ++p;
559 else
560 break;
561 }
562 if (p == 0)
563 {
564 char tinybuf[2];
565
566 tinybuf[0] = DIRNAME_SEPARATOR;
567 tinybuf[1] = '\0';
568
c04e0a08
JJ
569 /* If we have already tacked on a name(s) in this command, be sure they stay
570 on the front as we tack on some more. */
c906108c
SS
571 if (prefix)
572 {
573 char *temp, c;
574
575 c = old[prefix];
576 old[prefix] = '\0';
1754f103 577 temp = concat (old, tinybuf, name, (char *)NULL);
c906108c 578 old[prefix] = c;
1754f103 579 *which_path = concat (temp, "", &old[prefix], (char *)NULL);
c906108c 580 prefix = strlen (temp);
b8c9b27d 581 xfree (temp);
c906108c
SS
582 }
583 else
584 {
1754f103
MK
585 *which_path = concat (name, (old[0] ? tinybuf : old),
586 old, (char *)NULL);
c906108c
SS
587 prefix = strlen (name);
588 }
b8c9b27d 589 xfree (old);
c906108c
SS
590 old = *which_path;
591 }
592 }
c5aa993b
JM
593 skip_dup:;
594 }
13d35ae5 595 while (arg != NULL);
c906108c
SS
596}
597
598
599static void
fba45db2 600source_info (char *ignore, int from_tty)
c906108c 601{
52f0bd74 602 struct symtab *s = current_source_symtab;
c906108c
SS
603
604 if (!s)
605 {
a3f17187 606 printf_filtered (_("No current source file.\n"));
c906108c
SS
607 return;
608 }
a3f17187 609 printf_filtered (_("Current source file is %s\n"), s->filename);
c906108c 610 if (s->dirname)
a3f17187 611 printf_filtered (_("Compilation directory is %s\n"), s->dirname);
c906108c 612 if (s->fullname)
a3f17187 613 printf_filtered (_("Located in %s\n"), s->fullname);
c906108c 614 if (s->nlines)
a3f17187 615 printf_filtered (_("Contains %d line%s.\n"), s->nlines,
c906108c
SS
616 s->nlines == 1 ? "" : "s");
617
a3f17187
AC
618 printf_filtered (_("Source language is %s.\n"), language_str (s->language));
619 printf_filtered (_("Compiled with %s debugging format.\n"), s->debugformat);
620 printf_filtered (_("%s preprocessor macro info.\n"),
919d772c 621 s->macro_table ? "Includes" : "Does not include");
c906108c 622}
c5aa993b 623\f
c906108c 624
1da1a192
JB
625/* Return True if the file NAME exists and is a regular file */
626static int
627is_regular_file (const char *name)
628{
629 struct stat st;
630 const int status = stat (name, &st);
631
632 /* Stat should never fail except when the file does not exist.
633 If stat fails, analyze the source of error and return True
634 unless the file does not exist, to avoid returning false results
635 on obscure systems where stat does not work as expected.
636 */
637 if (status != 0)
638 return (errno != ENOENT);
639
640 return S_ISREG (st.st_mode);
641}
c906108c 642
c906108c 643/* Open a file named STRING, searching path PATH (dir names sep by some char)
fbdebf46
JK
644 using mode MODE in the calls to open. You cannot use this function to
645 create files (O_CREAT).
c906108c 646
014d698b
EZ
647 OPTS specifies the function behaviour in specific cases.
648
649 If OPF_TRY_CWD_FIRST, try to open ./STRING before searching PATH.
c906108c
SS
650 (ie pretend the first element of PATH is "."). This also indicates
651 that a slash in STRING disables searching of the path (this is
652 so that "exec-file ./foo" or "symbol-file ./foo" insures that you
653 get that particular version of foo or an error message).
654
014d698b
EZ
655 If OPTS has OPF_SEARCH_IN_PATH set, absolute names will also be
656 searched in path (we usually want this for source files but not for
657 executables).
658
e7a8479f 659 If FILENAME_OPENED is non-null, set it to a newly allocated string naming
a89f66e4 660 the actual file opened (this string will always start with a "/"). We
c906108c
SS
661 have to take special pains to avoid doubling the "/" between the directory
662 and the file, sigh! Emacs gets confuzzed by this when we print the
663 source file name!!!
664
665 If a file is found, return the descriptor.
666 Otherwise, return -1, with errno set for the last name we tried to open. */
667
668/* >>>> This should only allow files of certain types,
f2172603 669 >>>> eg executable, non-directory */
c906108c 670int
014d698b 671openp (const char *path, int opts, const char *string,
fbdebf46 672 int mode, char **filename_opened)
c906108c 673{
52f0bd74
AC
674 int fd;
675 char *filename;
1f8cc6db
AC
676 const char *p;
677 const char *p1;
52f0bd74 678 int len;
c906108c
SS
679 int alloclen;
680
fbdebf46
JK
681 /* The open syscall MODE parameter is not specified. */
682 gdb_assert ((mode & O_CREAT) == 0);
f91e5ac3
JB
683 gdb_assert (string != NULL);
684
685 /* A file with an empty name cannot possibly exist. Report a failure
686 without further checking.
687
688 This is an optimization which also defends us against buggy
689 implementations of the "stat" function. For instance, we have
690 noticed that a MinGW debugger built on Windows XP 32bits crashes
691 when the debugger is started with an empty argument. */
692 if (string[0] == '\0')
693 {
694 errno = ENOENT;
695 return -1;
696 }
fbdebf46 697
c906108c
SS
698 if (!path)
699 path = ".";
700
c906108c 701 mode |= O_BINARY;
c906108c 702
014d698b 703 if ((opts & OPF_TRY_CWD_FIRST) || IS_ABSOLUTE_PATH (string))
c906108c
SS
704 {
705 int i;
072b1022
DJ
706
707 if (is_regular_file (string))
708 {
709 filename = alloca (strlen (string) + 1);
710 strcpy (filename, string);
fbdebf46 711 fd = open (filename, mode);
072b1022
DJ
712 if (fd >= 0)
713 goto done;
714 }
715 else
3f565f1e
DJ
716 {
717 filename = NULL;
718 fd = -1;
719 }
072b1022 720
014d698b
EZ
721 if (!(opts & OPF_SEARCH_IN_PATH))
722 for (i = 0; string[i]; i++)
723 if (IS_DIR_SEPARATOR (string[i]))
724 goto done;
c906108c
SS
725 }
726
014d698b
EZ
727 /* /foo => foo, to avoid multiple slashes that Emacs doesn't like. */
728 while (IS_DIR_SEPARATOR(string[0]))
729 string++;
730
c906108c 731 /* ./foo => foo */
fe4e3eb8 732 while (string[0] == '.' && IS_DIR_SEPARATOR (string[1]))
c906108c
SS
733 string += 2;
734
735 alloclen = strlen (path) + strlen (string) + 2;
1f8cc6db 736 filename = alloca (alloclen);
c906108c
SS
737 fd = -1;
738 for (p = path; p; p = p1 ? p1 + 1 : 0)
739 {
1f8cc6db 740 p1 = strchr (p, DIRNAME_SEPARATOR);
c906108c
SS
741 if (p1)
742 len = p1 - p;
743 else
744 len = strlen (p);
745
746 if (len == 4 && p[0] == '$' && p[1] == 'c'
c5aa993b
JM
747 && p[2] == 'w' && p[3] == 'd')
748 {
749 /* Name is $cwd -- insert current directory name instead. */
750 int newlen;
751
752 /* First, realloc the filename buffer if too short. */
753 len = strlen (current_directory);
754 newlen = len + strlen (string) + 2;
755 if (newlen > alloclen)
756 {
757 alloclen = newlen;
1f8cc6db 758 filename = alloca (alloclen);
c5aa993b
JM
759 }
760 strcpy (filename, current_directory);
761 }
762 else
763 {
764 /* Normal file name in path -- just use it. */
765 strncpy (filename, p, len);
766 filename[len] = 0;
08001717
DE
767
768 /* Don't search $cdir. It's also a magic path like $cwd, but we
769 don't have enough information to expand it. The user *could*
770 have an actual directory named '$cdir' but handling that would
771 be confusing, it would mean different things in different
772 contexts. If the user really has '$cdir' one can use './$cdir'.
773 We can get $cdir when loading scripts. When loading source files
774 $cdir must have already been expanded to the correct value. */
775 if (strcmp (filename, "$cdir") == 0)
776 continue;
c906108c 777 }
c906108c
SS
778
779 /* Remove trailing slashes */
fe4e3eb8 780 while (len > 0 && IS_DIR_SEPARATOR (filename[len - 1]))
c906108c
SS
781 filename[--len] = 0;
782
c5aa993b 783 strcat (filename + len, SLASH_STRING);
c906108c
SS
784 strcat (filename, string);
785
1da1a192 786 if (is_regular_file (filename))
5e987968
AS
787 {
788 fd = open (filename, mode);
789 if (fd >= 0)
790 break;
791 }
c906108c
SS
792 }
793
c5aa993b 794done:
c906108c
SS
795 if (filename_opened)
796 {
a89f66e4
JB
797 /* If a file was opened, canonicalize its filename. Use xfullpath
798 rather than gdb_realpath to avoid resolving the basename part
799 of filenames when the associated file is a symbolic link. This
800 fixes a potential inconsistency between the filenames known to
801 GDB and the filenames it prints in the annotations. */
c906108c 802 if (fd < 0)
1f8cc6db 803 *filename_opened = NULL;
fe4e3eb8 804 else if (IS_ABSOLUTE_PATH (filename))
a89f66e4 805 *filename_opened = xfullpath (filename);
c906108c
SS
806 else
807 {
808 /* Beware the // my son, the Emacs barfs, the botch that catch... */
c5aa993b 809
58d370e0 810 char *f = concat (current_directory,
5e987968
AS
811 IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1])
812 ? "" : SLASH_STRING,
1754f103 813 filename, (char *)NULL);
a89f66e4 814 *filename_opened = xfullpath (f);
58d370e0 815 xfree (f);
c5aa993b 816 }
c906108c 817 }
c906108c
SS
818
819 return fd;
820}
821
c5aa993b 822
c906108c
SS
823/* This is essentially a convenience, for clients that want the behaviour
824 of openp, using source_path, but that really don't want the file to be
825 opened but want instead just to know what the full pathname is (as
826 qualified against source_path).
827
828 The current working directory is searched first.
829
830 If the file was found, this function returns 1, and FULL_PATHNAME is
831 set to the fully-qualified pathname.
832
5e987968 833 Else, this functions returns 0, and FULL_PATHNAME is set to NULL. */
c906108c 834int
24f81874 835source_full_path_of (const char *filename, char **full_pathname)
c906108c 836{
c5aa993b 837 int fd;
c906108c 838
014d698b 839 fd = openp (source_path, OPF_TRY_CWD_FIRST | OPF_SEARCH_IN_PATH, filename,
fbdebf46 840 O_RDONLY, full_pathname);
c906108c
SS
841 if (fd < 0)
842 {
843 *full_pathname = NULL;
844 return 0;
845 }
846
847 close (fd);
848 return 1;
849}
850
2f61ca93
JB
851/* Return non-zero if RULE matches PATH, that is if the rule can be
852 applied to PATH. */
853
854static int
855substitute_path_rule_matches (const struct substitute_path_rule *rule,
856 const char *path)
857{
858 const int from_len = strlen (rule->from);
859 const int path_len = strlen (path);
860 char *path_start;
861
862 if (path_len < from_len)
863 return 0;
864
865 /* The substitution rules are anchored at the start of the path,
866 so the path should start with rule->from. There is no filename
867 comparison routine, so we need to extract the first FROM_LEN
868 characters from PATH first and use that to do the comparison. */
869
870 path_start = alloca (from_len + 1);
871 strncpy (path_start, path, from_len);
872 path_start[from_len] = '\0';
873
874 if (FILENAME_CMP (path_start, rule->from) != 0)
875 return 0;
876
877 /* Make sure that the region in the path that matches the substitution
878 rule is immediately followed by a directory separator (or the end of
879 string character). */
880
881 if (path[from_len] != '\0' && !IS_DIR_SEPARATOR (path[from_len]))
882 return 0;
883
884 return 1;
885}
886
887/* Find the substitute-path rule that applies to PATH and return it.
888 Return NULL if no rule applies. */
889
890static struct substitute_path_rule *
891get_substitute_path_rule (const char *path)
892{
893 struct substitute_path_rule *rule = substitute_path_rules;
894
895 while (rule != NULL && !substitute_path_rule_matches (rule, path))
896 rule = rule->next;
897
898 return rule;
899}
900
901/* If the user specified a source path substitution rule that applies
902 to PATH, then apply it and return the new path. This new path must
903 be deallocated afterwards.
904
905 Return NULL if no substitution rule was specified by the user,
906 or if no rule applied to the given PATH. */
907
908static char *
909rewrite_source_path (const char *path)
910{
911 const struct substitute_path_rule *rule = get_substitute_path_rule (path);
912 char *new_path;
913 int from_len;
914
915 if (rule == NULL)
916 return NULL;
917
918 from_len = strlen (rule->from);
919
920 /* Compute the rewritten path and return it. */
921
922 new_path =
923 (char *) xmalloc (strlen (path) + 1 + strlen (rule->to) - from_len);
924 strcpy (new_path, rule->to);
925 strcat (new_path, path + from_len);
926
927 return new_path;
928}
929
57c22c6c 930/* This function is capable of finding the absolute path to a
e2357892
JK
931 source file, and opening it, provided you give it a FILENAME. Both the
932 DIRNAME and FULLNAME are only added suggestions on where to find the file.
57c22c6c 933
57c22c6c
BR
934 FILENAME should be the filename to open.
935 DIRNAME is the compilation directory of a particular source file.
936 Only some debug formats provide this info.
937 FULLNAME can be the last known absolute path to the file in question.
86991504
DE
938 Space for the path must have been malloc'd. If a path substitution
939 is applied we free the old value and set a new one.
57c22c6c
BR
940
941 On Success
942 A valid file descriptor is returned. ( the return value is positive )
943 FULLNAME is set to the absolute path to the file just opened.
86991504 944 The caller is responsible for freeing FULLNAME.
57c22c6c
BR
945
946 On Failure
2f61ca93 947 An invalid file descriptor is returned. ( the return value is negative )
57c22c6c 948 FULLNAME is set to NULL. */
86991504 949
ccefe4c4 950int
e2357892 951find_and_open_source (const char *filename,
5e987968
AS
952 const char *dirname,
953 char **fullname)
c906108c
SS
954{
955 char *path = source_path;
31889e00 956 const char *p;
c906108c 957 int result;
c906108c
SS
958
959 /* Quick way out if we already know its full name */
2f61ca93 960
57c22c6c 961 if (*fullname)
c906108c 962 {
2f61ca93
JB
963 /* The user may have requested that source paths be rewritten
964 according to substitution rules he provided. If a substitution
965 rule applies to this path, then apply it. */
966 char *rewritten_fullname = rewrite_source_path (*fullname);
967
968 if (rewritten_fullname != NULL)
969 {
970 xfree (*fullname);
971 *fullname = rewritten_fullname;
972 }
973
57c22c6c 974 result = open (*fullname, OPEN_MODE);
c906108c 975 if (result >= 0)
c5aa993b 976 return result;
c906108c 977 /* Didn't work -- free old one, try again. */
2dc74dc1 978 xfree (*fullname);
57c22c6c 979 *fullname = NULL;
c906108c
SS
980 }
981
57c22c6c 982 if (dirname != NULL)
c906108c 983 {
2f61ca93
JB
984 /* If necessary, rewrite the compilation directory name according
985 to the source path substitution rules specified by the user. */
986
987 char *rewritten_dirname = rewrite_source_path (dirname);
988
989 if (rewritten_dirname != NULL)
990 {
991 make_cleanup (xfree, rewritten_dirname);
992 dirname = rewritten_dirname;
993 }
994
c906108c
SS
995 /* Replace a path entry of $cdir with the compilation directory name */
996#define cdir_len 5
997 /* We cast strstr's result in case an ANSIhole has made it const,
c5aa993b
JM
998 which produces a "required warning" when assigned to a nonconst. */
999 p = (char *) strstr (source_path, "$cdir");
c906108c 1000 if (p && (p == path || p[-1] == DIRNAME_SEPARATOR)
c5aa993b 1001 && (p[cdir_len] == DIRNAME_SEPARATOR || p[cdir_len] == '\0'))
c906108c
SS
1002 {
1003 int len;
1004
1005 path = (char *)
57c22c6c 1006 alloca (strlen (source_path) + 1 + strlen (dirname) + 1);
c906108c 1007 len = p - source_path;
c5aa993b 1008 strncpy (path, source_path, len); /* Before $cdir */
57c22c6c 1009 strcpy (path + len, dirname); /* new stuff */
c5aa993b 1010 strcat (path + len, source_path + len + cdir_len); /* After $cdir */
c906108c
SS
1011 }
1012 }
8da2a1df
DJ
1013
1014 if (IS_ABSOLUTE_PATH (filename))
56163ce1 1015 {
8da2a1df
DJ
1016 /* If filename is absolute path, try the source path
1017 substitution on it. */
56163ce1
JB
1018 char *rewritten_filename = rewrite_source_path (filename);
1019
1020 if (rewritten_filename != NULL)
1021 {
1022 make_cleanup (xfree, rewritten_filename);
1023 filename = rewritten_filename;
1024 }
1025 }
c906108c 1026
fbdebf46 1027 result = openp (path, OPF_SEARCH_IN_PATH, filename, OPEN_MODE, fullname);
c906108c
SS
1028 if (result < 0)
1029 {
1030 /* Didn't work. Try using just the basename. */
57c22c6c
BR
1031 p = lbasename (filename);
1032 if (p != filename)
fbdebf46 1033 result = openp (path, OPF_SEARCH_IN_PATH, p, OPEN_MODE, fullname);
c906108c 1034 }
c906108c 1035
c906108c
SS
1036 return result;
1037}
1038
57c22c6c
BR
1039/* Open a source file given a symtab S. Returns a file descriptor or
1040 negative number for error.
1041
1042 This function is a convience function to find_and_open_source. */
1043
1044int
1045open_source_file (struct symtab *s)
1046{
5e987968
AS
1047 if (!s)
1048 return -1;
57c22c6c 1049
e2357892 1050 return find_and_open_source (s->filename, s->dirname, &s->fullname);
57c22c6c
BR
1051}
1052
1053/* Finds the fullname that a symtab represents.
c906108c 1054
f132ba9d 1055 If this functions finds the fullname, it will save it in s->fullname
57c22c6c
BR
1056 and it will also return the value.
1057
1058 If this function fails to find the file that this symtab represents,
f132ba9d 1059 NULL will be returned and s->fullname will be set to NULL. */
c906108c 1060char *
57c22c6c 1061symtab_to_fullname (struct symtab *s)
c906108c 1062{
57c22c6c 1063 int r;
c906108c
SS
1064
1065 if (!s)
1066 return NULL;
1067
57c22c6c
BR
1068 /* Don't check s->fullname here, the file could have been
1069 deleted/moved/..., look for it again */
e2357892 1070 r = find_and_open_source (s->filename, s->dirname, &s->fullname);
c906108c 1071
9fe4a216 1072 if (r >= 0)
5e987968
AS
1073 {
1074 close (r);
1075 return s->fullname;
1076 }
c906108c 1077
57c22c6c
BR
1078 return NULL;
1079}
5e987968 1080\f
c906108c
SS
1081/* Create and initialize the table S->line_charpos that records
1082 the positions of the lines in the source file, which is assumed
1083 to be open on descriptor DESC.
1084 All set S->nlines to the number of such lines. */
1085
1086void
fba45db2 1087find_source_lines (struct symtab *s, int desc)
c906108c
SS
1088{
1089 struct stat st;
52f0bd74 1090 char *data, *p, *end;
c906108c
SS
1091 int nlines = 0;
1092 int lines_allocated = 1000;
1093 int *line_charpos;
1094 long mtime = 0;
1095 int size;
1096
be8ca11b 1097 gdb_assert (s);
7936743b 1098 line_charpos = (int *) xmalloc (lines_allocated * sizeof (int));
c906108c
SS
1099 if (fstat (desc, &st) < 0)
1100 perror_with_name (s->filename);
1101
be8ca11b 1102 if (s->objfile && s->objfile->obfd)
c04ea773 1103 mtime = s->objfile->mtime;
c906108c 1104 else if (exec_bfd)
c04ea773 1105 mtime = exec_bfd_mtime;
c906108c
SS
1106
1107 if (mtime && mtime < st.st_mtime)
8a3fe4f8 1108 warning (_("Source file is more recent than executable."));
c906108c
SS
1109
1110#ifdef LSEEK_NOT_LINEAR
1111 {
1112 char c;
1113
1114 /* Have to read it byte by byte to find out where the chars live */
1115
1116 line_charpos[0] = lseek (desc, 0, SEEK_CUR);
1117 nlines = 1;
c5aa993b 1118 while (myread (desc, &c, 1) > 0)
c906108c 1119 {
c5aa993b 1120 if (c == '\n')
c906108c 1121 {
c5aa993b 1122 if (nlines == lines_allocated)
c906108c
SS
1123 {
1124 lines_allocated *= 2;
1125 line_charpos =
0efffb96
AC
1126 (int *) xrealloc ((char *) line_charpos,
1127 sizeof (int) * lines_allocated);
c906108c
SS
1128 }
1129 line_charpos[nlines++] = lseek (desc, 0, SEEK_CUR);
1130 }
1131 }
1132 }
1133#else /* lseek linear. */
1134 {
1135 struct cleanup *old_cleanups;
1136
1137 /* st_size might be a large type, but we only support source files whose
1138 size fits in an int. */
1139 size = (int) st.st_size;
1140
1141 /* Use malloc, not alloca, because this may be pretty large, and we may
1142 run into various kinds of limits on stack size. */
1143 data = (char *) xmalloc (size);
b8c9b27d 1144 old_cleanups = make_cleanup (xfree, data);
c906108c
SS
1145
1146 /* Reassign `size' to result of read for systems where \r\n -> \n. */
1147 size = myread (desc, data, size);
1148 if (size < 0)
1149 perror_with_name (s->filename);
1150 end = data + size;
1151 p = data;
1152 line_charpos[0] = 0;
1153 nlines = 1;
1154 while (p != end)
1155 {
1156 if (*p++ == '\n'
c5aa993b 1157 /* A newline at the end does not start a new line. */
c906108c
SS
1158 && p != end)
1159 {
1160 if (nlines == lines_allocated)
1161 {
1162 lines_allocated *= 2;
1163 line_charpos =
0efffb96
AC
1164 (int *) xrealloc ((char *) line_charpos,
1165 sizeof (int) * lines_allocated);
c906108c
SS
1166 }
1167 line_charpos[nlines++] = p - data;
1168 }
1169 }
1170 do_cleanups (old_cleanups);
1171 }
1172#endif /* lseek linear. */
1173 s->nlines = nlines;
1174 s->line_charpos =
0efffb96 1175 (int *) xrealloc ((char *) line_charpos, nlines * sizeof (int));
c906108c
SS
1176
1177}
1178
1179/* Return the character position of a line LINE in symtab S.
1180 Return 0 if anything is invalid. */
1181
c5aa993b 1182#if 0 /* Currently unused */
c906108c
SS
1183
1184int
fba45db2 1185source_line_charpos (struct symtab *s, int line)
c906108c 1186{
c5aa993b
JM
1187 if (!s)
1188 return 0;
1189 if (!s->line_charpos || line <= 0)
1190 return 0;
c906108c
SS
1191 if (line > s->nlines)
1192 line = s->nlines;
1193 return s->line_charpos[line - 1];
1194}
1195
1196/* Return the line number of character position POS in symtab S. */
1197
1198int
aa1ee363 1199source_charpos_line (struct symtab *s, int chr)
c906108c 1200{
52f0bd74
AC
1201 int line = 0;
1202 int *lnp;
c5aa993b
JM
1203
1204 if (s == 0 || s->line_charpos == 0)
1205 return 0;
c906108c
SS
1206 lnp = s->line_charpos;
1207 /* Files are usually short, so sequential search is Ok */
c5aa993b 1208 while (line < s->nlines && *lnp <= chr)
c906108c
SS
1209 {
1210 line++;
1211 lnp++;
1212 }
1213 if (line >= s->nlines)
1214 line = s->nlines;
1215 return line;
1216}
1217
c5aa993b 1218#endif /* 0 */
c906108c 1219\f
c5aa993b 1220
c906108c
SS
1221/* Get full pathname and line number positions for a symtab.
1222 Return nonzero if line numbers may have changed.
1223 Set *FULLNAME to actual name of the file as found by `openp',
1224 or to 0 if the file is not found. */
1225
1226static int
fba45db2 1227get_filename_and_charpos (struct symtab *s, char **fullname)
c906108c 1228{
52f0bd74 1229 int desc, linenums_changed = 0;
9fe4a216 1230 struct cleanup *cleanups;
c5aa993b 1231
c906108c
SS
1232 desc = open_source_file (s);
1233 if (desc < 0)
1234 {
1235 if (fullname)
1236 *fullname = NULL;
1237 return 0;
c5aa993b 1238 }
9fe4a216 1239 cleanups = make_cleanup_close (desc);
c906108c
SS
1240 if (fullname)
1241 *fullname = s->fullname;
c5aa993b
JM
1242 if (s->line_charpos == 0)
1243 linenums_changed = 1;
1244 if (linenums_changed)
1245 find_source_lines (s, desc);
9fe4a216 1246 do_cleanups (cleanups);
c906108c
SS
1247 return linenums_changed;
1248}
1249
1250/* Print text describing the full name of the source file S
1251 and the line number LINE and its corresponding character position.
1252 The text starts with two Ctrl-z so that the Emacs-GDB interface
1253 can easily find it.
1254
1255 MID_STATEMENT is nonzero if the PC is not at the beginning of that line.
1256
1257 Return 1 if successful, 0 if could not find the file. */
1258
1259int
fba45db2
KB
1260identify_source_line (struct symtab *s, int line, int mid_statement,
1261 CORE_ADDR pc)
c906108c
SS
1262{
1263 if (s->line_charpos == 0)
c5aa993b 1264 get_filename_and_charpos (s, (char **) NULL);
c906108c
SS
1265 if (s->fullname == 0)
1266 return 0;
1267 if (line > s->nlines)
1268 /* Don't index off the end of the line_charpos array. */
1269 return 0;
1270 annotate_source (s->fullname, line, s->line_charpos[line - 1],
5af949e3 1271 mid_statement, get_objfile_arch (s->objfile), pc);
c906108c
SS
1272
1273 current_source_line = line;
1274 first_line_listed = line;
1275 last_line_listed = line;
1276 current_source_symtab = s;
1277 return 1;
1278}
c906108c 1279\f
c5aa993b 1280
c906108c
SS
1281/* Print source lines from the file of symtab S,
1282 starting with line number LINE and stopping before line number STOPLINE. */
1283
a14ed312
KB
1284static void print_source_lines_base (struct symtab *s, int line, int stopline,
1285 int noerror);
c906108c 1286static void
fba45db2 1287print_source_lines_base (struct symtab *s, int line, int stopline, int noerror)
c906108c 1288{
52f0bd74
AC
1289 int c;
1290 int desc;
1291 FILE *stream;
c906108c 1292 int nlines = stopline - line;
7c8a8b04 1293 struct cleanup *cleanup;
c906108c
SS
1294
1295 /* Regardless of whether we can open the file, set current_source_symtab. */
1296 current_source_symtab = s;
1297 current_source_line = line;
1298 first_line_listed = line;
1299
8b93c638
JM
1300 /* If printing of source lines is disabled, just print file and line number */
1301 if (ui_out_test_flags (uiout, ui_source_list))
1302 {
c5aa993b
JM
1303 /* Only prints "No such file or directory" once */
1304 if ((s != last_source_visited) || (!last_source_error))
1305 {
1306 last_source_visited = s;
1307 desc = open_source_file (s);
1308 }
1309 else
1310 {
1311 desc = last_source_error;
1312 noerror = 1;
1313 }
8b93c638
JM
1314 }
1315 else
1316 {
1317 desc = -1;
1318 noerror = 1;
1319 }
c906108c
SS
1320
1321 if (desc < 0)
1322 {
1323 last_source_error = desc;
1324
c5aa993b
JM
1325 if (!noerror)
1326 {
c906108c
SS
1327 char *name = alloca (strlen (s->filename) + 100);
1328 sprintf (name, "%d\t%s", line, s->filename);
1329 print_sys_errmsg (name, errno);
1330 }
1331 else
8b93c638
JM
1332 ui_out_field_int (uiout, "line", line);
1333 ui_out_text (uiout, "\tin ");
1334 ui_out_field_string (uiout, "file", s->filename);
1335 ui_out_text (uiout, "\n");
c906108c
SS
1336
1337 return;
1338 }
1339
1340 last_source_error = 0;
1341
1342 if (s->line_charpos == 0)
1343 find_source_lines (s, desc);
1344
1345 if (line < 1 || line > s->nlines)
1346 {
1347 close (desc);
8a3fe4f8 1348 error (_("Line number %d out of range; %s has %d lines."),
c906108c
SS
1349 line, s->filename, s->nlines);
1350 }
1351
1352 if (lseek (desc, s->line_charpos[line - 1], 0) < 0)
1353 {
1354 close (desc);
1355 perror_with_name (s->filename);
1356 }
1357
1358 stream = fdopen (desc, FDOPEN_MODE);
1359 clearerr (stream);
7c8a8b04 1360 cleanup = make_cleanup_fclose (stream);
c906108c
SS
1361
1362 while (nlines-- > 0)
1363 {
8b93c638
JM
1364 char buf[20];
1365
1366 c = fgetc (stream);
1367 if (c == EOF)
1368 break;
1369 last_line_listed = current_source_line;
1370 sprintf (buf, "%d\t", current_source_line++);
1371 ui_out_text (uiout, buf);
1372 do
1373 {
1374 if (c < 040 && c != '\t' && c != '\n' && c != '\r')
1375 {
1376 sprintf (buf, "^%c", c + 0100);
1377 ui_out_text (uiout, buf);
1378 }
1379 else if (c == 0177)
1380 ui_out_text (uiout, "^?");
8b93c638
JM
1381 else if (c == '\r')
1382 {
1383 /* Skip a \r character, but only before a \n. */
1384 int c1 = fgetc (stream);
1385
1386 if (c1 != '\n')
1387 printf_filtered ("^%c", c + 0100);
1388 if (c1 != EOF)
1389 ungetc (c1, stream);
1390 }
8b93c638
JM
1391 else
1392 {
1393 sprintf (buf, "%c", c);
1394 ui_out_text (uiout, buf);
1395 }
1396 }
1397 while (c != '\n' && (c = fgetc (stream)) >= 0);
c906108c
SS
1398 }
1399
7c8a8b04 1400 do_cleanups (cleanup);
c906108c
SS
1401}
1402\f
1403/* Show source lines from the file of symtab S, starting with line
f132ba9d 1404 number LINE and stopping before line number STOPLINE. If this is
c906108c
SS
1405 not the command line version, then the source is shown in the source
1406 window otherwise it is simply printed */
1407
c5aa993b 1408void
fba45db2 1409print_source_lines (struct symtab *s, int line, int stopline, int noerror)
c906108c 1410{
c5aa993b 1411 print_source_lines_base (s, line, stopline, noerror);
c906108c
SS
1412}
1413\f
c906108c
SS
1414/* Print info on range of pc's in a specified line. */
1415
1416static void
fba45db2 1417line_info (char *arg, int from_tty)
c906108c
SS
1418{
1419 struct symtabs_and_lines sals;
1420 struct symtab_and_line sal;
1421 CORE_ADDR start_pc, end_pc;
1422 int i;
1423
fe39c653 1424 init_sal (&sal); /* initialize to zeroes */
c906108c
SS
1425
1426 if (arg == 0)
1427 {
1428 sal.symtab = current_source_symtab;
1429 sal.line = last_line_listed;
1430 sals.nelts = 1;
1431 sals.sals = (struct symtab_and_line *)
1432 xmalloc (sizeof (struct symtab_and_line));
1433 sals.sals[0] = sal;
1434 }
1435 else
1436 {
1437 sals = decode_line_spec_1 (arg, 0);
c5aa993b 1438
c906108c
SS
1439 dont_repeat ();
1440 }
1441
1442 /* C++ More than one line may have been specified, as when the user
1443 specifies an overloaded function name. Print info on them all. */
1444 for (i = 0; i < sals.nelts; i++)
1445 {
1446 sal = sals.sals[i];
c5aa993b 1447
c906108c
SS
1448 if (sal.symtab == 0)
1449 {
5af949e3
UW
1450 struct gdbarch *gdbarch = get_current_arch ();
1451
a3f17187 1452 printf_filtered (_("No line number information available"));
c906108c
SS
1453 if (sal.pc != 0)
1454 {
1455 /* This is useful for "info line *0x7f34". If we can't tell the
c5aa993b
JM
1456 user about a source line, at least let them have the symbolic
1457 address. */
c906108c
SS
1458 printf_filtered (" for address ");
1459 wrap_here (" ");
5af949e3 1460 print_address (gdbarch, sal.pc, gdb_stdout);
c906108c
SS
1461 }
1462 else
1463 printf_filtered (".");
1464 printf_filtered ("\n");
1465 }
1466 else if (sal.line > 0
1467 && find_line_pc_range (sal, &start_pc, &end_pc))
1468 {
5af949e3
UW
1469 struct gdbarch *gdbarch = get_objfile_arch (sal.symtab->objfile);
1470
c906108c
SS
1471 if (start_pc == end_pc)
1472 {
1473 printf_filtered ("Line %d of \"%s\"",
1474 sal.line, sal.symtab->filename);
1475 wrap_here (" ");
1476 printf_filtered (" is at address ");
5af949e3 1477 print_address (gdbarch, start_pc, gdb_stdout);
c906108c
SS
1478 wrap_here (" ");
1479 printf_filtered (" but contains no code.\n");
1480 }
1481 else
1482 {
1483 printf_filtered ("Line %d of \"%s\"",
1484 sal.line, sal.symtab->filename);
1485 wrap_here (" ");
1486 printf_filtered (" starts at address ");
5af949e3 1487 print_address (gdbarch, start_pc, gdb_stdout);
c906108c
SS
1488 wrap_here (" ");
1489 printf_filtered (" and ends at ");
5af949e3 1490 print_address (gdbarch, end_pc, gdb_stdout);
c906108c
SS
1491 printf_filtered (".\n");
1492 }
1493
1494 /* x/i should display this line's code. */
5af949e3 1495 set_next_address (gdbarch, start_pc);
c906108c
SS
1496
1497 /* Repeating "info line" should do the following line. */
1498 last_line_listed = sal.line + 1;
1499
1500 /* If this is the only line, show the source code. If it could
1501 not find the file, don't do anything special. */
1502 if (annotation_level && sals.nelts == 1)
1503 identify_source_line (sal.symtab, sal.line, 0, start_pc);
1504 }
1505 else
1506 /* Is there any case in which we get here, and have an address
1507 which the user would want to see? If we have debugging symbols
1508 and no line numbers? */
a3f17187 1509 printf_filtered (_("Line number %d is out of range for \"%s\".\n"),
c906108c
SS
1510 sal.line, sal.symtab->filename);
1511 }
b8c9b27d 1512 xfree (sals.sals);
c906108c
SS
1513}
1514\f
1515/* Commands to search the source file for a regexp. */
1516
c906108c 1517static void
fba45db2 1518forward_search_command (char *regex, int from_tty)
c906108c 1519{
52f0bd74
AC
1520 int c;
1521 int desc;
1522 FILE *stream;
c906108c
SS
1523 int line;
1524 char *msg;
9fe4a216 1525 struct cleanup *cleanups;
c906108c 1526
c906108c 1527 line = last_line_listed + 1;
c906108c
SS
1528
1529 msg = (char *) re_comp (regex);
1530 if (msg)
8a3fe4f8 1531 error (("%s"), msg);
c906108c
SS
1532
1533 if (current_source_symtab == 0)
1534 select_source_symtab (0);
1535
1536 desc = open_source_file (current_source_symtab);
1537 if (desc < 0)
1538 perror_with_name (current_source_symtab->filename);
9fe4a216 1539 cleanups = make_cleanup_close (desc);
c906108c
SS
1540
1541 if (current_source_symtab->line_charpos == 0)
1542 find_source_lines (current_source_symtab, desc);
1543
1544 if (line < 1 || line > current_source_symtab->nlines)
9fe4a216 1545 error (_("Expression not found"));
c906108c
SS
1546
1547 if (lseek (desc, current_source_symtab->line_charpos[line - 1], 0) < 0)
9fe4a216 1548 perror_with_name (current_source_symtab->filename);
c906108c 1549
9fe4a216 1550 discard_cleanups (cleanups);
c906108c
SS
1551 stream = fdopen (desc, FDOPEN_MODE);
1552 clearerr (stream);
9fe4a216 1553 cleanups = make_cleanup_fclose (stream);
c5aa993b
JM
1554 while (1)
1555 {
1556 static char *buf = NULL;
aa1ee363 1557 char *p;
c5aa993b
JM
1558 int cursize, newsize;
1559
1560 cursize = 256;
1561 buf = xmalloc (cursize);
1562 p = buf;
1563
1564 c = getc (stream);
1565 if (c == EOF)
1566 break;
1567 do
c906108c 1568 {
c5aa993b
JM
1569 *p++ = c;
1570 if (p - buf == cursize)
1571 {
1572 newsize = cursize + cursize / 2;
1573 buf = xrealloc (buf, newsize);
1574 p = buf + cursize;
1575 cursize = newsize;
1576 }
c906108c 1577 }
c5aa993b 1578 while (c != '\n' && (c = getc (stream)) >= 0);
c906108c 1579
7be570e7
JM
1580 /* Remove the \r, if any, at the end of the line, otherwise
1581 regular expressions that end with $ or \n won't work. */
1582 if (p - buf > 1 && p[-2] == '\r')
1583 {
1584 p--;
1585 p[-1] = '\n';
1586 }
7be570e7 1587
c5aa993b
JM
1588 /* we now have a source line in buf, null terminate and match */
1589 *p = 0;
1590 if (re_exec (buf) > 0)
1591 {
1592 /* Match! */
e681b284 1593 do_cleanups (cleanups);
c5aa993b 1594 print_source_lines (current_source_symtab, line, line + 1, 0);
4fa62494 1595 set_internalvar_integer (lookup_internalvar ("_"), line);
c5aa993b
JM
1596 current_source_line = max (line - lines_to_list / 2, 1);
1597 return;
1598 }
1599 line++;
1600 }
c906108c 1601
a3f17187 1602 printf_filtered (_("Expression not found\n"));
9fe4a216 1603 do_cleanups (cleanups);
c906108c
SS
1604}
1605
c906108c 1606static void
fba45db2 1607reverse_search_command (char *regex, int from_tty)
c906108c 1608{
52f0bd74
AC
1609 int c;
1610 int desc;
1611 FILE *stream;
c906108c
SS
1612 int line;
1613 char *msg;
9fe4a216 1614 struct cleanup *cleanups;
063190b6 1615
c906108c 1616 line = last_line_listed - 1;
c906108c
SS
1617
1618 msg = (char *) re_comp (regex);
1619 if (msg)
8a3fe4f8 1620 error (("%s"), msg);
c906108c
SS
1621
1622 if (current_source_symtab == 0)
1623 select_source_symtab (0);
1624
1625 desc = open_source_file (current_source_symtab);
1626 if (desc < 0)
1627 perror_with_name (current_source_symtab->filename);
9fe4a216 1628 cleanups = make_cleanup_close (desc);
c906108c
SS
1629
1630 if (current_source_symtab->line_charpos == 0)
1631 find_source_lines (current_source_symtab, desc);
1632
1633 if (line < 1 || line > current_source_symtab->nlines)
9fe4a216 1634 error (_("Expression not found"));
c906108c
SS
1635
1636 if (lseek (desc, current_source_symtab->line_charpos[line - 1], 0) < 0)
9fe4a216 1637 perror_with_name (current_source_symtab->filename);
c906108c 1638
9fe4a216 1639 discard_cleanups (cleanups);
c906108c
SS
1640 stream = fdopen (desc, FDOPEN_MODE);
1641 clearerr (stream);
9fe4a216 1642 cleanups = make_cleanup_fclose (stream);
c906108c
SS
1643 while (line > 1)
1644 {
1645/* FIXME!!! We walk right off the end of buf if we get a long line!!! */
1646 char buf[4096]; /* Should be reasonable??? */
aa1ee363 1647 char *p = buf;
c906108c
SS
1648
1649 c = getc (stream);
1650 if (c == EOF)
1651 break;
c5aa993b
JM
1652 do
1653 {
1654 *p++ = c;
1655 }
1656 while (c != '\n' && (c = getc (stream)) >= 0);
c906108c 1657
7be570e7
JM
1658 /* Remove the \r, if any, at the end of the line, otherwise
1659 regular expressions that end with $ or \n won't work. */
1660 if (p - buf > 1 && p[-2] == '\r')
1661 {
1662 p--;
1663 p[-1] = '\n';
1664 }
7be570e7 1665
c906108c
SS
1666 /* We now have a source line in buf; null terminate and match. */
1667 *p = 0;
1668 if (re_exec (buf) > 0)
1669 {
1670 /* Match! */
e681b284 1671 do_cleanups (cleanups);
c5aa993b 1672 print_source_lines (current_source_symtab, line, line + 1, 0);
4fa62494 1673 set_internalvar_integer (lookup_internalvar ("_"), line);
c906108c
SS
1674 current_source_line = max (line - lines_to_list / 2, 1);
1675 return;
1676 }
1677 line--;
1678 if (fseek (stream, current_source_symtab->line_charpos[line - 1], 0) < 0)
1679 {
e681b284 1680 do_cleanups (cleanups);
c906108c
SS
1681 perror_with_name (current_source_symtab->filename);
1682 }
1683 }
1684
a3f17187 1685 printf_filtered (_("Expression not found\n"));
9fe4a216 1686 do_cleanups (cleanups);
c906108c
SS
1687 return;
1688}
2f61ca93
JB
1689
1690/* If the last character of PATH is a directory separator, then strip it. */
1691
1692static void
1693strip_trailing_directory_separator (char *path)
1694{
1695 const int last = strlen (path) - 1;
1696
1697 if (last < 0)
1698 return; /* No stripping is needed if PATH is the empty string. */
1699
1700 if (IS_DIR_SEPARATOR (path[last]))
1701 path[last] = '\0';
1702}
1703
1704/* Return the path substitution rule that matches FROM.
1705 Return NULL if no rule matches. */
1706
1707static struct substitute_path_rule *
1708find_substitute_path_rule (const char *from)
1709{
1710 struct substitute_path_rule *rule = substitute_path_rules;
1711
1712 while (rule != NULL)
1713 {
1714 if (FILENAME_CMP (rule->from, from) == 0)
1715 return rule;
1716 rule = rule->next;
1717 }
1718
1719 return NULL;
1720}
1721
1722/* Add a new substitute-path rule at the end of the current list of rules.
1723 The new rule will replace FROM into TO. */
1724
29b0e8a2 1725void
2f61ca93
JB
1726add_substitute_path_rule (char *from, char *to)
1727{
1728 struct substitute_path_rule *rule;
1729 struct substitute_path_rule *new_rule;
1730
1731 new_rule = xmalloc (sizeof (struct substitute_path_rule));
1732 new_rule->from = xstrdup (from);
1733 new_rule->to = xstrdup (to);
1734 new_rule->next = NULL;
1735
1736 /* If the list of rules are empty, then insert the new rule
1737 at the head of the list. */
1738
1739 if (substitute_path_rules == NULL)
1740 {
1741 substitute_path_rules = new_rule;
1742 return;
1743 }
1744
1745 /* Otherwise, skip to the last rule in our list and then append
1746 the new rule. */
1747
1748 rule = substitute_path_rules;
1749 while (rule->next != NULL)
1750 rule = rule->next;
1751
1752 rule->next = new_rule;
1753}
1754
1755/* Remove the given source path substitution rule from the current list
1756 of rules. The memory allocated for that rule is also deallocated. */
1757
1758static void
1759delete_substitute_path_rule (struct substitute_path_rule *rule)
1760{
1761 if (rule == substitute_path_rules)
1762 substitute_path_rules = rule->next;
1763 else
1764 {
1765 struct substitute_path_rule *prev = substitute_path_rules;
1766
1767 while (prev != NULL && prev->next != rule)
1768 prev = prev->next;
1769
1770 gdb_assert (prev != NULL);
1771
1772 prev->next = rule->next;
1773 }
1774
1775 xfree (rule->from);
1776 xfree (rule->to);
1777 xfree (rule);
1778}
1779
1780/* Implement the "show substitute-path" command. */
1781
1782static void
1783show_substitute_path_command (char *args, int from_tty)
1784{
1785 struct substitute_path_rule *rule = substitute_path_rules;
1786 char **argv;
1787 char *from = NULL;
1788
d1a41061 1789 argv = gdb_buildargv (args);
2f61ca93
JB
1790 make_cleanup_freeargv (argv);
1791
1792 /* We expect zero or one argument. */
1793
1794 if (argv != NULL && argv[0] != NULL && argv[1] != NULL)
1795 error (_("Too many arguments in command"));
1796
1797 if (argv != NULL && argv[0] != NULL)
1798 from = argv[0];
1799
1800 /* Print the substitution rules. */
1801
1802 if (from != NULL)
1803 printf_filtered
1804 (_("Source path substitution rule matching `%s':\n"), from);
1805 else
1806 printf_filtered (_("List of all source path substitution rules:\n"));
1807
1808 while (rule != NULL)
1809 {
1810 if (from == NULL || FILENAME_CMP (rule->from, from) == 0)
1811 printf_filtered (" `%s' -> `%s'.\n", rule->from, rule->to);
1812 rule = rule->next;
1813 }
1814}
1815
1816/* Implement the "unset substitute-path" command. */
1817
1818static void
1819unset_substitute_path_command (char *args, int from_tty)
1820{
1821 struct substitute_path_rule *rule = substitute_path_rules;
d1a41061 1822 char **argv = gdb_buildargv (args);
2f61ca93
JB
1823 char *from = NULL;
1824 int rule_found = 0;
1825
1826 /* This function takes either 0 or 1 argument. */
1827
77accacd 1828 make_cleanup_freeargv (argv);
2f61ca93
JB
1829 if (argv != NULL && argv[0] != NULL && argv[1] != NULL)
1830 error (_("Incorrect usage, too many arguments in command"));
1831
1832 if (argv != NULL && argv[0] != NULL)
1833 from = argv[0];
1834
1835 /* If the user asked for all the rules to be deleted, ask him
1836 to confirm and give him a chance to abort before the action
1837 is performed. */
1838
1839 if (from == NULL
1840 && !query (_("Delete all source path substitution rules? ")))
1841 error (_("Canceled"));
1842
1843 /* Delete the rule matching the argument. No argument means that
1844 all rules should be deleted. */
1845
1846 while (rule != NULL)
1847 {
1848 struct substitute_path_rule *next = rule->next;
1849
1850 if (from == NULL || FILENAME_CMP (from, rule->from) == 0)
1851 {
1852 delete_substitute_path_rule (rule);
1853 rule_found = 1;
1854 }
1855
1856 rule = next;
1857 }
1858
1859 /* If the user asked for a specific rule to be deleted but
1860 we could not find it, then report an error. */
1861
1862 if (from != NULL && !rule_found)
1863 error (_("No substitution rule defined for `%s'"), from);
c4e86dd4
DJ
1864
1865 forget_cached_source_info ();
2f61ca93
JB
1866}
1867
1868/* Add a new source path substitution rule. */
1869
1870static void
1871set_substitute_path_command (char *args, int from_tty)
1872{
1873 char *from_path, *to_path;
1874 char **argv;
1875 struct substitute_path_rule *rule;
1876
d1a41061 1877 argv = gdb_buildargv (args);
2f61ca93
JB
1878 make_cleanup_freeargv (argv);
1879
1880 if (argv == NULL || argv[0] == NULL || argv [1] == NULL)
1881 error (_("Incorrect usage, too few arguments in command"));
1882
1883 if (argv[2] != NULL)
1884 error (_("Incorrect usage, too many arguments in command"));
1885
1886 if (*(argv[0]) == '\0')
1887 error (_("First argument must be at least one character long"));
1888
1889 /* Strip any trailing directory separator character in either FROM
1890 or TO. The substitution rule already implicitly contains them. */
1891 strip_trailing_directory_separator (argv[0]);
1892 strip_trailing_directory_separator (argv[1]);
1893
1894 /* If a rule with the same "from" was previously defined, then
1895 delete it. This new rule replaces it. */
1896
1897 rule = find_substitute_path_rule (argv[0]);
1898 if (rule != NULL)
1899 delete_substitute_path_rule (rule);
1900
1901 /* Insert the new substitution rule. */
1902
1903 add_substitute_path_rule (argv[0], argv[1]);
c4e86dd4 1904 forget_cached_source_info ();
2f61ca93
JB
1905}
1906
c906108c
SS
1907\f
1908void
fba45db2 1909_initialize_source (void)
c906108c
SS
1910{
1911 struct cmd_list_element *c;
1912 current_source_symtab = 0;
1913 init_source_path ();
1914
1915 /* The intention is to use POSIX Basic Regular Expressions.
1916 Always use the GNU regex routine for consistency across all hosts.
1917 Our current GNU regex.c does not have all the POSIX features, so this is
1918 just an approximation. */
1919 re_set_syntax (RE_SYNTAX_GREP);
1920
1a966eab
AC
1921 c = add_cmd ("directory", class_files, directory_command, _("\
1922Add directory DIR to beginning of search path for source files.\n\
c906108c
SS
1923Forget cached info on source file locations and line positions.\n\
1924DIR can also be $cwd for the current working directory, or $cdir for the\n\
1925directory in which the source file was compiled into object code.\n\
1a966eab 1926With no argument, reset the search path to $cdir:$cwd, the default."),
c906108c
SS
1927 &cmdlist);
1928
1929 if (dbx_commands)
c5aa993b 1930 add_com_alias ("use", "directory", class_files, 0);
c906108c 1931
5ba2abeb 1932 set_cmd_completer (c, filename_completer);
c906108c 1933
1a966eab
AC
1934 add_cmd ("directories", no_class, show_directories, _("\
1935Current search path for finding source files.\n\
c906108c 1936$cwd in the path means the current working directory.\n\
1a966eab 1937$cdir in the path means the compilation directory of the source file."),
c906108c
SS
1938 &showlist);
1939
1940 if (xdb_commands)
1941 {
c5aa993b 1942 add_com_alias ("D", "directory", class_files, 0);
1a966eab
AC
1943 add_cmd ("ld", no_class, show_directories, _("\
1944Current search path for finding source files.\n\
c906108c 1945$cwd in the path means the current working directory.\n\
1a966eab 1946$cdir in the path means the compilation directory of the source file."),
c5aa993b 1947 &cmdlist);
c906108c
SS
1948 }
1949
1950 add_info ("source", source_info,
1bedd215 1951 _("Information about the current source file."));
c906108c 1952
1bedd215
AC
1953 add_info ("line", line_info, _("\
1954Core addresses of the code for a source line.\n\
c906108c
SS
1955Line can be specified as\n\
1956 LINENUM, to list around that line in current file,\n\
1957 FILE:LINENUM, to list around that line in that file,\n\
1958 FUNCTION, to list around beginning of that function,\n\
1959 FILE:FUNCTION, to distinguish among like-named static functions.\n\
c906108c
SS
1960Default is to describe the last source line that was listed.\n\n\
1961This sets the default address for \"x\" to the line's first instruction\n\
1962so that \"x/i\" suffices to start examining the machine code.\n\
1bedd215 1963The address is also stored as the value of \"$_\"."));
c906108c 1964
1bedd215
AC
1965 add_com ("forward-search", class_files, forward_search_command, _("\
1966Search for regular expression (see regex(3)) from last line listed.\n\
1967The matching line number is also stored as the value of \"$_\"."));
c906108c
SS
1968 add_com_alias ("search", "forward-search", class_files, 0);
1969
1bedd215
AC
1970 add_com ("reverse-search", class_files, reverse_search_command, _("\
1971Search backward for regular expression (see regex(3)) from last line listed.\n\
1972The matching line number is also stored as the value of \"$_\"."));
c906108c
SS
1973
1974 if (xdb_commands)
1975 {
c5aa993b
JM
1976 add_com_alias ("/", "forward-search", class_files, 0);
1977 add_com_alias ("?", "reverse-search", class_files, 0);
c906108c
SS
1978 }
1979
bd4109fb 1980 add_setshow_integer_cmd ("listsize", class_support, &lines_to_list, _("\
35096d9d
AC
1981Set number of source lines gdb will list by default."), _("\
1982Show number of source lines gdb will list by default."), NULL,
1983 NULL,
920d2a44 1984 show_lines_to_list,
35096d9d 1985 &setlist, &showlist);
2f61ca93
JB
1986
1987 add_cmd ("substitute-path", class_files, set_substitute_path_command,
1988 _("\
7ef2b397
JB
1989Usage: set substitute-path FROM TO\n\
1990Add a substitution rule replacing FROM into TO in source file names.\n\
1991If a substitution rule was previously set for FROM, the old rule\n\
1992is replaced by the new one."),
1993 &setlist);
2f61ca93
JB
1994
1995 add_cmd ("substitute-path", class_files, unset_substitute_path_command,
1996 _("\
7ef2b397
JB
1997Usage: unset substitute-path [FROM]\n\
1998Delete the rule for substituting FROM in source file names. If FROM\n\
1999is not specified, all substituting rules are deleted.\n\
2000If the debugger cannot find a rule for FROM, it will display a warning."),
2f61ca93
JB
2001 &unsetlist);
2002
2003 add_cmd ("substitute-path", class_files, show_substitute_path_command,
7ef2b397
JB
2004 _("\
2005Usage: show substitute-path [FROM]\n\
2006Print the rule for substituting FROM in source file names. If FROM\n\
2007is not specified, print all substitution rules."),
2f61ca93 2008 &showlist);
c906108c 2009}
This page took 1.389367 seconds and 4 git commands to generate.