From: 'Daniel Jacobowitz' <drow@false.org>
To: Pierre Muller <muller@ics.u-strasbg.fr>
Cc: gdb-patches@sourceware.org
Subject: Re: [rfc] Remote file transfer support
Date: Mon, 03 Dec 2007 12:56:00 -0000 [thread overview]
Message-ID: <20071203125636.GA18863@caradoc.them.org> (raw)
In-Reply-To: <000001c83592$071fefd0$155fcf70$@u-strasbg.fr>
On Mon, Dec 03, 2007 at 10:51:08AM +0100, Pierre Muller wrote:
> Daniel,
>
> your patch breaks compilation of gdbserver on mingw32
> host.
> The problem is that pread and pwrite do not seem
> to be implemented:
> gcc -Wall -g -O2 -I. -I../../../purecvs/gdb/gdbserver
> -I../../../purecvs/gdb/gdbserver/../regformats
> -I../../../purecvs/gdb/gdbserver/../../include -I../../bfd
> -I../../../purecvs/gdb/gdbserver/../../bfd -o gdbserver.exe inferiors.o
> regcache.o remote-utils.o server.o signals.o target.o utils.o version.o
> mem-break.o hostio.o reg-i386.o win32-low.o win32-i386-low.o \
> -lwsock32
> hostio.o: In function
> `handle_vFile':c:/cygwin/usr/local/src/cvs/build-mingw/gdb/gdbserver/../../.
> ./purecvs/gdb/gdbserver/hostio.c:380: undefined reference to `pread'
> :c:/cygwin/usr/local/src/cvs/build-mingw/gdb/gdbserver/../../../purecvs/gdb/
> gdbserver/hostio.c:422: undefined reference to `pwrite'
> collect2: ld returned 1 exit status
> make[2]: *** [gdbserver.exe] Error 1
>
> Can this be fixed?
Sorry, I should have remembered that. Does this patch work?
--
Daniel Jacobowitz
CodeSourcery
2007-12-03 Daniel Jacobowitz <dan@codesourcery.com>
* config.in, configure: Regenerated.
* configure.ac: Check for pread and pwrite.
* hostio.c (handle_pread): Fall back to lseek and read.
(handle_pwrite): Fall back to lseek and write.
Index: config.in
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/config.in,v
retrieving revision 1.19
diff -u -p -r1.19 config.in
--- config.in 19 Sep 2007 14:41:50 -0000 1.19
+++ config.in 3 Dec 2007 12:55:11 -0000
@@ -53,6 +53,9 @@
/* Define to 1 if you have the <netinet/tcp.h> header file. */
#undef HAVE_NETINET_TCP_H
+/* Define to 1 if you have the `pread' function. */
+#undef HAVE_PREAD
+
/* Define to 1 if you have the `pread64' function. */
#undef HAVE_PREAD64
@@ -72,6 +75,9 @@
/* Define if the target supports PTRACE_GETREGS for register access. */
#undef HAVE_PTRACE_GETREGS
+/* Define to 1 if you have the `pwrite' function. */
+#undef HAVE_PWRITE
+
/* Define to 1 if you have the <sgtty.h> header file. */
#undef HAVE_SGTTY_H
Index: configure
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/configure,v
retrieving revision 1.30
diff -u -p -r1.30 configure
--- configure 15 Oct 2007 19:58:17 -0000 1.30
+++ configure 3 Dec 2007 12:55:11 -0000
@@ -3099,7 +3099,9 @@ fi
done
-for ac_func in pread64
+
+
+for ac_func in pread pwrite pread64
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
Index: configure.ac
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/configure.ac,v
retrieving revision 1.18
diff -u -p -r1.18 configure.ac
--- configure.ac 15 Oct 2007 19:58:17 -0000 1.18
+++ configure.ac 3 Dec 2007 12:55:11 -0000
@@ -41,7 +41,7 @@ AC_CHECK_HEADERS(sgtty.h termio.h termio
errno.h fcntl.h signal.h sys/file.h malloc.h dnl
sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
netinet/tcp.h arpa/inet.h sys/wait.h)
-AC_CHECK_FUNCS(pread64)
+AC_CHECK_FUNCS(pread pwrite pread64)
have_errno=no
AC_MSG_CHECKING(for errno)
Index: hostio.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/hostio.c,v
retrieving revision 1.3
diff -u -p -r1.3 hostio.c
--- hostio.c 1 Dec 2007 05:00:04 -0000 1.3
+++ hostio.c 3 Dec 2007 12:55:11 -0000
@@ -377,7 +377,13 @@ handle_pread (char *own_buf, int *new_pa
}
data = malloc (len);
+#ifdef HAVE_PREAD
ret = pread (fd, data, len, offset);
+#else
+ ret = lseek (fd, offset, SEEK_SET);
+ if (ret != -1)
+ ret = read (fd, data, len);
+#endif
if (ret == -1)
{
@@ -419,7 +425,13 @@ handle_pwrite (char *own_buf, int packet
return;
}
+#ifdef HAVE_PWRITE
ret = pwrite (fd, data, len, offset);
+#else
+ ret = lseek (fd, offset, SEEK_SET);
+ if (ret != -1)
+ ret = write (fd, data, len);
+#endif
if (ret == -1)
{
next prev parent reply other threads:[~2007-12-03 12:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-29 20:32 Daniel Jacobowitz
2007-10-31 21:35 ` Eli Zaretskii
2007-11-30 18:37 ` Daniel Jacobowitz
2007-11-30 21:22 ` Eli Zaretskii
2007-11-30 21:50 ` Daniel Jacobowitz
2007-12-01 4:10 ` Pedro Alves
2007-12-01 5:00 ` Daniel Jacobowitz
2007-12-03 9:51 ` Pierre Muller
2007-12-03 12:56 ` 'Daniel Jacobowitz' [this message]
2007-12-03 13:41 ` Pierre Muller
2007-12-16 21:54 ` 'Daniel Jacobowitz'
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071203125636.GA18863@caradoc.them.org \
--to=drow@false.org \
--cc=gdb-patches@sourceware.org \
--cc=muller@ics.u-strasbg.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox