gdb/gdbserver/win32-arm-low.c - gdb

Global variables defined

Functions defined

Macros defined

Source code

  1. /* Copyright (C) 2007-2015 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 "win32-low.h"

  15. #ifndef CONTEXT_FLOATING_POINT
  16. #define CONTEXT_FLOATING_POINT 0
  17. #endif

  18. /* Defined in auto-generated file reg-arm.c.  */
  19. void init_registers_arm (void);
  20. extern const struct target_desc *tdesc_arm;

  21. static void
  22. arm_get_thread_context (win32_thread_info *th)
  23. {
  24.   th->context.ContextFlags = \
  25.     CONTEXT_FULL | \
  26.     CONTEXT_FLOATING_POINT;

  27.   GetThreadContext (th->h, &th->context);
  28. }

  29. #define context_offset(x) ((int)&(((CONTEXT *)NULL)->x))
  30. static const int mappings[] = {
  31.   context_offset (R0),
  32.   context_offset (R1),
  33.   context_offset (R2),
  34.   context_offset (R3),
  35.   context_offset (R4),
  36.   context_offset (R5),
  37.   context_offset (R6),
  38.   context_offset (R7),
  39.   context_offset (R8),
  40.   context_offset (R9),
  41.   context_offset (R10),
  42.   context_offset (R11),
  43.   context_offset (R12),
  44.   context_offset (Sp),
  45.   context_offset (Lr),
  46.   context_offset (Pc),
  47.   -1, /* f0 */
  48.   -1, /* f1 */
  49.   -1, /* f2 */
  50.   -1, /* f3 */
  51.   -1, /* f4 */
  52.   -1, /* f5 */
  53.   -1, /* f6 */
  54.   -1, /* f7 */
  55.   -1, /* fps */
  56.   context_offset (Psr),
  57. };
  58. #undef context_offset

  59. /* Return a pointer into a CONTEXT field indexed by gdb register number.
  60.    Return a pointer to an dummy register holding zero if there is no
  61.    corresponding CONTEXT field for the given register number.  */
  62. static char *
  63. regptr (CONTEXT* c, int r)
  64. {
  65.   if (mappings[r] < 0)
  66.   {
  67.     static ULONG zero;
  68.     /* Always force value to zero, in case the user tried to write
  69.        to this register before.  */
  70.     zero = 0;
  71.     return (char *) &zero;
  72.   }
  73.   else
  74.     return (char *) c + mappings[r];
  75. }

  76. /* Fetch register from gdbserver regcache data.  */
  77. static void
  78. arm_fetch_inferior_register (struct regcache *regcache,
  79.                              win32_thread_info *th, int r)
  80. {
  81.   char *context_offset = regptr (&th->context, r);
  82.   supply_register (regcache, r, context_offset);
  83. }

  84. /* Store a new register value into the thread context of TH.  */
  85. static void
  86. arm_store_inferior_register (struct regcache *regcache,
  87.                              win32_thread_info *th, int r)
  88. {
  89.   collect_register (regcache, r, regptr (&th->context, r));
  90. }

  91. static void
  92. arm_arch_setup (void)
  93. {
  94.   init_registers_arm ();
  95.   win32_tdesc = tdesc_arm;
  96. }

  97. /* Correct in either endianness.  We do not support Thumb yet.  */
  98. static const unsigned long arm_wince_breakpoint = 0xe6000010;
  99. #define arm_wince_breakpoint_len 4

  100. struct win32_target_ops the_low_target = {
  101.   arm_arch_setup,
  102.   sizeof (mappings) / sizeof (mappings[0]),
  103.   NULL, /* initial_stuff */
  104.   arm_get_thread_context,
  105.   NULL, /* prepare_to_resume */
  106.   NULL, /* thread_added */
  107.   arm_fetch_inferior_register,
  108.   arm_store_inferior_register,
  109.   NULL, /* single_step */
  110.   (const unsigned char *) &arm_wince_breakpoint,
  111.   arm_wince_breakpoint_len,
  112.   /* Watchpoint related functions.  See target.h for comments.  */
  113.   NULL, /* supports_z_point_type */
  114.   NULL, /* insert_point */
  115.   NULL, /* remove_point */
  116.   NULL, /* stopped_by_watchpoint */
  117.   NULL  /* stopped_data_address */
  118. };