diff options
author | Pedro Alves <palves@redhat.com> | 2014-05-20 19:11:39 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2014-05-20 19:11:39 +0100 |
commit | 936d299246c2be32cfc92e0ad824f31d5b8cec73 (patch) | |
tree | b177ec4c4f4bc0061c5abc62169cb40878599d2c /gdb/remote.c | |
parent | 9440a9045928d3d4624b8dbcfbd98587a49d35e7 (diff) | |
download | gdb-936d299246c2be32cfc92e0ad824f31d5b8cec73.zip gdb-936d299246c2be32cfc92e0ad824f31d5b8cec73.tar.gz gdb-936d299246c2be32cfc92e0ad824f31d5b8cec73.tar.bz2 |
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 <palves@redhat.com>
* gdb.texinfo (Memory) <compare-sections>: 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) <qCRC packet>: Add anchor.
gdb/
2014-05-20 Pedro Alves <palves@redhat.com>
* 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) <to_verify_memory>: Default to
default_verify_memory.
(simple_verify_memory): New declaration.
* target-delegates.c: Regenerate.
gdb/testsuite/
2014-05-20 Pedro Alves <palves@redhat.com>
* gdb.base/compare-sections.c: New file.
* gdb.base/compare-sections.exp: New file.
Diffstat (limited to 'gdb/remote.c')
-rw-r--r-- | gdb/remote.c | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/gdb/remote.c b/gdb/remote.c index ba04d0c..964bd41 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1273,6 +1273,7 @@ enum { PACKET_qTStatus, PACKET_QPassSignals, PACKET_QProgramSignals, + PACKET_qCRC, PACKET_qSearch_memory, PACKET_vAttach, PACKET_vRun, @@ -8441,29 +8442,40 @@ remote_verify_memory (struct target_ops *ops, unsigned long host_crc, target_crc; char *tmp; - /* Make sure the remote is pointing at the right process. */ - set_general_process (); + /* It doesn't make sense to use qCRC if the remote target is + connected but not running. */ + if (target_has_execution && packet_support (PACKET_qCRC) != PACKET_DISABLE) + { + enum packet_result result; - /* FIXME: assumes lma can fit into long. */ - xsnprintf (rs->buf, get_remote_packet_size (), "qCRC:%lx,%lx", - (long) lma, (long) size); - putpkt (rs->buf); + /* Make sure the remote is pointing at the right process. */ + set_general_process (); - /* Be clever; compute the host_crc before waiting for target - reply. */ - host_crc = xcrc32 (data, size, 0xffffffff); + /* FIXME: assumes lma can fit into long. */ + xsnprintf (rs->buf, get_remote_packet_size (), "qCRC:%lx,%lx", + (long) lma, (long) size); + putpkt (rs->buf); - getpkt (&rs->buf, &rs->buf_size, 0); - if (rs->buf[0] == 'E') - return -1; + /* Be clever; compute the host_crc before waiting for target + reply. */ + host_crc = xcrc32 (data, size, 0xffffffff); + + getpkt (&rs->buf, &rs->buf_size, 0); - if (rs->buf[0] != 'C') - error (_("remote target does not support this operation")); + result = packet_ok (rs->buf, + &remote_protocol_packets[PACKET_qCRC]); + if (result == PACKET_ERROR) + return -1; + else if (result == PACKET_OK) + { + for (target_crc = 0, tmp = &rs->buf[1]; *tmp; tmp++) + target_crc = target_crc * 16 + fromhex (*tmp); - for (target_crc = 0, tmp = &rs->buf[1]; *tmp; tmp++) - target_crc = target_crc * 16 + fromhex (*tmp); + return (host_crc == target_crc); + } + } - return (host_crc == target_crc); + return simple_verify_memory (ops, data, lma, size); } /* compare-sections command @@ -8542,7 +8554,7 @@ compare_sections_command (char *args, int from_tty) do_cleanups (old_chain); } if (mismatched > 0) - warning (_("One or more sections of the remote executable does not match\n\ + warning (_("One or more sections of the target image does not match\n\ the loaded file\n")); if (args && !matched) printf_filtered (_("No loaded section named '%s'.\n"), args); @@ -12097,7 +12109,9 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL, case PACKET_tracenz_feature: case PACKET_DisconnectedTracing_feature: case PACKET_augmented_libraries_svr4_read_feature: - /* Additions to this list need to be well justified. */ + case PACKET_qCRC: + /* Additions to this list need to be well justified: + pre-existing packets are OK; new packets are not. */ excepted = 1; break; default: |