aboutsummaryrefslogtreecommitdiff
path: root/gdb/ctf.c
diff options
context:
space:
mode:
authorYao Qi <yao@codesourcery.com>2014-02-10 17:17:32 +0800
committerYao Qi <yao@codesourcery.com>2014-02-23 11:44:27 +0800
commit1ca49d376dec6a93e879bc9456617622d7e349b3 (patch)
tree0e2564e9ec48472a73c83abb826f6ec19e7de5f7 /gdb/ctf.c
parenta283690eb7320dfe4074301c673f6cc3dd21fb11 (diff)
downloadfsf-binutils-gdb-1ca49d376dec6a93e879bc9456617622d7e349b3.zip
fsf-binutils-gdb-1ca49d376dec6a93e879bc9456617622d7e349b3.tar.gz
fsf-binutils-gdb-1ca49d376dec6a93e879bc9456617622d7e349b3.tar.bz2
Share code on to_xfer_partial for tfile and ctf target
In the to_xfer_partial implementations of ctf and tfile, the code on reading from read-only sections is duplicated. This patch moves it to a separate function exec_read_partial_read_only. gdb: 2014-02-23 Yao Qi <yao@codesourcery.com> * ctf.c (ctf_xfer_partial): Move code to ... * exec.c (exec_read_partial_read_only): ... it. New function. * tracefile-tfile.c (tfile_xfer_partial): Likewise. * tracefile.c: Include "exec.h". * exec.h (exec_read_partial_read_only): Declare.
Diffstat (limited to 'gdb/ctf.c')
-rw-r--r--gdb/ctf.c42
1 files changed, 1 insertions, 41 deletions
diff --git a/gdb/ctf.c b/gdb/ctf.c
index 6924fb0..9c8f4d7 100644
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -1467,47 +1467,7 @@ ctf_xfer_partial (struct target_ops *ops, enum target_object object,
bt_iter_set_pos (bt_ctf_get_iter (ctf_iter), pos);
}
- /* It's unduly pedantic to refuse to look at the executable for
- read-only pieces; so do the equivalent of readonly regions aka
- QTro packet. */
- if (exec_bfd != NULL)
- {
- asection *s;
- bfd_size_type size;
- bfd_vma vma;
-
- for (s = exec_bfd->sections; s; s = s->next)
- {
- if ((s->flags & SEC_LOAD) == 0
- || (s->flags & SEC_READONLY) == 0)
- continue;
-
- vma = s->vma;
- size = bfd_get_section_size (s);
- if (vma <= offset && offset < (vma + size))
- {
- ULONGEST amt;
-
- amt = (vma + size) - offset;
- if (amt > len)
- amt = len;
-
- amt = bfd_get_section_contents (exec_bfd, s,
- readbuf, offset - vma, amt);
-
- if (amt == 0)
- return TARGET_XFER_EOF;
- else
- {
- *xfered_len = amt;
- return TARGET_XFER_OK;
- }
- }
- }
- }
-
- /* Indicate failure to find the requested memory block. */
- return TARGET_XFER_E_IO;
+ return exec_read_partial_read_only (readbuf, offset, len, xfered_len);
}
/* This is the implementation of target_ops method