* [PATCH 0/7] eliminate deprecated_xfer_memory
@ 2014-02-19 20:29 Pedro Alves
2014-02-19 20:29 ` [PATCH 7/7] bsd-uthread.c: Don't install a to_xfer_partial method Pedro Alves
` (7 more replies)
0 siblings, 8 replies; 19+ messages in thread
From: Pedro Alves @ 2014-02-19 20:29 UTC (permalink / raw)
To: gdb-patches
This series converts the remaining targets that are still implementing
deprecated_xfer_memory hooks to use to_xfer_partial instead, and then
eliminates deprecated_xfer_memory completely. The last patch of the
series is a follow up cleanup that could go in anytime actually.
An --enable-targets=all build includes remote-mips.c,
remote-m32r-sdi.c and bsd-uthread.c, so those got built tested. I
have a djgpp cross compiler handy so I build tested go32-nat.c too.
I have no way to test nto-procfs.c (nto/qnx) nor procfs.c (Solaris).
I put this at:
https://github.com/palves/gdb.git deprecated_xfer_memory
for convenience if anyone wants to test.
I plan to put this in after a while.
Pedro Alves (7):
remote-mips.c: Don't install a deprecated_xfer_memory method
remote-m32r-sdi.c: Don't install a deprecated_xfer_memory method
procfs.c: Don't install a deprecated_xfer_memory method
nto-procfs.c: Don't install a deprecated_xfer_memory method
go32-nat.c: Don't install a deprecated_xfer_memory method
eliminate target_ops->deprecated_xfer_memory
bsd-uthread.c: Don't install a to_xfer_partial method
gdb/bsd-uthread.c | 16 -------
gdb/go32-nat.c | 76 ++++++++++++++++++++++---------
gdb/nto-procfs.c | 58 ++++++++++++++----------
gdb/procfs.c | 72 +++++++++++------------------
gdb/remote-m32r-sdi.c | 60 +++++++++++++++++--------
gdb/remote-mips.c | 65 +++++++++++++++++----------
gdb/target.c | 122 --------------------------------------------------
gdb/target.h | 26 -----------
8 files changed, 199 insertions(+), 296 deletions(-)
--
1.7.11.7
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 7/7] bsd-uthread.c: Don't install a to_xfer_partial method
2014-02-19 20:29 [PATCH 0/7] eliminate deprecated_xfer_memory Pedro Alves
@ 2014-02-19 20:29 ` Pedro Alves
2014-02-20 13:26 ` Mark Kettenis
2014-02-19 20:29 ` [PATCH 4/7] nto-procfs.c: Don't install a deprecated_xfer_memory method Pedro Alves
` (6 subsequent siblings)
7 siblings, 1 reply; 19+ messages in thread
From: Pedro Alves @ 2014-02-19 20:29 UTC (permalink / raw)
To: gdb-patches
Whatever the comment about deprecated_xfer_memory referred to,
deprecated_xfer_memory is gone now. There's no need to install a
target method that just delegates, as that's what the default
delegator does already.
Tested by building an --enable-targets=all gdb on x86_64 Fedora 17.
gdb/
2014-02-19 Pedro Alves <palves@redhat.com>
* bsd-uthread.c (bsd_uthread_xfer_partial): Delete function.
(bsd_uthread_target): Don't install bsd_uthread_xfer_partial as
to_xfer_partial method.
---
gdb/bsd-uthread.c | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index 39bc05a..5f55763 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -331,21 +331,6 @@ bsd_uthread_store_registers (struct target_ops *ops,
}
}
-/* Implement the to_xfer_partial target_ops method. FIXME: This
- function is only there because otherwise GDB tries to invoke
- deprecate_xfer_memory. */
-
-static enum target_xfer_status
-bsd_uthread_xfer_partial (struct target_ops *ops, enum target_object object,
- const char *annex, gdb_byte *readbuf,
- const gdb_byte *writebuf,
- ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
-{
- gdb_assert (ops->beneath->to_xfer_partial);
- return ops->beneath->to_xfer_partial (ops->beneath, object, annex, readbuf,
- writebuf, offset, len, xfered_len);
-}
-
static ptid_t
bsd_uthread_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *status, int options)
@@ -529,7 +514,6 @@ bsd_uthread_target (void)
t->to_mourn_inferior = bsd_uthread_mourn_inferior;
t->to_fetch_registers = bsd_uthread_fetch_registers;
t->to_store_registers = bsd_uthread_store_registers;
- t->to_xfer_partial = bsd_uthread_xfer_partial;
t->to_wait = bsd_uthread_wait;
t->to_resume = bsd_uthread_resume;
t->to_thread_alive = bsd_uthread_thread_alive;
--
1.7.11.7
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 1/7] remote-mips.c: Don't install a deprecated_xfer_memory method
2014-02-19 20:29 [PATCH 0/7] eliminate deprecated_xfer_memory Pedro Alves
` (3 preceding siblings ...)
2014-02-19 20:29 ` [PATCH 3/7] procfs.c: Don't install a deprecated_xfer_memory method Pedro Alves
@ 2014-02-19 20:29 ` Pedro Alves
2014-02-19 20:29 ` [PATCH 5/7] go32-nat.c: " Pedro Alves
` (2 subsequent siblings)
7 siblings, 0 replies; 19+ messages in thread
From: Pedro Alves @ 2014-02-19 20:29 UTC (permalink / raw)
To: gdb-patches
This removes another yet instance of a deprecated_xfer_memory user.
Tested by building a --enable-targets=all gdb, on x86-64 Fedora 17.
gdb/
2014-02-19 Pedro Alves <palves@redhat.com>
* remote-mips.c (mips_xfer_memory): Adjust as to_xfer_partial
helper.
(mips_xfer_partial): New function.
(_initialize_remote_mips): Don't install a deprecated_xfer_memory
hook. Install a to_xfer_partial hook.
---
gdb/remote-mips.c | 65 +++++++++++++++++++++++++++++++++++--------------------
1 file changed, 41 insertions(+), 24 deletions(-)
diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index 4338ffa..383d31c 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -98,10 +98,11 @@ static int mips_fetch_word (CORE_ADDR addr, unsigned int *valp);
static int mips_store_word (CORE_ADDR addr, unsigned int value,
int *old_contents);
-static int mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len,
- int write,
- struct mem_attrib *attrib,
- struct target_ops *target);
+static enum target_xfer_status mips_xfer_memory (gdb_byte *readbuf,
+ const gdb_byte *writebuf,
+ ULONGEST memaddr,
+ ULONGEST len,
+ ULONGEST *xfered_len);
static void mips_files_info (struct target_ops *ignore);
@@ -2141,18 +2142,17 @@ mips_store_word (CORE_ADDR addr, unsigned int val, int *old_contents)
return 0;
}
-/* Read or write LEN bytes from inferior memory at MEMADDR,
- transferring to or from debugger address MYADDR. Write to inferior
- if SHOULD_WRITE is nonzero. Returns length of data written or
- read; 0 for error. Note that protocol gives us the correct value
- for a longword, since it transfers values in ASCII. We want the
- byte values, so we have to swap the longword values. */
+/* Helper for mips_xfer_partial that handles memory transfers.
+ Arguments are like target_xfer_partial. Note that the protocol
+ gives us the correct value for a longword, since it transfers
+ values in ASCII. We want the byte values, so we have to swap the
+ longword values. */
static int mask_address_p = 1;
-static int
-mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
- struct mem_attrib *attrib, struct target_ops *target)
+static enum target_xfer_status
+mips_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf,
+ ULONGEST memaddr, ULONGEST len, ULONGEST *xfered_len)
{
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
int i;
@@ -2173,7 +2173,7 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
/* Allocate buffer of that many longwords. */
buffer = alloca (count * 4);
- if (write)
+ if (writebuf != NULL)
{
/* Fill start and end extra bytes of buffer with existing data. */
if (addr != memaddr || len < 4)
@@ -2181,7 +2181,7 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
unsigned int val;
if (mips_fetch_word (addr, &val))
- return 0;
+ return TARGET_XFER_E_IO;
/* Need part of initial word -- fetch it. */
store_unsigned_integer (&buffer[0], 4, byte_order, val);
@@ -2194,7 +2194,7 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
/* Need part of last word -- fetch it. FIXME: we do this even
if we don't need it. */
if (mips_fetch_word (addr + (count - 1) * 4, &val))
- return 0;
+ return TARGET_XFER_E_IO;
store_unsigned_integer (&buffer[(count - 1) * 4],
4, byte_order, val);
@@ -2202,7 +2202,7 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
/* Copy data to be written over corresponding part of buffer. */
- memcpy ((char *) buffer + (memaddr & 3), myaddr, len);
+ memcpy ((char *) buffer + (memaddr & 3), writebuf, len);
/* Write the entire buffer. */
@@ -2219,10 +2219,7 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
gdb_flush (gdb_stdout);
}
if (status)
- {
- errno = status;
- return 0;
- }
+ return TARGET_XFER_E_IO;
/* FIXME: Do we want a QUIT here? */
}
if (count >= 256)
@@ -2236,18 +2233,38 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
unsigned int val;
if (mips_fetch_word (addr, &val))
- return 0;
+ return TARGET_XFER_E_IO;
store_unsigned_integer (&buffer[i * 4], 4, byte_order, val);
QUIT;
}
/* Copy appropriate bytes out of the buffer. */
- memcpy (myaddr, buffer + (memaddr & 3), len);
+ memcpy (readbuf, buffer + (memaddr & 3), len);
}
return len;
}
+/* Target to_xfer_partial implementation. */
+
+static enum target_xfer_status
+mips_xfer_partial (struct target_ops *ops, enum target_object object,
+ const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
+ ULONGEST *xfered_len)
+{
+ switch (object)
+ {
+ case TARGET_OBJECT_MEMORY:
+ return mips_xfer_memory (readbuf, writebuf, offset, len, xfered_len);
+
+ default:
+ return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
+ readbuf, writebuf, offset, len,
+ xfered_len);
+ }
+}
+
/* Print info on this target. */
static void
@@ -3623,7 +3640,7 @@ _initialize_remote_mips (void)
mips_ops.to_fetch_registers = mips_fetch_registers;
mips_ops.to_store_registers = mips_store_registers;
mips_ops.to_prepare_to_store = mips_prepare_to_store;
- mips_ops.deprecated_xfer_memory = mips_xfer_memory;
+ mips_ops.to_xfer_partial = mips_xfer_partial;
mips_ops.to_files_info = mips_files_info;
mips_ops.to_insert_breakpoint = mips_insert_breakpoint;
mips_ops.to_remove_breakpoint = mips_remove_breakpoint;
--
1.7.11.7
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 6/7] eliminate target_ops->deprecated_xfer_memory
2014-02-19 20:29 [PATCH 0/7] eliminate deprecated_xfer_memory Pedro Alves
2014-02-19 20:29 ` [PATCH 7/7] bsd-uthread.c: Don't install a to_xfer_partial method Pedro Alves
2014-02-19 20:29 ` [PATCH 4/7] nto-procfs.c: Don't install a deprecated_xfer_memory method Pedro Alves
@ 2014-02-19 20:29 ` Pedro Alves
2014-02-19 20:29 ` [PATCH 3/7] procfs.c: Don't install a deprecated_xfer_memory method Pedro Alves
` (4 subsequent siblings)
7 siblings, 0 replies; 19+ messages in thread
From: Pedro Alves @ 2014-02-19 20:29 UTC (permalink / raw)
To: gdb-patches
As no target uses it anymore, it can finally go away.
After removing the deprecated_xfer_memory handling from
default_xfer_partial, we can delete the latter, because the only thing
it does is delegate to the target beneath unconditionally, which is
what the delegator installed by target-delegates.c will do for us if
no to_xfer_partial method is installed.
This was the last user of de_fault, so that goes away too.
Tested on x86_64 Fedora 17.
gdb/
2014-02-19 Pedro Alves <palves@redhat.com>
* target.c (complete_target_initialization): Don't install
default_xfer_partial as to_xfer_partial hook.
(nomemory): Delete.
(update_current_target): Don't INHERIT nor de_fault
deprecated_xfer_memory. Delete de_fault macro.
(default_xfer_partial, deprecated_debug_xfer_memory): Delete.
(setup_target_debug): Don't install a deprecated_xfer_memory hook.
* target.h (struct target_ops) <deprecated_xfer_memory>: Delete
field.
---
gdb/target.c | 122 -----------------------------------------------------------
gdb/target.h | 26 -------------
2 files changed, 148 deletions(-)
diff --git a/gdb/target.c b/gdb/target.c
index 4adc094..752d933 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -75,8 +75,6 @@ static int default_search_memory (struct target_ops *ops,
static void tcomplain (void) ATTRIBUTE_NORETURN;
-static int nomemory (CORE_ADDR, char *, int, int, struct target_ops *);
-
static int return_zero (struct target_ops *);
static int return_zero_has_execution (struct target_ops *, ptid_t);
@@ -87,8 +85,6 @@ static void target_command (char *, int);
static struct target_ops *find_default_run_target (char *);
-static target_xfer_partial_ftype default_xfer_partial;
-
static struct gdbarch *default_thread_architecture (struct target_ops *ops,
ptid_t ptid);
@@ -377,8 +373,6 @@ void
complete_target_initialization (struct target_ops *t)
{
/* Provide default values for all "must have" methods. */
- if (t->to_xfer_partial == NULL)
- t->to_xfer_partial = default_xfer_partial;
if (t->to_has_all_memory == NULL)
t->to_has_all_memory = return_zero;
@@ -523,14 +517,6 @@ target_terminal_inferior (void)
(*current_target.to_terminal_inferior) (¤t_target);
}
-static int
-nomemory (CORE_ADDR memaddr, char *myaddr, int len, int write,
- struct target_ops *t)
-{
- errno = EIO; /* Can't read/write this location. */
- return 0; /* No bytes handled. */
-}
-
static void
tcomplain (void)
{
@@ -610,28 +596,12 @@ update_current_target (void)
INHERIT (to_shortname, t);
INHERIT (to_longname, t);
INHERIT (to_attach_no_wait, t);
- INHERIT (deprecated_xfer_memory, t);
INHERIT (to_have_steppable_watchpoint, t);
INHERIT (to_have_continuable_watchpoint, t);
INHERIT (to_has_thread_control, t);
}
#undef INHERIT
- /* Clean up a target struct so it no longer has any zero pointers in
- it. Do not add any new de_faults here. Instead, use the
- delegation mechanism provided by make-target-delegates. */
-
-#define de_fault(field, value) \
- if (!current_target.field) \
- current_target.field = value
-
- de_fault (deprecated_xfer_memory,
- (int (*) (CORE_ADDR, gdb_byte *, int, int,
- struct mem_attrib *, struct target_ops *))
- nomemory);
-
-#undef de_fault
-
/* Finally, position the target-stack beneath the squashed
"current_target". That way code looking for a non-inherited
target method can quickly and simply find it. */
@@ -1658,56 +1628,6 @@ show_trust_readonly (struct ui_file *file, int from_tty,
value);
}
-/* More generic transfers. */
-
-static enum target_xfer_status
-default_xfer_partial (struct target_ops *ops, enum target_object object,
- const char *annex, gdb_byte *readbuf,
- const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
- ULONGEST *xfered_len)
-{
- if (object == TARGET_OBJECT_MEMORY
- && ops->deprecated_xfer_memory != NULL)
- /* If available, fall back to the target's
- "deprecated_xfer_memory" method. */
- {
- int xfered = -1;
-
- errno = 0;
- if (writebuf != NULL)
- {
- void *buffer = xmalloc (len);
- struct cleanup *cleanup = make_cleanup (xfree, buffer);
-
- memcpy (buffer, writebuf, len);
- xfered = ops->deprecated_xfer_memory (offset, buffer, len,
- 1/*write*/, NULL, ops);
- do_cleanups (cleanup);
- }
- if (readbuf != NULL)
- xfered = ops->deprecated_xfer_memory (offset, readbuf, len,
- 0/*read*/, NULL, ops);
- if (xfered > 0)
- {
- *xfered_len = (ULONGEST) xfered;
- return TARGET_XFER_E_IO;
- }
- else if (xfered == 0 && errno == 0)
- /* "deprecated_xfer_memory" uses 0, cross checked against
- ERRNO as one indication of an error. */
- return TARGET_XFER_EOF;
- else
- return TARGET_XFER_E_IO;
- }
- else
- {
- gdb_assert (ops->beneath != NULL);
- return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
- readbuf, writebuf, offset, len,
- xfered_len);
- }
-}
-
/* Target vector read/write partial wrapper functions. */
static enum target_xfer_status
@@ -3850,47 +3770,6 @@ target_decr_pc_after_break (struct gdbarch *gdbarch)
return current_target.to_decr_pc_after_break (¤t_target, gdbarch);
}
-static int
-deprecated_debug_xfer_memory (CORE_ADDR memaddr, bfd_byte *myaddr, int len,
- int write, struct mem_attrib *attrib,
- struct target_ops *target)
-{
- int retval;
-
- retval = debug_target.deprecated_xfer_memory (memaddr, myaddr, len, write,
- attrib, target);
-
- fprintf_unfiltered (gdb_stdlog,
- "target_xfer_memory (%s, xxx, %d, %s, xxx) = %d",
- paddress (target_gdbarch (), memaddr), len,
- write ? "write" : "read", retval);
-
- if (retval > 0)
- {
- int i;
-
- fputs_unfiltered (", bytes =", gdb_stdlog);
- for (i = 0; i < retval; i++)
- {
- if ((((intptr_t) &(myaddr[i])) & 0xf) == 0)
- {
- if (targetdebug < 2 && i > 0)
- {
- fprintf_unfiltered (gdb_stdlog, " ...");
- break;
- }
- fprintf_unfiltered (gdb_stdlog, "\n");
- }
-
- fprintf_unfiltered (gdb_stdlog, " %02x", myaddr[i] & 0xff);
- }
- }
-
- fputc_unfiltered ('\n', gdb_stdlog);
-
- return retval;
-}
-
static void
debug_to_files_info (struct target_ops *target)
{
@@ -4319,7 +4198,6 @@ setup_target_debug (void)
current_target.to_open = debug_to_open;
current_target.to_post_attach = debug_to_post_attach;
current_target.to_prepare_to_store = debug_to_prepare_to_store;
- current_target.deprecated_xfer_memory = deprecated_debug_xfer_memory;
current_target.to_files_info = debug_to_files_info;
current_target.to_insert_breakpoint = debug_to_insert_breakpoint;
current_target.to_remove_breakpoint = debug_to_remove_breakpoint;
diff --git a/gdb/target.h b/gdb/target.h
index 2cc3c13..a1fac30 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -423,32 +423,6 @@ struct target_ops
void (*to_prepare_to_store) (struct target_ops *, struct regcache *)
TARGET_DEFAULT_NORETURN (noprocess ());
- /* Transfer LEN bytes of memory between GDB address MYADDR and
- target address MEMADDR. If WRITE, transfer them to the target, else
- transfer them from the target. TARGET is the target from which we
- get this function.
-
- Return value, N, is one of the following:
-
- 0 means that we can't handle this. If errno has been set, it is the
- error which prevented us from doing it (FIXME: What about bfd_error?).
-
- positive (call it N) means that we have transferred N bytes
- starting at MEMADDR. We might be able to handle more bytes
- beyond this length, but no promises.
-
- negative (call its absolute value N) means that we cannot
- transfer right at MEMADDR, but we could transfer at least
- something at MEMADDR + N.
-
- NOTE: cagney/2004-10-01: This has been entirely superseeded by
- to_xfer_partial and inferior inheritance. */
-
- int (*deprecated_xfer_memory) (CORE_ADDR memaddr, gdb_byte *myaddr,
- int len, int write,
- struct mem_attrib *attrib,
- struct target_ops *target);
-
void (*to_files_info) (struct target_ops *)
TARGET_DEFAULT_IGNORE ();
int (*to_insert_breakpoint) (struct target_ops *, struct gdbarch *,
--
1.7.11.7
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 3/7] procfs.c: Don't install a deprecated_xfer_memory method
2014-02-19 20:29 [PATCH 0/7] eliminate deprecated_xfer_memory Pedro Alves
` (2 preceding siblings ...)
2014-02-19 20:29 ` [PATCH 6/7] eliminate target_ops->deprecated_xfer_memory Pedro Alves
@ 2014-02-19 20:29 ` Pedro Alves
2014-02-20 15:48 ` Joel Brobecker
2014-02-19 20:29 ` [PATCH 1/7] remote-mips.c: " Pedro Alves
` (3 subsequent siblings)
7 siblings, 1 reply; 19+ messages in thread
From: Pedro Alves @ 2014-02-19 20:29 UTC (permalink / raw)
To: gdb-patches
This removes yet another instance of a deprecated_xfer_memory user.
I don't have any way to test this.
gdb/
2014-02-19 Pedro Alves <palves@redhat.com>
* procfs.c (procfs_target): Don't install procfs_xfer_memory as
deprecated_xfer_memory hook.
(procfs_xfer_partial): Call procfs_xfer_memory instead
of the deprecated_xfer_memory target hook.
(procfs_xfer_memory): Adjust interface as a to_xfer_partial
helper.
---
gdb/procfs.c | 72 ++++++++++++++++++++++--------------------------------------
1 file changed, 26 insertions(+), 46 deletions(-)
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 822e1e0..8aa43f1 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -127,9 +127,9 @@ static void procfs_create_inferior (struct target_ops *, char *,
char *, char **, int);
static ptid_t procfs_wait (struct target_ops *,
ptid_t, struct target_waitstatus *, int);
-static int procfs_xfer_memory (CORE_ADDR, gdb_byte *, int, int,
- struct mem_attrib *attrib,
- struct target_ops *);
+static enum target_xfer_status procfs_xfer_memory (gdb_byte *,
+ const gdb_byte *,
+ ULONGEST, ULONGEST);
static target_xfer_partial_ftype procfs_xfer_partial;
static int procfs_thread_alive (struct target_ops *ops, ptid_t);
@@ -197,7 +197,6 @@ procfs_target (void)
t->to_fetch_registers = procfs_fetch_registers;
t->to_store_registers = procfs_store_registers;
t->to_xfer_partial = procfs_xfer_partial;
- t->deprecated_xfer_memory = procfs_xfer_memory;
t->to_pass_signals = procfs_pass_signals;
t->to_files_info = procfs_files_info;
t->to_stop = procfs_stop;
@@ -3986,13 +3985,7 @@ procfs_xfer_partial (struct target_ops *ops, enum target_object object,
switch (object)
{
case TARGET_OBJECT_MEMORY:
- if (readbuf)
- return (*ops->deprecated_xfer_memory) (offset, readbuf,
- len, 0/*read*/, NULL, ops);
- if (writebuf)
- return (*ops->deprecated_xfer_memory) (offset, (gdb_byte *) writebuf,
- len, 1/*write*/, NULL, ops);
- return TARGET_XFER_E_IO;
+ return procfs_xfer_memory (readbuf, writebuf, offset, len, xfered_len);
#ifdef NEW_PROC_API
case TARGET_OBJECT_AUXV:
@@ -4009,23 +4002,15 @@ procfs_xfer_partial (struct target_ops *ops, enum target_object object,
}
}
+/* Helper for procfs_xfer_partial that handles memory transfers.
+ Arguments are like target_xfer_partial. */
-/* Transfer LEN bytes between GDB address MYADDR and target address
- MEMADDR. If DOWRITE is non-zero, transfer them to the target,
- otherwise transfer them from the target. TARGET is unused.
-
- The return value is 0 if an error occurred or no bytes were
- transferred. Otherwise, it will be a positive value which
- indicates the number of bytes transferred between gdb and the
- target. (Note that the interface also makes provisions for
- negative values, but this capability isn't implemented here.) */
-
-static int
-procfs_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int dowrite,
- struct mem_attrib *attrib, struct target_ops *target)
+static enum target_xfer_status
+procfs_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf,
+ ULONGEST memaddr, ULONGEST len, ULONGEST *xfered_len)
{
procinfo *pi;
- int nbytes = 0;
+ int nbytes;
/* Find procinfo for main process. */
pi = find_procinfo_or_die (ptid_get_pid (inferior_ptid), 0);
@@ -4033,31 +4018,26 @@ procfs_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int dowrite,
open_procinfo_files (pi, FD_AS) == 0)
{
proc_warn (pi, "xfer_memory, open_proc_files", __LINE__);
- return 0;
+ return TARGET_XFER_E_IO;
}
- if (lseek (pi->as_fd, (off_t) memaddr, SEEK_SET) == (off_t) memaddr)
+ if (lseek (pi->as_fd, (off_t) memaddr, SEEK_SET) != (off_t) memaddr)
+ return TARGET_XFER_E_IO;
+
+ if (writebuf != NULL)
{
- if (dowrite)
- {
-#ifdef NEW_PROC_API
- PROCFS_NOTE ("write memory:\n");
-#else
- PROCFS_NOTE ("write memory:\n");
-#endif
- nbytes = write (pi->as_fd, myaddr, len);
- }
- else
- {
- PROCFS_NOTE ("read memory:\n");
- nbytes = read (pi->as_fd, myaddr, len);
- }
- if (nbytes < 0)
- {
- nbytes = 0;
- }
+ PROCFS_NOTE ("write memory:\n");
+ nbytes = write (pi->as_fd, writebuf, len);
+ }
+ else
+ {
+ PROCFS_NOTE ("read memory:\n");
+ nbytes = read (pi->as_fd, readbuf, len);
}
- return nbytes;
+ if (nbytes <= 0)
+ return TARGET_XFER_E_IO;
+ *xfered_len = nbytes;
+ return TARGET_XFER_OK;
}
/* Called by target_resume before making child runnable. Mark cached
--
1.7.11.7
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 4/7] nto-procfs.c: Don't install a deprecated_xfer_memory method
2014-02-19 20:29 [PATCH 0/7] eliminate deprecated_xfer_memory Pedro Alves
2014-02-19 20:29 ` [PATCH 7/7] bsd-uthread.c: Don't install a to_xfer_partial method Pedro Alves
@ 2014-02-19 20:29 ` Pedro Alves
2014-02-19 20:29 ` [PATCH 6/7] eliminate target_ops->deprecated_xfer_memory Pedro Alves
` (5 subsequent siblings)
7 siblings, 0 replies; 19+ messages in thread
From: Pedro Alves @ 2014-02-19 20:29 UTC (permalink / raw)
To: gdb-patches
This removes yet another instance of a deprecated_xfer_memory user.
I have no way to test this.
gdb/
2014-02-19 Pedro Alves <palves@redhat.com>
* nto-procfs.c (procfs_xfer_memory): Adjust interface as a
to_xfer_partial helper. Rewrite.
(procfs_xfer_partial): New function.
(init_procfs_ops): Don't install a deprecated_xfer_memory hook.
Install a to_xfer_partial hook.
---
gdb/nto-procfs.c | 58 +++++++++++++++++++++++++++++++++-----------------------
1 file changed, 34 insertions(+), 24 deletions(-)
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index d0bdc90..bdda7ce 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -59,10 +59,6 @@ static void procfs_open (char *, int);
static int procfs_can_run (struct target_ops *self);
-static int procfs_xfer_memory (CORE_ADDR, gdb_byte *, int, int,
- struct mem_attrib *attrib,
- struct target_ops *);
-
static void init_procfs_ops (void);
static ptid_t do_attach (ptid_t ptid);
@@ -849,30 +845,44 @@ procfs_fetch_registers (struct target_ops *ops,
nto_supply_altregset (regcache, (char *) ®.altreg);
}
-/* Copy LEN bytes to/from inferior's memory starting at MEMADDR
- from/to debugger memory starting at MYADDR. Copy from inferior
- if DOWRITE is zero or to inferior if DOWRITE is nonzero.
+/* Helper for procfs_xfer_partial that handles memory transfers.
+ Arguments are like target_xfer_partial. */
- Returns the length copied, which is either the LEN argument or
- zero. This xfer function does not do partial moves, since procfs_ops
- doesn't allow memory operations to cross below us in the target stack
- anyway. */
-static int
-procfs_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int dowrite,
- struct mem_attrib *attrib, struct target_ops *target)
+static enum target_xfer_status
+procfs_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf,
+ ULONGEST memaddr, ULONGEST len, ULONGEST *xfered_len)
{
- int nbytes = 0;
+ int nbytes;
+
+ if (lseek (ctl_fd, (off_t) memaddr, SEEK_SET) != (off_t) memaddr)
+ return TARGET_XFER_E_IO;
+
+ if (writebuf != NULL)
+ nbytes = write (ctl_fd, writebuf, len);
+ else
+ nbytes = read (ctl_fd, readbuf, len);
+ if (nbytes <= 0)
+ return TARGET_XFER_E_IO;
+ *xfered_len = nbytes;
+ return TARGET_XFER_OK;
+}
+
+/* Target to_xfer_partial implementation. */
- if (lseek (ctl_fd, (off_t) memaddr, SEEK_SET) == (off_t) memaddr)
+static enum target_xfer_status
+procfs_xfer_partial (struct target_ops *ops, enum target_object object,
+ const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
+ ULONGEST *xfered_len)
+{
+ switch (object)
{
- if (dowrite)
- nbytes = write (ctl_fd, myaddr, len);
- else
- nbytes = read (ctl_fd, myaddr, len);
- if (nbytes < 0)
- nbytes = 0;
+ case TARGET_OBJECT_MEMORY:
+ return procfs_xfer_memory (readbuf, writebuf, offset, len, xfered_len);
+ default:
+ return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
+ readbuf, writebuf, offset, len);
}
- return (nbytes);
}
/* Take a program previously attached to and detaches it.
@@ -1397,7 +1407,7 @@ init_procfs_ops (void)
procfs_ops.to_fetch_registers = procfs_fetch_registers;
procfs_ops.to_store_registers = procfs_store_registers;
procfs_ops.to_prepare_to_store = procfs_prepare_to_store;
- procfs_ops.deprecated_xfer_memory = procfs_xfer_memory;
+ procfs_ops.to_xfer_partial = procfs_xfer_partial;
procfs_ops.to_files_info = procfs_files_info;
procfs_ops.to_insert_breakpoint = procfs_insert_breakpoint;
procfs_ops.to_remove_breakpoint = procfs_remove_breakpoint;
--
1.7.11.7
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 5/7] go32-nat.c: Don't install a deprecated_xfer_memory method
2014-02-19 20:29 [PATCH 0/7] eliminate deprecated_xfer_memory Pedro Alves
` (4 preceding siblings ...)
2014-02-19 20:29 ` [PATCH 1/7] remote-mips.c: " Pedro Alves
@ 2014-02-19 20:29 ` Pedro Alves
[not found] ` <00c801cf2e59$acae60f0$060b22d0$@muller@ics-cnrs.unistra.fr>
2014-02-19 20:29 ` [PATCH 2/7] remote-m32r-sdi.c: " Pedro Alves
2014-02-20 18:27 ` [PATCH 0/7] eliminate deprecated_xfer_memory Tom Tromey
7 siblings, 1 reply; 19+ messages in thread
From: Pedro Alves @ 2014-02-19 20:29 UTC (permalink / raw)
To: gdb-patches
This removes yet another instance of a deprecated_xfer_memory user.
Unfortunately djgpp's write_child function takes a non-const buffer
pointer, while GDB's xfer_partial api passes a const pointer. To be
const-correct, we need to copy that buffer to a non-const buffer, and
pass the copy to write_child. This is actually what
target.c:default_xfer_partial itself does, when calling into the
ops->deprecated_xfer_memory hook.
Tested by cross-building djgpp gdb, on x86-64 Fedora 17.
gdb/
2014-02-19 Pedro Alves <palves@redhat.com>
* go32-nat.c (my_write_child): New function.
(go32_xfer_memory): Rewrite as to_xfer_partial helper.
(go32_xfer_partial): New function.
(init_go32_ops): Don't install a deprecated_xfer_memory hook.
Instad a to_xfer_partial hook.
---
gdb/go32-nat.c | 76 ++++++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 56 insertions(+), 20 deletions(-)
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index 2e91b12..7978a5e 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -577,31 +577,67 @@ go32_prepare_to_store (struct target_ops *self, struct regcache *regcache)
{
}
+
+/* Const-correct version of DJGPP's write_child, which unfortunately
+ takes a non-const buffer pointer. */
+
static int
-go32_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
- struct mem_attrib *attrib, struct target_ops *target)
+my_write_child (unsigned child_addr, const void *buf, unsigned len)
{
- if (write)
+ static void *buffer = NULL;
+ static unsigned buffer_len = 0;
+ int res;
+
+ if (buffer_len < len)
{
- if (write_child (memaddr, myaddr, len))
- {
- return 0;
- }
- else
- {
- return len;
- }
+ buffer = xrealloc (buffer, len);
+ buffer_len = len;
}
+
+ memcpy (buffer, buf, len);
+ res = write_child (child_addr, buffer, len);
+ xfree (buffer);
+ return res;
+}
+
+/* Helper for go32_xfer_partial that handles memory transfers.
+ Arguments are like target_xfer_partial. */
+
+static enum target_xfer_status
+go32_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf,
+ ULONGEST memaddr, ULONGEST len, ULONGEST *xfered_len)
+{
+ int res;
+
+ if (writebuf != NULL)
+ res = my_write_child (memaddr, writebuf, len);
else
+ res = read_child (memaddr, readbuf, len);
+
+ if (res <= 0)
+ return TARGET_XFER_E_IO;
+
+ *xfered_len = res;
+ return TARGET_XFER_OK;
+}
+
+/* Target to_xfer_partial implementation. */
+
+static enum target_xfer_status
+go32_xfer_partial (struct target_ops *ops, enum target_object object,
+ const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
+ ULONGEST *xfered_len)
+{
+ switch (object)
{
- if (read_child (memaddr, myaddr, len))
- {
- return 0;
- }
- else
- {
- return len;
- }
+ case TARGET_OBJECT_MEMORY:
+ return go32_xfer_memory (readbuf, writebuf, offset, len, xfered_len);
+
+ default:
+ return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
+ readbuf, writebuf, offset, len,
+ xfered_len);
}
}
@@ -957,7 +993,7 @@ init_go32_ops (void)
go32_ops.to_fetch_registers = go32_fetch_registers;
go32_ops.to_store_registers = go32_store_registers;
go32_ops.to_prepare_to_store = go32_prepare_to_store;
- go32_ops.deprecated_xfer_memory = go32_xfer_memory;
+ go32_ops.to_xfer_partial = go32_xfer_partial;
go32_ops.to_files_info = go32_files_info;
go32_ops.to_insert_breakpoint = memory_insert_breakpoint;
go32_ops.to_remove_breakpoint = memory_remove_breakpoint;
--
1.7.11.7
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 2/7] remote-m32r-sdi.c: Don't install a deprecated_xfer_memory method
2014-02-19 20:29 [PATCH 0/7] eliminate deprecated_xfer_memory Pedro Alves
` (5 preceding siblings ...)
2014-02-19 20:29 ` [PATCH 5/7] go32-nat.c: " Pedro Alves
@ 2014-02-19 20:29 ` Pedro Alves
2014-02-20 18:27 ` [PATCH 0/7] eliminate deprecated_xfer_memory Tom Tromey
7 siblings, 0 replies; 19+ messages in thread
From: Pedro Alves @ 2014-02-19 20:29 UTC (permalink / raw)
To: gdb-patches
This removes yet another instance of a deprecated_xfer_memory user.
Tested by building a --enable-targets=all gdb, on x86-64 Fedora 17.
gdb/
2014-02-19 Pedro Alves <palves@redhat.com>
* remote-m32r-sdi.c (send_data): Constify 'buf' parameter.
(m32r_xfer_memory): Adjust as a to_xfer_partial helper.
(m32r_xfer_partial): New function.
(init_m32r_ops): Don't install a deprecated_xfer_memory hook.
Install a to_xfer_partial hook.
---
gdb/remote-m32r-sdi.c | 60 +++++++++++++++++++++++++++++++++++----------------
1 file changed, 42 insertions(+), 18 deletions(-)
diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c
index 02a812a..0c23403 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -179,7 +179,7 @@ get_ack (void)
/* Send data to the target and check an ack packet. */
static int
-send_data (void *buf, int len)
+send_data (const void *buf, int len)
{
if (!sdi_desc)
return -1;
@@ -1032,11 +1032,12 @@ m32r_files_info (struct target_ops *target)
}
}
-/* Read/Write memory. */
-static int
-m32r_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len,
- int write,
- struct mem_attrib *attrib, struct target_ops *target)
+/* Helper for m32r_xfer_partial that handles memory transfers.
+ Arguments are like target_xfer_partial. */
+
+static enum target_xfer_status
+m32r_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf,
+ ULONGEST memaddr, ULONGEST len, ULONGEST *xfered_len)
{
unsigned long taddr;
unsigned char buf[0x2000];
@@ -1052,22 +1053,24 @@ m32r_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len,
if (remote_debug)
{
- if (write)
- fprintf_unfiltered (gdb_stdlog, "m32r_xfer_memory(%s,%d,write)\n",
- paddress (target_gdbarch (), memaddr), len);
+ if (writebuf != NULL)
+ fprintf_unfiltered (gdb_stdlog, "m32r_xfer_memory(%s,%s,write)\n",
+ paddress (target_gdbarch (), memaddr),
+ plongest (len));
else
- fprintf_unfiltered (gdb_stdlog, "m32r_xfer_memory(%s,%d,read)\n",
- paddress (target_gdbarch (), memaddr), len);
+ fprintf_unfiltered (gdb_stdlog, "m32r_xfer_memory(%s,%s,read)\n",
+ paddress (target_gdbarch (), memaddr),
+ plongest (len));
}
- if (write)
+ if (writebuf != NULL)
{
buf[0] = SDI_WRITE_MEMORY;
store_long_parameter (buf + 1, taddr);
store_long_parameter (buf + 5, len);
if (len < 0x1000)
{
- memcpy (buf + 9, myaddr, len);
+ memcpy (buf + 9, writebuf, len);
ret = send_data (buf, len + 9) - 9;
}
else
@@ -1079,7 +1082,7 @@ m32r_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len,
"m32r_xfer_memory() failed\n");
return 0;
}
- ret = send_data (myaddr, len);
+ ret = send_data (writebuf, len);
}
}
else
@@ -1102,17 +1105,38 @@ m32r_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len,
return 0;
}
- ret = recv_data (myaddr, len);
+ ret = recv_data (readbuf, len);
}
if (ret <= 0)
{
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "m32r_xfer_memory() fails\n");
- return 0;
+ return TARGET_XFER_E_IO;
}
- return ret;
+ *xfered_len = ret;
+ return TARGET_XFER_OK;
+}
+
+/* Target to_xfer_partial implementation. */
+
+static enum target_xfer_status
+m32r_xfer_partial (struct target_ops *ops, enum target_object object,
+ const char *annex, gdb_byte *readbuf,
+ const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
+ ULONGEST *xfered_len)
+{
+ switch (object)
+ {
+ case TARGET_OBJECT_MEMORY:
+ return m32r_xfer_memory (readbuf, writebuf, offset, len, xfered_len);
+
+ default:
+ return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
+ readbuf, writebuf, offset, len,
+ xfered_len);
+ }
}
static void
@@ -1635,7 +1659,7 @@ init_m32r_ops (void)
m32r_ops.to_fetch_registers = m32r_fetch_register;
m32r_ops.to_store_registers = m32r_store_register;
m32r_ops.to_prepare_to_store = m32r_prepare_to_store;
- m32r_ops.deprecated_xfer_memory = m32r_xfer_memory;
+ m32r_ops.to_xfer_partial = m32r_xfer_partial;
m32r_ops.to_files_info = m32r_files_info;
m32r_ops.to_insert_breakpoint = m32r_insert_breakpoint;
m32r_ops.to_remove_breakpoint = m32r_remove_breakpoint;
--
1.7.11.7
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 7/7] bsd-uthread.c: Don't install a to_xfer_partial method
2014-02-19 20:29 ` [PATCH 7/7] bsd-uthread.c: Don't install a to_xfer_partial method Pedro Alves
@ 2014-02-20 13:26 ` Mark Kettenis
2014-02-20 16:42 ` Pedro Alves
0 siblings, 1 reply; 19+ messages in thread
From: Mark Kettenis @ 2014-02-20 13:26 UTC (permalink / raw)
To: palves; +Cc: gdb-patches
> From: Pedro Alves <palves@redhat.com>
> Date: Wed, 19 Feb 2014 20:29:35 +0000
>
> Whatever the comment about deprecated_xfer_memory referred to,
> deprecated_xfer_memory is gone now. There's no need to install a
> target method that just delegates, as that's what the default
> delegator does already.
>
> Tested by building an --enable-targets=all gdb on x86_64 Fedora 17.
Sure. Go ahead. These days OpenBSD has real threads anyway; I just
need to find some time to integrate the changes I have lying around to
make that work with GDB.
> gdb/
> 2014-02-19 Pedro Alves <palves@redhat.com>
>
> * bsd-uthread.c (bsd_uthread_xfer_partial): Delete function.
> (bsd_uthread_target): Don't install bsd_uthread_xfer_partial as
> to_xfer_partial method.
> ---
> gdb/bsd-uthread.c | 16 ----------------
> 1 file changed, 16 deletions(-)
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 3/7] procfs.c: Don't install a deprecated_xfer_memory method
2014-02-19 20:29 ` [PATCH 3/7] procfs.c: Don't install a deprecated_xfer_memory method Pedro Alves
@ 2014-02-20 15:48 ` Joel Brobecker
2014-02-20 15:56 ` Joel Brobecker
0 siblings, 1 reply; 19+ messages in thread
From: Joel Brobecker @ 2014-02-20 15:48 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
Hi Pedro,
> This removes yet another instance of a deprecated_xfer_memory user.
>
> I don't have any way to test this.
>
> gdb/
> 2014-02-19 Pedro Alves <palves@redhat.com>
>
> * procfs.c (procfs_target): Don't install procfs_xfer_memory as
> deprecated_xfer_memory hook.
> (procfs_xfer_partial): Call procfs_xfer_memory instead
> of the deprecated_xfer_memory target hook.
> (procfs_xfer_memory): Adjust interface as a to_xfer_partial
> helper.
FYI: I tried to test it, but the sparc-solaris debugger appears to be
badly broken at the moment, and I won't have much time left this week
to investigate the failures, so I'll schedule that for next week.
--
Joel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 3/7] procfs.c: Don't install a deprecated_xfer_memory method
2014-02-20 15:48 ` Joel Brobecker
@ 2014-02-20 15:56 ` Joel Brobecker
2014-02-20 16:38 ` Pedro Alves
0 siblings, 1 reply; 19+ messages in thread
From: Joel Brobecker @ 2014-02-20 15:56 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 825 bytes --]
> > gdb/
> > 2014-02-19 Pedro Alves <palves@redhat.com>
> >
> > * procfs.c (procfs_target): Don't install procfs_xfer_memory as
> > deprecated_xfer_memory hook.
> > (procfs_xfer_partial): Call procfs_xfer_memory instead
> > of the deprecated_xfer_memory target hook.
> > (procfs_xfer_memory): Adjust interface as a to_xfer_partial
> > helper.
>
> FYI: I tried to test it, but the sparc-solaris debugger appears to be
> badly broken at the moment, and I won't have much time left this week
> to investigate the failures, so I'll schedule that for next week.
I forgot to attach a small patch that fixes a build failure because
of a declaration that no longer matches the definition...
After your patch, we could probably avoid the need for this declaration
by swapping two functions, but for another day.
--
Joel
[-- Attachment #2: 0001-Small-fixup.patch --]
[-- Type: text/x-diff, Size: 802 bytes --]
From c4116d749ac04b4c77a25f03c748b6a170cae4e5 Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
Date: Thu, 20 Feb 2014 15:41:34 +0100
Subject: [PATCH] Small fixup.
---
gdb/procfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 0e2112b..8887f10 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -129,7 +129,8 @@ static ptid_t procfs_wait (struct target_ops *,
ptid_t, struct target_waitstatus *, int);
static enum target_xfer_status procfs_xfer_memory (gdb_byte *,
const gdb_byte *,
- ULONGEST, ULONGEST);
+ ULONGEST, ULONGEST,
+ ULONGEST *);
static target_xfer_partial_ftype procfs_xfer_partial;
static int procfs_thread_alive (struct target_ops *ops, ptid_t);
--
1.7.10.4
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 5/7] go32-nat.c: Don't install a deprecated_xfer_memory method
[not found] ` <00c801cf2e59$acae60f0$060b22d0$@muller@ics-cnrs.unistra.fr>
@ 2014-02-20 16:37 ` Pedro Alves
0 siblings, 0 replies; 19+ messages in thread
From: Pedro Alves @ 2014-02-20 16:37 UTC (permalink / raw)
To: Pierre Muller, GDB Patches
(adding back gdb-patches@)
On 02/20/2014 04:34 PM, Pierre Muller wrote:
> I found something that looks suspicious in your patch...
> But once again, it could be my lack of proper C formation...
>
>> +/* Const-correct version of DJGPP's write_child, which unfortunately
>> + takes a non-const buffer pointer. */
>> +
>> static int
>> +my_write_child (unsigned child_addr, const void *buf, unsigned len)
>> {
>> - if (write)
>> + static void *buffer = NULL;
>> + static unsigned buffer_len = 0;
> It seems odd to me to use
> a static variable buffer_len, which keeps the size
> of the last allocated buffer, when you do
> a xfree before returning from this function...
>
>> + int res;
>> +
>> + if (buffer_len < len)
>> {
>> - if (write_child (memaddr, myaddr, len))
>> - {
>> - return 0;
>> - }
>> - else
>> - {
>> - return len;
>> - }
>> + buffer = xrealloc (buffer, len);
>> + buffer_len = len;
>> }
>> +
>> + memcpy (buffer, buf, len);
>> + res = write_child (child_addr, buffer, len);
>> + xfree (buffer);
> This line should be removed, or did I miss something?
You're right. I'll remove it. Thanks!
--
Pedro Alves
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 3/7] procfs.c: Don't install a deprecated_xfer_memory method
2014-02-20 15:56 ` Joel Brobecker
@ 2014-02-20 16:38 ` Pedro Alves
2014-02-24 17:53 ` Joel Brobecker
0 siblings, 1 reply; 19+ messages in thread
From: Pedro Alves @ 2014-02-20 16:38 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
On 02/20/2014 03:56 PM, Joel Brobecker wrote:
>>> gdb/
>>> 2014-02-19 Pedro Alves <palves@redhat.com>
>>>
>>> * procfs.c (procfs_target): Don't install procfs_xfer_memory as
>>> deprecated_xfer_memory hook.
>>> (procfs_xfer_partial): Call procfs_xfer_memory instead
>>> of the deprecated_xfer_memory target hook.
>>> (procfs_xfer_memory): Adjust interface as a to_xfer_partial
>>> helper.
>>
>> FYI: I tried to test it, but the sparc-solaris debugger appears to be
>> badly broken at the moment, and I won't have much time left this week
>> to investigate the failures, so I'll schedule that for next week.
Thanks.
>
> I forgot to attach a small patch that fixes a build failure because
> of a declaration that no longer matches the definition...
Thanks! I'll merge that in.
> After your patch, we could probably avoid the need for this declaration
> by swapping two functions, but for another day.
Yeah.
--
Pedro Alves
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 7/7] bsd-uthread.c: Don't install a to_xfer_partial method
2014-02-20 13:26 ` Mark Kettenis
@ 2014-02-20 16:42 ` Pedro Alves
0 siblings, 0 replies; 19+ messages in thread
From: Pedro Alves @ 2014-02-20 16:42 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
On 02/20/2014 01:26 PM, Mark Kettenis wrote:
>> From: Pedro Alves <palves@redhat.com>
>> Date: Wed, 19 Feb 2014 20:29:35 +0000
>>
>> Whatever the comment about deprecated_xfer_memory referred to,
>> deprecated_xfer_memory is gone now. There's no need to install a
>> target method that just delegates, as that's what the default
>> delegator does already.
>>
>> Tested by building an --enable-targets=all gdb on x86_64 Fedora 17.
>
> Sure. Go ahead. These days OpenBSD has real threads anyway; I just
> need to find some time to integrate the changes I have lying around to
> make that work with GDB.
Thanks. I'll merge it along with the rest of the series, as otherwise
I'd have to come up with a different commit log. :-)
--
Pedro Alves
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 0/7] eliminate deprecated_xfer_memory
2014-02-19 20:29 [PATCH 0/7] eliminate deprecated_xfer_memory Pedro Alves
` (6 preceding siblings ...)
2014-02-19 20:29 ` [PATCH 2/7] remote-m32r-sdi.c: " Pedro Alves
@ 2014-02-20 18:27 ` Tom Tromey
2014-02-26 14:50 ` Pedro Alves
7 siblings, 1 reply; 19+ messages in thread
From: Tom Tromey @ 2014-02-20 18:27 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
Pedro> This series converts the remaining targets that are still implementing
Pedro> deprecated_xfer_memory hooks to use to_xfer_partial instead, and then
Pedro> eliminates deprecated_xfer_memory completely. The last patch of the
Pedro> series is a follow up cleanup that could go in anytime actually.
Thanks for doing this.
I read through the otherwise-uncommented-on patches and they all looked
sane to me.
Tom
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 3/7] procfs.c: Don't install a deprecated_xfer_memory method
2014-02-20 16:38 ` Pedro Alves
@ 2014-02-24 17:53 ` Joel Brobecker
2014-02-24 18:21 ` Pedro Alves
0 siblings, 1 reply; 19+ messages in thread
From: Joel Brobecker @ 2014-02-24 17:53 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 2007 bytes --]
Hi Pedro,
> >>> 2014-02-19 Pedro Alves <palves@redhat.com>
> >>>
> >>> * procfs.c (procfs_target): Don't install procfs_xfer_memory as
> >>> deprecated_xfer_memory hook.
> >>> (procfs_xfer_partial): Call procfs_xfer_memory instead
> >>> of the deprecated_xfer_memory target hook.
> >>> (procfs_xfer_memory): Adjust interface as a to_xfer_partial
> >>> helper.
> >>
> >> FYI: I tried to test it, but the sparc-solaris debugger appears to be
> >> badly broken at the moment, and I won't have much time left this week
> >> to investigate the failures, so I'll schedule that for next week.
It turns out that your patch fixes the breakage as a side-effect.
Since it's bad breakage, I pushed the patch immediately, after having
updated the revision log:
This removes yet another instance of a deprecated_xfer_memory user,
and fixes a nasty regression as a side-effect:
(gdb) start
Temporary breakpoint 1 at 0x19070: file simple_main.adb, line 4.
Starting program: /[...]/simple_main
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x19070
Cannot insert breakpoint -3.
Temporarily disabling shared library breakpoints:
breakpoint #-3
The regression was introduced by the to_xfer_partial transition
to return a status enum. procfs_xfer_partial was updated but
not the case where object is TARGET_OBJECT_MEMORY. As result,
procfs_xfer_partial was returning the length xfered rather than
the status, and the xfered buffer was left uninitialized.
gdb/
2014-02-19 Pedro Alves <palves@redhat.com>
* procfs.c (procfs_target): Don't install procfs_xfer_memory as
deprecated_xfer_memory hook.
(procfs_xfer_partial): Call procfs_xfer_memory instead
of the deprecated_xfer_memory target hook.
(procfs_xfer_memory): Adjust interface as a to_xfer_partial
helper.
Tested on sparc-solaris, and pushed.
I still see one regression, which I will now investigate separately.
Thanks for the patch!
--
Joel
[-- Attachment #2: 0001-procfs.c-Don-t-install-a-deprecated_xfer_memory-meth.patch --]
[-- Type: text/x-diff, Size: 6131 bytes --]
From e96027e0d9b0a600aabd2c1c7cfdde6ce6d076e8 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Wed, 19 Feb 2014 20:29:31 +0000
Subject: [PATCH] procfs.c: Don't install a deprecated_xfer_memory method
This removes yet another instance of a deprecated_xfer_memory user,
and fixes a nasty regression as a side-effect:
(gdb) start
Temporary breakpoint 1 at 0x19070: file simple_main.adb, line 4.
Starting program: /[...]/simple_main
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x19070
Cannot insert breakpoint -3.
Temporarily disabling shared library breakpoints:
breakpoint #-3
The regression was introduced by the to_xfer_partial transition
to return a status enum. procfs_xfer_partial was updated but
not the case where object is TARGET_OBJECT_MEMORY. As result,
procfs_xfer_partial was returning the length xfered rather than
the status, and the xfered buffer was left uninitialized.
gdb/
2014-02-19 Pedro Alves <palves@redhat.com>
* procfs.c (procfs_target): Don't install procfs_xfer_memory as
deprecated_xfer_memory hook.
(procfs_xfer_partial): Call procfs_xfer_memory instead
of the deprecated_xfer_memory target hook.
(procfs_xfer_memory): Adjust interface as a to_xfer_partial
helper.
---
gdb/ChangeLog | 9 +++++++
gdb/procfs.c | 73 +++++++++++++++++++++------------------------------------
2 files changed, 36 insertions(+), 46 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bc8573c..b642ac9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2014-02-24 Pedro Alves <palves@redhat.com>
+
+ * procfs.c (procfs_target): Don't install procfs_xfer_memory as
+ deprecated_xfer_memory hook.
+ (procfs_xfer_partial): Call procfs_xfer_memory instead
+ of the deprecated_xfer_memory target hook.
+ (procfs_xfer_memory): Adjust interface as a to_xfer_partial
+ helper.
+
2014-02-24 Yuanhui Zhang <asmwarrior@gmail.com>
* windows-nat.c (windows_xfer_shared_libraries): Return
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 822e1e0..8204747 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -127,9 +127,10 @@ static void procfs_create_inferior (struct target_ops *, char *,
char *, char **, int);
static ptid_t procfs_wait (struct target_ops *,
ptid_t, struct target_waitstatus *, int);
-static int procfs_xfer_memory (CORE_ADDR, gdb_byte *, int, int,
- struct mem_attrib *attrib,
- struct target_ops *);
+static enum target_xfer_status procfs_xfer_memory (gdb_byte *,
+ const gdb_byte *,
+ ULONGEST, ULONGEST,
+ ULONGEST *);
static target_xfer_partial_ftype procfs_xfer_partial;
static int procfs_thread_alive (struct target_ops *ops, ptid_t);
@@ -197,7 +198,6 @@ procfs_target (void)
t->to_fetch_registers = procfs_fetch_registers;
t->to_store_registers = procfs_store_registers;
t->to_xfer_partial = procfs_xfer_partial;
- t->deprecated_xfer_memory = procfs_xfer_memory;
t->to_pass_signals = procfs_pass_signals;
t->to_files_info = procfs_files_info;
t->to_stop = procfs_stop;
@@ -3986,13 +3986,7 @@ procfs_xfer_partial (struct target_ops *ops, enum target_object object,
switch (object)
{
case TARGET_OBJECT_MEMORY:
- if (readbuf)
- return (*ops->deprecated_xfer_memory) (offset, readbuf,
- len, 0/*read*/, NULL, ops);
- if (writebuf)
- return (*ops->deprecated_xfer_memory) (offset, (gdb_byte *) writebuf,
- len, 1/*write*/, NULL, ops);
- return TARGET_XFER_E_IO;
+ return procfs_xfer_memory (readbuf, writebuf, offset, len, xfered_len);
#ifdef NEW_PROC_API
case TARGET_OBJECT_AUXV:
@@ -4009,23 +4003,15 @@ procfs_xfer_partial (struct target_ops *ops, enum target_object object,
}
}
+/* Helper for procfs_xfer_partial that handles memory transfers.
+ Arguments are like target_xfer_partial. */
-/* Transfer LEN bytes between GDB address MYADDR and target address
- MEMADDR. If DOWRITE is non-zero, transfer them to the target,
- otherwise transfer them from the target. TARGET is unused.
-
- The return value is 0 if an error occurred or no bytes were
- transferred. Otherwise, it will be a positive value which
- indicates the number of bytes transferred between gdb and the
- target. (Note that the interface also makes provisions for
- negative values, but this capability isn't implemented here.) */
-
-static int
-procfs_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int dowrite,
- struct mem_attrib *attrib, struct target_ops *target)
+static enum target_xfer_status
+procfs_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf,
+ ULONGEST memaddr, ULONGEST len, ULONGEST *xfered_len)
{
procinfo *pi;
- int nbytes = 0;
+ int nbytes;
/* Find procinfo for main process. */
pi = find_procinfo_or_die (ptid_get_pid (inferior_ptid), 0);
@@ -4033,31 +4019,26 @@ procfs_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int dowrite,
open_procinfo_files (pi, FD_AS) == 0)
{
proc_warn (pi, "xfer_memory, open_proc_files", __LINE__);
- return 0;
+ return TARGET_XFER_E_IO;
}
- if (lseek (pi->as_fd, (off_t) memaddr, SEEK_SET) == (off_t) memaddr)
+ if (lseek (pi->as_fd, (off_t) memaddr, SEEK_SET) != (off_t) memaddr)
+ return TARGET_XFER_E_IO;
+
+ if (writebuf != NULL)
{
- if (dowrite)
- {
-#ifdef NEW_PROC_API
- PROCFS_NOTE ("write memory:\n");
-#else
- PROCFS_NOTE ("write memory:\n");
-#endif
- nbytes = write (pi->as_fd, myaddr, len);
- }
- else
- {
- PROCFS_NOTE ("read memory:\n");
- nbytes = read (pi->as_fd, myaddr, len);
- }
- if (nbytes < 0)
- {
- nbytes = 0;
- }
+ PROCFS_NOTE ("write memory:\n");
+ nbytes = write (pi->as_fd, writebuf, len);
+ }
+ else
+ {
+ PROCFS_NOTE ("read memory:\n");
+ nbytes = read (pi->as_fd, readbuf, len);
}
- return nbytes;
+ if (nbytes <= 0)
+ return TARGET_XFER_E_IO;
+ *xfered_len = nbytes;
+ return TARGET_XFER_OK;
}
/* Called by target_resume before making child runnable. Mark cached
--
1.7.9.5
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 3/7] procfs.c: Don't install a deprecated_xfer_memory method
2014-02-24 17:53 ` Joel Brobecker
@ 2014-02-24 18:21 ` Pedro Alves
2014-02-24 18:37 ` Joel Brobecker
0 siblings, 1 reply; 19+ messages in thread
From: Pedro Alves @ 2014-02-24 18:21 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
On 02/24/2014 05:53 PM, Joel Brobecker wrote:
>>>>> 2014-02-19 Pedro Alves <palves@redhat.com>
>>>>>
>>>>> * procfs.c (procfs_target): Don't install procfs_xfer_memory as
>>>>> deprecated_xfer_memory hook.
>>>>> (procfs_xfer_partial): Call procfs_xfer_memory instead
>>>>> of the deprecated_xfer_memory target hook.
>>>>> (procfs_xfer_memory): Adjust interface as a to_xfer_partial
>>>>> helper.
>>>>
>>>> FYI: I tried to test it, but the sparc-solaris debugger appears to be
>>>> badly broken at the moment, and I won't have much time left this week
>>>> to investigate the failures, so I'll schedule that for next week.
>
> It turns out that your patch fixes the breakage as a side-effect.
> Since it's bad breakage, I pushed the patch immediately, after having
> updated the revision log:
Eh, cool, thanks!
--
Pedro Alves
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 3/7] procfs.c: Don't install a deprecated_xfer_memory method
2014-02-24 18:21 ` Pedro Alves
@ 2014-02-24 18:37 ` Joel Brobecker
0 siblings, 0 replies; 19+ messages in thread
From: Joel Brobecker @ 2014-02-24 18:37 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
> > It turns out that your patch fixes the breakage as a side-effect.
> > Since it's bad breakage, I pushed the patch immediately, after having
> > updated the revision log:
>
> Eh, cool, thanks!
You are welcome. And in the continuing series of "how it is taking me
all morning to do nothing...", I found that the remaining regression
mentioned in my earlier message went away as soon as I realized that
my sources were a few days out of date, and I updated them. Not sure
what fixed it, but I will pass on satisfying my curiosity... :-/
--
Joel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 0/7] eliminate deprecated_xfer_memory
2014-02-20 18:27 ` [PATCH 0/7] eliminate deprecated_xfer_memory Tom Tromey
@ 2014-02-26 14:50 ` Pedro Alves
0 siblings, 0 replies; 19+ messages in thread
From: Pedro Alves @ 2014-02-26 14:50 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 02/20/2014 06:27 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
>
> Pedro> This series converts the remaining targets that are still implementing
> Pedro> deprecated_xfer_memory hooks to use to_xfer_partial instead, and then
> Pedro> eliminates deprecated_xfer_memory completely. The last patch of the
> Pedro> series is a follow up cleanup that could go in anytime actually.
>
> Thanks for doing this.
>
> I read through the otherwise-uncommented-on patches and they all looked
> sane to me.
Thank you. I've now pushed the remaining patches.
--
Pedro Alves
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2014-02-26 14:50 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-19 20:29 [PATCH 0/7] eliminate deprecated_xfer_memory Pedro Alves
2014-02-19 20:29 ` [PATCH 7/7] bsd-uthread.c: Don't install a to_xfer_partial method Pedro Alves
2014-02-20 13:26 ` Mark Kettenis
2014-02-20 16:42 ` Pedro Alves
2014-02-19 20:29 ` [PATCH 4/7] nto-procfs.c: Don't install a deprecated_xfer_memory method Pedro Alves
2014-02-19 20:29 ` [PATCH 6/7] eliminate target_ops->deprecated_xfer_memory Pedro Alves
2014-02-19 20:29 ` [PATCH 3/7] procfs.c: Don't install a deprecated_xfer_memory method Pedro Alves
2014-02-20 15:48 ` Joel Brobecker
2014-02-20 15:56 ` Joel Brobecker
2014-02-20 16:38 ` Pedro Alves
2014-02-24 17:53 ` Joel Brobecker
2014-02-24 18:21 ` Pedro Alves
2014-02-24 18:37 ` Joel Brobecker
2014-02-19 20:29 ` [PATCH 1/7] remote-mips.c: " Pedro Alves
2014-02-19 20:29 ` [PATCH 5/7] go32-nat.c: " Pedro Alves
[not found] ` <00c801cf2e59$acae60f0$060b22d0$@muller@ics-cnrs.unistra.fr>
2014-02-20 16:37 ` Pedro Alves
2014-02-19 20:29 ` [PATCH 2/7] remote-m32r-sdi.c: " Pedro Alves
2014-02-20 18:27 ` [PATCH 0/7] eliminate deprecated_xfer_memory Tom Tromey
2014-02-26 14:50 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).