GDB (xrefs)

/tmp/gdb-8.1/gdb/filesystem.c
Go to the documentation of this file.
1 /* Handle different target file systems for GDB, the GNU Debugger.
2
3 Copyright (C) 2010-2018 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 #include "filesystem.h"
22 #include "gdbarch.h"
23 #include "gdbcmd.h"
24
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[] =
29 {
30 file_system_kind_auto,
31 file_system_kind_unix,
32 file_system_kind_dos_based,
33 NULL
34 };
35 const char *target_file_system_kind = file_system_kind_auto;
36
37 const char *
38 effective_target_file_system_kind (void)
39 {
40 if (target_file_system_kind == file_system_kind_auto)
41 {
42 if (gdbarch_has_dos_based_file_system (target_gdbarch ()))
43 return file_system_kind_dos_based;
44 else
45 return file_system_kind_unix;
46 }
47 else
48 return target_file_system_kind;
49 }
50
51 const char *
52 target_lbasename (const char *kind, const char *name)
53 {
54 if (kind == file_system_kind_dos_based)
55 return dos_lbasename (name);
56 else
57 return unix_lbasename (name);
58 }
59
60 static void
61 show_target_file_system_kind_command (struct ui_file *file,
62 int from_tty,
63 struct cmd_list_element *c,
64 const char *value)
65 {
66 if (target_file_system_kind == file_system_kind_auto)
67 fprintf_filtered (file, _("\
68 The assumed file system kind for target reported file names \
69 is \"%s\" (currently \"%s\").\n"),
70 value,
71 effective_target_file_system_kind ());
72 else
73 fprintf_filtered (file, _("\
74 The assumed file system kind for target reported file names \
75 is \"%s\".\n"),
76 value);
77 }
78
79 void
80 _initialize_filesystem (void)
81 {
82 add_setshow_enum_cmd ("target-file-system-kind",
83 class_files,
84 target_file_system_kinds,
85 &target_file_system_kind, _("\
86 Set assumed file system kind for target reported file names"), _("\
87 Show assumed file system kind for target reported file names"),
88 _("\
89 If `unix', target file names (e.g., loaded shared library file names)\n\
90 starting the forward slash (`/') character are considered absolute,\n\
91 and the directory separator character is the forward slash (`/'). If\n\
92 `dos-based', target file names starting with a drive letter followed\n\
93 by a colon (e.g., `c:'), are also considered absolute, and the\n\
94 backslash (`\\') is also considered a directory separator. Set to\n\
95 `auto' (which is the default), to let GDB decide, based on its\n\
96 knowledge of the target operating system."),
97 NULL, /* setfunc */
98 show_target_file_system_kind_command,
99 &setlist, &showlist);
100 }
target_gdbarch
struct gdbarch * target_gdbarch(void)
Definition: gdbarch.c:5467
target_file_system_kinds
const char *const target_file_system_kinds[]
Definition: filesystem.c:28
cmd_list_element
Definition: cli-decode.h:46
add_setshow_enum_cmd
void add_setshow_enum_cmd(const char *name, enum command_class theclass, const char *const *enumlist, const char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition: cli-decode.c:515
_
#define _(String)
Definition: gdb_locale.h:35
ui_file
Definition: ui-file.h:26
defs.h
class_files
Definition: command.h:41
file_system_kind_dos_based
const char file_system_kind_dos_based[]
Definition: filesystem.c:27
setlist
struct cmd_list_element * setlist
Definition: cli-cmds.c:111
name
const char *const name
Definition: aarch64-tdep.c:76
target_lbasename
const char * target_lbasename(const char *kind, const char *name)
Definition: filesystem.c:52
fprintf_filtered
void fprintf_filtered(struct ui_file *stream, const char *format,...)
Definition: utils.c:2008
show_target_file_system_kind_command
static void show_target_file_system_kind_command(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition: filesystem.c:61
gdbarch.h
showlist
struct cmd_list_element * showlist
Definition: cli-cmds.c:119
filesystem.h
target_file_system_kind
const char * target_file_system_kind
Definition: filesystem.c:35
file_system_kind_unix
const char file_system_kind_unix[]
Definition: filesystem.c:26
value
Definition: value.c:169
effective_target_file_system_kind
const char * effective_target_file_system_kind(void)
Definition: filesystem.c:38
_initialize_filesystem
void _initialize_filesystem(void)
Definition: filesystem.c:80
file_system_kind_auto
const char file_system_kind_auto[]
Definition: filesystem.c:25
gdbarch_has_dos_based_file_system
int gdbarch_has_dos_based_file_system(struct gdbarch *gdbarch)
Definition: gdbarch.c:4737
gdbcmd.h