From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2111) id DC8933858C62; Mon, 28 Nov 2022 19:44:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC8933858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669664690; bh=d0GUEKt1dwqGf0UBi1lpMOmvzDRzLYyrggEzCzEpHFI=; h=From:To:Subject:Date:From; b=DaWbGlAqBDFWteuC7OkdZwY0+54URVDo9XHQB7KM3Nw/ZJJjU0BSJlnNckJ1ouCGI XYEIW4ag2UgU7+ocWZ8hmr2PHDWtVJlLxhBfwJwLnr0hS3/UZ2K/HPovfOyF5Ylefi heujRXVrm9bJqH4ZltXOZijdewD0TK2pYSdla4u0= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Hannes Domani To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Fix calling convention of thread entry point X-Act-Checkin: binutils-gdb X-Git-Author: Hannes Domani X-Git-Refname: refs/heads/master X-Git-Oldrev: 5975a5caceb238be7eddb3b279d51145a1628af8 X-Git-Newrev: 1d39fec4aeacc53f6eb696eaa846f8f07948fcf5 Message-Id: <20221128194450.DC8933858C62@sourceware.org> Date: Mon, 28 Nov 2022 19:44:50 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D1d39fec4aeac= c53f6eb696eaa846f8f07948fcf5 commit 1d39fec4aeacc53f6eb696eaa846f8f07948fcf5 Author: Hannes Domani Date: Mon Nov 28 19:22:38 2022 +0100 Fix calling convention of thread entry point =20 For i686 the CreateThread entry point function needs the WINAPI (stdcal= l) calling convention: =20 ../../gdb/windows-nat.c: In constructor 'windows_nat_target::windows_na= t_target()': ../../gdb/windows-nat.c:450:56: error: invalid user-defined conversion = from 'windows_nat_target::windows_nat_target()::' to 'LPTHR= EAD_START_ROUTINE' {aka 'long unsigned int (__attribute__((stdcall)) *)(voi= d*)'} [-fpermissive] 450 | HANDLE bg_thread =3D CreateThread (nullptr, 64 * 1024, fn, th= is, 0, nullptr); | ^~ ../../gdb/windows-nat.c:444:13: note: candidate is: 'constexpr windows_= nat_target::windows_nat_target()::::operator DWORD (*)(LPVO= ID)() const' (near match) 444 | auto fn =3D [] (LPVOID self) -> DWORD | ^ ../../gdb/windows-nat.c:444:13: note: no known conversion from 'DWORD= (*)(LPVOID)' {aka 'long unsigned int (*)(void*)'} to 'LPTHREAD_START_ROUTI= NE' {aka 'long unsigned int (__attribute__((stdcall)) *)(void*)'} =20 Since it's not possible to change the calling convention of a lambda, I= 've moved it to a separate function. Diff: --- gdb/windows-nat.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 5d506507b6d..f61f6c1cb35 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -344,6 +344,9 @@ private: BOOL windows_continue (DWORD continue_status, int id, int killed, bool last_call =3D false); =20 + /* Helper function to start process_thread. */ + static DWORD WINAPI process_thread_starter (LPVOID self); + /* This function implements the background thread that starts inferiors and waits for events. */ void process_thread (); @@ -404,13 +407,8 @@ windows_nat_target::windows_nat_target () m_response_event (CreateEvent (nullptr, false, false, nullptr)), m_wait_event (make_serial_event ()) { - auto fn =3D [] (LPVOID self) -> DWORD - { - ((windows_nat_target *) self)->process_thread (); - return 0; - }; - - HANDLE bg_thread =3D CreateThread (nullptr, 64 * 1024, fn, this, 0, null= ptr); + HANDLE bg_thread =3D CreateThread (nullptr, 64 * 1024, + process_thread_starter, this, 0, nullptr); CloseHandle (bg_thread); } =20 @@ -453,6 +451,13 @@ wait_for_single (HANDLE handle, DWORD howlong) } } =20 +DWORD WINAPI +windows_nat_target::process_thread_starter (LPVOID self) +{ + ((windows_nat_target *) self)->process_thread (); + return 0; +} + void windows_nat_target::process_thread () {