This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 2/8] Avoid shadowing in gdbserver
- From: Tom Tromey <tom at tromey dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tom at tromey dot com>
- Date: Sat, 22 Sep 2018 22:08:08 -0600
- Subject: [PATCH 2/8] Avoid shadowing in gdbserver
- References: <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