linux-arm-tdesc.cc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* Copyright (C) 2019-2022 Free Software Foundation, Inc.
  2. This file is part of GDB.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. #include "server.h"
  14. #include "linux-arm-tdesc.h"
  15. #include "tdesc.h"
  16. #include "arch/arm.h"
  17. #include <inttypes.h>
  18. /* All possible Arm target descriptors. */
  19. static struct target_desc *tdesc_arm_list[ARM_FP_TYPE_INVALID];
  20. /* See linux-arm-tdesc.h. */
  21. const target_desc *
  22. arm_linux_read_description (arm_fp_type fp_type)
  23. {
  24. struct target_desc *tdesc = tdesc_arm_list[fp_type];
  25. if (tdesc == nullptr)
  26. {
  27. tdesc = arm_create_target_description (fp_type);
  28. static const char *expedite_regs[] = { "r11", "sp", "pc", 0 };
  29. init_target_desc (tdesc, expedite_regs);
  30. tdesc_arm_list[fp_type] = tdesc;
  31. }
  32. return tdesc;
  33. }
  34. /* See linux-arm-tdesc.h. */
  35. arm_fp_type
  36. arm_linux_get_tdesc_fp_type (const target_desc *tdesc)
  37. {
  38. gdb_assert (tdesc != nullptr);
  39. /* Many of the tdesc_arm_list entries may not have been initialised yet. This
  40. is ok, because tdesc must be one of the initialised ones. */
  41. for (int i = ARM_FP_TYPE_NONE; i < ARM_FP_TYPE_INVALID; i++)
  42. {
  43. if (tdesc == tdesc_arm_list[i])
  44. return (arm_fp_type) i;
  45. }
  46. return ARM_FP_TYPE_INVALID;
  47. }