Commit | Line | Data |
---|---|---|
efa86080 DE |
1 | /* Remote target system call callback support. |
2 | Copyright 1997 Free Software Foundation, Inc. | |
3 | ||
4 | This file is part of GDB. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2 of the License, or | |
9 | (at your option) any later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program; if not, write to the Free Software | |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
19 | ||
bf008f98 DE |
20 | /* ??? This interface isn't intended to be specific to any particular kind |
21 | of remote (hardware, simulator, whatever). However, at the present | |
22 | time it is only used by the simulators. At some point this should be | |
23 | an entity onto itself. For example, it's wrong that the definitions of the | |
24 | functions host_to_target_errno, target_to_host_open live in the simulator | |
25 | sources. It would also be wrong for such functions to live in gdb | |
26 | sources. Until such time perhaps it would be best to avoid adding | |
27 | prototypes of functions (and thus expanding the definition of the | |
28 | interface). */ | |
29 | ||
9d10b92d DE |
30 | #ifndef CALLBACK_H |
31 | #define CALLBACK_H | |
32 | ||
8902803f MM |
33 | #ifndef va_start |
34 | #include <ansidecl.h> | |
35 | #ifdef ANSI_PROTOTYPES | |
36 | #include <stdarg.h> | |
37 | #else | |
38 | #include <varargs.h> | |
39 | #endif | |
40 | #endif | |
41 | ||
9d10b92d DE |
42 | typedef struct host_callback_struct host_callback; |
43 | ||
44 | #define MAX_CALLBACK_FDS 10 | |
45 | ||
46 | struct host_callback_struct | |
47 | { | |
48 | int (*close) PARAMS ((host_callback *,int)); | |
49 | int (*get_errno) PARAMS ((host_callback *)); | |
50 | int (*isatty) PARAMS ((host_callback *, int)); | |
51 | int (*lseek) PARAMS ((host_callback *, int, long , int)); | |
52 | int (*open) PARAMS ((host_callback *, const char*, int mode)); | |
53 | int (*read) PARAMS ((host_callback *,int, char *, int)); | |
54 | int (*read_stdin) PARAMS (( host_callback *, char *, int)); | |
55 | int (*rename) PARAMS ((host_callback *, const char *, const char *)); | |
56 | int (*system) PARAMS ((host_callback *, const char *)); | |
57 | long (*time) PARAMS ((host_callback *, long *)); | |
58 | int (*unlink) PARAMS ((host_callback *, const char *)); | |
59 | int (*write) PARAMS ((host_callback *,int, const char *, int)); | |
60 | int (*write_stdout) PARAMS ((host_callback *, const char *, int)); | |
6d685937 AC |
61 | void (*flush_stdout) PARAMS ((host_callback *)); |
62 | int (*write_stderr) PARAMS ((host_callback *, const char *, int)); | |
63 | void (*flush_stderr) PARAMS ((host_callback *)); | |
9d10b92d | 64 | |
8517f62b AC |
65 | /* When present, call to the client to give it the oportunity to |
66 | poll any io devices for a request to quit (indicated by a nonzero | |
67 | return value). */ | |
68 | int (*poll_quit) PARAMS ((host_callback *)); | |
69 | ||
9d10b92d | 70 | /* Used when the target has gone away, so we can close open |
e1144153 | 71 | handles and free memory etc etc. */ |
9d10b92d DE |
72 | int (*shutdown) PARAMS ((host_callback *)); |
73 | int (*init) PARAMS ((host_callback *)); | |
74 | ||
6d685937 | 75 | /* depreciated, use vprintf_filtered - Talk to the user on a console. */ |
9d10b92d | 76 | void (*printf_filtered) PARAMS ((host_callback *, const char *, ...)); |
6d685937 | 77 | |
09e34873 | 78 | /* Talk to the user on a console. */ |
8902803f | 79 | void (*vprintf_filtered) PARAMS ((host_callback *, const char *, va_list)); |
6d685937 | 80 | |
efa86080 | 81 | /* Same as vprintf_filtered but to stderr. */ |
8902803f | 82 | void (*evprintf_filtered) PARAMS ((host_callback *, const char *, va_list)); |
efa86080 | 83 | |
e1144153 DE |
84 | /* Print an error message and "exit". |
85 | In the case of gdb "exiting" means doing a longjmp back to the main | |
86 | command loop. */ | |
87 | void (*error) PARAMS ((host_callback *, const char *, ...)); | |
9d10b92d DE |
88 | |
89 | int last_errno; /* host format */ | |
90 | ||
91 | int fdmap[MAX_CALLBACK_FDS]; | |
92 | char fdopen[MAX_CALLBACK_FDS]; | |
93 | char alwaysopen[MAX_CALLBACK_FDS]; | |
8517f62b AC |
94 | |
95 | /* Marker for thse wanting to do sanity checks. | |
96 | This should remain the last memeber of this struct to help catch | |
97 | miscompilation errors. */ | |
98 | #define HOST_CALLBACK_MAGIC 4705 /* teds constant */ | |
99 | int magic; | |
9d10b92d DE |
100 | }; |
101 | ||
102 | extern host_callback default_callback; | |
103 | ||
104 | /* Mapping of host/target values. */ | |
105 | /* ??? For debugging purposes, one might want to add a string of the | |
106 | name of the symbol. */ | |
107 | ||
108 | typedef struct { | |
109 | int host_val; | |
110 | int target_val; | |
111 | } target_defs_map; | |
112 | ||
113 | extern target_defs_map errno_map[]; | |
114 | extern target_defs_map open_map[]; | |
115 | ||
116 | extern int host_to_target_errno PARAMS ((int)); | |
117 | extern int target_to_host_open PARAMS ((int)); | |
118 | ||
119 | #endif |