diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2013-02-03 16:09:33 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2013-02-03 16:09:33 +0000 |
commit | 1b56eb55405f0222188073473e1ab563899424ca (patch) | |
tree | 1a79fc095fcae3d4e0a122f1384ceae7e1a9190a /gdb/source.c | |
parent | aa079c9346c65921b85c75da180a887b7bd7a776 (diff) | |
download | gdb-1b56eb55405f0222188073473e1ab563899424ca.zip gdb-1b56eb55405f0222188073473e1ab563899424ca.tar.gz gdb-1b56eb55405f0222188073473e1ab563899424ca.tar.bz2 |
gdb/
Add a new variable that controls a way in which filenames are
displayed.
* NEWS (set filename-display): New entry.
* source.c (filename_display_basename, filename_display_relative)
(filename_display_absolute, filename_display_kind_names)
(filename_display_string, show_filename_display_string)
(symtab_to_filename_for_display): New.
(_initialize_source): Added initialization of 'filename-display'
variable.
* source.h (symtab_to_filename_for_display): Added declaration.
* stack.c (print_frame): Added new variable and calling of a new
function and condition with this variable. Changed third argument of
calling of a function.
gdb/doc/
* gdb.texinfo (Backtrace): Added description of 'filename-display'
variable in 'set/show backtrace' section.
gdb/testsuite/
* gdb.dwarf2/dw2-dir-file-name.exp: New file.
* gdb.dwarf2/dw2-dir-file-name.c: New file.
Diffstat (limited to 'gdb/source.c')
-rw-r--r-- | gdb/source.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/gdb/source.c b/gdb/source.c index 13cc7c8..68fbcdf 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -109,6 +109,27 @@ show_lines_to_list (struct ui_file *file, int from_tty, value); } +/* Possible values of 'set filename-display'. */ +static const char filename_display_basename[] = "basename"; +static const char filename_display_relative[] = "relative"; +static const char filename_display_absolute[] = "absolute"; + +static const char *const filename_display_kind_names[] = { + filename_display_basename, + filename_display_relative, + filename_display_absolute, + NULL +}; + +static const char *filename_display_string = filename_display_relative; + +static void +show_filename_display_string (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + fprintf_filtered (file, _("Filenames are displayed as \"%s\".\n"), value); +} + /* Line number of last line printed. Default for various commands. current_source_line is usually, but not always, the same as this. */ @@ -1111,6 +1132,21 @@ symtab_to_fullname (struct symtab *s) return s->fullname; } + +/* See commentary in source.h. */ + +const char * +symtab_to_filename_for_display (struct symtab *symtab) +{ + if (filename_display_string == filename_display_basename) + return lbasename (symtab->filename); + else if (filename_display_string == filename_display_absolute) + return symtab_to_fullname (symtab); + else if (filename_display_string == filename_display_relative) + return symtab->filename; + else + internal_error (__FILE__, __LINE__, _("invalid filename_display_string")); +} /* Create and initialize the table S->line_charpos that records the positions of the lines in the source file, which is assumed @@ -2014,4 +2050,19 @@ Usage: show substitute-path [FROM]\n\ Print the rule for substituting FROM in source file names. If FROM\n\ is not specified, print all substitution rules."), &showlist); + + add_setshow_enum_cmd ("filename-display", class_files, + filename_display_kind_names, + &filename_display_string, _("\ +Set how to display filenames."), _("\ +Show how to display filenames."), _("\ +filename-display can be:\n\ + basename - display only basename of a filename\n\ + relative - display a filename relative to the compilation directory\n\ + absolute - display an absolute filename\n\ +By default, relative filenames are displayed."), + NULL, + show_filename_display_string, + &setlist, &showlist); + } |