From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 6AFD9395253D; Tue, 7 Jun 2022 18:21:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6AFD9395253D Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Turn some windows-nat.c static functions into methods X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: bcb9251f029da8dcf360a4f5acfa3b4211c87bb0 X-Git-Newrev: 551765020680c23de7641577e72d88083c50194d Message-Id: <20220607182146.6AFD9395253D@sourceware.org> Date: Tue, 7 Jun 2022 18:21:46 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jun 2022 18:21:46 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D551765020680= c23de7641577e72d88083c50194d commit 551765020680c23de7641577e72d88083c50194d Author: Tom Tromey Date: Tue Apr 5 13:23:59 2022 -0600 Turn some windows-nat.c static functions into methods =20 This patch turns some windows-nat.c static functions into methods on windows_nat_target. This avoids having to reference the windows_nat_target singleton in some more spots -- a minor code cleanup. Diff: --- gdb/windows-nat.c | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 0f9fde9f804..586671b1902 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -286,6 +286,13 @@ struct windows_nat_target final : public x86_nat_targe= t { return disable_randomization_available (); } + +private: + + windows_thread_info *add_thread (ptid_t ptid, HANDLE h, void *tlb, + bool main_thread_p); + void delete_thread (ptid_t ptid, DWORD exit_code, bool main_thread_p); + DWORD fake_create_process (); }; =20 static windows_nat_target the_windows_nat_target; @@ -357,8 +364,9 @@ windows_nat::windows_process_info::thread_rec MAIN_THREAD_P should be true if the thread to be added is the main thread, false otherwise. */ =20 -static windows_thread_info * -windows_add_thread (ptid_t ptid, HANDLE h, void *tlb, bool main_thread_p) +windows_thread_info * +windows_nat_target::add_thread (ptid_t ptid, HANDLE h, void *tlb, + bool main_thread_p) { windows_thread_info *th; =20 @@ -383,9 +391,9 @@ windows_add_thread (ptid_t ptid, HANDLE h, void *tlb, b= ool main_thread_p) the main thread silently (in reality, this thread is really more of a process to the user than a thread). */ if (main_thread_p) - add_thread_silent (&the_windows_nat_target, ptid); + add_thread_silent (this, ptid); else - add_thread (&the_windows_nat_target, ptid); + ::add_thread (this, ptid); =20 /* It's simplest to always set this and update the debug registers. */ @@ -410,8 +418,9 @@ windows_init_thread_list (void) MAIN_THREAD_P should be true if the thread to be deleted is the main thread, false otherwise. */ =20 -static void -windows_delete_thread (ptid_t ptid, DWORD exit_code, bool main_thread_p) +void +windows_nat_target::delete_thread (ptid_t ptid, DWORD exit_code, + bool main_thread_p) { DWORD id; =20 @@ -433,7 +442,7 @@ windows_delete_thread (ptid_t ptid, DWORD exit_code, bo= ol main_thread_p) target_pid_to_str (ptid).c_str (), (unsigned) exit_code); =20 - delete_thread (find_thread_ptid (&the_windows_nat_target, ptid)); + ::delete_thread (find_thread_ptid (&the_windows_nat_target, ptid)); =20 auto iter =3D std::find_if (thread_list.begin (), thread_list.end (), [=3D] (auto &th) @@ -1174,8 +1183,8 @@ windows_continue (DWORD continue_status, int id, int = killed) =20 /* Called in pathological case where Windows fails to send a CREATE_PROCESS_DEBUG_EVENT after an attach. */ -static DWORD -fake_create_process (void) +DWORD +windows_nat_target::fake_create_process () { windows_process.handle =3D OpenProcess (PROCESS_ALL_ACCESS, FALSE, @@ -1188,7 +1197,7 @@ fake_create_process (void) (unsigned) GetLastError ()); /* We can not debug anything in that case. */ } - windows_add_thread (ptid_t (windows_process.current_event.dwProcessId, 0, + add_thread (ptid_t (windows_process.current_event.dwProcessId, 0, windows_process.current_event.dwThreadId), windows_process.current_event.u.CreateThread.hThread, windows_process.current_event.u.CreateThread.lpThreadLocalBase, @@ -1438,7 +1447,7 @@ windows_nat_target::get_windows_debug_event (int pid, } /* Record the existence of this thread. */ thread_id =3D current_event->dwThreadId; - windows_add_thread + add_thread (ptid_t (current_event->dwProcessId, current_event->dwThreadId, 0), current_event->u.CreateThread.hThread, current_event->u.CreateThread.lpThreadLocalBase, @@ -1451,10 +1460,10 @@ windows_nat_target::get_windows_debug_event (int pi= d, (unsigned) current_event->dwProcessId, (unsigned) current_event->dwThreadId, "EXIT_THREAD_DEBUG_EVENT"); - windows_delete_thread (ptid_t (current_event->dwProcessId, - current_event->dwThreadId, 0), - current_event->u.ExitThread.dwExitCode, - false /* main_thread_p */); + delete_thread (ptid_t (current_event->dwProcessId, + current_event->dwThreadId, 0), + current_event->u.ExitThread.dwExitCode, + false /* main_thread_p */); break; =20 case CREATE_PROCESS_DEBUG_EVENT: @@ -1468,7 +1477,7 @@ windows_nat_target::get_windows_debug_event (int pid, =20 windows_process.handle =3D current_event->u.CreateProcessInfo.hProce= ss; /* Add the main thread. */ - windows_add_thread + add_thread (ptid_t (current_event->dwProcessId, current_event->dwThreadId, 0), current_event->u.CreateProcessInfo.hThread, @@ -1491,9 +1500,9 @@ windows_nat_target::get_windows_debug_event (int pid, } else if (saw_create =3D=3D 1) { - windows_delete_thread (ptid_t (current_event->dwProcessId, - current_event->dwThreadId, 0), - 0, true /* main_thread_p */); + delete_thread (ptid_t (current_event->dwProcessId, + current_event->dwThreadId, 0), + 0, true /* main_thread_p */); DWORD exit_status =3D current_event->u.ExitProcess.dwExitCode; /* If the exit status looks like a fatal exception, but we don't recognize the exception's code, make the original