diff options
author | Yao Qi <yao.qi@linaro.org> | 2017-09-05 09:54:52 +0100 |
---|---|---|
committer | Yao Qi <yao.qi@linaro.org> | 2017-09-05 09:54:52 +0100 |
commit | f7000548a2b79d7e5cb924468117ca4245e6b820 (patch) | |
tree | 67f9fdac040944ddf81ddd3058d6bea134796432 /gdb/gdbserver/tdesc.c | |
parent | c9a5e2a5b2b20d83f60026459d3a6b68481566c9 (diff) | |
download | fsf-binutils-gdb-f7000548a2b79d7e5cb924468117ca4245e6b820.zip fsf-binutils-gdb-f7000548a2b79d7e5cb924468117ca4245e6b820.tar.gz fsf-binutils-gdb-f7000548a2b79d7e5cb924468117ca4245e6b820.tar.bz2 |
Use VEC for target_desc.reg_defs
Nowadays, target_desc.reg_defs is a pointer points to a pre-generated
array, which is not flexible. This patch changes it from an array
to a VEC so that GDBserver can create target descriptions dynamically
later. Instead of using pre-generated array, the -generated.c calls
VEC_safe_push to add each register to vector.
Since target_desc.reg_defs is used in IPA, we need to build common/vec.c
for IPA too.
gdb/gdbserver:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* Makefile.in (IPA_OBJS): Add vec-ipa.o
* regcache.c (get_thread_regcache): Use VEC_length.
(init_register_cache): Likewise.
(regcache_cpy): Likewise.
(registers_to_string): Iterate reg_defs via VEC_iterate.
(find_regno): Likewise.
(find_register_by_number): Use VEC_index.
(register_size): Call find_register_by_number.
(register_data): Call find_register_by_number.
(supply_regblock): Use VEC_length.
(regcache_raw_read_unsigned): Likewise.
* tdesc.c (init_target_desc): Iterate reg_defs via
VEC_iterate.
(default_description): Update initializer.
(copy_target_description): Don't update field num_registers.
* tdesc.h (struct target_desc) <reg_defs>: Change it to VEC.
<num_registers>: Remove.
gdb:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* regformats/regdat.sh: Update generated code.
Diffstat (limited to 'gdb/gdbserver/tdesc.c')
-rw-r--r-- | gdb/gdbserver/tdesc.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gdb/gdbserver/tdesc.c b/gdb/gdbserver/tdesc.c index fdd35197..1b1882e 100644 --- a/gdb/gdbserver/tdesc.c +++ b/gdb/gdbserver/tdesc.c @@ -23,12 +23,13 @@ void init_target_desc (struct target_desc *tdesc) { int offset, i; + struct reg *reg; offset = 0; - for (i = 0; i < tdesc->num_registers; i++) + for (i = 0; VEC_iterate (tdesc_reg_p, tdesc->reg_defs, i, reg); i++) { - tdesc->reg_defs[i].offset = offset; - offset += tdesc->reg_defs[i].size; + reg->offset = offset; + offset += reg->size; } tdesc->registers_size = offset / 8; @@ -40,14 +41,13 @@ init_target_desc (struct target_desc *tdesc) #ifndef IN_PROCESS_AGENT -static const struct target_desc default_description = { 0 }; +static const struct target_desc default_description = { NULL, 0, NULL, NULL }; void copy_target_description (struct target_desc *dest, const struct target_desc *src) { dest->reg_defs = src->reg_defs; - dest->num_registers = src->num_registers; dest->expedite_regs = src->expedite_regs; dest->registers_size = src->registers_size; dest->xmltarget = src->xmltarget; |