From: Hannes Domani <ssbssa@yahoo.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/4] Fix calling convention of thread entry point
Date: Mon, 28 Nov 2022 20:12:21 +0100 [thread overview]
Message-ID: <20221128191224.1411-1-ssbssa@yahoo.de> (raw)
In-Reply-To: <20221128191224.1411-1-ssbssa.ref@yahoo.de>
For i686 the CreateThread entry point function needs the WINAPI (stdcall)
calling convention:
../../gdb/windows-nat.c: In constructor 'windows_nat_target::windows_nat_target()':
../../gdb/windows-nat.c:450:56: error: invalid user-defined conversion from 'windows_nat_target::windows_nat_target()::<lambda(LPVOID)>' to 'LPTHREAD_START_ROUTINE' {aka 'long unsigned int (__attribute__((stdcall)) *)(void*)'} [-fpermissive]
450 | HANDLE bg_thread = CreateThread (nullptr, 64 * 1024, fn, this, 0, nullptr);
| ^~
../../gdb/windows-nat.c:444:13: note: candidate is: 'constexpr windows_nat_target::windows_nat_target()::<lambda(LPVOID)>::operator DWORD (*)(LPVOID)() const' (near match)
444 | auto fn = [] (LPVOID self) -> DWORD
| ^
../../gdb/windows-nat.c:444:13: note: no known conversion from 'DWORD (*)(LPVOID)' {aka 'long unsigned int (*)(void*)'} to 'LPTHREAD_START_ROUTINE' {aka 'long unsigned int (__attribute__((stdcall)) *)(void*)'}
Since it's not possible to change the calling convention of a lambda, I've
moved it to a separate function.
---
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 @@ struct windows_nat_target final : public x86_nat_target<inf_child_target>
BOOL windows_continue (DWORD continue_status, int id, int killed,
bool last_call = false);
+ /* 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 = [] (LPVOID self) -> DWORD
- {
- ((windows_nat_target *) self)->process_thread ();
- return 0;
- };
-
- HANDLE bg_thread = CreateThread (nullptr, 64 * 1024, fn, this, 0, nullptr);
+ HANDLE bg_thread = CreateThread (nullptr, 64 * 1024,
+ process_thread_starter, this, 0, nullptr);
CloseHandle (bg_thread);
}
@@ -453,6 +451,13 @@ wait_for_single (HANDLE handle, DWORD howlong)
}
}
+DWORD WINAPI
+windows_nat_target::process_thread_starter (LPVOID self)
+{
+ ((windows_nat_target *) self)->process_thread ();
+ return 0;
+}
+
void
windows_nat_target::process_thread ()
{
--
2.35.1
next parent reply other threads:[~2022-11-28 19:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20221128191224.1411-1-ssbssa.ref@yahoo.de>
2022-11-28 19:12 ` Hannes Domani [this message]
2022-11-28 19:12 ` [PATCH 2/4] Don't use auto for lambda parameter Hannes Domani
2022-11-28 19:25 ` Tom Tromey
2022-11-28 19:12 ` [PATCH 3/4] Actually set m_is_async to current async mode Hannes Domani
2022-11-28 19:26 ` Tom Tromey
2022-11-28 19:12 ` [PATCH 4/4] Remove no longer used jump label Hannes Domani
2022-11-28 19:35 ` Tom Tromey
2022-11-28 19:24 ` [PATCH 1/4] Fix calling convention of thread entry point Tom Tromey
2022-11-28 19:45 ` Hannes Domani
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=20221128191224.1411-1-ssbssa@yahoo.de \
--to=ssbssa@yahoo.de \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).