1 /* Remote target system call callback support.
2 Copyright 1997 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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. */
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
35 #ifdef ANSI_PROTOTYPES
42 typedef struct host_callback_struct host_callback
;
44 #define MAX_CALLBACK_FDS 10
46 struct host_callback_struct
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));
61 void (*flush_stdout
) PARAMS ((host_callback
*));
62 int (*write_stderr
) PARAMS ((host_callback
*, const char *, int));
63 void (*flush_stderr
) PARAMS ((host_callback
*));
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
68 int (*poll_quit
) PARAMS ((host_callback
*));
70 /* Used when the target has gone away, so we can close open
71 handles and free memory etc etc. */
72 int (*shutdown
) PARAMS ((host_callback
*));
73 int (*init
) PARAMS ((host_callback
*));
75 /* depreciated, use vprintf_filtered - Talk to the user on a console. */
76 void (*printf_filtered
) PARAMS ((host_callback
*, const char *, ...));
78 /* Talk to the user on a console. */
79 void (*vprintf_filtered
) PARAMS ((host_callback
*, const char *, va_list));
81 /* Same as vprintf_filtered but to stderr. */
82 void (*evprintf_filtered
) PARAMS ((host_callback
*, const char *, va_list));
84 /* Print an error message and "exit".
85 In the case of gdb "exiting" means doing a longjmp back to the main
87 void (*error
) PARAMS ((host_callback
*, const char *, ...));
89 int last_errno
; /* host format */
91 int fdmap
[MAX_CALLBACK_FDS
];
92 char fdopen
[MAX_CALLBACK_FDS
];
93 char alwaysopen
[MAX_CALLBACK_FDS
];
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 */
102 extern host_callback default_callback
;
104 /* Mapping of host/target values. */
105 /* ??? For debugging purposes, one might want to add a string of the
106 name of the symbol. */
113 extern target_defs_map errno_map
[];
114 extern target_defs_map open_map
[];
116 extern int host_to_target_errno
PARAMS ((int));
117 extern int target_to_host_open
PARAMS ((int));