Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Alan Hayward <Alan.Hayward@arm.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: nd <nd@arm.com>
Subject: [PATCH 4/4] Add xml selftests
Date: Wed, 25 Oct 2017 08:31:00 -0000	[thread overview]
Message-ID: <5D4CBA87-0666-4FB9-B7B5-9414C3152C98@arm.com> (raw)

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 --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


             reply	other threads:[~2017-10-25  8:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-25  8:31 Alan Hayward [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-10-25  8:31 [PATCH 3/4] Use flexible target descriptors for aarch64 Alan Hayward
2017-10-30 13:00 ` Yao Qi
     [not found]   ` <A0F02AC1-8FF2-4022-B089-F68D2949CEB6@arm.com>
2017-11-06 10:06     ` Alan Hayward
2017-11-06 11:49       ` Yao Qi
2017-11-06 12:58         ` Alan Hayward
     [not found]           ` <B3614F09-2732-4B13-A45D-5EC111A8DC7E@arm.com>
2017-11-22 15:47             ` Yao Qi
2017-11-22 16:00               ` Yao Qi
     [not found]                 ` <8E1DED12-D169-49CD-A9A3-388280EBDB60@arm.com>
2017-11-23 17:53                   ` [PATCH 4/4] Add xml selftests Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5D4CBA87-0666-4FB9-B7B5-9414C3152C98@arm.com \
    --to=alan.hayward@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=nd@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox