nto-tdep.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /* nto-tdep.h - QNX Neutrino target header.
  2. Copyright (C) 2003-2022 Free Software Foundation, Inc.
  3. Contributed by QNX Software Systems Ltd.
  4. This file is part of GDB.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. #ifndef NTO_TDEP_H
  16. #define NTO_TDEP_H
  17. #include "solist.h"
  18. #include "osabi.h"
  19. #include "regset.h"
  20. #include "gdbthread.h"
  21. /* Target operations defined for Neutrino targets (<target>-nto-tdep.c). */
  22. struct nto_target_ops
  23. {
  24. /* The CPUINFO flags from the remote. Currently used by
  25. i386 for fxsave but future proofing other hosts.
  26. This is initialized in procfs_attach or nto_start_remote
  27. depending on our host/target. It would only be invalid
  28. if we were talking to an older pdebug which didn't support
  29. the cpuinfo message. */
  30. unsigned cpuinfo_flags;
  31. /* True if successfully retrieved cpuinfo from remote. */
  32. int cpuinfo_valid;
  33. /* Given a register, return an id that represents the Neutrino
  34. regset it came from. If reg == -1 update all regsets. */
  35. int (*regset_id) (int);
  36. void (*supply_gregset) (struct regcache *, char *);
  37. void (*supply_fpregset) (struct regcache *, char *);
  38. void (*supply_altregset) (struct regcache *, char *);
  39. /* Given a regset, tell gdb about registers stored in data. */
  40. void (*supply_regset) (struct regcache *, int, char *);
  41. /* Given a register and regset, calculate the offset into the regset
  42. and stuff it into the last argument. If regno is -1, calculate the
  43. size of the entire regset. Returns length of data, -1 if unknown
  44. regset, 0 if unknown register. */
  45. int (*register_area) (struct gdbarch *, int, int, unsigned *);
  46. /* Build the Neutrino register set info into the data buffer.
  47. Return -1 if unknown regset, 0 otherwise. */
  48. int (*regset_fill) (const struct regcache *, int, char *);
  49. /* Gives the fetch_link_map_offsets function exposure outside of
  50. solib-svr4.c so that we can override relocate_section_addresses(). */
  51. struct link_map_offsets *(*fetch_link_map_offsets) (void);
  52. /* Used by nto_elf_osabi_sniffer to determine if we're connected to an
  53. Neutrino target. */
  54. enum gdb_osabi (*is_nto_target) (bfd *abfd);
  55. };
  56. extern struct nto_target_ops current_nto_target;
  57. #define nto_cpuinfo_flags (current_nto_target.cpuinfo_flags)
  58. #define nto_cpuinfo_valid (current_nto_target.cpuinfo_valid)
  59. #define nto_regset_id (current_nto_target.regset_id)
  60. #define nto_supply_gregset (current_nto_target.supply_gregset)
  61. #define nto_supply_fpregset (current_nto_target.supply_fpregset)
  62. #define nto_supply_altregset (current_nto_target.supply_altregset)
  63. #define nto_supply_regset (current_nto_target.supply_regset)
  64. #define nto_register_area (current_nto_target.register_area)
  65. #define nto_regset_fill (current_nto_target.regset_fill)
  66. #define nto_fetch_link_map_offsets \
  67. (current_nto_target.fetch_link_map_offsets)
  68. #define nto_is_nto_target (current_nto_target.is_nto_target)
  69. /* Keep this consistant with neutrino syspage.h. */
  70. enum
  71. {
  72. CPUTYPE_X86,
  73. CPUTYPE_PPC,
  74. CPUTYPE_MIPS,
  75. CPUTYPE_SPARE,
  76. CPUTYPE_ARM,
  77. CPUTYPE_SH,
  78. CPUTYPE_UNKNOWN
  79. };
  80. enum
  81. {
  82. OSTYPE_QNX4,
  83. OSTYPE_NTO
  84. };
  85. /* These correspond to the DSMSG_* versions in dsmsgs.h. */
  86. enum
  87. {
  88. NTO_REG_GENERAL,
  89. NTO_REG_FLOAT,
  90. NTO_REG_SYSTEM,
  91. NTO_REG_ALT,
  92. NTO_REG_END
  93. };
  94. typedef char qnx_reg64[8];
  95. typedef struct _debug_regs
  96. {
  97. qnx_reg64 padding[1024];
  98. } nto_regset_t;
  99. struct nto_thread_info : public private_thread_info
  100. {
  101. short tid = 0;
  102. unsigned char state = 0;
  103. unsigned char flags = 0;
  104. std::string name;
  105. };
  106. static inline nto_thread_info *
  107. get_nto_thread_info (thread_info *thread)
  108. {
  109. return static_cast<nto_thread_info *> (thread->priv.get ());
  110. }
  111. /* Per-inferior data, common for both procfs and remote. */
  112. struct nto_inferior_data
  113. {
  114. /* Last stopped flags result from wait function */
  115. unsigned int stopped_flags = 0;
  116. /* Last known stopped PC */
  117. CORE_ADDR stopped_pc = 0;
  118. };
  119. /* Generic functions in nto-tdep.c. */
  120. void nto_init_solib_absolute_prefix (void);
  121. char **nto_parse_redirection (char *start_argv[], const char **in,
  122. const char **out, const char **err);
  123. void nto_relocate_section_addresses (struct so_list *,
  124. struct target_section *);
  125. int nto_map_arch_to_cputype (const char *);
  126. int nto_find_and_open_solib (const char *, unsigned,
  127. gdb::unique_xmalloc_ptr<char> *);
  128. enum gdb_osabi nto_elf_osabi_sniffer (bfd *abfd);
  129. void nto_initialize_signals (void);
  130. /* Dummy function for initializing nto_target_ops on targets which do
  131. not define a particular regset. */
  132. void nto_dummy_supply_regset (struct regcache *regcache, char *regs);
  133. int nto_in_dynsym_resolve_code (CORE_ADDR pc);
  134. const char *nto_extra_thread_info (struct target_ops *self, struct thread_info *);
  135. LONGEST nto_read_auxv_from_initial_stack (CORE_ADDR inital_stack,
  136. gdb_byte *readbuf,
  137. LONGEST len, size_t sizeof_auxv_t);
  138. struct nto_inferior_data *nto_inferior_data (struct inferior *inf);
  139. #endif /* NTO_TDEP_H */