* [PATCH 1/4] Fix calling convention of thread entry point [not found] <20221128191224.1411-1-ssbssa.ref@yahoo.de> @ 2022-11-28 19:12 ` Hannes Domani 2022-11-28 19:12 ` [PATCH 2/4] Don't use auto for lambda parameter Hannes Domani ` (3 more replies) 0 siblings, 4 replies; 9+ messages in thread From: Hannes Domani @ 2022-11-28 19:12 UTC (permalink / raw) To: gdb-patches 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/4] Don't use auto for lambda parameter 2022-11-28 19:12 ` [PATCH 1/4] Fix calling convention of thread entry point Hannes Domani @ 2022-11-28 19:12 ` 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 ` (2 subsequent siblings) 3 siblings, 1 reply; 9+ messages in thread From: Hannes Domani @ 2022-11-28 19:12 UTC (permalink / raw) To: gdb-patches Older gcc versions (here 4.9.2) can't handle auto for a lambda parameter: ../../gdb/windows-nat.c: In member function 'void windows_nat_target::delete_thread(ptid_t, DWORD, bool)': ../../gdb/windows-nat.c:629:12: error: use of 'auto' in lambda parameter declaration only available with -std=c++1y or -std=gnu++1y [-Werror] [=] (auto &th) ^ --- gdb/windows-nat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index f61f6c1cb35..6da6757acaf 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -631,7 +631,7 @@ windows_nat_target::delete_thread (ptid_t ptid, DWORD exit_code, auto iter = std::find_if (windows_process.thread_list.begin (), windows_process.thread_list.end (), - [=] (auto &th) + [=] (std::unique_ptr<windows_thread_info> &th) { return th->tid == id; }); -- 2.35.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/4] Don't use auto for lambda parameter 2022-11-28 19:12 ` [PATCH 2/4] Don't use auto for lambda parameter Hannes Domani @ 2022-11-28 19:25 ` Tom Tromey 0 siblings, 0 replies; 9+ messages in thread From: Tom Tromey @ 2022-11-28 19:25 UTC (permalink / raw) To: Hannes Domani via Gdb-patches; +Cc: Hannes Domani >>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes: Hannes> Older gcc versions (here 4.9.2) can't handle auto for a lambda parameter: This is ok. Thank you for the patch. Tom ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/4] Actually set m_is_async to current async mode 2022-11-28 19:12 ` [PATCH 1/4] Fix calling convention of thread entry point Hannes Domani 2022-11-28 19:12 ` [PATCH 2/4] Don't use auto for lambda parameter Hannes Domani @ 2022-11-28 19:12 ` 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:24 ` [PATCH 1/4] Fix calling convention of thread entry point Tom Tromey 3 siblings, 1 reply; 9+ messages in thread From: Hannes Domani @ 2022-11-28 19:12 UTC (permalink / raw) To: gdb-patches Looks like this was missed in the async mode implementation. --- gdb/windows-nat.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 6da6757acaf..e2d2176f138 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -427,6 +427,8 @@ windows_nat_target::async (bool enable) nullptr, "windows_nat_target"); else delete_file_handler (async_wait_fd ()); + + m_is_async = enable; } /* A wrapper for WaitForSingleObject that issues a warning if -- 2.35.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/4] Actually set m_is_async to current async mode 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 0 siblings, 0 replies; 9+ messages in thread From: Tom Tromey @ 2022-11-28 19:26 UTC (permalink / raw) To: Hannes Domani via Gdb-patches; +Cc: Hannes Domani >>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes: Hannes> Looks like this was missed in the async mode implementation. Yikes, that's a bad oversight. Sorry about this. The patch is ok. Tom ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/4] Remove no longer used jump label 2022-11-28 19:12 ` [PATCH 1/4] Fix calling convention of thread entry point Hannes Domani 2022-11-28 19:12 ` [PATCH 2/4] Don't use auto for lambda parameter Hannes Domani 2022-11-28 19:12 ` [PATCH 3/4] Actually set m_is_async to current async mode Hannes Domani @ 2022-11-28 19:12 ` 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 3 siblings, 1 reply; 9+ messages in thread From: Hannes Domani @ 2022-11-28 19:12 UTC (permalink / raw) To: gdb-patches --- gdb/windows-nat.c | 1 - 1 file changed, 1 deletion(-) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index e2d2176f138..17422e15f80 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1824,7 +1824,6 @@ windows_nat_target::get_windows_debug_event windows_process.desired_stop_thread_id, 0)); } -out: if (thread_id == 0) return null_ptid; return ptid_t (windows_process.current_event.dwProcessId, thread_id, 0); -- 2.35.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 4/4] Remove no longer used jump label 2022-11-28 19:12 ` [PATCH 4/4] Remove no longer used jump label Hannes Domani @ 2022-11-28 19:35 ` Tom Tromey 0 siblings, 0 replies; 9+ messages in thread From: Tom Tromey @ 2022-11-28 19:35 UTC (permalink / raw) To: Hannes Domani via Gdb-patches; +Cc: Hannes Domani >>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes: Hannes> --- It's good to have a bit of text in the commit message. Anyway this patch is ok, could even be done under the 'obvious' rule. Thank you. Tom ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/4] Fix calling convention of thread entry point 2022-11-28 19:12 ` [PATCH 1/4] Fix calling convention of thread entry point Hannes Domani ` (2 preceding siblings ...) 2022-11-28 19:12 ` [PATCH 4/4] Remove no longer used jump label Hannes Domani @ 2022-11-28 19:24 ` Tom Tromey 2022-11-28 19:45 ` Hannes Domani 3 siblings, 1 reply; 9+ messages in thread From: Tom Tromey @ 2022-11-28 19:24 UTC (permalink / raw) To: Hannes Domani via Gdb-patches; +Cc: Hannes Domani >>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes: Hannes> For i686 the CreateThread entry point function needs the WINAPI (stdcall) Hannes> calling convention: Thanks, this is ok. I don't know why, but I don't see this when building on a Windows machine here. However, I can reproduce it using the mingw cross toolchain on Fedora. Tom ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/4] Fix calling convention of thread entry point 2022-11-28 19:24 ` [PATCH 1/4] Fix calling convention of thread entry point Tom Tromey @ 2022-11-28 19:45 ` Hannes Domani 0 siblings, 0 replies; 9+ messages in thread From: Hannes Domani @ 2022-11-28 19:45 UTC (permalink / raw) To: Hannes Domani via Gdb-patches, Tom Tromey Am Montag, 28. November 2022, 20:24:51 MEZ hat Tom Tromey <tom@tromey.com> Folgendes geschrieben: > >>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes: > > Hannes> For i686 the CreateThread entry point function needs the WINAPI (stdcall) > Hannes> calling convention: > > Thanks, this is ok. > > I don't know why, but I don't see this when building on a Windows > machine here. However, I can reproduce it using the mingw cross > toolchain on Fedora. Thanks, I've pushed these 4 patches. Hannes ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-11-28 19:45 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20221128191224.1411-1-ssbssa.ref@yahoo.de> 2022-11-28 19:12 ` [PATCH 1/4] Fix calling convention of thread entry point Hannes Domani 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
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).