From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sonic314-20.consmr.mail.ir2.yahoo.com (sonic314-20.consmr.mail.ir2.yahoo.com [77.238.177.146]) by sourceware.org (Postfix) with ESMTPS id 28B8F3840C36 for ; Thu, 17 Sep 2020 20:23:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 28B8F3840C36 X-YMail-OSG: t4wNRrUVM1l6sOcVshY_320oPhCW0TxAR3eRNGyFNUgDAQgHJrWFKtIUfP1Na7N QVK261E9cQdreEZ3V87YsGoyv_GblhZ_Biva_qrpGUrSoAqca_6DGnLSDXBTi34mcwgam2E_tHjw P1KGXBGhCwLcfLro1xggaR76KGp9hcOcGs_z4cIoArJg_zMOb9ENhw5uxLrmTZVf7lMyUnMwwhCP kAYiJzNKn6jjq7Fqe0vnv.tenFaylS7MSLztT6rfSbQsB1rF6kuXpFCpTKp9TCJWN6GnbLGPiswA 03incfq_OYlI4vsXfTN1yg222acACa.s2y9GeapsLPFWRKD4aCOEilMASU3r7Ld5fifjcYpRoaTY VH7sc8Y3FFFwLWI7.2JnlePrv2mXhqx_NKDmfRFEH7A8YmzSmUgGxVWjQPiGiwlS8rxztBt8ttlV hzqMp8B8vccrHRj9TW8gAGCVb2x1ylC0PB2sfdZAhC4REzKZhkXaHvReQOy6.YX63vAbLpqLTzbP alWs7.19zMrHoe32nicTGo69ThiwDXTrjPH9aY8.DEo9dnXeMOeiheNxRLBGymw0wQblUmTzWfCd _S3pxL_HJqCQezn9c68gnI6zmSJOr0xSL5MsG_050FLylUaBo.edzmTuwPlv9JSbZ7FqBg98AYso udcK8CZ3TXUQ1kBGEkJ6BzsSuAydNFntgPP5YAEL_L9FOiP9RKaHbxfLBCFFsjb_4Q_12XJfe8mE Sf0bBCAYyEtZrtFaIsfPAOe0Xz9mUBocEN6vHBE86THE206W4hBSAodNOxDJcEtKSOZgnoIIhz_o 6kpMOOoG67RCNpGE4T6xS3wgCTdpb3RgtUeIZ8SWWdFyhhILLisHNFUtT9hZno6UvQJJZSMYy1ZB dHOw9sLBoHy.6UGhTpOTeljOjhf079wlNiNcuG3TmG1Re7LeAaPMcl8x5XcenwY_2UlU9MFrVhXB M1Hh0lDz6wRts6A7pUHuq1UahJbESysAhO9uAMHyTNdYJyrdmtXwAW35u6jAnFryHWvtBsrYtuX0 pER95iYNIBmkLpvbAE5KlCL6v8GDz1BrL1RrrRvx2teUHNdgVdFjXi_TsuDDIhpjRmfJkxgJEVHb t2JPP_kUElYL_tdnP4oH6wROC6D784SNOiJZBx7mPvHYlg8vV61kA3R.GwlC2MCNvAmovPAeB2rO mn6aw85xyTepY237Gdeph4FLhiNF.J8Ox9ocnnaEQo4ew2hQxqL5G8wdGwaPThI9Om9kEs97xr3i Osv50gGtZqgOg1dBwdofqNPsRyfwbS608MNlv1K78U_xLGdgkHQxyO7_fHRMDaLgyEuniPrbdHod BfXjTLMpMHbbDYcVp2L77XLdwMHn4WF4kcyFqOOwNExFK.g4WIQ.To_N2aHiyldcDJUcmweGFFwx jZKSQLgTt_x1FRS.aP9rBNiy9NFSf641PEQvhCmoykMEchC5E73lGv20k93UtNwHTSF.sJGOYmPw - Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.ir2.yahoo.com with HTTP; Thu, 17 Sep 2020 20:23:45 +0000 Date: Thu, 17 Sep 2020 20:23:45 +0000 (UTC) From: Hannes Domani To: "gdb-patches@sourceware.org" , Simon Marchi Message-ID: <1811381142.1345868.1600374225078@mail.yahoo.com> In-Reply-To: <0c8dc56c-22cd-be59-3fdb-bae6878ea331@simark.ca> References: <20200917180337.1984-1-ssbssa.ref@yahoo.de> <20200917180337.1984-1-ssbssa@yahoo.de> <0c8dc56c-22cd-be59-3fdb-bae6878ea331@simark.ca> Subject: Re: [PATCH] Fix ctrl-c when debugging WOW64 processes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Mailer: WebService/1.1.16583 YMailNorrin Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0 X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2020 20:23:48 -0000 Am Donnerstag, 17. September 2020, 22:00:29 MESZ hat Simon Marchi Folgendes geschrieben: > On 2020-09-17 2:03 p.m., Hannes Domani via Gdb-patches wrote: > > DebugBreakProcess starts a new thread in the target process with the > > entry point DbgUiRemoteBreakin, where an int3 triggers a breakpoint > > exception for gdb. > > > > But this uses DbgUiRemoteBreakin of the 64bit ntdll.dll even for > > WOW64 processes. > > It stops in 64bit code, Wow64GetThreadContext reports a wrong pc withou= t > > the int3, and gdb lets the target process continue. > > > > So this uses DbgUiRemoteBreakin of the 32bit ntdll.dll as the thread > > entry point for WOW64 processes instead. > > Interesting.=C2=A0 Is there any reference somewhere that explains that th= ings > must be done this way when a 64 bit process is debugging a 32 bit > process? Sadly, I could find no real reference for this. It took me quite a few hours to debug/understand this problem. > In any case, the patch is OK, with the formatting nits below fixed. > > > @@ -1522,9 +1524,36 @@ ctrl_c_handler (DWORD event_type) > >=C2=A0=C2=A0=C2=A0 if (!new_console && !attach_flag) > >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return TRUE; > > > > -=C2=A0 if (!DebugBreakProcess (current_process_handle)) > > -=C2=A0=C2=A0=C2=A0 warning (_("Could not interrupt program.=C2=A0 " > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "Press Ctrl-c i= n the program console.")); > > +#ifdef __x86_64__ > > +=C2=A0 if (wow64_process) > > +=C2=A0=C2=A0=C2=A0 { > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Call DbgUiRemoteBreakin of the 32bit= ntdll.dll in the target process. > > +=C2=A0=C2=A0=C2=A0 DebugBreakProcess would call the one of the 64bit n= tdll.dll, which > > +=C2=A0=C2=A0=C2=A0 can't be correctly handled by gdb.=C2=A0 */ > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!wow64_dbgbreak) > > wow64_dbgbreak =3D=3D nullptr > > > > +=C2=A0=C2=A0=C2=A0 { > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 CORE_ADDR addr; > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!find_minimal_symbol_address ("ntdl= l!DbgUiRemoteBreakin", > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &addr= , 0)) > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 wow64_dbgbreak =3D (void *)= addr; > > +=C2=A0=C2=A0=C2=A0 } > > + > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (wow64_dbgbreak) > > > wow64_dbgbreak !=3D nullptr Pushed with these changes, thanks. Hannes