filesystem.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* Handle different target file systems for GDB, the GNU Debugger.
  2. Copyright (C) 2010-2022 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. gdb_printf (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. gdb_printf (file, _("\
  64. The assumed file system kind for target reported file names \
  65. is \"%s\".\n"),
  66. value);
  67. }
  68. void _initialize_filesystem ();
  69. void
  70. _initialize_filesystem ()
  71. {
  72. add_setshow_enum_cmd ("target-file-system-kind",
  73. class_files,
  74. target_file_system_kinds,
  75. &target_file_system_kind, _("\
  76. Set assumed file system kind for target reported file names."), _("\
  77. Show assumed file system kind for target reported file names."),
  78. _("\
  79. If `unix', target file names (e.g., loaded shared library file names)\n\
  80. starting the forward slash (`/') character are considered absolute,\n\
  81. and the directory separator character is the forward slash (`/'). If\n\
  82. `dos-based', target file names starting with a drive letter followed\n\
  83. by a colon (e.g., `c:'), are also considered absolute, and the\n\
  84. backslash (`\\') is also considered a directory separator. Set to\n\
  85. `auto' (which is the default), to let GDB decide, based on its\n\
  86. knowledge of the target operating system."),
  87. NULL, /* setfunc */
  88. show_target_file_system_kind_command,
  89. &setlist, &showlist);
  90. }