]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/gdbserver/tdesc.c
Update year range in copyright notice of all files owned by the GDB project.
[thirdparty/binutils-gdb.git] / gdb / gdbserver / tdesc.c
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
23 init_target_desc (struct target_desc *tdesc)
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
46 copy_target_description (struct target_desc *dest,
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 *
57 current_target_desc (void)
58 {
59 if (current_thread == NULL)
60 return &default_description;
61
62 return current_process ()->tdesc;
63 }
64
65 #endif