198944Sobrien/* List lines of source files for GDB, the GNU debugger. 298944Sobrien Copyright 1999 Free Software Foundation, Inc. 398944Sobrien 498944Sobrien This file is part of GDB. 598944Sobrien 698944Sobrien This program is free software; you can redistribute it and/or modify 798944Sobrien it under the terms of the GNU General Public License as published by 898944Sobrien the Free Software Foundation; either version 2 of the License, or 998944Sobrien (at your option) any later version. 1098944Sobrien 1198944Sobrien This program is distributed in the hope that it will be useful, 1298944Sobrien but WITHOUT ANY WARRANTY; without even the implied warranty of 1398944Sobrien MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1498944Sobrien GNU General Public License for more details. 1598944Sobrien 1698944Sobrien You should have received a copy of the GNU General Public License 1798944Sobrien along with this program; if not, write to the Free Software 1898944Sobrien Foundation, Inc., 59 Temple Place - Suite 330, 1998944Sobrien Boston, MA 02111-1307, USA. */ 2098944Sobrien 2198944Sobrien#ifndef SOURCE_H 2298944Sobrien#define SOURCE_H 2398944Sobrien 24130803Smarcelstruct symtab; 25130803Smarcel 2698944Sobrien/* Open a source file given a symtab S. Returns a file descriptor or 2798944Sobrien negative number for error. */ 2898944Sobrienextern int open_source_file (struct symtab *s); 2998944Sobrien 3098944Sobrien/* Create and initialize the table S->line_charpos that records the 3198944Sobrien positions of the lines in the source file, which is assumed to be 3298944Sobrien open on descriptor DESC. All set S->nlines to the number of such 3398944Sobrien lines. */ 3498944Sobrienextern void find_source_lines (struct symtab *s, int desc); 3598944Sobrien 36130803Smarcel/* Return the first line listed by print_source_lines. 37130803Smarcel Used by command interpreters to request listing from 38130803Smarcel a previous point. */ 39130803Smarcelextern int get_first_line_listed (void); 40130803Smarcel 41130803Smarcel/* Return the default number of lines to print with commands like the 42130803Smarcel cli "list". The caller of print_source_lines must use this to 43130803Smarcel calculate the end line and use it in the call to print_source_lines 44130803Smarcel as it does not automatically use this value. */ 45130803Smarcelextern int get_lines_to_list (void); 46130803Smarcel 47130803Smarcel/* Return the current source file for listing and next line to list. 48130803Smarcel NOTE: The returned sal pc and end fields are not valid. */ 49130803Smarcelextern struct symtab_and_line get_current_source_symtab_and_line (void); 50130803Smarcel 51130803Smarcel/* If the current source file for listing is not set, try and get a default. 52130803Smarcel Usually called before get_current_source_symtab_and_line() is called. 53130803Smarcel It may err out if a default cannot be determined. 54130803Smarcel We must be cautious about where it is called, as it can recurse as the 55130803Smarcel process of determining a new default may call the caller! 56130803Smarcel Use get_current_source_symtab_and_line only to get whatever 57130803Smarcel we have without erroring out or trying to get a default. */ 58130803Smarcelextern void set_default_source_symtab_and_line (void); 59130803Smarcel 60130803Smarcel/* Return the current default file for listing and next line to list 61130803Smarcel (the returned sal pc and end fields are not valid.) 62130803Smarcel and set the current default to whatever is in SAL. 63130803Smarcel NOTE: The returned sal pc and end fields are not valid. */ 64130803Smarcelextern struct symtab_and_line set_current_source_symtab_and_line (const struct symtab_and_line *); 65130803Smarcel 66130803Smarcel/* Reset any information stored about a default file and line to print. */ 67130803Smarcelextern void clear_current_source_symtab_and_line (void); 6898944Sobrien#endif 69