GDB (xrefs)
|
#include "defs.h"
#include "arch-utils.h"
#include "symtab.h"
#include "expression.h"
#include "language.h"
#include "command.h"
#include "source.h"
#include "gdbcmd.h"
#include "frame.h"
#include "value.h"
#include "gdb_assert.h"
#include "filestuff.h"
#include <sys/types.h>
#include "gdb_string.h"
#include "gdb_stat.h"
#include <fcntl.h>
#include "gdbcore.h"
#include "gdb_regex.h"
#include "symfile.h"
#include "objfiles.h"
#include "annotate.h"
#include "gdbtypes.h"
#include "linespec.h"
#include "filenames.h"
#include "completer.h"
#include "ui-out.h"
#include "readline/readline.h"
Go to the source code of this file.
#define cdir_len 5 |
Referenced by find_and_open_source().
#define FDOPEN_MODE FOPEN_RB |
Definition at line 49 of file source.c.
Referenced by forward_search_command(), print_source_lines_base(), and reverse_search_command().
#define OPEN_MODE (O_RDONLY | O_BINARY) |
Definition at line 48 of file source.c.
Referenced by find_and_open_source().
void _initialize_source | ( | void | ) |
Definition at line 459 of file source.c.
References _, current_directory, dirnames_to_char_ptr_vec_append(), do_cleanups(), fprintf_unfiltered(), gdb_buildargv(), gdb_stderr, len, make_cleanup(), make_cleanup_free_char_ptr_vec(), memmove(), name, p, print_sys_errmsg(), savestring(), VEC, VEC_iterate, VEC_safe_push, warning(), and xfree().
Referenced by directory_switch(), env_mod_path(), and mod_path().
void add_substitute_path_rule | ( | char * | from, |
char * | to | ||
) |
Definition at line 1799 of file source.c.
References substitute_path_rule::from, substitute_path_rule::next, substitute_path_rules, substitute_path_rule::to, and xmalloc().
Referenced by captured_main(), and set_substitute_path_command().
void clear_current_source_symtab_and_line | ( | void | ) |
Definition at line 229 of file source.c.
References current_source_line.
Referenced by clear_symtab_users(), and free_objfile().
static void delete_substitute_path_rule | ( | struct substitute_path_rule * | rule | ) | [static] |
Definition at line 1832 of file source.c.
References substitute_path_rule::from, gdb_assert, substitute_path_rule::next, substitute_path_rules, substitute_path_rule::to, and xfree().
Referenced by set_substitute_path_command(), and unset_substitute_path_command().
static void directory_command | ( | char * | dirname, |
int | from_tty | ||
) | [static] |
Definition at line 414 of file source.c.
References _, dont_repeat(), forget_cached_source_info(), init_source_path(), mod_path(), query(), show_directories_1(), source_path, and xfree().
void directory_switch | ( | char * | dirname, |
int | from_tty | ||
) |
Definition at line 439 of file source.c.
References add_path(), and source_path.
Referenced by captured_main().
int find_and_open_source | ( | const char * | filename, |
const char * | dirname, | ||
char ** | fullname | ||
) |
Definition at line 993 of file source.c.
References cdir_len, do_cleanups(), gdb_open_cloexec(), gdb_realpath(), len, make_cleanup(), null_cleanup(), OPEN_MODE, openp(), OPF_RETURN_REALPATH, OPF_SEARCH_IN_PATH, p, rewrite_source_path(), source_path, strstr(), and xfree().
Referenced by open_source_file(), psymtab_to_fullname(), and symtab_to_fullname().
void find_source_lines | ( | struct symtab * | s, |
int | desc | ||
) |
Definition at line 1176 of file source.c.
References _, do_cleanups(), exec_bfd, exec_bfd_mtime, gdb_assert, int, symtab::line_charpos, make_cleanup(), objfile::mtime, myread(), symtab::nlines, objfile::obfd, symtab::objfile, p, perror_with_name(), size, symtab_to_filename_for_display(), warning(), xfree(), xmalloc(), and xrealloc().
Referenced by forward_search_command(), gdbtk_load_source(), get_filename_and_charpos(), print_source_lines_base(), reverse_search_command(), and tui_set_source_content().
static struct substitute_path_rule* find_substitute_path_rule | ( | const char * | from | ) | [static, read] |
Definition at line 1781 of file source.c.
References substitute_path_rule::from, substitute_path_rule::next, and substitute_path_rules.
Referenced by set_substitute_path_command().
void forget_cached_source_info | ( | void | ) |
Definition at line 387 of file source.c.
References ALL_PSPACE_OBJFILES, ALL_PSPACES, and forget_cached_source_info_for_objfile().
Referenced by cd_command(), directory_command(), init_source_path(), mi_cmd_env_dir(), set_substitute_path_command(), and unset_substitute_path_command().
void forget_cached_source_info_for_objfile | ( | struct objfile * | objfile | ) |
Definition at line 360 of file source.c.
References ALL_OBJFILE_SYMTABS, quick_symbol_functions::forget_cached_source_info, symtab::fullname, symtab::line_charpos, sym_fns::qf, objfile::sf, and xfree().
Referenced by forget_cached_source_info(), and free_objfile().
static void forward_search_command | ( | char * | regex, |
int | from_tty | ||
) | [static] |
Definition at line 1588 of file source.c.
References _, current_source_line, discard_cleanups(), do_cleanups(), error(), FDOPEN_MODE, find_source_lines(), last_line_listed, line, symtab::line_charpos, lines_to_list, lookup_internalvar(), make_cleanup_close(), make_cleanup_fclose(), max, symtab::nlines, open_source_file(), p, perror_with_name(), print_source_lines(), printf_filtered(), re_comp(), select_source_symtab(), set_internalvar_integer(), symtab_to_filename_for_display(), xmalloc(), and xrealloc().
struct symtab_and_line get_current_source_symtab_and_line | ( | void | ) | [read] |
Definition at line 171 of file source.c.
References current_source_line, current_source_pspace, current_source_symtab, symtab_and_line::end, symtab_and_line::line, symtab_and_line::pc, symtab_and_line::pspace, and symtab_and_line::symtab.
Referenced by decode_line_with_current_source(), default_macro_scope(), edit_command(), extract_display_start_addr(), free_objfile(), initialize_defaults(), list_command(), make_visible_with_new_height(), mi_cmd_file_list_exec_source_file(), parse_breakpoint_sals(), parse_exp_in_context_1(), tui_horizontal_source_scroll(), tui_show_source(), and tui_vertical_source_scroll().
static int get_filename_and_charpos | ( | struct symtab * | s, |
char ** | fullname | ||
) | [static] |
Definition at line 1252 of file source.c.
References do_cleanups(), find_source_lines(), symtab::fullname, symtab::line_charpos, make_cleanup_close(), and open_source_file().
Referenced by identify_source_line().
int get_first_line_listed | ( | void | ) |
Definition at line 151 of file source.c.
References first_line_listed.
Referenced by list_command().
int get_lines_to_list | ( | void | ) |
Definition at line 162 of file source.c.
References lines_to_list.
Referenced by edit_command(), list_command(), and set_current_sal_from_frame().
static struct substitute_path_rule* get_substitute_path_rule | ( | const char * | path | ) | [static, read] |
Definition at line 953 of file source.c.
References substitute_path_rule::next, substitute_path_rule_matches(), and substitute_path_rules.
Referenced by rewrite_source_path().
Definition at line 1285 of file source.c.
References annotate_source(), current_source_line, first_line_listed, symtab::fullname, get_filename_and_charpos(), get_objfile_arch(), last_line_listed, line, symtab::line_charpos, symtab::nlines, and symtab::objfile.
Referenced by line_info(), and print_frame_info().
void init_source_path | ( | void | ) |
Definition at line 402 of file source.c.
References forget_cached_source_info(), source_path, and xsnprintf().
Referenced by directory_command(), mi_cmd_env_dir(), and set_directories_command().
static int is_regular_file | ( | const char * | name | ) | [static] |
Definition at line 1479 of file source.c.
References _, annotation_level, current_program_space, current_source_symtab, DECODE_LINE_LIST_MODE, decode_line_with_last_displayed(), do_cleanups(), dont_repeat(), find_line_pc_range(), gdb_stdout, get_current_arch(), get_objfile_arch(), identify_source_line(), init_sal(), last_line_listed, symtab_and_line::line, make_cleanup(), symtabs_and_lines::nelts, symtab::objfile, symtab_and_line::pc, print_address(), printf_filtered(), symtab_and_line::pspace, symtabs_and_lines::sals, set_next_address(), symtab_and_line::symtab, symtab_to_filename_for_display(), wrap_here(), xfree(), and xmalloc().
void mod_path | ( | char * | dirname, |
char ** | which_path | ||
) |
Definition at line 447 of file source.c.
References add_path().
Referenced by directory_command(), path_command(), and set_directories_command().
int open_source_file | ( | struct symtab * | s | ) |
Definition at line 1102 of file source.c.
References symtab::dirname, symtab::filename, find_and_open_source(), and symtab::fullname.
Referenced by forward_search_command(), gdbtk_load_source(), get_filename_and_charpos(), print_source_lines_base(), reverse_search_command(), symtab_to_filename(), and tui_set_source_content().
Definition at line 703 of file source.c.
References current_directory, do_cleanups(), gdb_assert, gdb_open_cloexec(), gdb_realpath(), is_regular_file(), len, make_cleanup_free_char_ptr_vec(), OPF_RETURN_REALPATH, OPF_SEARCH_IN_PATH, OPF_TRY_CWD_FIRST, strchr(), VEC, VEC_iterate, and xfree().
Referenced by exec_file_attach(), find_and_open_script(), find_and_open_source(), nto_find_and_open_solib(), solib_find(), source_full_path_of(), symfile_bfd_open(), and try_open_dwop_file().
void print_source_lines | ( | struct symtab * | s, |
int | line, | ||
int | stopline, | ||
enum print_source_lines_flags | flags | ||
) |
Definition at line 1470 of file source.c.
References print_source_lines_base().
Referenced by do_mixed_source_and_assembly(), forward_search_command(), list_command(), print_frame_info(), reverse_search_command(), and tui_vertical_source_scroll().
static void print_source_lines_base | ( | struct symtab * | s, |
int | line, | ||
int | stopline, | ||
enum print_source_lines_flags | flags | ||
) | [static] |
Definition at line 1310 of file source.c.
References _, current_source_line, current_uiout, do_cleanups(), error(), FDOPEN_MODE, find_source_lines(), first_line_listed, last_line_listed, last_source_error, len, line, symtab::line_charpos, make_cleanup_fclose(), name, symtab::nlines, open_source_file(), perror_with_name(), PRINT_SOURCE_LINES_FILENAME, PRINT_SOURCE_LINES_NOERROR, print_sys_errmsg(), printf_filtered(), symtab_to_filename_for_display(), symtab_to_fullname(), ui_out_field_int(), ui_out_field_string(), ui_out_is_mi_like_p(), ui_out_test_flags(), ui_out_text(), ui_source_list, and xsnprintf().
Referenced by print_source_lines().
static void reverse_search_command | ( | char * | regex, |
int | from_tty | ||
) | [static] |
Definition at line 1677 of file source.c.
References _, current_source_line, discard_cleanups(), do_cleanups(), error(), FDOPEN_MODE, find_source_lines(), last_line_listed, line, symtab::line_charpos, lines_to_list, lookup_internalvar(), make_cleanup_close(), make_cleanup_fclose(), max, symtab::nlines, open_source_file(), p, perror_with_name(), print_source_lines(), printf_filtered(), re_comp(), select_source_symtab(), set_internalvar_integer(), and symtab_to_filename_for_display().
char* rewrite_source_path | ( | const char * | path | ) |
Definition at line 971 of file source.c.
References substitute_path_rule::from, get_substitute_path_rule(), substitute_path_rule::to, and xmalloc().
Referenced by find_and_open_source(), psymtab_to_fullname(), and symtab_to_fullname().
void select_source_symtab | ( | struct symtab * | s | ) |
Definition at line 244 of file source.c.
References _, ALL_OBJFILES, current_program_space, current_source_line, DECODE_LINE_FUNFIRSTLINE, decode_line_with_current_source(), error(), symtab::filename, quick_symbol_functions::find_last_source_symtab, len, symtab_and_line::line, lines_to_list, lookup_symbol(), main_name(), max, name, symtab::next, symtab_and_line::pspace, sym_fns::qf, symtabs_and_lines::sals, objfile::sf, symtab_and_line::symtab, SYMTAB_PSPACE, objfile::symtabs, VAR_DOMAIN, and xfree().
Referenced by forward_search_command(), reverse_search_command(), set_default_source_symtab_and_line(), tui_print_frame_info_listing_hook(), and tui_selected_frame_level_changed_hook().
struct symtab_and_line set_current_source_symtab_and_line | ( | const struct symtab_and_line * | sal | ) | [read] |
Definition at line 209 of file source.c.
References current_source_line, current_source_pspace, current_source_symtab, symtab_and_line::end, symtab_and_line::line, symtab_and_line::pc, symtab_and_line::pspace, and symtab_and_line::symtab.
Referenced by set_current_sal_from_frame(), tui_show_disassem_and_update_source(), and tui_update_source_window_as_is().
void set_default_source_symtab_and_line | ( | void | ) |
Definition at line 193 of file source.c.
References _, error(), have_full_symbols(), have_partial_symbols(), and select_source_symtab().
Referenced by create_sals_line_offset(), edit_command(), list_command(), and mi_cmd_file_list_exec_source_file().
static void set_directories_command | ( | char * | args, |
int | from_tty, | ||
struct cmd_list_element * | c | ||
) | [static] |
Definition at line 318 of file source.c.
References init_source_path(), mod_path(), source_path, and xfree().
static void set_substitute_path_command | ( | char * | args, |
int | from_tty | ||
) | [static] |
Definition at line 1950 of file source.c.
References _, add_substitute_path_rule(), delete_substitute_path_rule(), do_cleanups(), error(), find_substitute_path_rule(), forget_cached_source_info(), gdb_buildargv(), make_cleanup_freeargv(), and strip_trailing_directory_separator().
static void show_directories_1 | ( | char * | ignore, |
int | from_tty | ||
) | [static] |
Definition at line 340 of file source.c.
References puts_filtered(), and source_path.
Referenced by directory_command(), and show_directories_command().
static void show_directories_command | ( | struct ui_file * | file, |
int | from_tty, | ||
struct cmd_list_element * | c, | ||
const char * | value | ||
) | [static] |
Definition at line 350 of file source.c.
References show_directories_1().
static void show_filename_display_string | ( | struct ui_file * | file, |
int | from_tty, | ||
struct cmd_list_element * | c, | ||
const char * | value | ||
) | [static] |
Definition at line 125 of file source.c.
References _, and fprintf_filtered().
static void show_lines_to_list | ( | struct ui_file * | file, |
int | from_tty, | ||
struct cmd_list_element * | c, | ||
const char * | value | ||
) | [static] |
Definition at line 101 of file source.c.
References _, and fprintf_filtered().
static void show_substitute_path_command | ( | char * | args, |
int | from_tty | ||
) | [static] |
Definition at line 1856 of file source.c.
References _, do_cleanups(), error(), substitute_path_rule::from, from, gdb_buildargv(), make_cleanup_freeargv(), substitute_path_rule::next, printf_filtered(), substitute_path_rules, and substitute_path_rule::to.
int source_full_path_of | ( | const char * | filename, |
char ** | full_pathname | ||
) |
Definition at line 896 of file source.c.
References openp(), OPF_RETURN_REALPATH, OPF_SEARCH_IN_PATH, OPF_TRY_CWD_FIRST, and source_path.
Referenced by attach_command_post_wait().
static void source_info | ( | char * | ignore, |
int | from_tty | ||
) | [static] |
Definition at line 626 of file source.c.
References _, current_source_symtab, symtab::debugformat, symtab::dirname, symtab::filename, symtab::fullname, symtab::language, language_str(), symtab::macro_table, symtab::nlines, and printf_filtered().
static void strip_trailing_directory_separator | ( | char * | path | ) | [static] |
Definition at line 1766 of file source.c.
Referenced by set_substitute_path_command().
static int substitute_path_rule_matches | ( | const struct substitute_path_rule * | rule, |
const char * | path | ||
) | [static] |
Definition at line 917 of file source.c.
References substitute_path_rule::from.
Referenced by get_substitute_path_rule().
const char* symtab_to_filename_for_display | ( | struct symtab * | symtab | ) |
Definition at line 1158 of file source.c.
References _, symtab::filename, filename_display_absolute, filename_display_basename, filename_display_relative, filename_display_string, internal_error(), and symtab_to_fullname().
Referenced by ambiguous_line_spec(), btrace_func_history_src_line(), build_address_symbolic(), debug_symtab_name(), decode_line_2(), dump_objfile(), dump_symtab_1(), edit_command(), error_in_psymtab_expansion(), find_source_lines(), fixup_go_packaging(), forward_search_command(), frame_info(), ftrace_print_filename(), info_checkpoints_command(), line_info(), list_command(), maintenance_check_symtabs(), maintenance_info_symtabs(), maintenance_print_symbols(), mi_cmd_file_list_exec_source_file(), mi_cmd_file_list_exec_source_files(), print_breakpoint_location(), print_frame(), print_one_static_tracepoint_marker(), print_source_lines_base(), print_symbol_info(), psymtab_to_symtab_1(), rbreak_command(), resolve_sal_pc(), reverse_search_command(), sal_macro_scope(), salpy_str(), say_where(), set_traceframe_context(), stpy_get_filename(), stpy_str(), symtab_symbol_info(), trace_find_line_command(), tui_set_source_content(), update_static_tracepoint(), and user_select_syms().
const char* symtab_to_fullname | ( | struct symtab * | s | ) |
Definition at line 1120 of file source.c.
References symtab::dirname, do_cleanups(), symtab::filename, find_and_open_source(), symtab::fullname, make_cleanup(), rewrite_source_path(), and xfree().
Referenced by add_sal_to_sals(), canonical_to_fullform(), clear_command(), convert_linespec_to_sals(), create_sals_line_offset(), edit_command(), find_line_symtab(), ftrace_function_switched(), ftrace_skip_file(), function_name_is_marked_for_skip(), is_known_support_routine(), iterate_over_some_symtabs(), mi_cmd_file_list_exec_source_file(), mi_cmd_file_list_exec_source_files(), print_breakpoint_location(), print_frame(), print_one_static_tracepoint_marker(), print_source_lines_base(), rbreak_command(), search_symbols(), skip_file_command(), sources_info(), stpy_fullname(), symtab_to_filename_for_display(), tui_display_main(), tui_set_source_content(), tui_show_disassem_and_update_source(), tui_show_frame_info(), tui_update_breakpoint_info(), update_static_tracepoint(), and VEC().
static void unset_substitute_path_command | ( | char * | args, |
int | from_tty | ||
) | [static] |
Definition at line 1895 of file source.c.
References _, delete_substitute_path_rule(), do_cleanups(), error(), forget_cached_source_info(), substitute_path_rule::from, from, gdb_buildargv(), make_cleanup_freeargv(), substitute_path_rule::next, query(), and substitute_path_rules.
int current_source_line [static] |
Definition at line 89 of file source.c.
Referenced by clear_current_source_symtab_and_line(), forward_search_command(), get_current_source_symtab_and_line(), identify_source_line(), print_source_lines_base(), reverse_search_command(), select_source_symtab(), and set_current_source_symtab_and_line().
struct program_space* current_source_pspace [static] |
Definition at line 91 of file source.c.
Referenced by get_current_source_symtab_and_line(), and set_current_source_symtab_and_line().
struct symtab* current_source_symtab [static] |
Definition at line 85 of file source.c.
Referenced by get_current_source_symtab_and_line(), line_info(), set_current_source_symtab_and_line(), and source_info().
const char filename_display_absolute[] = "absolute" [static] |
Definition at line 113 of file source.c.
Referenced by symtab_to_filename_for_display().
const char filename_display_basename[] = "basename" [static] |
Definition at line 111 of file source.c.
Referenced by symtab_to_filename_for_display().
const char* const filename_display_kind_names[] [static] |
const char filename_display_relative[] = "relative" [static] |
Definition at line 112 of file source.c.
Referenced by symtab_to_filename_for_display().
const char* filename_display_string = filename_display_relative [static] |
Definition at line 122 of file source.c.
Referenced by symtab_to_filename_for_display().
int first_line_listed [static] |
Definition at line 138 of file source.c.
Referenced by get_first_line_listed(), identify_source_line(), and print_source_lines_base().
int last_line_listed [static] |
Definition at line 134 of file source.c.
Referenced by forward_search_command(), identify_source_line(), line_info(), print_source_lines_base(), and reverse_search_command().
int last_source_error = 0 [static] |
Definition at line 144 of file source.c.
Referenced by print_source_lines_base().
struct symtab* last_source_visited = NULL [static] |
int lines_to_list = 10 |
Definition at line 99 of file source.c.
Referenced by forward_search_command(), get_lines_to_list(), reverse_search_command(), and select_source_symtab().
char* source_path |
Definition at line 70 of file source.c.
Referenced by directory_command(), directory_switch(), find_and_open_script(), find_and_open_source(), Gdbtk_Init(), init_source_path(), mi_cmd_env_dir(), set_directories_command(), show_directories_1(), and source_full_path_of().
struct substitute_path_rule* substitute_path_rules = NULL [static] |
Definition at line 81 of file source.c.
Referenced by add_substitute_path_rule(), delete_substitute_path_rule(), find_substitute_path_rule(), get_substitute_path_rule(), show_substitute_path_command(), and unset_substitute_path_command().