GDBserver
tdesc.c
Go to the documentation of this file.
1 /* Copyright (C) 2012-2015 Free Software Foundation, Inc.
2 
3  This file is part of GDB.
4 
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 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 
18 #include "server.h"
19 #include "tdesc.h"
20 #include "regdef.h"
21 
22 void
24 {
25  int offset, i;
26 
27  offset = 0;
28  for (i = 0; i < tdesc->num_registers; i++)
29  {
30  tdesc->reg_defs[i].offset = offset;
31  offset += tdesc->reg_defs[i].size;
32  }
33 
34  tdesc->registers_size = offset / 8;
35 
36  /* Make sure PBUFSIZ is large enough to hold a full register
37  packet. */
38  gdb_assert (2 * tdesc->registers_size + 32 <= PBUFSIZ);
39 }
40 
41 #ifndef IN_PROCESS_AGENT
42 
43 static const struct target_desc default_description;
44 
45 void
47  const struct target_desc *src)
48 {
49  dest->reg_defs = src->reg_defs;
50  dest->num_registers = src->num_registers;
51  dest->expedite_regs = src->expedite_regs;
52  dest->registers_size = src->registers_size;
53  dest->xmltarget = src->xmltarget;
54 }
55 
56 const struct target_desc *
58 {
59  if (current_thread == NULL)
60  return &default_description;
61 
62  return current_process ()->tdesc;
63 }
64 
65 #endif
struct thread_info * current_thread
Definition: inferiors.c:28
const char ** expedite_regs
Definition: tdesc.h:41
static const struct target_desc default_description
Definition: tdesc.c:43
const char * xmltarget
Definition: tdesc.h:47
const struct target_desc * tdesc
Definition: inferiors.h:69
void copy_target_description(struct target_desc *dest, const struct target_desc *src)
Definition: tdesc.c:46
int num_registers
Definition: tdesc.h:34
int offset
Definition: tracepoint.c:179
#define gdb_assert(expr)
Definition: gdb_assert.h:33
struct process_info * current_process(void)
Definition: inferiors.c:356
int registers_size
Definition: tdesc.h:37
void init_target_desc(struct target_desc *tdesc)
Definition: tdesc.c:23
const struct target_desc * current_target_desc(void)
Definition: tdesc.c:57
struct reg * reg_defs
Definition: tdesc.h:30
#define PBUFSIZ
Definition: server.h:129