diff options
-rw-r--r-- | gdb/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/target.c | 36 | ||||
-rw-r--r-- | gdb/target.h | 5 |
3 files changed, 31 insertions, 14 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 00217db..a63f51f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2003-10-17 Andrew Cagney <cagney@redhat.com> + * target.c (target_section_by_addr): New function. + (do_xfer_memory): Use "target_section_by_addr". + * target.h (target_section_by_addr): Declare. + * target.h (struct target_ops): Add "to_read_partial" and "to_write_partial", delete "to_query". (target_read_partial, target_write_partial): Declare. diff --git a/gdb/target.c b/gdb/target.c index 252cb14..c763af3 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -814,6 +814,21 @@ done: return nbytes_read; } +/* Find a section containing ADDR. */ +struct section_table * +target_section_by_addr (struct target_ops *target, CORE_ADDR addr) +{ + struct section_table *secp; + for (secp = target->to_sections; + secp < target->to_sections_end; + secp++) + { + if (addr >= secp->addr && addr < secp->endaddr) + return secp; + } + return NULL; +} + /* Read LEN bytes of target memory at address MEMADDR, placing the results in GDB's memory at MYADDR. Returns either 0 for success or an errno value if any error occurs. @@ -861,22 +876,15 @@ do_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, if (!write && trust_readonly) { + struct section_table *secp; /* User-settable option, "trust-readonly-sections". If true, then memory from any SEC_READONLY bfd section may be read - directly from the bfd file. */ - - struct section_table *secp; - - for (secp = current_target.to_sections; - secp < current_target.to_sections_end; - secp++) - { - if (bfd_get_section_flags (secp->bfd, secp->the_bfd_section) - & SEC_READONLY) - if (memaddr >= secp->addr && memaddr < secp->endaddr) - return xfer_memory (memaddr, myaddr, len, 0, - attrib, ¤t_target); - } + directly from the bfd file. */ + secp = target_section_by_addr (¤t_target, memaddr); + if (secp != NULL + && (bfd_get_section_flags (secp->bfd, secp->the_bfd_section) + & SEC_READONLY)) + return xfer_memory (memaddr, myaddr, len, 0, attrib, ¤t_target); } /* The quick case is that the top target can handle the transfer. */ diff --git a/gdb/target.h b/gdb/target.h index b8c5a44..7bee270 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1147,6 +1147,11 @@ struct section_table bfd *bfd; /* BFD file pointer */ }; +/* Return the "section" containing the specified address. */ +struct section_table *target_section_by_addr (struct target_ops *target, + CORE_ADDR addr); + + /* Builds a section table, given args BFD, SECTABLE_PTR, SECEND_PTR. Returns 0 if OK, 1 on error. */ |