From 936d299246c2be32cfc92e0ad824f31d5b8cec73 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 20 May 2014 19:11:39 +0100 Subject: Make compare-sections work against all targets; add compare-sections [-r] tests. This does two things: 1. Adds a test. Recently compare-sections got a new "-r" switch, but given no test existed for compare-sections, the patch was allowed in with no testsuite addition. This now adds a test for both compare-sections and compare-sections -r. 2. Makes the compare-sections command work against all targets. Currently, compare-sections only works with remote targets, and only those that support the qCRC packet. The patch makes it so that if the target doesn't support accelerating memory verification, then GDB falls back to comparing memory itself. This is of course slower, but it's better than nothing, IMO. While testing against extended-remote GDBserver I noticed that we send the qCRC request to the target if we're connected, but not yet running a program. That can't work of course -- the patch fixes that. This all also goes in the direction of bridging the local/remote parity gap. I didn't decouple 1. from 2., because that would mean that the test would need to handle the case of the target not supporting the command. Tested on x86_64 Fedora 17, native, remote GDBserver, and extended-remote GDBserver. I also hack-disabled qCRC support to make sure the fallback paths in remote.c work. gdb/doc/ 2014-05-20 Pedro Alves * gdb.texinfo (Memory) : Generalize comments to not be remote specific. Add cross reference to the qCRC packet. (Separate Debug Files): Update cross reference to the qCRC packet. (General Query Packets) : Add anchor. gdb/ 2014-05-20 Pedro Alves * NEWS: Mention that compare-sections now works with all targets. * remote.c (PACKET_qCRC): New enum value. (remote_verify_memory): Don't send qCRC if the target has no execution. Use packet_support/packet_ok. If the target doesn't support the qCRC packet, fallback to a deep memory copy. (compare_sections_command): Say "target image" instead of "remote executable". (_initialize_remote): Add PACKET_qCRC to the list of config packets that have no associated command. Extend comment. * target.c (simple_verify_memory, default_verify_memory): New function. * target.h (struct target_ops) : Default to default_verify_memory. (simple_verify_memory): New declaration. * target-delegates.c: Regenerate. gdb/testsuite/ 2014-05-20 Pedro Alves * gdb.base/compare-sections.c: New file. * gdb.base/compare-sections.exp: New file. --- gdb/target.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'gdb/target.h') diff --git a/gdb/target.h b/gdb/target.h index 492ecb5..23a7566 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -941,7 +941,7 @@ struct target_ops encountered while reading memory. */ int (*to_verify_memory) (struct target_ops *, const gdb_byte *data, CORE_ADDR memaddr, ULONGEST size) - TARGET_DEFAULT_NORETURN (tcomplain ()); + TARGET_DEFAULT_FUNC (default_verify_memory); /* Return the address of the start of the Thread Information Block a Windows OS specific feature. */ @@ -2005,6 +2005,14 @@ extern const struct frame_unwind *target_get_unwinder (void); /* See to_get_tailcall_unwinder in struct target_ops. */ extern const struct frame_unwind *target_get_tailcall_unwinder (void); +/* This implements basic memory verification, reading target memory + and performing the comparison here (as opposed to accelerated + verification making use of the qCRC packet, for example). */ + +extern int simple_verify_memory (struct target_ops* ops, + const gdb_byte *data, + CORE_ADDR memaddr, ULONGEST size); + /* Verify that the memory in the [MEMADDR, MEMADDR+SIZE) range matches the contents of [DATA,DATA+SIZE). Returns 1 if there's a match, 0 if there's a mismatch, and -1 if an error is encountered while -- cgit v1.1