gdb/gdbserver/tdesc.c - gdb

Global variables defined

Functions defined

Source code

  1. /* Copyright (C) 2012-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 "tdesc.h"
  15. #include "regdef.h"

  16. void
  17. init_target_desc (struct target_desc *tdesc)
  18. {
  19.   int offset, i;

  20.   offset = 0;
  21.   for (i = 0; i < tdesc->num_registers; i++)
  22.     {
  23.       tdesc->reg_defs[i].offset = offset;
  24.       offset += tdesc->reg_defs[i].size;
  25.     }

  26.   tdesc->registers_size = offset / 8;

  27.   /* Make sure PBUFSIZ is large enough to hold a full register
  28.      packet.  */
  29.   gdb_assert (2 * tdesc->registers_size + 32 <= PBUFSIZ);
  30. }

  31. #ifndef IN_PROCESS_AGENT

  32. static const struct target_desc default_description;

  33. void
  34. copy_target_description (struct target_desc *dest,
  35.                          const struct target_desc *src)
  36. {
  37.   dest->reg_defs = src->reg_defs;
  38.   dest->num_registers = src->num_registers;
  39.   dest->expedite_regs = src->expedite_regs;
  40.   dest->registers_size = src->registers_size;
  41.   dest->xmltarget = src->xmltarget;
  42. }

  43. const struct target_desc *
  44. current_target_desc (void)
  45. {
  46.   if (current_thread == NULL)
  47.     return &default_description;

  48.   return current_process ()->tdesc;
  49. }

  50. #endif