GDB (API)
/home/stan/gdb/src/gdb/filesystem.c
Go to the documentation of this file.
00001 /* Handle different target file systems for GDB, the GNU Debugger.
00002 
00003    Copyright (C) 2010-2013 Free Software Foundation, Inc.
00004 
00005    This file is part of GDB.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 3 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 #include "defs.h"
00021 #include "filesystem.h"
00022 #include "gdbarch.h"
00023 #include "gdbcmd.h"
00024 
00025 const char file_system_kind_auto[] = "auto";
00026 const char file_system_kind_unix[] = "unix";
00027 const char file_system_kind_dos_based[] = "dos-based";
00028 const char *const target_file_system_kinds[] =
00029 {
00030   file_system_kind_auto,
00031   file_system_kind_unix,
00032   file_system_kind_dos_based,
00033   NULL
00034 };
00035 const char *target_file_system_kind = file_system_kind_auto;
00036 
00037 const char *
00038 effective_target_file_system_kind (void)
00039 {
00040   if (target_file_system_kind == file_system_kind_auto)
00041     {
00042       if (gdbarch_has_dos_based_file_system (target_gdbarch ()))
00043         return file_system_kind_dos_based;
00044       else
00045         return file_system_kind_unix;
00046     }
00047   else
00048     return target_file_system_kind;
00049 }
00050 
00051 const char *
00052 target_lbasename (const char *kind, const char *name)
00053 {
00054   if (kind == file_system_kind_dos_based)
00055     return dos_lbasename (name);
00056   else
00057     return unix_lbasename (name);
00058 }
00059 
00060 static void
00061 show_target_file_system_kind_command (struct ui_file *file,
00062                                       int from_tty,
00063                                       struct cmd_list_element *c,
00064                                       const char *value)
00065 {
00066   if (target_file_system_kind == file_system_kind_auto)
00067     fprintf_filtered (file, _("\
00068 The assumed file system kind for target reported file names \
00069 is \"%s\" (currently \"%s\").\n"),
00070                       value,
00071                       effective_target_file_system_kind ());
00072   else
00073     fprintf_filtered (file, _("\
00074 The assumed file system kind for target reported file names \
00075 is \"%s\".\n"),
00076                       value);
00077 }
00078 
00079 /* Provide a prototype to silence -Wmissing-prototypes.  */
00080 extern initialize_file_ftype _initialize_filesystem;
00081 
00082 void
00083 _initialize_filesystem (void)
00084 {
00085   add_setshow_enum_cmd ("target-file-system-kind",
00086                         class_files,
00087                         target_file_system_kinds,
00088                         &target_file_system_kind, _("\
00089 Set assumed file system kind for target reported file names"), _("\
00090 Show assumed file system kind for target reported file names"),
00091                         _("\
00092 If `unix', target file names (e.g., loaded shared library file names)\n\
00093 starting the forward slash (`/') character are considered absolute,\n\
00094 and the directory separator character is the forward slash (`/').  If\n\
00095 `dos-based', target file names starting with a drive letter followed\n\
00096 by a colon (e.g., `c:'), are also considered absolute, and the\n\
00097 backslash (`\\') is also considered a directory separator.  Set to\n\
00098 `auto' (which is the default), to let GDB decide, based on its\n\
00099 knowledge of the target operating system."),
00100                         NULL, /* setfunc */
00101                         show_target_file_system_kind_command,
00102                         &setlist, &showlist);
00103 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines