binutils-gdb/gdb/filesystem.c

104 lines
3.3 KiB
C
Raw Normal View History

/* Handle different target file systems for GDB, the GNU Debugger.
Copyright (C) 2010-2015 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "filesystem.h"
#include "gdbarch.h"
#include "gdbcmd.h"
const char file_system_kind_auto[] = "auto";
const char file_system_kind_unix[] = "unix";
const char file_system_kind_dos_based[] = "dos-based";
gdb/ Code cleanup: Make 1440 bytes of data segment read-only. * arch-utils.c (endian_enum): Make it const char *const []. * arm-tdep.c (fp_model_strings, arm_abi_strings, arm_mode_strings): Likewise. * breakpoint.c (always_inserted_enums): Likewise. * cli/cli-cmds.c (script_ext_enums): Likewise. * cli/cli-decode.c (add_setshow_enum_cmd, complete_on_enum): Make the enumlist parameter const char *const *. * cli/cli-decode.h (struct cmd_list_element): Make the enums field const char *const *. * command.h (complete_on_enum, add_setshow_enum_cmd): Make the enumlist parameter const char *const *. * cris-tdep.c (cris_modes): Make it const char *const []. * filesystem.c (target_file_system_kinds): Likewise. * i386-tdep.c (valid_flavors, valid_conventions): Likewise. * infrun.c (follow_fork_mode_kind_names, follow_exec_mode_names) (can_use_displaced_stepping_enum, scheduler_enums) (exec_direction_names): Likewise. * language.c (_initialize_language): Make the type_or_range_names and case_sensitive_names variables const char *const []. * mips-tdep.c (mips_abi_strings): Make it const char *const []. * python/python.c (python_excp_enums): Likewise. * remote.c (interrupt_sequence_modes): Likewise. * rs6000-tdep.c (powerpc_vector_strings): Likewise. * serial.c (logbase_enums): Likewise. * sh-tdep.c (sh_cc_enum): Likewise. * stack.c (print_frame_arguments_choices, print_entry_values_choices): Likewise. * symtab.c (multiple_symbols_modes): Likewise. * tui/tui-win.c (tui_border_kind_enums, tui_border_mode_enums): Likewise. * utils.c (internal_problem_modes): Likewise.
2012-01-29 02:08:22 +08:00
const char *const target_file_system_kinds[] =
{
file_system_kind_auto,
file_system_kind_unix,
file_system_kind_dos_based,
NULL
};
const char *target_file_system_kind = file_system_kind_auto;
const char *
effective_target_file_system_kind (void)
{
if (target_file_system_kind == file_system_kind_auto)
{
if (gdbarch_has_dos_based_file_system (target_gdbarch ()))
return file_system_kind_dos_based;
else
return file_system_kind_unix;
}
else
return target_file_system_kind;
}
const char *
target_lbasename (const char *kind, const char *name)
{
if (kind == file_system_kind_dos_based)
return dos_lbasename (name);
else
return unix_lbasename (name);
}
static void
show_target_file_system_kind_command (struct ui_file *file,
int from_tty,
struct cmd_list_element *c,
const char *value)
{
if (target_file_system_kind == file_system_kind_auto)
fprintf_filtered (file, _("\
The assumed file system kind for target reported file names \
is \"%s\" (currently \"%s\").\n"),
value,
effective_target_file_system_kind ());
else
fprintf_filtered (file, _("\
The assumed file system kind for target reported file names \
is \"%s\".\n"),
value);
}
/* Provide a prototype to silence -Wmissing-prototypes. */
extern initialize_file_ftype _initialize_filesystem;
void
_initialize_filesystem (void)
{
add_setshow_enum_cmd ("target-file-system-kind",
class_files,
target_file_system_kinds,
&target_file_system_kind, _("\
Set assumed file system kind for target reported file names"), _("\
Show assumed file system kind for target reported file names"),
_("\
If `unix', target file names (e.g., loaded shared library file names)\n\
starting the forward slash (`/') character are considered absolute,\n\
and the directory separator character is the forward slash (`/'). If\n\
`dos-based', target file names starting with a drive letter followed\n\
by a colon (e.g., `c:'), are also considered absolute, and the\n\
backslash (`\\') is also considered a directory separator. Set to\n\
`auto' (which is the default), to let GDB decide, based on its\n\
knowledge of the target operating system."),
NULL, /* setfunc */
show_target_file_system_kind_command,
&setlist, &showlist);
}