* source.c: Make global variables current_source_symtab and

current_source_line static.
        (list_command): Moved to cli/cli-cmds.c.
        (ambiguous_line_spec): Moved to cli/cli-cmds.c.
        (get_first_line_listed): New accessor function.
        (get_lines_to_list): New accessor function.
        (get_current_source_symtab_and_line): New function. Retrieves the
        position in the source code that we consider current.
        (get_current_or_default_source_symtab_and_line): New function.
        Like the above but attempts to determine a default position if one
        is not currently defined.
        (set_current_source_symtab_and_line): New function. Sets the source
        code position considered current and returns the previously set one.
        (clear_current_source_symtab_and_line): Reset stored information about
        a current source line.
        (_initialize_source): Remove registration for the "list" command and
        its alias.
        * source.h: Add declarations for the new functions above.
        * symtab.h: Remove declarations for the global variables mentioned
        above.
        * breakpoint.c (parse_breakpoint_sals): Use accessor functions to
        obtain current source line.
        * linespec.c (decode_line_1): Ditto.
        * macroscope.c (default_macro_scope): Ditto.
        * scm-lang.c (scm_unpac): Ditto.
        * stack.c (print_frame_info_base): Ditto.
        * symfile.c (clear_symtab_users): Ditto.
        * symtab.c (decode_line_spec): Ditto.
        * cli/cli-cmds.c (list_command): Moved here from source.c.
        (ambiguous_line_spec): Moved here from source.c.
        (_init_cli_cmds): Add definition for "list" and its alias.
        * Makefile.in: Update dependencies.
This commit is contained in:
Fernando Nasser
2002-09-20 14:58:59 +00:00
parent 7cf108933b
commit 0378c33231
13 changed files with 561 additions and 243 deletions

View File

@@ -33,6 +33,7 @@
#include "gdbcmd.h"
#include "gdbcore.h"
#include "target.h"
#include "source.h"
#include "breakpoint.h"
#include "demangle.h"
#include "inferior.h"
@@ -108,7 +109,6 @@ struct frame_info *parse_frame_specification (char *);
static void frame_info (char *, int);
extern int addressprint; /* Print addresses, or stay symbolic only? */
extern int lines_to_list; /* # of lines "list" command shows by default */
/* The "selected" stack frame is used by default for local and arg access.
May be zero, for no selected frame. */
@@ -398,14 +398,13 @@ print_frame_info_base (struct frame_info *fi, int level, int source, int args)
print_frame (fi, level, source, args, sal);
source_print = (source == SRC_LINE || source == SRC_AND_LOC);
if (sal.symtab)
{
current_source_symtab = sal.symtab;
current_source_line = sal.line;
}
set_current_source_symtab_and_line (&sal);
if (source_print && sal.symtab)
{
struct symtab_and_line cursal;
int done = 0;
int mid_statement = (source == SRC_LINE) && (fi->pc != sal.pc);
@@ -435,7 +434,9 @@ print_frame_info_base (struct frame_info *fi, int level, int source, int args)
print_source_lines (sal.symtab, sal.line, sal.line + 1, 0);
}
}
current_source_line = max (sal.line - lines_to_list / 2, 1);
cursal = get_current_or_default_source_symtab_and_line ();
cursal.line = max (sal.line - get_lines_to_list () / 2, 1);
set_current_source_symtab_and_line (&cursal);
}
if (source != 0)