From f7000548a2b79d7e5cb924468117ca4245e6b820 Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Tue, 5 Sep 2017 09:54:52 +0100 Subject: 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 * 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) : Change it to VEC. : Remove. gdb: 2017-09-05 Yao Qi * regformats/regdat.sh: Update generated code. --- gdb/regformats/regdat.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'gdb/regformats') diff --git a/gdb/regformats/regdat.sh b/gdb/regformats/regdat.sh index 2c764cd..236cd93 100755 --- a/gdb/regformats/regdat.sh +++ b/gdb/regformats/regdat.sh @@ -131,8 +131,8 @@ do echo "{" echo " static struct target_desc tdesc_${name}_s;" echo " struct target_desc *result = &tdesc_${name}_s;" + echo " memset (result, 0, sizeof (*result));" - echo "static struct reg regs_${name}[] = {" continue elif test "${type}" = "xmltarget"; then xmltarget="${entry}" @@ -150,13 +150,17 @@ do echo "$0: $1 does not specify \`\`name''." 1>&2 exit 1 else - echo " { \"${entry}\", ${offset}, ${type} }," + echo " {struct reg *reg = XCNEW (struct reg);" + echo " reg->name = \"${entry}\";" + echo " reg->offset = ${offset};" + echo " reg->size = ${type};" + echo " VEC_safe_push (tdesc_reg_p, result->reg_defs, reg);" + echo " };" offset=`expr ${offset} + ${type}` i=`expr $i + 1` fi done -echo "};" echo echo "static const char *expedite_regs_${name}[] = { \"`echo ${expedite} | sed 's/,/", "/g'`\", 0 };" if test "${xmltarget}" = x; then @@ -178,9 +182,6 @@ fi echo cat <reg_defs = regs_${name}; - result->num_registers = sizeof (regs_${name}) / sizeof (regs_${name}[0]); - #ifndef IN_PROCESS_AGENT result->expedite_regs = expedite_regs_${name}; result->xmltarget = xmltarget_${name}; -- cgit v1.1