This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] linux-record: Squash cases with identical handling


Andreas Arnez <arnez@linux.vnet.ibm.com> writes:

Hi Andreas,

> While discussing a fix for a bad fall-through in linux-record.c, it was
> pointed out that the cases for gdb_sys_pipe2 and gdb_sys_pipe can be
> squashed into one.  Thus I promised a minor cleanup for cases with
> identical handling:
>
>   https://sourceware.org/ml/gdb-patches/2016-03/msg00310.html

I thought about squashing them too, but the reason I didn't do that is
these enum gdb_syscall in the switch block are listed in the numeric
order, so that it is quite easy to find whether a syscall is supported,
or add a new syscall.

I am not against your patch, but want to let people know why the code is
written that way, so that people can judge which one is better.

>  
>      case gdb_sys_read:
> +    case gdb_sys_readlink:
> +    case gdb_sys_recv:
>        regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
>        if (record_mem_at_reg (regcache, tdep->arg2, (int) tmpulongest))
>  	return -1;
> @@ -348,6 +350,7 @@ record_linux_system_call (enum gdb_syscall syscall,
>        break;
>  
>      case gdb_sys_pipe:
> +    case gdb_sys_pipe2:
>        if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_int * 2))
>  	return -1;
>        break;

I don't mind this...  anyway, it can shorten the code.


> @@ -1364,6 +1355,11 @@ Do you want to stop the program?"),
>      case gdb_sys_ni_syscall167:
>        break;
>  
> +    case gdb_sys_ppoll:
> +      if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_timespec))
> +	return -1;
> +      /* Fall through.  */
> +
>      case gdb_sys_poll:
>        regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
>        if (tmpulongest)
> @@ -1959,21 +1955,6 @@ Do you want to stop the program?"),

but, I don't like the fall-through.

-- 
Yao (éå)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]