1 /* Handle different target file systems for GDB, the GNU Debugger.
3 Copyright (C) 2010-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
20 #include "filesystem.h"
25 const char file_system_kind_auto
[] = "auto";
26 const char file_system_kind_unix
[] = "unix";
27 const char file_system_kind_dos_based
[] = "dos-based";
28 const char *const target_file_system_kinds
[] =
30 file_system_kind_auto
,
31 file_system_kind_unix
,
32 file_system_kind_dos_based
,
35 const char *target_file_system_kind
= file_system_kind_auto
;
38 effective_target_file_system_kind (void)
40 if (target_file_system_kind
== file_system_kind_auto
)
42 if (gdbarch_has_dos_based_file_system (current_inferior ()->arch ()))
43 return file_system_kind_dos_based
;
45 return file_system_kind_unix
;
48 return target_file_system_kind
;
52 target_lbasename (const char *kind
, const char *name
)
54 if (kind
== file_system_kind_dos_based
)
55 return dos_lbasename (name
);
57 return unix_lbasename (name
);
61 show_target_file_system_kind_command (struct ui_file
*file
,
63 struct cmd_list_element
*c
,
66 if (target_file_system_kind
== file_system_kind_auto
)
67 gdb_printf (file
, _("\
68 The assumed file system kind for target reported file names \
69 is \"%s\" (currently \"%s\").\n"),
71 effective_target_file_system_kind ());
73 gdb_printf (file
, _("\
74 The assumed file system kind for target reported file names \
79 void _initialize_filesystem ();
81 _initialize_filesystem ()
83 add_setshow_enum_cmd ("target-file-system-kind",
85 target_file_system_kinds
,
86 &target_file_system_kind
, _("\
87 Set assumed file system kind for target reported file names."), _("\
88 Show assumed file system kind for target reported file names."),
90 If `unix', target file names (e.g., loaded shared library file names)\n\
91 starting the forward slash (`/') character are considered absolute,\n\
92 and the directory separator character is the forward slash (`/'). If\n\
93 `dos-based', target file names starting with a drive letter followed\n\
94 by a colon (e.g., `c:'), are also considered absolute, and the\n\
95 backslash (`\\') is also considered a directory separator. Set to\n\
96 `auto' (which is the default), to let GDB decide, based on its\n\
97 knowledge of the target operating system."),
99 show_target_file_system_kind_command
,
100 &setlist
, &showlist
);