OSDN Git Service

adcea6c558a2ae4d83eec9470a3604a829230a19
[pf3gnuchains/pf3gnuchains3x.git] / rda / include / gdbserv-utils.h
1 /* gdbserv-utils.h
2
3    Copyright 1998, 2000, 2002 Red Hat, Inc.
4
5    This file is part of RDA, the Red Hat Debug Agent (and library).
6
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.
11
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.
16
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.
21    
22    Alternative licenses for RDA may be arranged by contacting Red Hat,
23    Inc.  */
24
25 #ifdef __cplusplus
26 extern "C" {
27 #elif 0
28 }
29 #endif
30
31 struct gdbserv;
32 struct gdbserv_reg;
33
34 /* Return the ASCII equivalent of C (C>=0 && C<=15). The result will be 
35    lower-case. */
36
37 extern unsigned char gdbserv_to_hex (int c);
38 extern int gdbserv_hex_to (unsigned char c);
39
40 extern unsigned int gdbserv_ulong_to_hex (char *ptr, unsigned long val, int num_bits);
41
42
43 extern unsigned int gdbserv_raw_to_hex (char **ptr, char *mem, int nr_bytes);
44
45 /* Convert between a REG and the native unsigned long/long-long. */
46
47 extern void gdbserv_reg_to_ulong (struct gdbserv *gdbserv,
48                                   const struct gdbserv_reg *reg,
49                                   unsigned long *val);
50
51 extern void gdbserv_reg_to_ulonglong (struct gdbserv *gdbserv,
52                                       const struct gdbserv_reg *reg,
53                                       unsigned long long *val);
54
55 extern void gdbserv_ulong_to_reg (struct gdbserv *gdbserv,
56                                   unsigned long val,
57                                   struct gdbserv_reg *reg);
58
59 extern void gdbserv_ulonglong_to_reg (struct gdbserv *gdbserv,
60                                       unsigned long long val,
61                                       struct gdbserv_reg *reg);
62
63 /* Convert between a REG and a buffer representing a numeric type.
64    Handle big endian and little endian cases explicitly.  */
65
66 extern void gdbserv_be_bytes_to_reg (struct gdbserv *gdbserv,
67                                      const void *buf,
68                                      int len,
69                                      struct gdbserv_reg *reg);
70
71 extern void gdbserv_le_bytes_to_reg (struct gdbserv *gdbserv,
72                                      const void *buf,
73                                      int len,
74                                      struct gdbserv_reg *reg);
75
76 extern void gdbserv_be_bytes_from_reg (struct gdbserv *gdbserv,
77                                        void *buf,
78                                        int *lenp,
79                                        const struct gdbserv_reg *reg);
80
81 extern void gdbserv_le_bytes_from_reg (struct gdbserv *gdbserv,
82                                        void *buf,
83                                        int *lenp,
84                                        const struct gdbserv_reg *reg);
85
86 /* Convert between a REG and a buffer representing a native numeric
87    type.  These are just wrappers for the routines above, but are
88    useful nonetheless since they free the caller from having to
89    worry about byte order issues.  */
90
91 extern void gdbserv_host_bytes_to_reg (struct gdbserv *gdbserv,
92                                        const void *buf,
93                                        int len,
94                                        struct gdbserv_reg *reg);
95
96 extern void gdbserv_host_bytes_from_reg (struct gdbserv *gdbserv,
97                                          void *buf,
98                                          int *lenp,
99                                          const struct gdbserv_reg *reg);
100
101 #ifdef __cplusplus
102 }
103 #endif