xref: /dflybsd-src/contrib/gdb-7/gdb/source.h (revision de8e141f24382815c10a4012d209bbbf7abf1112)
15796c8dcSSimon Schubert /* List lines of source files for GDB, the GNU debugger.
2*ef5ccd6cSJohn Marino    Copyright (C) 1999-2013 Free Software Foundation, Inc.
35796c8dcSSimon Schubert 
45796c8dcSSimon Schubert    This file is part of GDB.
55796c8dcSSimon Schubert 
65796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
75796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
85796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
95796c8dcSSimon Schubert    (at your option) any later version.
105796c8dcSSimon Schubert 
115796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
125796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
135796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
145796c8dcSSimon Schubert    GNU General Public License for more details.
155796c8dcSSimon Schubert 
165796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
175796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
185796c8dcSSimon Schubert 
195796c8dcSSimon Schubert #ifndef SOURCE_H
205796c8dcSSimon Schubert #define SOURCE_H
215796c8dcSSimon Schubert 
225796c8dcSSimon Schubert struct symtab;
235796c8dcSSimon Schubert 
24*ef5ccd6cSJohn Marino /* This function is capable of finding the absolute path to a
25*ef5ccd6cSJohn Marino    source file, and opening it, provided you give it a FILENAME.  Both the
26*ef5ccd6cSJohn Marino    DIRNAME and FULLNAME are only added suggestions on where to find the file.
27*ef5ccd6cSJohn Marino 
28*ef5ccd6cSJohn Marino    FILENAME should be the filename to open.
29*ef5ccd6cSJohn Marino    DIRNAME is the compilation directory of a particular source file.
30*ef5ccd6cSJohn Marino 	   Only some debug formats provide this info.
31*ef5ccd6cSJohn Marino    FULLNAME can be the last known absolute path to the file in question.
32*ef5ccd6cSJohn Marino      Space for the path must have been malloc'd.  If a path substitution
33*ef5ccd6cSJohn Marino      is applied we free the old value and set a new one.
34*ef5ccd6cSJohn Marino 
35*ef5ccd6cSJohn Marino    On Success
36*ef5ccd6cSJohn Marino      A valid file descriptor is returned (the return value is positive).
37*ef5ccd6cSJohn Marino      FULLNAME is set to the absolute path to the file just opened.
38*ef5ccd6cSJohn Marino      The caller is responsible for freeing FULLNAME.
39*ef5ccd6cSJohn Marino 
40*ef5ccd6cSJohn Marino    On Failure
41*ef5ccd6cSJohn Marino      An invalid file descriptor is returned (the return value is negative).
42*ef5ccd6cSJohn Marino      FULLNAME is set to NULL.  */
43*ef5ccd6cSJohn Marino extern int find_and_open_source (const char *filename,
44*ef5ccd6cSJohn Marino 				 const char *dirname,
45*ef5ccd6cSJohn Marino 				 char **fullname);
46*ef5ccd6cSJohn Marino 
475796c8dcSSimon Schubert /* Open a source file given a symtab S.  Returns a file descriptor or
485796c8dcSSimon Schubert    negative number for error.  */
495796c8dcSSimon Schubert extern int open_source_file (struct symtab *s);
505796c8dcSSimon Schubert 
51*ef5ccd6cSJohn Marino extern char *rewrite_source_path (const char *path);
52*ef5ccd6cSJohn Marino 
53*ef5ccd6cSJohn Marino extern const char *symtab_to_fullname (struct symtab *s);
54*ef5ccd6cSJohn Marino 
55*ef5ccd6cSJohn Marino /* Returns filename without the compile directory part, basename or absolute
56*ef5ccd6cSJohn Marino    filename.  It depends on 'set filename-display' value.  */
57*ef5ccd6cSJohn Marino extern const char *symtab_to_filename_for_display (struct symtab *symtab);
585796c8dcSSimon Schubert 
595796c8dcSSimon Schubert /* Create and initialize the table S->line_charpos that records the
605796c8dcSSimon Schubert    positions of the lines in the source file, which is assumed to be
615796c8dcSSimon Schubert    open on descriptor DESC.  All set S->nlines to the number of such
625796c8dcSSimon Schubert    lines.  */
635796c8dcSSimon Schubert extern void find_source_lines (struct symtab *s, int desc);
645796c8dcSSimon Schubert 
655796c8dcSSimon Schubert /* Return the first line listed by print_source_lines.
665796c8dcSSimon Schubert    Used by command interpreters to request listing from
675796c8dcSSimon Schubert    a previous point.  */
685796c8dcSSimon Schubert extern int get_first_line_listed (void);
695796c8dcSSimon Schubert 
705796c8dcSSimon Schubert /* Return the default number of lines to print with commands like the
715796c8dcSSimon Schubert    cli "list".  The caller of print_source_lines must use this to
725796c8dcSSimon Schubert    calculate the end line and use it in the call to print_source_lines
735796c8dcSSimon Schubert    as it does not automatically use this value.  */
745796c8dcSSimon Schubert extern int get_lines_to_list (void);
755796c8dcSSimon Schubert 
765796c8dcSSimon Schubert /* Return the current source file for listing and next line to list.
775796c8dcSSimon Schubert    NOTE: The returned sal pc and end fields are not valid.  */
785796c8dcSSimon Schubert extern struct symtab_and_line get_current_source_symtab_and_line (void);
795796c8dcSSimon Schubert 
805796c8dcSSimon Schubert /* If the current source file for listing is not set, try and get a default.
815796c8dcSSimon Schubert    Usually called before get_current_source_symtab_and_line() is called.
825796c8dcSSimon Schubert    It may err out if a default cannot be determined.
835796c8dcSSimon Schubert    We must be cautious about where it is called, as it can recurse as the
845796c8dcSSimon Schubert    process of determining a new default may call the caller!
855796c8dcSSimon Schubert    Use get_current_source_symtab_and_line only to get whatever
865796c8dcSSimon Schubert    we have without erroring out or trying to get a default.  */
875796c8dcSSimon Schubert extern void set_default_source_symtab_and_line (void);
885796c8dcSSimon Schubert 
895796c8dcSSimon Schubert /* Return the current default file for listing and next line to list
905796c8dcSSimon Schubert    (the returned sal pc and end fields are not valid.)
915796c8dcSSimon Schubert    and set the current default to whatever is in SAL.
925796c8dcSSimon Schubert    NOTE: The returned sal pc and end fields are not valid.  */
935796c8dcSSimon Schubert extern struct symtab_and_line set_current_source_symtab_and_line (const struct symtab_and_line *);
945796c8dcSSimon Schubert 
955796c8dcSSimon Schubert /* Reset any information stored about a default file and line to print.  */
965796c8dcSSimon Schubert extern void clear_current_source_symtab_and_line (void);
975796c8dcSSimon Schubert 
985796c8dcSSimon Schubert /* Add a source path substitution rule.  */
995796c8dcSSimon Schubert extern void add_substitute_path_rule (char *, char *);
1005796c8dcSSimon Schubert #endif
101