OSDN Git Service

Merge branch 'master' of git://github.com/monaka/binutils
[pf3gnuchains/pf3gnuchains3x.git] / rda / include / gdbserv.h
1 /* gdbserv.h
2
3    Copyright 1998, 2000, 2001, 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
33 /* A ``struct gdbserv_reg'' is an object for storing an arbitrary
34    numeric value in a system independant way.  Part of an input packet
35    will be parsed into a REG object (using gdbserv_input_reg_...) and
36    then later converted into a specific value (using
37    gdbserv_reg_to_...).  The bytes in BUF are always ordered
38    big-endian. */
39
40 enum {
41   GDBSERV_REG_SIZE = 16 /* space for a 128-bit quantity */
42 };
43 struct gdbserv_reg {
44   int negative_p;
45   int len;
46   unsigned char buf[GDBSERV_REG_SIZE];
47 };
48
49
50
51 /* Fetch data from the current input packet.
52    Return -1 on error. */
53
54
55 /* Number of characters remaining in input packet */
56 int gdbserv_input_size (struct gdbserv *gdbserv);
57
58 /* NIBBLE: 4 bit quantity represented by a single HEX digit.
59    BYTE: 8 bit quantity represented by two HEX digits. */
60 int gdbserv_input_nibble (struct gdbserv *gdbserv);
61 int gdbserv_input_byte (struct gdbserv *gdbserv);
62
63 /* BYTES: LEN 8 bit stream represented by LEN*2 HEX digits.
64    BINARY: LEN 8 bit stream represented by LEN bytes + escape characters */
65 int gdbserv_input_bytes (struct gdbserv *gdbserv, char *buf, int len);
66 int gdbserv_input_escaped_binary (struct gdbserv *gdbserv, char *buf, int len);
67
68 /* Next character/string in packet.  Return -1 on error. */
69 int gdbserv_input_peek (struct gdbserv *gdbserv);
70 int gdbserv_input_char (struct gdbserv *gdbserv);
71 int gdbserv_input_string (struct gdbserv *gdbserv, char *buf, int len);
72
73 /* Peek at input packet comparing next few characters against STRING.
74    Return -1 on non or partial match.  Return strlen (STRING) on full
75    match and skip corresponding number of characters in input
76    packet. */
77 int gdbserv_input_string_match (struct gdbserv *gdbserv, const char *string);
78
79 /* Set VAL to a SMALL (unsigned) integer encoded in (network byte
80    ordered) HEX.  Return a negative value if there is a parse
81    error. */
82 int gdbserv_input_hex_long (struct gdbserv *gdbserv, long *val);
83 int gdbserv_input_hex_ulong (struct gdbserv *gdbserv, unsigned long *val);
84
85 /* Parse a HEX value of almost arbitrary length into the ``struct
86    gdbserv_reg''.  When BYTE_LEN is zero, it may include a leading
87    minus sign. When BYTE_LEN is non-zero it indicates the exact number
88    of RAW BYTES (HEX digits / 2) that should be transfered to
89    REG. ..._hex_beb () expects a true big-endian hex value.
90    ..._hex_leb () expects a hybrid little-endian hex value - the bytes
91    are ordered little-endian but the hex encoded nibble-pair that make
92    up a byte is ordered big endian (ex: 0x12345678 is leb encoded as
93    78563412). */
94 int gdbserv_input_reg_beb (struct gdbserv *gdbserv, struct gdbserv_reg *reg, int byte_len);
95 int gdbserv_input_reg_leb (struct gdbserv *gdbserv, struct gdbserv_reg *reg, int byte_len);
96
97
98 /* Write data to the current output packet. */
99
100
101 /* Integer values converted to HEX. */
102 void gdbserv_output_nibble (struct gdbserv *gdbserv, int h);
103 void gdbserv_output_byte (struct gdbserv *gdbserv, int h);
104 void gdbserv_output_bytes (struct gdbserv *gdbserv, const char *buf, unsigned sizeof_buf); 
105
106 /* Character values output verbatum. */
107 void gdbserv_output_char (struct gdbserv *gdbserv, char c);
108 void gdbserv_output_string (struct gdbserv *gdbserv, const char *buf);
109 void gdbserv_output_string_as_bytes (struct gdbserv *gdbserv, const char *buf);
110
111
112 /* Output a HEX value of almost arbitrary length in ``struct
113    gdbserv_reg''.  May include a leading minus sign.  When BYTE_LEN is
114    non-zero this specifies the exact number of RAW bytes (two HEX
115    characters per byte) that should be output. */
116 /* FIXME: Can't have both a leading minus sign and a non-zero
117    BYTE_LENGTH. */
118 void gdbserv_output_reg_beb (struct gdbserv *gdbserv, struct gdbserv_reg *reg, int byte_len);
119 void gdbserv_output_reg_leb (struct gdbserv *gdbserv, struct gdbserv_reg *reg, int byte_len);
120
121 #ifdef __cplusplus
122 }
123 #endif