Sort includes for files gdb/[a-f]*.[chyl].
[binutils-gdb.git] / gdb / filesystem.c
1 /* Handle different target file systems for GDB, the GNU Debugger.
2
3 Copyright (C) 2010-2019 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #include "defs.h"
21
22 /* Local non-gdb includes. */
23 #include "filesystem.h"
24 #include "gdbarch.h"
25 #include "gdbcmd.h"
26
27 const char file_system_kind_auto[] = "auto";
28 const char file_system_kind_unix[] = "unix";
29 const char file_system_kind_dos_based[] = "dos-based";
30 const char *const target_file_system_kinds[] =
31 {
32 file_system_kind_auto,
33 file_system_kind_unix,
34 file_system_kind_dos_based,
35 NULL
36 };
37 const char *target_file_system_kind = file_system_kind_auto;
38
39 const char *
40 effective_target_file_system_kind (void)
41 {
42 if (target_file_system_kind == file_system_kind_auto)
43 {
44 if (gdbarch_has_dos_based_file_system (target_gdbarch ()))
45 return file_system_kind_dos_based;
46 else
47 return file_system_kind_unix;
48 }
49 else
50 return target_file_system_kind;
51 }
52
53 const char *
54 target_lbasename (const char *kind, const char *name)
55 {
56 if (kind == file_system_kind_dos_based)
57 return dos_lbasename (name);
58 else
59 return unix_lbasename (name);
60 }
61
62 static void
63 show_target_file_system_kind_command (struct ui_file *file,
64 int from_tty,
65 struct cmd_list_element *c,
66 const char *value)
67 {
68 if (target_file_system_kind == file_system_kind_auto)
69 fprintf_filtered (file, _("\
70 The assumed file system kind for target reported file names \
71 is \"%s\" (currently \"%s\").\n"),
72 value,
73 effective_target_file_system_kind ());
74 else
75 fprintf_filtered (file, _("\
76 The assumed file system kind for target reported file names \
77 is \"%s\".\n"),
78 value);
79 }
80
81 void
82 _initialize_filesystem (void)
83 {
84 add_setshow_enum_cmd ("target-file-system-kind",
85 class_files,
86 target_file_system_kinds,
87 &target_file_system_kind, _("\
88 Set assumed file system kind for target reported file names"), _("\
89 Show assumed file system kind for target reported file names"),
90 _("\
91 If `unix', target file names (e.g., loaded shared library file names)\n\
92 starting the forward slash (`/') character are considered absolute,\n\
93 and the directory separator character is the forward slash (`/'). If\n\
94 `dos-based', target file names starting with a drive letter followed\n\
95 by a colon (e.g., `c:'), are also considered absolute, and the\n\
96 backslash (`\\') is also considered a directory separator. Set to\n\
97 `auto' (which is the default), to let GDB decide, based on its\n\
98 knowledge of the target operating system."),
99 NULL, /* setfunc */
100 show_target_file_system_kind_command,
101 &setlist, &showlist);
102 }