From: Tom Tromey Date: Sun, 22 Apr 2018 16:50:27 +0000 (-0600) Subject: Avoid shadowing in gdbserver X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=da4ae14a4d1614015f6e8d4a37df1b882806630a;p=binutils-gdb.git Avoid shadowing in gdbserver This fixes a few instances of shadowing in gdbserver. These are all simple fixes. gdb/gdbserver/ChangeLog 2018-10-04 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". --- diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index f74b4fdc903..5e35062b40a 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,12 @@ +2018-10-04 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". + 2018-10-01 Gary Benson * gdb_proc_service.h: Moved common code to diff --git a/gdb/gdbserver/gdbthread.h b/gdb/gdbserver/gdbthread.h index 0edf870c56f..03ace2ee16d 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 984464fcc21..701f3e863c0 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 a491ae02574..d711c53e5fd 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);