Clear GDB internal state after each unit test
authorYao Qi <yao.qi@linaro.org>
Wed, 24 May 2017 21:15:22 +0000 (22:15 +0100)
committerYao Qi <yao.qi@linaro.org>
Wed, 24 May 2017 21:15:22 +0000 (22:15 +0100)
GDB has some global variables, like sentinel_frame,
current_thread_arch, and etc, we need to reset them after each unit
tests.

gdb:

2017-05-24  Yao Qi  <yao.qi@linaro.org>

* selftest-arch.c (tests_with_arch): Call registers_changed
and reinit_frame_cache.
* selftest.c (run_self_tests): Likewise.

gdb/ChangeLog
gdb/selftest-arch.c
gdb/selftest.c

index a96e71f69da610a26aa919c969a29bac970df7a0..e5222c615ec29db6d4c400894325d909e25284f6 100644 (file)
@@ -1,3 +1,9 @@
+2017-05-24  Yao Qi  <yao.qi@linaro.org>
+
+       * selftest-arch.c (tests_with_arch): Call registers_changed
+       and reinit_frame_cache.
+       * selftest.c (run_self_tests): Likewise.
+
 2017-05-24  Yao Qi  <yao.qi@linaro.org>
 
        * rs6000-tdep.c (gdb_print_insn_powerpc): Remove.
index cbc8c50cda4c551537ade35df501443e0026d074..c4fe60db898d79dd880f682515d77b5f26a4e7d3 100644 (file)
@@ -81,6 +81,10 @@ tests_with_arch ()
                                 _("Self test failed: arch %s: "), arches[i]);
            }
          END_CATCH
+
+         /* Clear GDB internal state.  */
+         registers_changed ();
+         reinit_frame_cache ();
        }
     }
 
index adc7dda78b6ade9738f935e89cdcd91dbe692ae7..14b76f6f2596ee6c7a0f9959c75823dec1c3781f 100644 (file)
@@ -53,6 +53,10 @@ run_self_tests (void)
          exception_fprintf (gdb_stderr, ex, _("Self test failed: "));
        }
       END_CATCH
+
+      /* Clear GDB internal state.  */
+      registers_changed ();
+      reinit_frame_cache ();
     }
 
   printf_filtered (_("Ran %lu unit tests, %d failed\n"),