2002-11-22 Andrew Cagney <ac131313@redhat.com>
* dv-core.c: Update copyright. sim/common contributed to the FSF.
* dv-glue.c, dv-pal.c, hw-base.c, hw-base.h, hw-device.c: Ditto.
* hw-device.h, hw-handles.c, hw-handles.h: Ditto.
* hw-instances.c, hw-instances.h, hw-properties.c: Ditto.
* hw-properties.h, hw-tree.c, hw-tree.h, sim-alu.h: Ditto.
* sim-basics.h, sim-bits.c, sim-bits.h, sim-config.c: Ditto.
* sim-config.h, sim-core.c, sim-core.h, sim-endian.c: Ditto.
* sim-endian.h, sim-events.c, sim-events.h, sim-inline.c: Ditto.
* sim-inline.h, sim-io.c, sim-io.h, sim-n-bits.h: Ditto.
* sim-n-core.h, sim-n-endian.h, sim-types.h: Ditto.
2002-11-23 01:12:05 +00:00
|
|
|
/* The common simulator framework for GDB, the GNU Debugger.
|
|
|
|
|
2015-01-01 09:32:14 +00:00
|
|
|
Copyright 2002-2015 Free Software Foundation, Inc.
|
2002-11-22 Andrew Cagney <ac131313@redhat.com>
* dv-core.c: Update copyright. sim/common contributed to the FSF.
* dv-glue.c, dv-pal.c, hw-base.c, hw-base.h, hw-device.c: Ditto.
* hw-device.h, hw-handles.c, hw-handles.h: Ditto.
* hw-instances.c, hw-instances.h, hw-properties.c: Ditto.
* hw-properties.h, hw-tree.c, hw-tree.h, sim-alu.h: Ditto.
* sim-basics.h, sim-bits.c, sim-bits.h, sim-config.c: Ditto.
* sim-config.h, sim-core.c, sim-core.h, sim-endian.c: Ditto.
* sim-endian.h, sim-events.c, sim-events.h, sim-inline.c: Ditto.
* sim-inline.h, sim-io.c, sim-io.h, sim-n-bits.h: Ditto.
* sim-n-core.h, sim-n-endian.h, sim-types.h: Ditto.
2002-11-23 01:12:05 +00:00
|
|
|
|
|
|
|
Contributed by Andrew Cagney and Red Hat.
|
|
|
|
|
|
|
|
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
|
2007-08-24 14:30:15 +00:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2002-11-22 Andrew Cagney <ac131313@redhat.com>
* dv-core.c: Update copyright. sim/common contributed to the FSF.
* dv-glue.c, dv-pal.c, hw-base.c, hw-base.h, hw-device.c: Ditto.
* hw-device.h, hw-handles.c, hw-handles.h: Ditto.
* hw-instances.c, hw-instances.h, hw-properties.c: Ditto.
* hw-properties.h, hw-tree.c, hw-tree.h, sim-alu.h: Ditto.
* sim-basics.h, sim-bits.c, sim-bits.h, sim-config.c: Ditto.
* sim-config.h, sim-core.c, sim-core.h, sim-endian.c: Ditto.
* sim-endian.h, sim-events.c, sim-events.h, sim-inline.c: Ditto.
* sim-inline.h, sim-io.c, sim-io.h, sim-n-bits.h: Ditto.
* sim-n-core.h, sim-n-endian.h, sim-types.h: Ditto.
2002-11-23 01:12:05 +00:00
|
|
|
(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
|
2007-08-24 14:30:15 +00:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "sim-main.h"
|
|
|
|
#include "sim-io.h"
|
|
|
|
#include "targ-vals.h"
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#if HAVE_FCNTL_H
|
|
|
|
#include <fcntl.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
1999-04-26 18:34:20 +00:00
|
|
|
/* Define the rate at which the simulator should poll the host
|
|
|
|
for a quit. */
|
|
|
|
#ifndef POLL_QUIT_INTERVAL
|
|
|
|
#define POLL_QUIT_INTERVAL 0x10
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int poll_quit_count = POLL_QUIT_INTERVAL;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
/* See the file include/callbacks.h for a description */
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_init (SIM_DESC sd)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
return STATE_CALLBACK (sd)->init (STATE_CALLBACK (sd));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_shutdown (SIM_DESC sd)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
return STATE_CALLBACK (sd)->shutdown (STATE_CALLBACK (sd));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_unlink (SIM_DESC sd,
|
|
|
|
const char *f1)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
return STATE_CALLBACK (sd)->unlink (STATE_CALLBACK (sd), f1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_time (SIM_DESC sd,
|
|
|
|
long *t)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
return STATE_CALLBACK (sd)->time (STATE_CALLBACK (sd), t);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_system (SIM_DESC sd, const char *s)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
return STATE_CALLBACK (sd)->system (STATE_CALLBACK (sd), s);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_rename (SIM_DESC sd,
|
|
|
|
const char *f1,
|
|
|
|
const char *f2)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
return STATE_CALLBACK (sd)->rename (STATE_CALLBACK (sd), f1, f2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_write_stdout (SIM_DESC sd,
|
|
|
|
const char *buf,
|
|
|
|
int len)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
switch (CURRENT_STDIO) {
|
|
|
|
case DO_USE_STDIO:
|
|
|
|
return STATE_CALLBACK (sd)->write_stdout (STATE_CALLBACK (sd), buf, len);
|
|
|
|
break;
|
|
|
|
case DONT_USE_STDIO:
|
|
|
|
return STATE_CALLBACK (sd)->write (STATE_CALLBACK (sd), 1, buf, len);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sim_io_error (sd, "sim_io_write_stdout: unaccounted switch\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_flush_stdout (SIM_DESC sd)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
switch (CURRENT_STDIO) {
|
|
|
|
case DO_USE_STDIO:
|
|
|
|
STATE_CALLBACK (sd)->flush_stdout (STATE_CALLBACK (sd));
|
|
|
|
break;
|
|
|
|
case DONT_USE_STDIO:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sim_io_error (sd, "sim_io_flush_stdout: unaccounted switch\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_write_stderr (SIM_DESC sd,
|
|
|
|
const char *buf,
|
|
|
|
int len)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
switch (CURRENT_STDIO) {
|
|
|
|
case DO_USE_STDIO:
|
|
|
|
return STATE_CALLBACK (sd)->write_stderr (STATE_CALLBACK (sd), buf, len);
|
|
|
|
break;
|
|
|
|
case DONT_USE_STDIO:
|
|
|
|
return STATE_CALLBACK (sd)->write (STATE_CALLBACK (sd), 2, buf, len);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sim_io_error (sd, "sim_io_write_stderr: unaccounted switch\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_flush_stderr (SIM_DESC sd)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
switch (CURRENT_STDIO) {
|
|
|
|
case DO_USE_STDIO:
|
|
|
|
STATE_CALLBACK (sd)->flush_stderr (STATE_CALLBACK (sd));
|
|
|
|
break;
|
|
|
|
case DONT_USE_STDIO:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sim_io_error (sd, "sim_io_flush_stderr: unaccounted switch\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_write (SIM_DESC sd,
|
|
|
|
int fd,
|
|
|
|
const char *buf,
|
|
|
|
int len)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
return STATE_CALLBACK (sd)->write (STATE_CALLBACK (sd), fd, buf, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_read_stdin (SIM_DESC sd,
|
|
|
|
char *buf,
|
|
|
|
int len)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
switch (CURRENT_STDIO) {
|
|
|
|
case DO_USE_STDIO:
|
|
|
|
return STATE_CALLBACK (sd)->read_stdin (STATE_CALLBACK (sd), buf, len);
|
|
|
|
break;
|
|
|
|
case DONT_USE_STDIO:
|
|
|
|
return STATE_CALLBACK (sd)->read (STATE_CALLBACK (sd), 0, buf, len);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sim_io_error (sd, "sim_io_read_stdin: unaccounted switch\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_read (SIM_DESC sd, int fd,
|
|
|
|
char *buf,
|
|
|
|
int len)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
return STATE_CALLBACK (sd)->read (STATE_CALLBACK (sd), fd, buf, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_open (SIM_DESC sd,
|
|
|
|
const char *name,
|
|
|
|
int flags)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
return STATE_CALLBACK (sd)->open (STATE_CALLBACK (sd), name, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_lseek (SIM_DESC sd,
|
|
|
|
int fd,
|
|
|
|
long off,
|
|
|
|
int way)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
return STATE_CALLBACK (sd)->lseek (STATE_CALLBACK (sd), fd, off, way);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_isatty (SIM_DESC sd,
|
|
|
|
int fd)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
return STATE_CALLBACK (sd)->isatty (STATE_CALLBACK (sd), fd);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_get_errno (SIM_DESC sd)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
return STATE_CALLBACK (sd)->get_errno (STATE_CALLBACK (sd));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_close (SIM_DESC sd,
|
|
|
|
int fd)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
return STATE_CALLBACK (sd)->close (STATE_CALLBACK (sd), fd);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_printf (SIM_DESC sd,
|
|
|
|
const char *fmt,
|
|
|
|
...)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
va_list ap;
|
2011-05-11 20:02:42 +00:00
|
|
|
va_start (ap, fmt);
|
1999-04-16 01:35:26 +00:00
|
|
|
STATE_CALLBACK (sd)->vprintf_filtered (STATE_CALLBACK (sd), fmt, ap);
|
2011-05-11 20:02:42 +00:00
|
|
|
va_end (ap);
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_vprintf (SIM_DESC sd,
|
|
|
|
const char *fmt,
|
|
|
|
va_list ap)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
STATE_CALLBACK (sd)->vprintf_filtered (STATE_CALLBACK (sd), fmt, ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_eprintf (SIM_DESC sd,
|
|
|
|
const char *fmt,
|
|
|
|
...)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
va_list ap;
|
2011-05-11 20:02:42 +00:00
|
|
|
va_start (ap, fmt);
|
1999-04-16 01:35:26 +00:00
|
|
|
STATE_CALLBACK (sd)->evprintf_filtered (STATE_CALLBACK (sd), fmt, ap);
|
2011-05-11 20:02:42 +00:00
|
|
|
va_end (ap);
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_evprintf (SIM_DESC sd,
|
|
|
|
const char *fmt,
|
|
|
|
va_list ap)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
STATE_CALLBACK (sd)->evprintf_filtered (STATE_CALLBACK (sd), fmt, ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_error (SIM_DESC sd,
|
|
|
|
const char *fmt,
|
|
|
|
...)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
if (sd == NULL || STATE_CALLBACK (sd) == NULL) {
|
|
|
|
va_list ap;
|
2011-05-11 20:02:42 +00:00
|
|
|
va_start (ap, fmt);
|
1999-04-16 01:35:26 +00:00
|
|
|
vfprintf (stderr, fmt, ap);
|
2011-05-11 20:02:42 +00:00
|
|
|
va_end (ap);
|
1999-04-16 01:35:26 +00:00
|
|
|
fprintf (stderr, "\n");
|
|
|
|
abort ();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
va_list ap;
|
2011-05-11 20:02:42 +00:00
|
|
|
va_start (ap, fmt);
|
1999-04-16 01:35:26 +00:00
|
|
|
STATE_CALLBACK (sd)->evprintf_filtered (STATE_CALLBACK (sd), fmt, ap);
|
2011-05-11 20:02:42 +00:00
|
|
|
va_end (ap);
|
1999-04-16 01:35:26 +00:00
|
|
|
STATE_CALLBACK (sd)->error (STATE_CALLBACK (sd), "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2011-05-11 20:02:42 +00:00
|
|
|
sim_io_poll_quit (SIM_DESC sd)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
1999-04-26 18:34:20 +00:00
|
|
|
if (STATE_CALLBACK (sd)->poll_quit != NULL && poll_quit_count-- < 0)
|
|
|
|
{
|
|
|
|
poll_quit_count = POLL_QUIT_INTERVAL;
|
|
|
|
if (STATE_CALLBACK (sd)->poll_quit (STATE_CALLBACK (sd)))
|
|
|
|
sim_stop (sd);
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Based on gdb-4.17/sim/ppc/main.c:sim_io_read_stdin().
|
|
|
|
|
|
|
|
FIXME: Should not be calling fcntl() or grubbing around inside of
|
|
|
|
->fdmap and ->errno.
|
|
|
|
|
|
|
|
FIXME: Some completly new mechanism for handling the general
|
|
|
|
problem of asynchronous IO is needed.
|
|
|
|
|
|
|
|
FIXME: This function does not supress the echoing (ECHO) of input.
|
|
|
|
Consequently polled input is always displayed.
|
|
|
|
|
|
|
|
FIXME: This function does not perform uncooked reads.
|
|
|
|
Consequently, data will not be read until an EOLN character has
|
|
|
|
been entered. A cntrl-d may force the early termination of a line */
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
sim_io_poll_read (SIM_DESC sd,
|
|
|
|
int sim_io_fd,
|
|
|
|
char *buf,
|
|
|
|
int sizeof_buf)
|
|
|
|
{
|
|
|
|
#if defined(O_NDELAY) && defined(F_GETFL) && defined(F_SETFL)
|
|
|
|
int fd = STATE_CALLBACK (sd)->fdmap[sim_io_fd];
|
|
|
|
int flags;
|
|
|
|
int status;
|
|
|
|
int nr_read;
|
|
|
|
int result;
|
|
|
|
STATE_CALLBACK (sd)->last_errno = 0;
|
|
|
|
/* get the old status */
|
|
|
|
flags = fcntl (fd, F_GETFL, 0);
|
|
|
|
if (flags == -1)
|
|
|
|
{
|
|
|
|
perror ("sim_io_poll_read");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* temp, disable blocking IO */
|
|
|
|
status = fcntl (fd, F_SETFL, flags | O_NDELAY);
|
|
|
|
if (status == -1)
|
|
|
|
{
|
|
|
|
perror ("sim_io_read_stdin");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* try for input */
|
|
|
|
nr_read = read (fd, buf, sizeof_buf);
|
|
|
|
if (nr_read >= 0)
|
|
|
|
{
|
|
|
|
/* printf ("<nr-read=%d>\n", nr_read); */
|
|
|
|
result = nr_read;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* nr_read < 0 */
|
|
|
|
result = -1;
|
|
|
|
STATE_CALLBACK (sd)->last_errno = errno;
|
|
|
|
}
|
|
|
|
/* return to regular vewing */
|
|
|
|
status = fcntl (fd, F_SETFL, flags);
|
|
|
|
if (status == -1)
|
|
|
|
{
|
|
|
|
perror ("sim_io_read_stdin");
|
|
|
|
/* return 0; */
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
#else
|
|
|
|
return sim_io_read (sd, sim_io_fd, buf, sizeof_buf);
|
|
|
|
#endif
|
|
|
|
}
|
2011-03-21 22:06:55 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
sim_io_stat (SIM_DESC sd, const char *path, struct stat *buf)
|
|
|
|
{
|
callback.h:struct host_callback_struct compilation error on Windows hosts.
On Windows, a recent gnulib update imported the lstat module, and
this caused a remote-sim.c build failure in struct host_callback_struct:
In file included from /[...]/gdb/remote-sim.c:34:0:
/[...]/gdb/../include/gdb/callback.h:93:9: error: duplicate member '_stati64'
int (*lstat) (host_callback *, const char *, struct stat *);
^
What happens it that gnulib's stat.h makes the following defines:
/* Large File Support on native Windows. */
#if 1
# define stat _stati64
#endif
and then:
#if 1
# if ! 0
/* mingw does not support symlinks, therefore it does not have lstat. But
without links, stat does just fine. */
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define lstat stat
# endif
So, the following fields in struct host_callback_struct...
int (*stat) (host_callback *, const char *, struct stat *);
int (*fstat) (host_callback *, int, struct stat *);
int (*lstat) (host_callback *, const char *, struct stat *);
... get translated to...
int (*_stati64) (host_callback *, const char *, struct _stati64 *);
int (*_fstati64) (host_callback *, int, struct _stati64 *);
int (*_stati64) (host_callback *, const char *, struct _stati64 *);
... which causes two fields to have the same name.
This patch fixes the issue by renaming the stat-related fields
by adding a "to_" prefix, similar to what is done in GDB's
target_ops vector.
include/gdb/ChangeLog:
* callback.h (struct host_callback_struct) <to_stat>: Renamed
from "stat".
<to_fstat>: Renamed from "fstat".
<to_lstat>: Renamed from "lstat".
sim/common/ChangeLog:
* sim-io.c (sim_io_stat, sim_io_fstat): Adjust calls to "stat"
and "fstat" callbacks by calls to "to_stat" and "to_fstat" (resp)
callbacks following renaming in callback.h.
* syscall.c (cb_syscall): Likewise. Adjust calls to "lstat"
callback by call to "to_lstat" callback
sim/cris/ChangeLog:
* traps.c (cris_break_13_handler): Adjust call to "fstat" callback
by call to "to_fstat" following renaming in callback.h.
sim/h8300/ChangeLog:
* compile.c (sim_resume): Adjust calls to "stat" and "fstat"
callbacks by calls to "to_stat" and "to_fstat" (resp) callbacks
following renaming in callback.h.
2014-12-03 07:33:13 +00:00
|
|
|
return STATE_CALLBACK (sd)->to_stat (STATE_CALLBACK (sd), path, buf);
|
2011-03-21 22:06:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sim_io_fstat (SIM_DESC sd, int fd, struct stat *buf)
|
|
|
|
{
|
callback.h:struct host_callback_struct compilation error on Windows hosts.
On Windows, a recent gnulib update imported the lstat module, and
this caused a remote-sim.c build failure in struct host_callback_struct:
In file included from /[...]/gdb/remote-sim.c:34:0:
/[...]/gdb/../include/gdb/callback.h:93:9: error: duplicate member '_stati64'
int (*lstat) (host_callback *, const char *, struct stat *);
^
What happens it that gnulib's stat.h makes the following defines:
/* Large File Support on native Windows. */
#if 1
# define stat _stati64
#endif
and then:
#if 1
# if ! 0
/* mingw does not support symlinks, therefore it does not have lstat. But
without links, stat does just fine. */
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define lstat stat
# endif
So, the following fields in struct host_callback_struct...
int (*stat) (host_callback *, const char *, struct stat *);
int (*fstat) (host_callback *, int, struct stat *);
int (*lstat) (host_callback *, const char *, struct stat *);
... get translated to...
int (*_stati64) (host_callback *, const char *, struct _stati64 *);
int (*_fstati64) (host_callback *, int, struct _stati64 *);
int (*_stati64) (host_callback *, const char *, struct _stati64 *);
... which causes two fields to have the same name.
This patch fixes the issue by renaming the stat-related fields
by adding a "to_" prefix, similar to what is done in GDB's
target_ops vector.
include/gdb/ChangeLog:
* callback.h (struct host_callback_struct) <to_stat>: Renamed
from "stat".
<to_fstat>: Renamed from "fstat".
<to_lstat>: Renamed from "lstat".
sim/common/ChangeLog:
* sim-io.c (sim_io_stat, sim_io_fstat): Adjust calls to "stat"
and "fstat" callbacks by calls to "to_stat" and "to_fstat" (resp)
callbacks following renaming in callback.h.
* syscall.c (cb_syscall): Likewise. Adjust calls to "lstat"
callback by call to "to_lstat" callback
sim/cris/ChangeLog:
* traps.c (cris_break_13_handler): Adjust call to "fstat" callback
by call to "to_fstat" following renaming in callback.h.
sim/h8300/ChangeLog:
* compile.c (sim_resume): Adjust calls to "stat" and "fstat"
callbacks by calls to "to_stat" and "to_fstat" (resp) callbacks
following renaming in callback.h.
2014-12-03 07:33:13 +00:00
|
|
|
return STATE_CALLBACK (sd)->to_fstat (STATE_CALLBACK (sd), fd, buf);
|
2011-03-21 22:06:55 +00:00
|
|
|
}
|