alpha-linux-nat.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* Low level Alpha GNU/Linux interface, for GDB when running native.
  2. Copyright (C) 2005-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 "target.h"
  16. #include "regcache.h"
  17. #include "linux-nat-trad.h"
  18. #include "alpha-tdep.h"
  19. #include "gdbarch.h"
  20. #include "nat/gdb_ptrace.h"
  21. #include <alpha/ptrace.h>
  22. #include <sys/procfs.h>
  23. #include "gregset.h"
  24. /* The address of UNIQUE for ptrace. */
  25. #define ALPHA_UNIQUE_PTRACE_ADDR 65
  26. class alpha_linux_nat_target final : public linux_nat_trad_target
  27. {
  28. protected:
  29. /* Override linux_nat_trad_target methods. */
  30. CORE_ADDR register_u_offset (struct gdbarch *gdbarch,
  31. int regno, int store_p) override;
  32. };
  33. static alpha_linux_nat_target the_alpha_linux_nat_target;
  34. /* See the comment in m68k-tdep.c regarding the utility of these
  35. functions. */
  36. void
  37. supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp)
  38. {
  39. const long *regp = (const long *)gregsetp;
  40. /* PC is in slot 32, UNIQUE is in slot 33. */
  41. alpha_supply_int_regs (regcache, -1, regp, regp + 31, regp + 32);
  42. }
  43. void
  44. fill_gregset (const struct regcache *regcache,
  45. gdb_gregset_t *gregsetp, int regno)
  46. {
  47. long *regp = (long *)gregsetp;
  48. /* PC is in slot 32, UNIQUE is in slot 33. */
  49. alpha_fill_int_regs (regcache, regno, regp, regp + 31, regp + 32);
  50. }
  51. /* Now we do the same thing for floating-point registers.
  52. Again, see the comments in m68k-tdep.c. */
  53. void
  54. supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
  55. {
  56. const long *regp = (const long *)fpregsetp;
  57. /* FPCR is in slot 32. */
  58. alpha_supply_fp_regs (regcache, -1, regp, regp + 31);
  59. }
  60. void
  61. fill_fpregset (const struct regcache *regcache,
  62. gdb_fpregset_t *fpregsetp, int regno)
  63. {
  64. long *regp = (long *)fpregsetp;
  65. /* FPCR is in slot 32. */
  66. alpha_fill_fp_regs (regcache, regno, regp, regp + 31);
  67. }
  68. CORE_ADDR
  69. alpha_linux_nat_target::register_u_offset (struct gdbarch *gdbarch,
  70. int regno, int store_p)
  71. {
  72. if (regno == gdbarch_pc_regnum (gdbarch))
  73. return PC;
  74. if (regno == ALPHA_UNIQUE_REGNUM)
  75. return ALPHA_UNIQUE_PTRACE_ADDR;
  76. if (regno < gdbarch_fp0_regnum (gdbarch))
  77. return GPR_BASE + regno;
  78. else
  79. return FPR_BASE + regno - gdbarch_fp0_regnum (gdbarch);
  80. }
  81. void _initialize_alpha_linux_nat ();
  82. void
  83. _initialize_alpha_linux_nat ()
  84. {
  85. linux_target = &the_alpha_linux_nat_target;
  86. add_inf_child_target (&the_alpha_linux_nat_target);
  87. }