From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84289 invoked by alias); 23 Sep 2018 04:08:33 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 84074 invoked by uid 89); 23 Sep 2018 04:08:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:4385, luck, H*RU:sk:gateway, CORE_ADDR X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.146.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 23 Sep 2018 04:08:19 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 612381D35F0 for ; Sat, 22 Sep 2018 23:08:18 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 3vgwg5ROtPvAd3vgwgyBB5; Sat, 22 Sep 2018 23:08:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=COtfb1m3sya3LzNjy1IowuyrKuycbCOLw+uKYuI7PJA=; b=denL3Mh+uoyLE8RBHN8spyzq2q NMFNX50QaXr3cnJUqeuvh2CSTFaN7IDn9aXTA2m55kSrKt4m078XqgIYnZ1QqjrLPdK5KXZoeUZvF VTIKsLubtCbmqDarfFQlLHf0k; Received: from 97-122-190-66.hlrn.qwest.net ([97.122.190.66]:37440 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1g3vgw-002UJa-58; Sat, 22 Sep 2018 23:08:18 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 2/8] Avoid shadowing in gdbserver Date: Sun, 23 Sep 2018 04:08:00 -0000 Message-Id: <20180923040814.27941-3-tom@tromey.com> In-Reply-To: <20180923040814.27941-1-tom@tromey.com> References: <20180923040814.27941-1-tom@tromey.com> X-SW-Source: 2018-09/txt/msg00758.txt.bz2 This fixes a few instances of shadowing in gdbserver. These are all simple fixes. gdb/gdbserver/ChangeLog 2018-09-22 Tom Tromey * server.c (handle_status): Rename inner "thread". (process_serial_event): Declare "res" in 'm' case. * linux-low.c (last_thread_of_process_p, find_lwp_pid) (iterate_over_lwps): Rename inner "thread". (linux_qxfer_libraries_svr4): Rename inner "len". * gdbthread.h (find_thread_in_random): Rename inner "thread". --- gdb/gdbserver/ChangeLog | 9 +++++++++ gdb/gdbserver/gdbthread.h | 4 ++-- gdb/gdbserver/linux-low.c | 18 +++++++++--------- gdb/gdbserver/server.c | 21 +++++++++++---------- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/gdb/gdbserver/gdbthread.h b/gdb/gdbserver/gdbthread.h index 0edf870c56..03ace2ee16 100644 --- a/gdb/gdbserver/gdbthread.h +++ b/gdb/gdbserver/gdbthread.h @@ -188,8 +188,8 @@ find_thread_in_random (Func func) random_selector = (int) ((count * (double) rand ()) / (RAND_MAX + 1.0)); - thread_info *thread = find_thread ([&] (thread_info *thread) { - return func (thread) && (random_selector-- == 0); + thread_info *thread = find_thread ([&] (thread_info *thr_arg) { + return func (thr_arg) && (random_selector-- == 0); }); gdb_assert (thread != NULL); diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 984464fcc2..701f3e863c 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -1255,7 +1255,7 @@ last_thread_of_process_p (int pid) { bool seen_one = false; - thread_info *thread = find_thread (pid, [&] (thread_info *thread) + thread_info *thread = find_thread (pid, [&] (thread_info *thr_arg) { if (!seen_one) { @@ -1811,10 +1811,10 @@ status_pending_p_callback (thread_info *thread, ptid_t ptid) struct lwp_info * find_lwp_pid (ptid_t ptid) { - thread_info *thread = find_thread ([&] (thread_info *thread) + thread_info *thread = find_thread ([&] (thread_info *thr_arg) { int lwp = ptid.lwp () != 0 ? ptid.lwp () : ptid.pid (); - return thread->id.lwp () == lwp; + return thr_arg->id.lwp () == lwp; }); if (thread == NULL) @@ -1845,9 +1845,9 @@ iterate_over_lwps (ptid_t filter, iterate_over_lwps_ftype callback, void *data) { - thread_info *thread = find_thread (filter, [&] (thread_info *thread) + thread_info *thread = find_thread (filter, [&] (thread_info *thr_arg) { - lwp_info *lwp = get_thread_lwp (thread); + lwp_info *lwp = get_thread_lwp (thr_arg); return callback (lwp, data); }); @@ -7032,16 +7032,16 @@ linux_qxfer_libraries_svr4 (const char *annex, unsigned char *readbuf, { const char *sep; CORE_ADDR *addrp; - int len; + int name_len; sep = strchr (annex, '='); if (sep == NULL) break; - len = sep - annex; - if (len == 5 && startswith (annex, "start")) + name_len = sep - annex; + if (name_len == 5 && startswith (annex, "start")) addrp = &lm_addr; - else if (len == 4 && startswith (annex, "prev")) + else if (name_len == 4 && startswith (annex, "prev")) addrp = &lm_prev; else { diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index a491ae0257..d711c53e5f 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -3367,9 +3367,9 @@ handle_status (char *own_buf) /* If the last event thread is not found for some reason, look for some other thread that might have an event to report. */ if (thread == NULL) - thread = find_thread ([] (thread_info *thread) + thread = find_thread ([] (thread_info *thr_arg) { - return thread->status_pending_p; + return thr_arg->status_pending_p; }); /* If we're still out of luck, simply pick the first thread in @@ -4028,7 +4028,6 @@ process_serial_event (void) client_state &cs = get_client_state (); int signal; unsigned int len; - int res; CORE_ADDR mem_addr; unsigned char sig; int packet_len; @@ -4172,13 +4171,15 @@ process_serial_event (void) } break; case 'm': - require_running_or_break (cs.own_buf); - decode_m_packet (&cs.own_buf[1], &mem_addr, &len); - res = gdb_read_memory (mem_addr, mem_buf, len); - if (res < 0) - write_enn (cs.own_buf); - else - bin2hex (mem_buf, cs.own_buf, res); + { + require_running_or_break (cs.own_buf); + decode_m_packet (&cs.own_buf[1], &mem_addr, &len); + int res = gdb_read_memory (mem_addr, mem_buf, len); + if (res < 0) + write_enn (cs.own_buf); + else + bin2hex (mem_buf, cs.own_buf, res); + } break; case 'M': require_running_or_break (cs.own_buf); -- 2.17.1