gdb/filesystem.c - gdb

Global variables defined

Functions defined

Source code

  1. /* Handle different target file systems for GDB, the GNU Debugger.

  2.    Copyright (C) 2010-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #include "defs.h"
  15. #include "filesystem.h"
  16. #include "gdbarch.h"
  17. #include "gdbcmd.h"

  18. const char file_system_kind_auto[] = "auto";
  19. const char file_system_kind_unix[] = "unix";
  20. const char file_system_kind_dos_based[] = "dos-based";
  21. const char *const target_file_system_kinds[] =
  22. {
  23.   file_system_kind_auto,
  24.   file_system_kind_unix,
  25.   file_system_kind_dos_based,
  26.   NULL
  27. };
  28. const char *target_file_system_kind = file_system_kind_auto;

  29. const char *
  30. effective_target_file_system_kind (void)
  31. {
  32.   if (target_file_system_kind == file_system_kind_auto)
  33.     {
  34.       if (gdbarch_has_dos_based_file_system (target_gdbarch ()))
  35.         return file_system_kind_dos_based;
  36.       else
  37.         return file_system_kind_unix;
  38.     }
  39.   else
  40.     return target_file_system_kind;
  41. }

  42. const char *
  43. target_lbasename (const char *kind, const char *name)
  44. {
  45.   if (kind == file_system_kind_dos_based)
  46.     return dos_lbasename (name);
  47.   else
  48.     return unix_lbasename (name);
  49. }

  50. static void
  51. show_target_file_system_kind_command (struct ui_file *file,
  52.                                       int from_tty,
  53.                                       struct cmd_list_element *c,
  54.                                       const char *value)
  55. {
  56.   if (target_file_system_kind == file_system_kind_auto)
  57.     fprintf_filtered (file, _("\
  58. The assumed file system kind for target reported file names \
  59. is \"%s\" (currently \"%s\").\n"),
  60.                       value,
  61.                       effective_target_file_system_kind ());
  62.   else
  63.     fprintf_filtered (file, _("\
  64. The assumed file system kind for target reported file names \
  65. is \"%s\".\n"),
  66.                       value);
  67. }

  68. /* Provide a prototype to silence -Wmissing-prototypes.  */
  69. extern initialize_file_ftype _initialize_filesystem;

  70. void
  71. _initialize_filesystem (void)
  72. {
  73.   add_setshow_enum_cmd ("target-file-system-kind",
  74.                         class_files,
  75.                         target_file_system_kinds,
  76.                         &target_file_system_kind, _("\
  77. Set assumed file system kind for target reported file names"), _("\
  78. Show assumed file system kind for target reported file names"),
  79.                         _("\
  80. If `unix', target file names (e.g., loaded shared library file names)\n\
  81. starting the forward slash (`/') character are considered absolute,\n\
  82. and the directory separator character is the forward slash (`/').  If\n\
  83. `dos-based', target file names starting with a drive letter followed\n\
  84. by a colon (e.g., `c:'), are also considered absolute, and the\n\
  85. backslash (`\\') is also considered a directory separator.  Set to\n\
  86. `auto' (which is the default), to let GDB decide, based on its\n\
  87. knowledge of the target operating system."),
  88.                         NULL, /* setfunc */
  89.                         show_target_file_system_kind_command,
  90.                         &setlist, &showlist);
  91. }