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