diff options
author | Yao Qi <yao.qi@linaro.org> | 2017-09-05 09:54:53 +0100 |
---|---|---|
committer | Yao Qi <yao.qi@linaro.org> | 2017-09-05 09:54:53 +0100 |
commit | 0a188386c032126045979b7fb7c238d715c81eb5 (patch) | |
tree | 7a34674b979bf52bd421901a608bfad9417f9e5a /gdb/gdbserver/tdesc.h | |
parent | f49ff00066929bf7c38f9c89ad640561bbb331f6 (diff) | |
download | gdb-0a188386c032126045979b7fb7c238d715c81eb5.zip gdb-0a188386c032126045979b7fb7c238d715c81eb5.tar.gz gdb-0a188386c032126045979b7fb7c238d715c81eb5.tar.bz2 |
[GDBserver] unit test to i386_tdesc
This patch adds a unit test in GDBserver to test dynamically created
target descriptions equal these pre-generated ones.
gdb/gdbserver:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* linux-x86-tdesc.c: Include selftest.h.
(i386_tdesc_test): New function.
(initialize_low_tdesc): Call selftests::register_test.
* tdesc.h: Include regdef.h.
(target_desc): Override operator == and !=.
gdb:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* regformats/regdef.h (struct reg): Override operator == and !=.
Diffstat (limited to 'gdb/gdbserver/tdesc.h')
-rw-r--r-- | gdb/gdbserver/tdesc.h | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/gdb/gdbserver/tdesc.h b/gdb/gdbserver/tdesc.h index 50d0364..49c82c6 100644 --- a/gdb/gdbserver/tdesc.h +++ b/gdb/gdbserver/tdesc.h @@ -21,7 +21,7 @@ #include "arch/tdesc.h" -struct reg; +#include "regdef.h" typedef struct reg *tdesc_reg_p; DEF_VEC_P(tdesc_reg_p); @@ -66,6 +66,46 @@ public: xfree (reg); VEC_free (tdesc_reg_p, reg_defs); } + + bool operator== (const target_desc &other) const + { + if (VEC_length (tdesc_reg_p, reg_defs) + != VEC_length (tdesc_reg_p, other.reg_defs)) + return false; + + struct reg *reg; + + for (int ix = 0; + VEC_iterate (tdesc_reg_p, reg_defs, ix, reg); + ix++) + { + struct reg *reg2 + = VEC_index (tdesc_reg_p, other.reg_defs, ix); + + if (reg != reg2 && *reg != *reg2) + return false; + } + + /* Compare expedite_regs. */ + int i = 0; + for (; expedite_regs[i] != NULL; i++) + { + if (strcmp (expedite_regs[i], other.expedite_regs[i]) != 0) + return false; + } + if (other.expedite_regs[i] != NULL) + return false; + + if (strcmp (xmltarget, other.xmltarget) != 0) + return false; + + return true; + } + + bool operator!= (const target_desc &other) const + { + return !(*this == other); + } #endif }; |