This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 4/4] Add xml selftests
> On 22 Nov 2017, at 16:00, Yao Qi <qiyaoltc@gmail.com> wrote:
>
>
> Hi Alan,
> When you post the new version of patches, could you post the whole
> series in the same email thread? These four patches are not in the same
> thread, so I have to go through my inbox to find them one by one.
>
Will do for future patches.
Reposting 4/4 (nothing has changed since original post, except for a rebase):
This patch adds selftests for the new target descriptors.
Tested on a --enable-targets=all build and aarch64 build with board
files unix, native-gdbserver and unittest.exp.
Alan.
2017-11-23 Alan Hayward <alan.hayward@arm.com>
gdb/
* aarch64-tdep.c: Add target desc selftest.
gdbserver/
* configure.srv: Add new file.
* linux-aarch64-low.c (initialize_low_arch): Call init func.
* linux-aarch64-tdesc-selftest.c: New file.
* linux-aarch64-tdesc.h (initialize_low_tdesc): New declaration.
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 61023dd3bb946c2bfbfbc1b88e986030107acd26..6a0d4b744c89c39d5b62b7dcc12273fccb0c32e6 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -3069,6 +3069,8 @@ When on, AArch64 specific debugging is enabled."),
selftests::aarch64_analyze_prologue_test);
selftests::register_test ("aarch64-process-record",
selftests::aarch64_process_record_test);
+ selftests::record_xml_tdesc ("aarch64.xml",
+ aarch64_create_target_description ());
#endif
}
diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
index 0136ec326c916b0f35e49bf1500876e4cb80ce1f..3171b9791cafff80458a0648df58fed913f20d03 100644
--- a/gdb/gdbserver/configure.srv
+++ b/gdb/gdbserver/configure.srv
@@ -53,6 +53,7 @@ case "${target}" in
srv_regobj="arm-with-neon.o"
if $development; then
srv_regobj="${srv_regobj} aarch64.o"
+ srv_regobj="${srv_regobj} linux-aarch64-tdesc-selftest.o"
fi
srv_tgtobj="linux-aarch64-low.o aarch64-linux-hw-point.o"
srv_tgtobj="$srv_tgtobj linux-aarch32-low.o"
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index 9682537728847850d824c7eac949c68ab09226ac..243d1e0bbf3d31819136b0867953733379c9c437 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -2998,4 +2998,8 @@ initialize_low_arch (void)
initialize_low_arch_aarch32 ();
initialize_regsets_info (&aarch64_regsets_info);
+
+#if GDB_SELF_TEST
+ initialize_low_tdesc ();
+#endif
}
diff --git a/gdb/gdbserver/linux-aarch64-tdesc-selftest.c b/gdb/gdbserver/linux-aarch64-tdesc-selftest.c
new file mode 100644
index 0000000000000000000000000000000000000000..11284b0b9f5cbef967cfc0ebed6463d2ca9030a5
--- /dev/null
+++ b/gdb/gdbserver/linux-aarch64-tdesc-selftest.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 2017 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "server.h"
+#include "tdesc.h"
+#include "common/selftest.h"
+#include "linux-aarch64-tdesc.h"
+
+/* Defined in auto-generated file features/aarch64.c. */
+void init_registers_aarch64 (void);
+extern const struct target_desc *tdesc_aarch64;
+
+namespace selftests {
+namespace tdesc {
+static void
+aarch64_tdesc_test ()
+{
+ const target_desc *tdesc = aarch64_linux_read_description ();
+ SELF_CHECK (*tdesc == *tdesc_aarch64);
+}
+}
+} // namespace selftests
+
+void
+initialize_low_tdesc ()
+{
+ init_registers_aarch64 ();
+
+ selftests::register_test ("aarch64-tdesc",
+ selftests::tdesc::aarch64_tdesc_test);
+}
diff --git a/gdb/gdbserver/linux-aarch64-tdesc.h b/gdb/gdbserver/linux-aarch64-tdesc.h
index 6d6731720c3b4123d16f179acc5087ffd2d9b454..2dd969f5f0abcbe5b7aee56ec1a9319a7755dc62 100644
--- a/gdb/gdbserver/linux-aarch64-tdesc.h
+++ b/gdb/gdbserver/linux-aarch64-tdesc.h
@@ -18,3 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
const target_desc * aarch64_linux_read_description ();
+
+#if GDB_SELF_TEST
+void initialize_low_tdesc ();
+#endif