1 |
104 |
markom |
/* Generic support for remote debugging interfaces.
|
2 |
|
|
|
3 |
|
|
Copyright 1993 Free Software Foundation, Inc.
|
4 |
|
|
|
5 |
|
|
This file is part of GDB.
|
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 |
|
|
#ifndef REMOTE_UTILS_H
|
23 |
|
|
#define REMOTE_UTILS_H
|
24 |
|
|
|
25 |
|
|
#include "serial.h"
|
26 |
|
|
#include "target.h"
|
27 |
|
|
#include "dcache.h"
|
28 |
|
|
|
29 |
|
|
/* Stuff that should be shared (and handled consistently) among the various
|
30 |
|
|
remote targets. */
|
31 |
|
|
|
32 |
|
|
struct _sr_settings
|
33 |
|
|
{
|
34 |
|
|
unsigned int timeout;
|
35 |
|
|
|
36 |
|
|
int retries;
|
37 |
|
|
|
38 |
|
|
char *device;
|
39 |
|
|
serial_t desc;
|
40 |
|
|
|
41 |
|
|
};
|
42 |
|
|
|
43 |
|
|
extern struct _sr_settings sr_settings;
|
44 |
|
|
|
45 |
|
|
/* get and set debug value. */
|
46 |
|
|
#define sr_get_debug() (remote_debug)
|
47 |
|
|
#define sr_set_debug(newval) (remote_debug = (newval))
|
48 |
|
|
|
49 |
|
|
/* get and set timeout. */
|
50 |
|
|
#define sr_get_timeout() (sr_settings.timeout)
|
51 |
|
|
#define sr_set_timeout(newval) (sr_settings.timeout = (newval))
|
52 |
|
|
|
53 |
|
|
/* get and set device. */
|
54 |
|
|
#define sr_get_device() (sr_settings.device)
|
55 |
|
|
#define sr_set_device(newval) \
|
56 |
|
|
{ \
|
57 |
|
|
if (sr_settings.device) free(sr_settings.device); \
|
58 |
|
|
sr_settings.device = (newval); \
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
/* get and set descriptor value. */
|
62 |
|
|
#define sr_get_desc() (sr_settings.desc)
|
63 |
|
|
#define sr_set_desc(newval) (sr_settings.desc = (newval))
|
64 |
|
|
|
65 |
|
|
/* get and set retries. */
|
66 |
|
|
#define sr_get_retries() (sr_settings.retries)
|
67 |
|
|
#define sr_set_retries(newval) (sr_settings.retries = (newval))
|
68 |
|
|
|
69 |
|
|
#define sr_is_open() (sr_settings.desc != NULL)
|
70 |
|
|
|
71 |
|
|
#define sr_check_open() { if (!sr_is_open()) \
|
72 |
|
|
error ("Remote device not open"); }
|
73 |
|
|
|
74 |
|
|
struct gr_settings
|
75 |
|
|
{
|
76 |
|
|
/* This is our data cache. */
|
77 |
|
|
DCACHE *dcache;
|
78 |
|
|
char *prompt;
|
79 |
|
|
struct target_ops *ops;
|
80 |
|
|
int (*clear_all_breakpoints) PARAMS ((void));
|
81 |
|
|
memxferfunc readfunc;
|
82 |
|
|
memxferfunc writefunc;
|
83 |
|
|
void (*checkin) PARAMS ((void));
|
84 |
|
|
};
|
85 |
|
|
|
86 |
|
|
extern struct gr_settings *gr_settings;
|
87 |
|
|
|
88 |
|
|
/* get and set dcache. */
|
89 |
|
|
#define gr_get_dcache() (gr_settings->dcache)
|
90 |
|
|
#define gr_set_dcache(newval) (gr_settings->dcache = (newval))
|
91 |
|
|
|
92 |
|
|
/* get and set prompt. */
|
93 |
|
|
#define gr_get_prompt() (gr_settings->prompt)
|
94 |
|
|
#define gr_set_prompt(newval) (gr_settings->prompt = (newval))
|
95 |
|
|
|
96 |
|
|
/* get and set ops. */
|
97 |
|
|
#define gr_get_ops() (gr_settings->ops)
|
98 |
|
|
#define gr_set_ops(newval) (gr_settings->ops = (newval))
|
99 |
|
|
|
100 |
|
|
#define gr_clear_all_breakpoints() ((gr_settings->clear_all_breakpoints)())
|
101 |
|
|
#define gr_checkin() ((gr_settings->checkin)())
|
102 |
|
|
|
103 |
|
|
/* Keep discarding input until we see the prompt.
|
104 |
|
|
|
105 |
|
|
The convention for dealing with the prompt is that you
|
106 |
|
|
o give your command
|
107 |
|
|
o *then* wait for the prompt.
|
108 |
|
|
|
109 |
|
|
Thus the last thing that a procedure does with the serial line
|
110 |
|
|
will be an gr_expect_prompt(). Exception: resume does not
|
111 |
|
|
wait for the prompt, because the terminal is being handed over
|
112 |
|
|
to the inferior. However, the next thing which happens after that
|
113 |
|
|
is a bug_wait which does wait for the prompt.
|
114 |
|
|
Note that this includes abnormal exit, e.g. error(). This is
|
115 |
|
|
necessary to prevent getting into states from which we can't
|
116 |
|
|
recover. */
|
117 |
|
|
|
118 |
|
|
#define gr_expect_prompt() sr_expect(gr_get_prompt())
|
119 |
|
|
|
120 |
|
|
int gr_fetch_word PARAMS ((CORE_ADDR addr));
|
121 |
|
|
int gr_multi_scan PARAMS ((char *list[], int passthrough));
|
122 |
|
|
int sr_get_hex_digit PARAMS ((int ignore_space));
|
123 |
|
|
int sr_pollchar PARAMS ((void));
|
124 |
|
|
int sr_readchar PARAMS ((void));
|
125 |
|
|
int sr_timed_read PARAMS ((char *buf, int n));
|
126 |
|
|
long sr_get_hex_word PARAMS ((void));
|
127 |
|
|
void gr_close PARAMS ((int quitting));
|
128 |
|
|
void gr_create_inferior PARAMS ((char *execfile, char *args, char **env));
|
129 |
|
|
void gr_detach PARAMS ((char *args, int from_tty));
|
130 |
|
|
void gr_files_info PARAMS ((struct target_ops * ops));
|
131 |
|
|
void gr_generic_checkin PARAMS ((void));
|
132 |
|
|
void gr_kill PARAMS ((void));
|
133 |
|
|
void gr_mourn PARAMS ((void));
|
134 |
|
|
void gr_prepare_to_store PARAMS ((void));
|
135 |
|
|
void gr_store_word PARAMS ((CORE_ADDR addr, int word));
|
136 |
|
|
void sr_expect PARAMS ((char *string));
|
137 |
|
|
void sr_get_hex_byte PARAMS ((char *byt));
|
138 |
|
|
void sr_scan_args PARAMS ((char *proto, char *args));
|
139 |
|
|
void sr_write PARAMS ((char *a, int l));
|
140 |
|
|
void sr_write_cr PARAMS ((char *s));
|
141 |
|
|
|
142 |
|
|
void gr_open PARAMS ((char *args, int from_tty,
|
143 |
|
|
struct gr_settings * gr_settings));
|
144 |
|
|
void gr_load_image PARAMS ((char *, int from_tty));
|
145 |
|
|
#endif /* REMOTE_UTILS_H */
|