• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisiónebd61ee8b5161ded8653c32da0ec57927e1ba9c1 (tree)
Tiempo2020-06-26 01:23:38
AutorLuis Machado <luis.machado@lina...>
CommiterLuis Machado

Log Message

Unit testing for GDB-side remote memory tagging handling

Include some unit testing for the functions handling the new qMemTags and
QMemTags packets.

gdb/ChangeLog:

YYYY-MM-DD Luis Machado <luis.machado@linaro.org>

* remote: Include gdbsupport/selftest.h.
(test_memory_tagging_functions): New function.
(_initialize_remote): Register test_memory_tagging_functions.

Cambiar Resumen

Diferencia incremental

--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -78,6 +78,7 @@
7878 #include <algorithm>
7979 #include <unordered_map>
8080 #include "async-event.h"
81+#include "gdbsupport/selftest.h"
8182
8283 /* The remote target. */
8384
@@ -14504,6 +14505,89 @@ remote_target::store_memtags (CORE_ADDR address, size_t len,
1450414505 return 0;
1450514506 }
1450614507
14508+#if GDB_SELF_TEST
14509+
14510+namespace selftests {
14511+
14512+static void
14513+test_memory_tagging_functions (void)
14514+{
14515+ remote_target remote;
14516+
14517+ struct packet_config *config
14518+ = &remote_protocol_packets[PACKET_memory_tagging_feature];
14519+
14520+ /* Test memory tagging packet support. */
14521+ config->support = PACKET_SUPPORT_UNKNOWN;
14522+ SELF_CHECK (remote.supports_memory_tagging () == false);
14523+ config->support = PACKET_DISABLE;
14524+ SELF_CHECK (remote.supports_memory_tagging () == false);
14525+ config->support = PACKET_ENABLE;
14526+ SELF_CHECK (remote.supports_memory_tagging () == true);
14527+
14528+ /* Setup testing. */
14529+ gdb::char_vector packet;
14530+ gdb::byte_vector tags, bv;
14531+ std::string expected, reply;
14532+ packet.resize (32000);
14533+
14534+ /* Test creating a qMemTags request. */
14535+
14536+ expected = "qMemTags:0,0";
14537+ create_fmemtags_request (packet, 0x0, 0x0);
14538+ SELF_CHECK (strcmp (packet.data (), expected.c_str ()) == 0);
14539+
14540+ expected = "qMemTags:deadbeef,10";
14541+ create_fmemtags_request (packet, 0xdeadbeef, 16);
14542+ SELF_CHECK (strcmp (packet.data (), expected.c_str ()) == 0);
14543+
14544+ /* Test parsing a qMemTags reply. */
14545+
14546+ /* Error reply, tags vector unmodified. */
14547+ reply = "E00";
14548+ strcpy (packet.data (), reply.c_str ());
14549+ tags.resize (0);
14550+ SELF_CHECK (parse_fmemtags_reply (packet, tags) != 0);
14551+ SELF_CHECK (tags.size () == 0);
14552+
14553+ /* Valid reply, tags vector updated. */
14554+ tags.resize (0);
14555+ bv.resize (0);
14556+
14557+ for (int i = 0; i < 5; i++)
14558+ bv.push_back (i);
14559+
14560+ reply = "m" + bin2hex (bv.data (), bv.size ());
14561+ strcpy (packet.data (), reply.c_str ());
14562+
14563+ SELF_CHECK (parse_fmemtags_reply (packet, tags) == 0);
14564+ SELF_CHECK (tags.size () == 5);
14565+
14566+ for (int i = 0; i < 5; i++)
14567+ SELF_CHECK (tags[i] == i);
14568+
14569+ /* Test creating a QMemTags request. */
14570+
14571+ /* Empty tag data. */
14572+ tags.resize (0);
14573+ expected = "QMemTags:0,0:";
14574+ create_smemtags_request (packet, 0x0, 0x0, tags);
14575+ SELF_CHECK (memcmp (packet.data (), expected.c_str (),
14576+ expected.length ()) == 0);
14577+
14578+ /* Non-empty tag data. */
14579+ tags.resize (0);
14580+ for (int i = 0; i < 5; i++)
14581+ tags.push_back (i);
14582+ expected = "QMemTags:deadbeef,ff:0001020304";
14583+ create_smemtags_request (packet, 0xdeadbeef, 255, tags);
14584+ SELF_CHECK (memcmp (packet.data (), expected.c_str (),
14585+ expected.length ()) == 0);
14586+}
14587+
14588+} // namespace selftests
14589+#endif /* GDB_SELF_TEST */
14590+
1450714591 void _initialize_remote ();
1450814592 void
1450914593 _initialize_remote ()
@@ -15017,4 +15101,9 @@ Specify \"unlimited\" to display all the characters."),
1501715101
1501815102 /* Eventually initialize fileio. See fileio.c */
1501915103 initialize_remote_fileio (&remote_set_cmdlist, &remote_show_cmdlist);
15104+
15105+#if GDB_SELF_TEST
15106+ selftests::register_test ("remote_memory_tagging",
15107+ selftests::test_memory_tagging_functions);
15108+#endif
1502015109 }