diff mbox

[4/4] Add xml selftests

Message ID 5D4CBA87-0666-4FB9-B7B5-9414C3152C98@arm.com
State New
Headers show

Commit Message

Alan Hayward Oct. 25, 2017, 8:30 a.m. UTC
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-10-25  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 mbox

Patch

diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 5d6f455319f3003240239f7977da9f994765f4d3..e99da65af559408158a3276ebfe81c5fa4b389d6 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -3070,6 +3070,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 08d8e9875a148f931253bed2340498b6d94b9946..9863db0a85c3e0d55314cd0ef0669eba3b51dcca 100644
--- a/gdb/gdbserver/configure.srv
+++ b/gdb/gdbserver/configure.srv
@@ -27,7 +27,7 @@  srv_hostio_err_objs="hostio-errno.o"
 if $development; then
    srv_i386_linux_regobj="i386-linux.o i386-avx-linux.o i386-avx-avx512-linux.o i386-avx-mpx-avx512-pku-linux.o i386-mpx-linux.o i386-avx-mpx-linux.o i386-mmx-linux.o linux-x86-tdesc-selftest.o"
    srv_amd64_linux_regobj="amd64-linux.o amd64-avx-linux.o amd64-avx-avx512-linux.o amd64-avx-mpx-avx512-pku-linux.o amd64-mpx-linux.o amd64-avx-mpx-linux.o x32-linux.o x32-avx-linux.o x32-avx-avx512-linux.o"
-   srv_aarch64_linux_regobj="aarch64.o"
+   srv_aarch64_linux_regobj="aarch64.o linux-aarch64-tdesc-selftest.o"
 else
    srv_i386_linux_regobj=""
    srv_amd64_linux_regobj=""
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 48314e934e0c1163fce400b368a3717a27239be8..7c56b703a057b19dc8c610ac2e49698fd0277d21 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 struct target_desc * aarch64_linux_read_description ();
+
+#if GDB_SELF_TEST
+void initialize_low_tdesc ();
+#endif