From: Andreas Arnez Date: Fri, 12 Dec 2014 13:14:20 +0000 (+0100) Subject: gdbserver: Rephrase loops in regsets_fetch/store_inferior_registers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=28eef6727d3cd4461091a752c19c418d1bf3bcb7;p=binutils-gdb.git gdbserver: Rephrase loops in regsets_fetch/store_inferior_registers Replace the while-loops in linux-low.c that iterate over regsets by for-loops. This makes it clearer what is iterated over. Also, since "continue" now moves on to the next iteration without having to increment the regset pointer first, the code is slightly reduced. In case of EIO the old code did not increment the regset pointer, but iterated over the same (now disabled) regset again. This extra iteration is now avoided. gdb/gdbserver/ChangeLog: * linux-low.c (regsets_fetch_inferior_registers): Rephrase while-loop as for-loop. (regsets_store_inferior_registers): Likewise. --- diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index e378a5f5b86..7471dae583d 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,9 @@ +2014-12-12 Andreas Arnez + + * linux-low.c (regsets_fetch_inferior_registers): Rephrase + while-loop as for-loop. + (regsets_store_inferior_registers): Likewise. + 2014-11-28 Yao Qi * configure.ac(AC_CHECK_FUNCS): Remove readlink. diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 01f11b7dfca..164b0f66240 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -4221,19 +4221,14 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info, int pid; struct iovec iov; - regset = regsets_info->regsets; - pid = lwpid_of (current_thread); - while (regset->size >= 0) + for (regset = regsets_info->regsets; regset->size >= 0; regset++) { void *buf, *data; int nt_type, res; if (regset->size == 0 || regset_disabled (regsets_info, regset)) - { - regset ++; - continue; - } + continue; buf = xmalloc (regset->size); @@ -4274,7 +4269,6 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info, else if (regset->type == GENERAL_REGS) saw_general_regs = 1; regset->store_function (regcache, buf); - regset ++; free (buf); } if (saw_general_regs) @@ -4292,19 +4286,14 @@ regsets_store_inferior_registers (struct regsets_info *regsets_info, int pid; struct iovec iov; - regset = regsets_info->regsets; - pid = lwpid_of (current_thread); - while (regset->size >= 0) + for (regset = regsets_info->regsets; regset->size >= 0; regset++) { void *buf, *data; int nt_type, res; if (regset->size == 0 || regset_disabled (regsets_info, regset)) - { - regset ++; - continue; - } + continue; buf = xmalloc (regset->size); @@ -4350,8 +4339,6 @@ regsets_store_inferior_registers (struct regsets_info *regsets_info, /* If we get EIO on a regset, do not try it again for this process mode. */ disable_regset (regsets_info, regset); - free (buf); - continue; } else if (errno == ESRCH) { @@ -4369,7 +4356,6 @@ regsets_store_inferior_registers (struct regsets_info *regsets_info, } else if (regset->type == GENERAL_REGS) saw_general_regs = 1; - regset ++; free (buf); } if (saw_general_regs)