From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 2/8] Avoid shadowing in gdbserver
Date: Sun, 23 Sep 2018 04:08:00 -0000 [thread overview]
Message-ID: <20180923040814.27941-3-tom@tromey.com> (raw)
In-Reply-To: <20180923040814.27941-1-tom@tromey.com>
This fixes a few instances of shadowing in gdbserver. These are all
simple fixes.
gdb/gdbserver/ChangeLog
2018-09-22 Tom Tromey <tom@tromey.com>
* 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
next prev parent reply other threads:[~2018-09-23 4:08 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-23 4:08 [PATCH 0/8] Add -Wshadow=local Tom Tromey
2018-09-23 4:08 ` [PATCH 4/8] Avoid shadowing in linux-tdep.c Tom Tromey
2018-10-12 4:50 ` Kevin Buettner
2018-09-23 4:08 ` [PATCH 6/8] Avoid shadowing in fdwalk Tom Tromey
2018-10-12 4:54 ` Kevin Buettner
2018-09-23 4:08 ` [PATCH 7/8] Shadowing fix in gdbscm_frame_read_var Tom Tromey
[not found] ` <6d098a36-c483-77b8-61a6-87768c29f5d5@ericsson.com>
2018-10-04 12:44 ` Tom Tromey
2018-09-23 4:08 ` [PATCH 3/8] Use std::string in mdebugread.c Tom Tromey
2018-10-12 4:27 ` Kevin Buettner
2018-09-23 4:08 ` [PATCH 8/8] Add -Wshadow=local Tom Tromey
2018-09-23 4:08 ` [PATCH 5/8] Fix latent bug in msp430-tdep.c Tom Tromey
2018-10-12 4:10 ` Kevin Buettner
2018-09-23 4:08 ` Tom Tromey [this message]
2018-10-12 4:19 ` [PATCH 2/8] Avoid shadowing in gdbserver Kevin Buettner
2018-09-23 4:09 ` [PATCH 1/8] Simple -Wshadow=local fixes Tom Tromey
2018-10-04 3:36 ` Simon Marchi
2018-10-04 12:22 ` Simon Marchi
2018-10-04 12:43 ` Tom Tromey
2018-10-03 15:02 ` [PATCH 0/8] Add -Wshadow=local Simon Marchi
[not found] ` <c0393dbe-9dbe-837a-b93d-7c2825ef3649@ericsson.com>
[not found] ` <04748d1d-0fe6-76ad-31f1-68657f8e0d56@redhat.com>
2018-10-03 17:53 ` Joel Brobecker
2018-10-05 4:57 ` Tom Tromey
2018-10-05 9:06 ` Rainer Orth
2018-10-05 11:14 ` Joel Brobecker
2018-10-05 13:37 ` [SPAM] " Tom Tromey
2018-10-05 15:58 ` Rainer Orth
2018-10-12 5:25 ` Kevin Buettner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180923040814.27941-3-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox