]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/filesystem.c
gdb: remove target_gdbarch
[thirdparty/binutils-gdb.git] / gdb / filesystem.c
CommitLineData
ab38a727
PA
1/* Handle different target file systems for GDB, the GNU Debugger.
2
213516ef 3 Copyright (C) 2010-2023 Free Software Foundation, Inc.
ab38a727
PA
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#include "filesystem.h"
22#include "gdbarch.h"
23#include "gdbcmd.h"
99d9c3b9 24#include "inferior.h"
ab38a727
PA
25
26const char file_system_kind_auto[] = "auto";
27const char file_system_kind_unix[] = "unix";
28const char file_system_kind_dos_based[] = "dos-based";
40478521 29const char *const target_file_system_kinds[] =
ab38a727
PA
30{
31 file_system_kind_auto,
32 file_system_kind_unix,
33 file_system_kind_dos_based,
34 NULL
35};
36const char *target_file_system_kind = file_system_kind_auto;
37
38const char *
39effective_target_file_system_kind (void)
40{
41 if (target_file_system_kind == file_system_kind_auto)
42 {
99d9c3b9 43 if (gdbarch_has_dos_based_file_system (current_inferior ()->arch ()))
ab38a727
PA
44 return file_system_kind_dos_based;
45 else
46 return file_system_kind_unix;
47 }
48 else
49 return target_file_system_kind;
50}
51
52const char *
53target_lbasename (const char *kind, const char *name)
54{
55 if (kind == file_system_kind_dos_based)
56 return dos_lbasename (name);
57 else
58 return unix_lbasename (name);
59}
60
61static void
62show_target_file_system_kind_command (struct ui_file *file,
63 int from_tty,
64 struct cmd_list_element *c,
65 const char *value)
66{
67 if (target_file_system_kind == file_system_kind_auto)
6cb06a8c 68 gdb_printf (file, _("\
ab38a727
PA
69The assumed file system kind for target reported file names \
70is \"%s\" (currently \"%s\").\n"),
6cb06a8c
TT
71 value,
72 effective_target_file_system_kind ());
ab38a727 73 else
6cb06a8c 74 gdb_printf (file, _("\
ab38a727
PA
75The assumed file system kind for target reported file names \
76is \"%s\".\n"),
6cb06a8c 77 value);
ab38a727
PA
78}
79
6c265988 80void _initialize_filesystem ();
ab38a727 81void
6c265988 82_initialize_filesystem ()
ab38a727
PA
83{
84 add_setshow_enum_cmd ("target-file-system-kind",
85 class_files,
86 target_file_system_kinds,
87 &target_file_system_kind, _("\
590042fc
PW
88Set assumed file system kind for target reported file names."), _("\
89Show assumed file system kind for target reported file names."),
ab38a727 90 _("\
cce7e648
PA
91If `unix', target file names (e.g., loaded shared library file names)\n\
92starting the forward slash (`/') character are considered absolute,\n\
93and the directory separator character is the forward slash (`/'). If\n\
94`dos-based', target file names starting with a drive letter followed\n\
95by a colon (e.g., `c:'), are also considered absolute, and the\n\
96backslash (`\\') is also considered a directory separator. Set to\n\
97`auto' (which is the default), to let GDB decide, based on its\n\
ab38a727
PA
98knowledge of the target operating system."),
99 NULL, /* setfunc */
100 show_target_file_system_kind_command,
101 &setlist, &showlist);
102}