3 Copyright 1998, 2000, 2001, 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,
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
41 GDBSERV_REG_SIZE = 16 /* space for a 128-bit quantity */
46 unsigned char buf[GDBSERV_REG_SIZE];
51 /* Fetch data from the current input packet.
52 Return -1 on error. */
55 /* Number of characters remaining in input packet */
56 int gdbserv_input_size (struct gdbserv *gdbserv);
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);
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);
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);
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
77 int gdbserv_input_string_match (struct gdbserv *gdbserv, const char *string);
79 /* Set VAL to a SMALL (unsigned) integer encoded in (network byte
80 ordered) HEX. Return a negative value if there is a parse
82 int gdbserv_input_hex_long (struct gdbserv *gdbserv, long *val);
83 int gdbserv_input_hex_ulong (struct gdbserv *gdbserv, unsigned long *val);
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
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);
98 /* Write data to the current output packet. */
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);
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);
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
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);