Sorry, ENOPATCH,
(that's against current GDB head, but should be easy to
adjust to 6.8 if it doesn't apply)
On Wednesday 17 September 2008 22:22:10, Pedro Alves wrote:
> Sorry for the delay,
>
> On Sunday 07 September 2008 07:19:07, Danny Backx wrote:
> > When using the gdb we now have i cegcc svn, I used the automatic file
> > transfer (over synce) a lot. Is that possible with this version of gdb
> > too ?
>
> Not automatically, no, sorry. gdbserver doesn't use RAPI at all.
>
> But you *can* transfer manually. Check out "remote delete", "remote
> get", "remote put", in GDB's manual. It should work OOTB on gdb 6.8
> on a 32-bit host. If you're on a 64-bit host, you'll need the
> attached patch.
>
> Those commands were added for systems where pushings files over
> other protocols (RAPI/scp/ftp/rcp) is hard (when using gdbserver
> over a serial connection, for example).
--
Pedro Alves
2008-09-17 Pedro Alves <[EMAIL PROTECTED]>
* hostio.c (struct fd_list) <native_fd>: New member.
(record_fd, native_fd): New.
(handle_open, handle_pread, handle_pwrite, handle_close): Adjust
to native/internal mapping.
---
gdb/gdbserver/hostio.c | 68 ++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 59 insertions(+), 9 deletions(-)
Index: src/gdb/gdbserver/hostio.c
===================================================================
--- src.orig/gdb/gdbserver/hostio.c 2008-09-17 22:36:48.000000000 +0100
+++ src/gdb/gdbserver/hostio.c 2008-09-17 22:37:18.000000000 +0100
@@ -32,12 +32,47 @@ extern int remote_debug;
struct fd_list
{
int fd;
+ int native_fd;
struct fd_list *next;
};
static struct fd_list *open_fds;
static int
+record_fd (int native_fd)
+{
+ struct fd_list *new_fd, *fd_ptr, *prev_fd;
+
+ new_fd = malloc (sizeof (struct fd_list));
+ new_fd->native_fd = native_fd;
+ new_fd->next = open_fds;
+ new_fd->fd = 0;
+
+ for (prev_fd = NULL, fd_ptr = open_fds;
+ fd_ptr != NULL;
+ prev_fd = fd_ptr, fd_ptr = fd_ptr->next)
+ {
+ if (fd_ptr->fd == new_fd->fd)
+ new_fd->fd = fd_ptr->fd + 1;
+ else
+ break;
+ }
+
+ if (prev_fd)
+ {
+ new_fd->next = prev_fd->next;
+ prev_fd->next = new_fd;
+ }
+ else
+ {
+ new_fd->next = open_fds;
+ open_fds = new_fd;
+ }
+
+ return new_fd->fd;
+}
+
+static int
safe_fromhex (char a, int *nibble)
{
if (a >= '0' && a <= '9')
@@ -175,6 +210,18 @@ require_valid_fd (int fd)
return -1;
}
+static int
+native_fd (int fd)
+{
+ struct fd_list *fd_ptr;
+
+ for (fd_ptr = open_fds; fd_ptr != NULL; fd_ptr = fd_ptr->next)
+ if (fd_ptr->fd == fd)
+ return fd_ptr->native_fd;
+
+ return -1;
+}
+
/* Fill in own_buf with the last hostio error packet, however it
suitable for the target. */
static void
@@ -267,8 +314,7 @@ handle_open (char *own_buf)
{
char filename[PATH_MAX];
char *p;
- int fileio_flags, mode, flags, fd;
- struct fd_list *new_fd;
+ int fileio_flags, mode, flags, fd, native_fd;
p = own_buf + strlen ("vFile:open:");
@@ -286,20 +332,17 @@ handle_open (char *own_buf)
/* We do not need to convert MODE, since the fileio protocol
uses the standard values. */
- fd = open (filename, flags, mode);
+ native_fd = open (filename, flags, mode);
- if (fd == -1)
+ if (native_fd == -1)
{
hostio_error (own_buf);
return;
}
/* Record the new file descriptor. */
- new_fd = malloc (sizeof (struct fd_list));
- new_fd->fd = fd;
- new_fd->next = open_fds;
- open_fds = new_fd;
+ fd = record_fd (native_fd);
hostio_reply (own_buf, fd);
}
@@ -323,6 +366,8 @@ handle_pread (char *own_buf, int *new_pa
return;
}
+ fd = native_fd (fd);
+
data = malloc (len);
#ifdef HAVE_PREAD
ret = pread (fd, data, len, offset);
@@ -372,6 +417,8 @@ handle_pwrite (char *own_buf, int packet
return;
}
+ fd = native_fd (fd);
+
#ifdef HAVE_PWRITE
ret = pwrite (fd, data, len, offset);
#else
@@ -397,6 +444,7 @@ handle_close (char *own_buf)
int fd, ret;
char *p;
struct fd_list **open_fd_p, *old_fd;
+ int nfd;
p = own_buf + strlen ("vFile:close:");
@@ -408,7 +456,9 @@ handle_close (char *own_buf)
return;
}
- ret = close (fd);
+ nfd = native_fd (fd);
+
+ ret = close (nfd);
if (ret == -1)
{
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Cegcc-devel mailing list
Cegcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cegcc-devel