1 /* Register support routines for the remote server for GDB.
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
28 static char *registers
;
29 static int register_bytes
;
31 static struct reg
*reg_defs
;
32 static int num_registers
;
34 const char **gdbserver_expedite_regs
;
37 registers_length (void)
39 return 2 * register_bytes
;
43 set_register_cache (struct reg
*regs
, int n
)
51 for (i
= 0; i
< n
; i
++)
53 regs
[i
].offset
= offset
;
54 offset
+= regs
[i
].size
;
57 register_bytes
= offset
/ 8;
58 registers
= malloc (offset
/ 8);
60 fatal ("Could not allocate register cache.");
64 registers_to_string (char *buf
)
66 convert_int_to_ascii (registers
, buf
, register_bytes
);
70 registers_from_string (char *buf
)
72 int len
= strlen (buf
);
74 if (len
!= register_bytes
* 2)
76 warning ("Wrong sized register packet (expected %d bytes, got %d)", 2*register_bytes
, len
);
77 if (len
> register_bytes
* 2)
78 len
= register_bytes
* 2;
80 convert_ascii_to_int (buf
, registers
, len
/ 2);
84 find_register_by_name (const char *name
)
88 for (i
= 0; i
< num_registers
; i
++)
89 if (!strcmp (name
, reg_defs
[i
].name
))
91 fatal ("Unknown register %s requested", name
);
96 find_regno (const char *name
)
100 for (i
= 0; i
< num_registers
; i
++)
101 if (!strcmp (name
, reg_defs
[i
].name
))
103 fatal ("Unknown register %s requested", name
);
108 find_register_by_number (int n
)
114 register_size (int n
)
116 return reg_defs
[n
].size
/ 8;
120 register_data (int n
)
122 return registers
+ (reg_defs
[n
].offset
/ 8);
126 supply_register (int n
, const char *buf
)
128 memcpy (register_data (n
), buf
, register_size (n
));
132 supply_register_by_name (const char *name
, const char *buf
)
134 supply_register (find_regno (name
), buf
);
138 collect_register (int n
, char *buf
)
140 memcpy (buf
, register_data (n
), register_size (n
));
144 collect_register_by_name (const char *name
, char *buf
)
146 collect_register (find_regno (name
), buf
);
This page took 0.033696 seconds and 5 git commands to generate.