1997-03-14 01:13:15 +08:00
|
|
|
/* Remote target system call callback support.
|
|
|
|
Copyright 1997 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|
|
|
|
1996-11-20 16:42:22 +08:00
|
|
|
#ifndef CALLBACK_H
|
|
|
|
#define CALLBACK_H
|
|
|
|
|
1997-03-29 04:48:12 +08:00
|
|
|
#ifndef va_start
|
|
|
|
#include <ansidecl.h>
|
|
|
|
#ifdef ANSI_PROTOTYPES
|
|
|
|
#include <stdarg.h>
|
|
|
|
#else
|
|
|
|
#include <varargs.h>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
1996-11-20 16:42:22 +08:00
|
|
|
typedef struct host_callback_struct host_callback;
|
|
|
|
|
|
|
|
#define MAX_CALLBACK_FDS 10
|
|
|
|
|
|
|
|
struct host_callback_struct
|
|
|
|
{
|
|
|
|
int (*close) PARAMS ((host_callback *,int));
|
|
|
|
int (*get_errno) PARAMS ((host_callback *));
|
|
|
|
int (*isatty) PARAMS ((host_callback *, int));
|
|
|
|
int (*lseek) PARAMS ((host_callback *, int, long , int));
|
|
|
|
int (*open) PARAMS ((host_callback *, const char*, int mode));
|
|
|
|
int (*read) PARAMS ((host_callback *,int, char *, int));
|
|
|
|
int (*read_stdin) PARAMS (( host_callback *, char *, int));
|
|
|
|
int (*rename) PARAMS ((host_callback *, const char *, const char *));
|
|
|
|
int (*system) PARAMS ((host_callback *, const char *));
|
|
|
|
long (*time) PARAMS ((host_callback *, long *));
|
|
|
|
int (*unlink) PARAMS ((host_callback *, const char *));
|
|
|
|
int (*write) PARAMS ((host_callback *,int, const char *, int));
|
|
|
|
int (*write_stdout) PARAMS ((host_callback *, const char *, int));
|
1997-03-12 20:27:30 +08:00
|
|
|
void (*flush_stdout) PARAMS ((host_callback *));
|
|
|
|
int (*write_stderr) PARAMS ((host_callback *, const char *, int));
|
|
|
|
void (*flush_stderr) PARAMS ((host_callback *));
|
1996-11-20 16:42:22 +08:00
|
|
|
|
1997-04-18 20:24:52 +08:00
|
|
|
/* When present, call to the client to give it the oportunity to
|
|
|
|
poll any io devices for a request to quit (indicated by a nonzero
|
|
|
|
return value). */
|
|
|
|
int (*poll_quit) PARAMS ((host_callback *));
|
|
|
|
|
1996-11-20 16:42:22 +08:00
|
|
|
/* Used when the target has gone away, so we can close open
|
1996-12-09 09:12:03 +08:00
|
|
|
handles and free memory etc etc. */
|
1996-11-20 16:42:22 +08:00
|
|
|
int (*shutdown) PARAMS ((host_callback *));
|
|
|
|
int (*init) PARAMS ((host_callback *));
|
|
|
|
|
1997-03-12 20:27:30 +08:00
|
|
|
/* depreciated, use vprintf_filtered - Talk to the user on a console. */
|
1996-11-20 16:42:22 +08:00
|
|
|
void (*printf_filtered) PARAMS ((host_callback *, const char *, ...));
|
1997-03-12 20:27:30 +08:00
|
|
|
|
1997-04-17 21:46:50 +08:00
|
|
|
/* Talk to the user on a console. */
|
1997-03-29 04:48:12 +08:00
|
|
|
void (*vprintf_filtered) PARAMS ((host_callback *, const char *, va_list));
|
1997-03-12 20:27:30 +08:00
|
|
|
|
1997-03-14 01:13:15 +08:00
|
|
|
/* Same as vprintf_filtered but to stderr. */
|
1997-03-29 04:48:12 +08:00
|
|
|
void (*evprintf_filtered) PARAMS ((host_callback *, const char *, va_list));
|
1997-03-14 01:13:15 +08:00
|
|
|
|
1996-12-09 09:12:03 +08:00
|
|
|
/* Print an error message and "exit".
|
|
|
|
In the case of gdb "exiting" means doing a longjmp back to the main
|
|
|
|
command loop. */
|
|
|
|
void (*error) PARAMS ((host_callback *, const char *, ...));
|
1996-11-20 16:42:22 +08:00
|
|
|
|
|
|
|
int last_errno; /* host format */
|
|
|
|
|
|
|
|
int fdmap[MAX_CALLBACK_FDS];
|
|
|
|
char fdopen[MAX_CALLBACK_FDS];
|
|
|
|
char alwaysopen[MAX_CALLBACK_FDS];
|
1997-04-18 20:24:52 +08:00
|
|
|
|
|
|
|
/* Marker for thse wanting to do sanity checks.
|
|
|
|
This should remain the last memeber of this struct to help catch
|
|
|
|
miscompilation errors. */
|
|
|
|
#define HOST_CALLBACK_MAGIC 4705 /* teds constant */
|
|
|
|
int magic;
|
1996-11-20 16:42:22 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
extern host_callback default_callback;
|
|
|
|
|
|
|
|
/* Mapping of host/target values. */
|
|
|
|
/* ??? For debugging purposes, one might want to add a string of the
|
|
|
|
name of the symbol. */
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int host_val;
|
|
|
|
int target_val;
|
|
|
|
} target_defs_map;
|
|
|
|
|
|
|
|
extern target_defs_map errno_map[];
|
|
|
|
extern target_defs_map open_map[];
|
|
|
|
|
|
|
|
extern int host_to_target_errno PARAMS ((int));
|
|
|
|
extern int target_to_host_open PARAMS ((int));
|
|
|
|
|
1997-08-15 03:55:37 +08:00
|
|
|
/* Cover functions to the vprintf callbacks. */
|
|
|
|
extern void cb_printf PARAMS ((host_callback *, const char *, ...));
|
|
|
|
extern void cb_eprintf PARAMS ((host_callback *, const char *, ...));
|
|
|
|
|
1996-11-20 16:42:22 +08:00
|
|
|
#endif
|