3 Copyright 1998, 2000, 2002 Red Hat, Inc.
5 This file is part of RDA, the Red Hat Debug Agent (and library).
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.
22 Alternative licenses for RDA may be arranged by contacting Red Hat,
34 /* Return the ASCII equivalent of C (C>=0 && C<=15). The result will be
37 extern unsigned char gdbserv_to_hex (int c);
38 extern int gdbserv_hex_to (unsigned char c);
40 extern unsigned int gdbserv_ulong_to_hex (char *ptr, unsigned long val, int num_bits);
43 extern unsigned int gdbserv_raw_to_hex (char **ptr, char *mem, int nr_bytes);
45 /* Convert between a REG and the native unsigned long/long-long. */
47 extern void gdbserv_reg_to_ulong (struct gdbserv *gdbserv,
48 const struct gdbserv_reg *reg,
51 extern void gdbserv_reg_to_ulonglong (struct gdbserv *gdbserv,
52 const struct gdbserv_reg *reg,
53 unsigned long long *val);
55 extern void gdbserv_ulong_to_reg (struct gdbserv *gdbserv,
57 struct gdbserv_reg *reg);
59 extern void gdbserv_ulonglong_to_reg (struct gdbserv *gdbserv,
60 unsigned long long val,
61 struct gdbserv_reg *reg);
63 /* Convert between a REG and a buffer representing a (possibly signed)
64 numeric type. Handle big endian and little endian cases explicitly.
65 When the source buffer is bigger than the destination buffer, the
66 least significant bytes (as appropriate for the endianess) are
67 transferred. When the source buffer is smaller than the destination,
68 the most significant bytes of the destination are padded appropriately.
70 Note that gdbserv_be_bytes_from_reg() and gdbserv_le_bytes_from_reg()
71 have a buffer length parameter, but not a register length
72 parameter. This is because the register length was obtained from a
73 register packet sent by the debug client. On the other hand,
74 gdbserv_be_bytes_to_reg() and gdbserv_le_bytes_to_reg() take both a
75 buffer length and the register length. This is because we're
76 constructing a register (which will likely be sent to the client)
77 of a particular size. */
79 extern void gdbserv_be_bytes_to_reg (struct gdbserv *gdbserv,
82 struct gdbserv_reg *reg,
86 extern void gdbserv_le_bytes_to_reg (struct gdbserv *gdbserv,
89 struct gdbserv_reg *reg,
93 extern void gdbserv_be_bytes_from_reg (struct gdbserv *gdbserv,
96 const struct gdbserv_reg *reg,
99 extern void gdbserv_le_bytes_from_reg (struct gdbserv *gdbserv,
102 const struct gdbserv_reg *reg,
105 /* Convert between a REG and a buffer representing a native unsigned
106 numeric type. These are just wrappers for the routines above, but
107 are useful nonetheless since they free the caller from having to
108 worry about byte order issues. */
110 extern void gdbserv_host_bytes_to_reg (struct gdbserv *gdbserv,
113 struct gdbserv_reg *reg,
117 extern void gdbserv_host_bytes_from_reg (struct gdbserv *gdbserv,
120 const struct gdbserv_reg *reg,