1 /* List lines of source files for GDB, the GNU debugger.
2 Copyright (C) 1986, 1987, 1988, 1989, 1991 Free Software Foundation, Inc.
4 This file is part of GDB.
6 GDB is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 1, or (at your option)
11 GDB is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GDB; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
28 #include <sys/types.h>
32 #include <sys/param.h>
37 extern char *strstr();
39 extern void set_next_address ();
43 /* Path of directories to search for source files.
44 Same format as the PATH environment variable's value. */
48 /* Symtab of default file for listing lines of. */
50 struct symtab
*current_source_symtab
;
52 /* Default next line to list. */
54 int current_source_line
;
56 /* Line number of last line printed. Default for various commands.
57 current_source_line is usually, but not always, the same as this. */
59 static int last_line_listed
;
61 /* First line number listed by last listing command. */
63 static int first_line_listed
;
66 /* Set the source file default for the "list" command, specifying a
67 symtab. Sigh. Behavior specification: If it is called with a
68 non-zero argument, that is the symtab to select. If it is not,
69 first lookup "main"; if it exists, use the symtab and line it
70 defines. If not, take the last symtab in the symtab_list (if it
71 exists) or the last symtab in the psymtab_list (if *it* exists). If
72 none of this works, report an error. */
75 select_source_symtab (s
)
76 register struct symtab
*s
;
78 struct symtabs_and_lines sals
;
79 struct symtab_and_line sal
;
80 struct partial_symtab
*ps
;
81 struct partial_symtab
*cs_pst
= 0;
85 current_source_symtab
= s
;
86 current_source_line
= 1;
90 /* Make the default place to list be the function `main'
92 if (lookup_symbol ("main", 0, VAR_NAMESPACE
, 0, NULL
))
94 sals
= decode_line_spec ("main", 1);
97 current_source_symtab
= sal
.symtab
;
98 current_source_line
= max (sal
.line
- (lines_to_list () - 1), 1);
102 /* All right; find the last file in the symtab list (ignoring .h's). */
108 char *name
= s
->filename
;
109 int len
= strlen (name
);
110 if (! (len
> 2 && !strcmp (&name
[len
- 2], ".h")))
111 current_source_symtab
= s
;
115 current_source_line
= 1;
117 else if (partial_symtab_list
)
119 ps
= partial_symtab_list
;
122 char *name
= ps
->filename
;
123 int len
= strlen (name
);
124 if (! (len
> 2 && !strcmp (&name
[len
- 2], ".h")))
130 fatal ("Internal: select_source_symtab: readin pst found and no symtabs.");
132 current_source_symtab
= PSYMTAB_TO_SYMTAB (cs_pst
);
134 current_source_symtab
= 0;
135 current_source_line
= 1;
142 printf ("Source directories searched: %s\n", source_path
);
145 /* Forget what we learned about line positions in source files,
146 and which directories contain them;
147 must check again now since files may be found in
148 a different directory now. */
151 forget_cached_source_info ()
153 register struct symtab
*s
;
155 for (s
= symtab_list
; s
; s
= s
->next
)
157 if (s
->line_charpos
!= 0)
159 free (s
->line_charpos
);
162 if (s
->fullname
!= 0)
173 source_path
= savestring ("$cdir:$cwd", /* strlen of it */ 10);
174 forget_cached_source_info ();
177 /* Add zero or more directories to the front of the source path. */
180 directory_command (dirname
, from_tty
)
185 /* FIXME, this goes to "delete dir"... */
188 if (query ("Reinitialize source path to empty? ", ""))
195 mod_path (dirname
, from_tty
, &source_path
);
198 forget_cached_source_info ();
201 /* Add zero or more directories to the front of an arbitrary path. */
204 mod_path (dirname
, from_tty
, which_path
)
209 char *old
= *which_path
;
215 dirname
= strsave (dirname
);
216 make_cleanup (free
, dirname
);
220 extern char *index ();
221 char *name
= dirname
;
226 char *colon
= index (name
, ':');
227 char *space
= index (name
, ' ');
228 char *tab
= index (name
, '\t');
229 if (colon
== 0 && space
== 0 && tab
== 0)
230 p
= dirname
= name
+ strlen (name
);
234 if (colon
!= 0 && (p
== 0 || colon
< p
))
236 if (space
!= 0 && (p
== 0 || space
< p
))
238 if (tab
!= 0 && (p
== 0 || tab
< p
))
241 while (*dirname
== ':' || *dirname
== ' ' || *dirname
== '\t')
247 /* Sigh. "foo/" => "foo" */
255 /* "." => getwd (). */
256 name
= current_directory
;
259 else if (p
[-2] == '/')
269 /* "...foo/." => "...foo". */
280 name
= tilde_expand (name
);
281 else if (name
[0] != '/' && name
[0] != '$')
282 name
= concat (current_directory
, "/", name
);
284 name
= savestring (name
, p
- name
);
285 make_cleanup (free
, name
);
287 /* Unless it's a variable, check existence. */
288 if (name
[0] != '$') {
289 if (stat (name
, &st
) < 0)
290 perror_with_name (name
);
291 if ((st
.st_mode
& S_IFMT
) != S_IFDIR
)
292 error ("%s is not a directory.", name
);
297 register unsigned int len
= strlen (name
);
302 if (!strncmp (p
, name
, len
)
303 && (p
[len
] == '\0' || p
[len
] == ':'))
305 /* Found it in the search path, remove old copy */
307 p
--; /* Back over leading colon */
308 if (prefix
> p
- *which_path
)
309 goto skip_dup
; /* Same dir twice in one cmd */
310 strcpy (p
, &p
[len
+1]); /* Copy from next \0 or : */
320 /* If we have already tacked on a name(s) in this command, be sure they stay on the front as we tack on some more. */
327 temp
= concat (old
, ":", name
);
329 *which_path
= concat (temp
, "", &old
[prefix
]);
330 prefix
= strlen (temp
);
335 *which_path
= concat (name
, (old
[0]? ":" : old
), old
);
336 prefix
= strlen (name
);
343 } while (*dirname
!= '\0');
350 register struct symtab
*s
= current_source_symtab
;
354 printf("No current source file.\n");
357 printf ("Current source file is %s\n", s
->filename
);
359 printf ("Compilation directory is %s\n", s
->dirname
);
361 printf ("Located in %s\n", s
->fullname
);
363 printf ("Contains %d lines\n", s
->nlines
);
365 switch (s
->language
) {
367 printf("Written in the C language.\n");
368 /* Add more cases here when -Wswitch complains... */
369 case language_unknown
:
376 /* Open a file named STRING, searching path PATH (dir names sep by colons)
377 using mode MODE and protection bits PROT in the calls to open.
378 If TRY_CWD_FIRST, try to open ./STRING before searching PATH.
379 (ie pretend the first element of PATH is ".")
380 If FILENAMED_OPENED is non-null, set it to a newly allocated string naming
381 the actual file opened (this string will always start with a "/". We
382 have to take special pains to avoid doubling the "/" between the directory
383 and the file, sigh! Emacs gets confuzzed by this when we print the
386 If a file is found, return the descriptor.
387 Otherwise, return -1, with errno set for the last name we tried to open. */
389 /* >>>> This should only allow files of certain types,
390 >>>> eg executable, non-directory */
392 openp (path
, try_cwd_first
, string
, mode
, prot
, filename_opened
)
398 char **filename_opened
;
401 register char *filename
;
402 register char *p
, *p1
;
410 while (string
[0] == '.' && string
[1] == '/')
413 if (try_cwd_first
|| string
[0] == '/')
416 fd
= open (filename
, mode
, prot
);
417 if (fd
>= 0 || string
[0] == '/')
421 alloclen
= strlen (path
) + strlen (string
) + 2;
422 filename
= (char *) alloca (alloclen
);
424 for (p
= path
; p
; p
= p1
? p1
+ 1 : 0)
426 p1
= (char *) index (p
, ':');
432 if (len
== 4 && p
[0] == '$' && p
[1] == 'c'
433 && p
[2] == 'w' && p
[3] == 'd') {
434 /* Name is $cwd -- insert current directory name instead. */
437 /* First, realloc the filename buffer if too short. */
438 len
= strlen (current_directory
);
439 newlen
= len
+ strlen (string
) + 2;
440 if (newlen
> alloclen
) {
442 filename
= (char *) alloca (alloclen
);
444 strcpy (filename
, current_directory
);
446 /* Normal file name in path -- just use it. */
447 strncpy (filename
, p
, len
);
451 /* Beware the // my son, the Emacs barfs, the botch that catch... */
452 while (len
> 1 && filename
[len
-1] == '/')
454 strcat (filename
+len
, "/");
455 strcat (filename
, string
);
457 fd
= open (filename
, mode
, prot
);
464 *filename_opened
= (char *) 0;
465 else if (filename
[0] == '/')
466 *filename_opened
= savestring (filename
, strlen (filename
));
469 /* Beware the // my son, the Emacs barfs, the botch that catch... */
471 *filename_opened
= concat (current_directory
,
472 '/' == current_directory
[strlen(current_directory
)-1]? "": "/",
479 /* Open a source file given a symtab S. Returns a file descriptor
480 or negative number for error. */
485 char *path
= source_path
;
489 /* Quick way out if we already know its full name */
492 result
= open (s
->fullname
, O_RDONLY
);
495 /* Didn't work -- free old one, try again. */
500 if (s
->dirname
!= NULL
)
502 /* Replace a path entry of $cdir with the compilation directory name */
504 p
= strstr (source_path
, "$cdir");
505 if (p
&& (p
== path
|| p
[-1] == ':')
506 && (p
[cdir_len
] == ':' || p
[cdir_len
] == '\0')) {
510 alloca (strlen (source_path
) + 1 + strlen (s
->dirname
) + 1);
511 len
= p
- source_path
;
512 strncpy (path
, source_path
, len
); /* Before $cdir */
513 strcpy (path
+ len
, s
->dirname
); /* new stuff */
514 strcat (path
+ len
, source_path
+ len
+ cdir_len
); /* After $cdir */
518 return openp (path
, 0, s
->filename
, O_RDONLY
, 0, &s
->fullname
);
522 /* Create and initialize the table S->line_charpos that records
523 the positions of the lines in the source file, which is assumed
524 to be open on descriptor DESC.
525 All set S->nlines to the number of such lines. */
528 find_source_lines (s
, desc
)
533 register char *data
, *p
, *end
;
535 int lines_allocated
= 1000;
536 int *line_charpos
= (int *) xmalloc (lines_allocated
* sizeof (int));
538 if (fstat (desc
, &st
) < 0)
539 perror_with_name (s
->filename
);
540 if (exec_bfd
&& bfd_get_mtime(exec_bfd
) < st
.st_mtime
)
541 printf ("Source file is more recent than executable.\n");
543 #if defined (BROKEN_LARGE_ALLOCA)
544 data
= (char *) xmalloc (st
.st_size
);
545 make_cleanup (free
, data
);
547 data
= (char *) alloca (st
.st_size
);
549 if (myread (desc
, data
, st
.st_size
) < 0)
550 perror_with_name (s
->filename
);
551 end
= data
+ st
.st_size
;
558 /* A newline at the end does not start a new line. */
561 if (nlines
== lines_allocated
)
563 lines_allocated
*= 2;
564 line_charpos
= (int *) xrealloc (line_charpos
,
565 sizeof (int) * lines_allocated
);
567 line_charpos
[nlines
++] = p
- data
;
571 s
->line_charpos
= (int *) xrealloc (line_charpos
, nlines
* sizeof (int));
574 /* Return the character position of a line LINE in symtab S.
575 Return 0 if anything is invalid. */
578 source_line_charpos (s
, line
)
583 if (!s
->line_charpos
|| line
<= 0) return 0;
584 if (line
> s
->nlines
)
586 return s
->line_charpos
[line
- 1];
589 /* Return the line number of character position POS in symtab S. */
592 source_charpos_line (s
, chr
)
593 register struct symtab
*s
;
596 register int line
= 0;
599 if (s
== 0 || s
->line_charpos
== 0) return 0;
600 lnp
= s
->line_charpos
;
601 /* Files are usually short, so sequential search is Ok */
602 while (line
< s
->nlines
&& *lnp
<= chr
)
607 if (line
>= s
->nlines
)
612 /* Get full pathname and line number positions for a symtab.
613 Return nonzero if line numbers may have changed.
614 Set *FULLNAME to actual name of the file as found by `openp',
615 or to 0 if the file is not found. */
618 get_filename_and_charpos (s
, fullname
)
622 register int desc
, linenums_changed
= 0;
624 desc
= open_source_file (s
);
632 *fullname
= s
->fullname
;
633 if (s
->line_charpos
== 0) linenums_changed
= 1;
634 if (linenums_changed
) find_source_lines (s
, desc
);
636 return linenums_changed
;
639 /* Print text describing the full name of the source file S
640 and the line number LINE and its corresponding character position.
641 The text starts with two Ctrl-z so that the Emacs-GDB interface
644 MID_STATEMENT is nonzero if the PC is not at the beginning of that line.
646 Return 1 if successful, 0 if could not find the file. */
649 identify_source_line (s
, line
, mid_statement
)
654 if (s
->line_charpos
== 0)
655 get_filename_and_charpos (s
, (char **)NULL
);
656 if (s
->fullname
== 0)
658 printf ("\032\032%s:%d:%d:%s:0x%x\n", s
->fullname
,
659 line
, s
->line_charpos
[line
- 1],
660 mid_statement
? "middle" : "beg",
661 get_frame_pc (get_current_frame()));
662 current_source_line
= line
;
663 first_line_listed
= line
;
664 last_line_listed
= line
;
665 current_source_symtab
= s
;
669 /* Print source lines from the file of symtab S,
670 starting with line number LINE and stopping before line number STOPLINE. */
673 print_source_lines (s
, line
, stopline
, noerror
)
680 register FILE *stream
;
681 int nlines
= stopline
- line
;
683 /* Regardless of whether we can open the file, set current_source_symtab. */
684 current_source_symtab
= s
;
685 current_source_line
= line
;
686 first_line_listed
= line
;
688 desc
= open_source_file (s
);
692 char *name
= alloca (strlen (s
->filename
) + 100);
693 sprintf (name
, "%s:%d", s
->filename
, line
);
694 print_sys_errmsg (name
, errno
);
699 if (s
->line_charpos
== 0)
700 find_source_lines (s
, desc
);
702 if (line
< 1 || line
> s
->nlines
)
705 error ("Line number %d out of range; %s has %d lines.",
706 line
, s
->filename
, s
->nlines
);
709 if (lseek (desc
, s
->line_charpos
[line
- 1], 0) < 0)
712 perror_with_name (s
->filename
);
715 stream
= fdopen (desc
, "r");
722 last_line_listed
= current_source_line
;
723 printf_filtered ("%d\t", current_source_line
++);
726 if (c
< 040 && c
!= '\t' && c
!= '\n')
727 printf_filtered ("^%c", c
+ 0100);
729 printf_filtered ("^?");
731 printf_filtered ("%c", c
);
732 } while (c
!= '\n' && (c
= fgetc (stream
)) >= 0);
742 Print a list of files and line numbers which a user may choose from
743 in order to list a function which was specified ambiguously
744 (as with `list classname::overloadedfuncname', for example).
745 The vector in SALS provides the filenames and line numbers.
748 ambiguous_line_spec (sals
)
749 struct symtabs_and_lines
*sals
;
753 for (i
= 0; i
< sals
->nelts
; ++i
)
754 printf("file: \"%s\", line number: %d\n",
755 sals
->sals
[i
].symtab
->filename
, sals
->sals
[i
].line
);
760 list_command (arg
, from_tty
)
764 struct symtabs_and_lines sals
, sals_end
;
765 struct symtab_and_line sal
, sal_end
;
774 if (symtab_list
== 0 && partial_symtab_list
== 0)
775 error ("No symbol table is loaded. Use the \"symbol-file\" command.");
777 /* Pull in a current source symtab if necessary */
778 if (current_source_symtab
== 0 &&
779 (arg
== 0 || arg
[0] == '+' || arg
[0] == '-'))
780 select_source_symtab (0);
782 /* "l" or "l +" lists next ten lines. */
784 if (arg
== 0 || !strcmp (arg
, "+"))
786 if (current_source_symtab
== 0)
787 error ("No default source file yet. Do \"help list\".");
788 print_source_lines (current_source_symtab
, current_source_line
,
789 current_source_line
+ lines_to_list (), 0);
793 /* "l -" lists previous ten lines, the ones before the ten just listed. */
794 if (!strcmp (arg
, "-"))
796 if (current_source_symtab
== 0)
797 error ("No default source file yet. Do \"help list\".");
798 print_source_lines (current_source_symtab
,
799 max (first_line_listed
- lines_to_list (), 1),
800 first_line_listed
, 0);
804 /* Now if there is only one argument, decode it in SAL
806 If there are two arguments, decode them in SAL and SAL_END
807 and clear NO_END; however, if one of the arguments is blank,
808 set DUMMY_BEG or DUMMY_END to record that fact. */
815 sals
= decode_line_1 (&arg1
, 0, 0, 0);
817 if (! sals
.nelts
) return; /* C++ */
820 ambiguous_line_spec (&sals
);
829 /* Record whether the BEG arg is all digits. */
831 for (p
= arg
; p
!= arg1
&& *p
>= '0' && *p
<= '9'; p
++);
832 linenum_beg
= (p
== arg1
);
834 while (*arg1
== ' ' || *arg1
== '\t')
840 while (*arg1
== ' ' || *arg1
== '\t')
847 sals_end
= decode_line_1 (&arg1
, 0, 0, 0);
849 sals_end
= decode_line_1 (&arg1
, 0, sal
.symtab
, sal
.line
);
850 if (sals_end
.nelts
== 0)
852 if (sals_end
.nelts
> 1)
854 ambiguous_line_spec (&sals_end
);
855 free (sals_end
.sals
);
858 sal_end
= sals_end
.sals
[0];
859 free (sals_end
.sals
);
864 error ("Junk at end of line specification.");
866 if (!no_end
&& !dummy_beg
&& !dummy_end
867 && sal
.symtab
!= sal_end
.symtab
)
868 error ("Specified start and end are in different files.");
869 if (dummy_beg
&& dummy_end
)
870 error ("Two empty args do not say what lines to list.");
872 /* if line was specified by address,
873 first print exactly which line, and which file.
874 In this case, sal.symtab == 0 means address is outside
875 of all known source files, not that user failed to give a filename. */
879 error ("No source file for address 0x%x.", sal
.pc
);
880 sym
= find_pc_function (sal
.pc
);
882 printf ("0x%x is in %s (%s, line %d).\n",
883 sal
.pc
, SYMBOL_NAME (sym
), sal
.symtab
->filename
, sal
.line
);
885 printf ("0x%x is in %s, line %d.\n",
886 sal
.pc
, sal
.symtab
->filename
, sal
.line
);
889 /* If line was not specified by just a line number,
890 and it does not imply a symtab, it must be an undebuggable symbol
891 which means no source code. */
893 if (! linenum_beg
&& sal
.symtab
== 0)
894 error ("No line number known for %s.", arg
);
896 /* If this command is repeated with RET,
897 turn it into the no-arg variant. */
902 if (dummy_beg
&& sal_end
.symtab
== 0)
903 error ("No default source file yet. Do \"help list\".");
905 print_source_lines (sal_end
.symtab
,
906 max (sal_end
.line
- (lines_to_list () - 1), 1),
907 sal_end
.line
+ 1, 0);
908 else if (sal
.symtab
== 0)
909 error ("No default source file yet. Do \"help list\".");
911 print_source_lines (sal
.symtab
,
912 max (sal
.line
- (lines_to_list () / 2), 1),
915 print_source_lines (sal
.symtab
, sal
.line
,
917 ? sal
.line
+ lines_to_list ()
922 /* Print info on range of pc's in a specified line. */
925 line_info (arg
, from_tty
)
929 struct symtabs_and_lines sals
;
930 struct symtab_and_line sal
;
931 CORE_ADDR start_pc
, end_pc
;
936 sal
.symtab
= current_source_symtab
;
937 sal
.line
= last_line_listed
;
939 sals
.sals
= (struct symtab_and_line
*)
940 xmalloc (sizeof (struct symtab_and_line
));
945 sals
= decode_line_spec_1 (arg
, 0);
947 /* If this command is repeated with RET,
948 turn it into the no-arg variant. */
953 /* C++ More than one line may have been specified, as when the user
954 specifies an overloaded function name. Print info on them all. */
955 for (i
= 0; i
< sals
.nelts
; i
++)
960 error ("No source file specified.");
963 && find_line_pc_range (sal
.symtab
, sal
.line
, &start_pc
, &end_pc
))
965 if (start_pc
== end_pc
)
966 printf ("Line %d of \"%s\" is at pc 0x%x but contains no code.\n",
967 sal
.line
, sal
.symtab
->filename
, start_pc
);
969 printf ("Line %d of \"%s\" starts at pc 0x%x and ends at 0x%x.\n",
970 sal
.line
, sal
.symtab
->filename
, start_pc
, end_pc
);
971 /* x/i should display this line's code. */
972 set_next_address (start_pc
);
973 /* Repeating "info line" should do the following line. */
974 last_line_listed
= sal
.line
+ 1;
977 printf ("Line number %d is out of range for \"%s\".\n",
978 sal
.line
, sal
.symtab
->filename
);
982 /* Commands to search the source file for a regexp. */
985 forward_search_command (regex
, from_tty
)
991 register FILE *stream
;
992 int line
= last_line_listed
+ 1;
995 msg
= (char *) re_comp (regex
);
999 if (current_source_symtab
== 0)
1000 select_source_symtab (0);
1002 /* Search from last_line_listed+1 in current_source_symtab */
1004 desc
= open_source_file (current_source_symtab
);
1006 perror_with_name (current_source_symtab
->filename
);
1008 if (current_source_symtab
->line_charpos
== 0)
1009 find_source_lines (current_source_symtab
, desc
);
1011 if (line
< 1 || line
> current_source_symtab
->nlines
)
1014 error ("Expression not found");
1017 if (lseek (desc
, current_source_symtab
->line_charpos
[line
- 1], 0) < 0)
1020 perror_with_name (current_source_symtab
->filename
);
1023 stream
= fdopen (desc
, "r");
1026 char buf
[4096]; /* Should be reasonable??? */
1027 register char *p
= buf
;
1034 } while (c
!= '\n' && (c
= fgetc (stream
)) >= 0);
1036 /* we now have a source line in buf, null terminate and match */
1038 if (re_exec (buf
) > 0)
1042 print_source_lines (current_source_symtab
,
1044 current_source_line
= max (line
- lines_to_list () / 2, 1);
1050 printf ("Expression not found\n");
1055 reverse_search_command (regex
, from_tty
)
1061 register FILE *stream
;
1062 int line
= last_line_listed
- 1;
1065 msg
= (char *) re_comp (regex
);
1069 if (current_source_symtab
== 0)
1070 select_source_symtab (0);
1072 /* Search from last_line_listed-1 in current_source_symtab */
1074 desc
= open_source_file (current_source_symtab
);
1076 perror_with_name (current_source_symtab
->filename
);
1078 if (current_source_symtab
->line_charpos
== 0)
1079 find_source_lines (current_source_symtab
, desc
);
1081 if (line
< 1 || line
> current_source_symtab
->nlines
)
1084 error ("Expression not found");
1087 if (lseek (desc
, current_source_symtab
->line_charpos
[line
- 1], 0) < 0)
1090 perror_with_name (current_source_symtab
->filename
);
1093 stream
= fdopen (desc
, "r");
1097 char buf
[4096]; /* Should be reasonable??? */
1098 register char *p
= buf
;
1105 } while (c
!= '\n' && (c
= fgetc (stream
)) >= 0);
1107 /* We now have a source line in buf; null terminate and match. */
1109 if (re_exec (buf
) > 0)
1113 print_source_lines (current_source_symtab
,
1115 current_source_line
= max (line
- lines_to_list () / 2, 1);
1119 if (fseek (stream
, current_source_symtab
->line_charpos
[line
- 1], 0) < 0)
1122 perror_with_name (current_source_symtab
->filename
);
1126 printf ("Expression not found\n");
1132 _initialize_source ()
1134 current_source_symtab
= 0;
1135 init_source_path ();
1137 add_com ("directory", class_files
, directory_command
,
1138 "Add directory DIR to beginning of search path for source files.\n\
1139 Forget cached info on source file locations and line positions.\n\
1140 DIR can also be $cwd for the current working directory, or $cdir for the\n\
1141 directory in which the source file was compiled into object code.\n\
1142 With no argument, reset the search path to $cdir:$cwd, the default.");
1144 add_info ("directories", directories_info
,
1145 "Current search path for finding source files.\n\
1146 $cwd in the path means the current working directory.\n\
1147 $cdir in the path means the compilation directory of the source file.");
1149 add_info ("source", source_info
,
1150 "Information about the current source file.");
1152 add_info ("line", line_info
,
1153 "Core addresses of the code for a source line.\n\
1154 Line can be specified as\n\
1155 LINENUM, to list around that line in current file,\n\
1156 FILE:LINENUM, to list around that line in that file,\n\
1157 FUNCTION, to list around beginning of that function,\n\
1158 FILE:FUNCTION, to distinguish among like-named static functions.\n\
1159 Default is to describe the last source line that was listed.\n\n\
1160 This sets the default address for \"x\" to the line's first instruction\n\
1161 so that \"x/i\" suffices to start examining the machine code.\n\
1162 The address is also stored as the value of \"$_\".");
1164 add_com ("forward-search", class_files
, forward_search_command
,
1165 "Search for regular expression (see regex(3)) from last line listed.");
1166 add_com_alias ("search", "forward-search", class_files
, 0);
1168 add_com ("reverse-search", class_files
, reverse_search_command
,
1169 "Search backward for regular expression (see regex(3)) from last line listed.");
1171 add_com ("list", class_files
, list_command
,
1172 "List specified function or line.\n\
1173 With no argument, lists ten more lines after or around previous listing.\n\
1174 \"list -\" lists the ten lines before a previous ten-line listing.\n\
1175 One argument specifies a line, and ten lines are listed around that line.\n\
1176 Two arguments with comma between specify starting and ending lines to list.\n\
1177 Lines can be specified in these ways:\n\
1178 LINENUM, to list around that line in current file,\n\
1179 FILE:LINENUM, to list around that line in that file,\n\
1180 FUNCTION, to list around beginning of that function,\n\
1181 FILE:FUNCTION, to distinguish among like-named static functions.\n\
1182 *ADDRESS, to list around the line containing that address.\n\
1183 With two args if one is empty it stands for ten lines away from the other arg.");
1184 add_com_alias ("l", "list", class_files
, 0);