From patchwork Wed Apr 13 10:55:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 11726 Received: (qmail 84316 invoked by alias); 13 Apr 2016 10:55:58 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 84293 invoked by uid 89); 13 Apr 2016 10:55:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=squash, Squash, 2646, 2648 X-HELO: e06smtp06.uk.ibm.com Received: from e06smtp06.uk.ibm.com (HELO e06smtp06.uk.ibm.com) (195.75.94.102) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Wed, 13 Apr 2016 10:55:55 +0000 Received: from localhost by e06smtp06.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 13 Apr 2016 11:55:52 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp06.uk.ibm.com (192.168.101.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 13 Apr 2016 11:55:51 +0100 X-IBM-Helo: d06dlp02.portsmouth.uk.ibm.com X-IBM-MailFrom: arnez@linux.vnet.ibm.com X-IBM-RcptTo: gdb-patches@sourceware.org Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 39CE82190046 for ; Wed, 13 Apr 2016 11:55:29 +0100 (BST) Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u3DAtoIn64421956 for ; Wed, 13 Apr 2016 10:55:50 GMT Received: from d06av05.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u3DAtnFa009245 for ; Wed, 13 Apr 2016 04:55:50 -0600 Received: from oc1027705133.ibm.com (dyn-9-152-212-180.boeblingen.de.ibm.com [9.152.212.180]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u3DAtn90009232 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 13 Apr 2016 04:55:49 -0600 From: Andreas Arnez To: gdb-patches@sourceware.org Cc: Yao Qi , "Markus T. Metzger" Subject: [PATCH] linux-record: Squash cases with identical handling Date: Wed, 13 Apr 2016 12:55:49 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16041310-0025-0000-0000-0000107D3DA0 X-IsSubscribed: yes 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've had this in my pipe for some time, so here it is. There should not be any functional change. -- >8 -- Subject: [PATCH] linux-record: Squash cases with identical handling In record_linux_system_call there are some cases with identical handling. These are merged together to reduce code duplication. gdb/ChangeLog: * linux-record.c (record_linux_system_call): Merge handling for readlink/recv/read and pipe/pipe2. Also move handling for ppoll before the case for poll and use fall-through logic. --- gdb/linux-record.c | 40 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/gdb/linux-record.c b/gdb/linux-record.c index fda7ada..6b84a18 100644 --- a/gdb/linux-record.c +++ b/gdb/linux-record.c @@ -264,6 +264,8 @@ record_linux_system_call (enum gdb_syscall syscall, break; 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; @@ -645,12 +648,6 @@ record_linux_system_call (enum gdb_syscall syscall, case gdb_sys_symlink: break; - case gdb_sys_readlink: - regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest); - if (record_mem_at_reg (regcache, tdep->arg2, (int) tmpulongest)) - return -1; - break; - case gdb_sys_uselib: case gdb_sys_swapon: break; @@ -742,12 +739,6 @@ Do you want to stop the program?"), } break; - case gdb_sys_recv: - regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest); - if (record_mem_at_reg (regcache, tdep->arg2, (int) tmpulongest)) - return -1; - break; - case gdb_sys_recvmsg: regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest); if (record_linux_msghdr (regcache, tdep, tmpulongest)) @@ -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?"), return -1; break; - case gdb_sys_ppoll: - regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest); - if (tmpulongest) - { - ULONGEST nfds; - - regcache_raw_read_unsigned (regcache, tdep->arg2, &nfds); - if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest, - tdep->size_pollfd * nfds)) - return -1; - } - if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_timespec)) - return -1; - break; - case gdb_sys_unshare: case gdb_sys_set_robust_list: break; @@ -2035,11 +2016,6 @@ Do you want to stop the program?"), case gdb_sys_dup3: break; - case gdb_sys_pipe2: - if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_int * 2)) - return -1; - break; - case gdb_sys_inotify_init1: break;