This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Sort debug counter names.


On 11/11/19 3:20 PM, Richard Biener wrote:
On Mon, Nov 11, 2019 at 9:23 AM Martin Liška <mliska@suse.cz> wrote:

Hi.

The small patch is about sorting of debug counter
values.

Ready to be installed?

OK

Thanks,
Martin

Hi.

There's a small follow up where I enforce the sorting via a selftest.

Ready for trunk?
Thanks,
Martin
>From 18c70fd6cce1764ae7fa0860937b6f7360f4b78e Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Mon, 11 Nov 2019 20:37:57 +0100
Subject: [PATCH] Come up with selftests for dbgcnt.

gcc/ChangeLog:

2019-11-12  Martin Liska  <mliska@suse.cz>

	* dbgcnt.c (test_sorted_dbg_counters): New.
	(dbgcnt_c_tests): Likewise.
	* selftest-run-tests.c (selftest::run_tests): Likewise.
	* selftest.h (dbgcnt_c_tests): Likewise.
---
 gcc/dbgcnt.c             | 24 ++++++++++++++++++++++++
 gcc/selftest-run-tests.c |  1 +
 gcc/selftest.h           |  1 +
 3 files changed, 26 insertions(+)

diff --git a/gcc/dbgcnt.c b/gcc/dbgcnt.c
index 711ecc23619..a77bcf50124 100644
--- a/gcc/dbgcnt.c
+++ b/gcc/dbgcnt.c
@@ -24,6 +24,7 @@ See dbgcnt.def for usage information.  */
 #include "coretypes.h"
 #include "diagnostic-core.h"
 #include "dumpfile.h"
+#include "selftest.h"
 
 #include "dbgcnt.h"
 
@@ -249,3 +250,26 @@ dbg_cnt_list_all_counters (void)
     }
   printf ("\n");
 }
+
+#if CHECKING_P
+
+namespace selftest {
+
+/* Selftests.  */
+
+static void
+test_sorted_dbg_counters ()
+{
+  for (unsigned i = 0; i < debug_counter_number_of_counters - 1; i++)
+    ASSERT_LT (strcmp (map[i].name, map[i + 1].name), 0);
+}
+
+void
+dbgcnt_c_tests ()
+{
+  test_sorted_dbg_counters ();
+}
+
+} // namespace selftest
+
+#endif /* #if CHECKING_P */
diff --git a/gcc/selftest-run-tests.c b/gcc/selftest-run-tests.c
index 6ed7d82beeb..a35452caf48 100644
--- a/gcc/selftest-run-tests.c
+++ b/gcc/selftest-run-tests.c
@@ -108,6 +108,7 @@ selftest::run_tests ()
   store_merging_c_tests ();
   predict_c_tests ();
   simplify_rtx_c_tests ();
+  dbgcnt_c_tests ();
 
   /* Run any lang-specific selftests.  */
   lang_hooks.run_lang_selftests ();
diff --git a/gcc/selftest.h b/gcc/selftest.h
index 933c0aab539..cc7212317c3 100644
--- a/gcc/selftest.h
+++ b/gcc/selftest.h
@@ -254,6 +254,7 @@ extern void vec_c_tests ();
 extern void vec_perm_indices_c_tests ();
 extern void wide_int_cc_tests ();
 extern void opt_proposer_c_tests ();
+extern void dbgcnt_c_tests ();
 
 extern int num_passes;
 
-- 
2.24.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]