From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web11.473.1572413627145698009 for ; Tue, 29 Oct 2019 22:33:47 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: liming.gao@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Oct 2019 22:33:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,246,1569308400"; d="scan'208,217";a="190173581" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga007.jf.intel.com with ESMTP; 29 Oct 2019 22:33:46 -0700 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 29 Oct 2019 22:33:45 -0700 Received: from shsmsx154.ccr.corp.intel.com (10.239.6.54) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 29 Oct 2019 22:33:44 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.127]) by SHSMSX154.ccr.corp.intel.com ([169.254.7.200]) with mapi id 14.03.0439.000; Wed, 30 Oct 2019 13:33:43 +0800 From: "Liming Gao" To: "devel@edk2.groups.io" , "KILIAN_KEGEL@OUTLOOK.COM" CC: "Richardson, Brian" , "Kinney, Michael D" Subject: Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak() Thread-Topic: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak() Thread-Index: AQHVjY/g3fyCPIGsFE2OwuZEPryr9qdyqqyw Date: Wed, 30 Oct 2019 05:33:42 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E534825@SHSMSX104.ccr.corp.intel.com> References: <2d5ec4d308504c87b7b1390c1e2f1495@zhaoxin.com>,<4A89E2EF3DFEDB4C8BFDE51014F606A14E5325C1@SHSMSX104.ccr.corp.intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_4A89E2EF3DFEDB4C8BFDE51014F606A14E534825SHSMSX104ccrcor_" --_000_4A89E2EF3DFEDB4C8BFDE51014F606A14E534825SHSMSX104ccrcor_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Kilian: I normally modify the source code and insert CpuBreakpoint() function. = That will trig VS debugger for the source code. Thanks Liming From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Kili= an Kegel Sent: Monday, October 28, 2019 9:01 PM To: Gao, Liming Cc: devel@edk2.groups.io; Richardson, Brian ; = Kinney, Michael D Subject: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak() Hi Liming, If have observed in newer Windows 10 versions, when using __debugbreak()in= any application that Windows just terminates the app, instead offering to debu= g it. So in WinHost.exe too. That's why I usually insert the code snippet below to run into getchar() when the program was started with the /debug command line switch. As long as the App waits for the next keystroke, I can start the debugger = (VS2019) and connect to WinHost.exe process for debugging. Do you have a better solution without modifying the source code? Thanks, Kilian if(1){ int i; SecPrint ("#######################################################= ###############################################\n"); SecPrint ("add \"/debug\" command line switch, to connect to the d= ebugger at the very beginning of POST emulation\n"); SecPrint ("#######################################################= ###############################################\n"); if(Argc > 1){ for(i =3D 1 ; i < Argc ; i++){ if(0 =3D=3D strcmp("/debug", Argv[i])){ //SecPrint("IF YOU WANT TO DEBUG from the very beg= inning of the EMULATION:\n\t1. start the TASKMGR\n\t2. connect WinHost.exe = to the debugger\n\t3. and press ENTER in this command box\nOR\n"); SecPrint("\t1. start Visual Studio\n"); SecPrint("\t2. DEBUG->ATTACH TO PROCESS (CTRL + AL= T + P) --> WinHost.exe\n"); SecPrint("\t3. Break All (CTRL + ALT + Break) -->= WinHost.exe\n"); SecPrint("\t4. SET A SOFTWARE BREAKPOINT (F9) in l= ine 445\n"); SecPrint("\t5. and press ENTER in this command box= \n"); SecPrint("\t6. go back to Visual Studio an RUN/SIN= GLE STEP the application\n"); SecPrint("\t7. otherwise press enter to continue..= .\n"); getchar(); // // 1. SET A SOFTWARE BREAKPOINT TO THE NEXT LINE o= f code below -->> SecPrint(""); // 2. switch to the command box and press ENTER // 3. start single stepping the entire boot/emulat= ion process, good luck... // SecPrint("");//now you can single step the entire = boot/emulation process, good luck... } } } } --_000_4A89E2EF3DFEDB4C8BFDE51014F606A14E534825SHSMSX104ccrcor_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Kilian:

   I normal= ly modify the source code and insert CpuBreakpoint() function. That will tr= ig VS debugger for the source code.

 

Thanks

Liming

From: devel@edk2.groups.io [mailto:devel@edk= 2.groups.io] On Behalf Of Kilian Kegel
Sent: Monday, October 28, 2019 9:01 PM
To: Gao, Liming <liming.gao@intel.com>
Cc: devel@edk2.groups.io; Richardson, Brian <brian.richardson@in= tel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()

 

Hi Liming,

 

If have observed in newer Windows 10 versions, when= using __debugbreak()in any

application that Windows just terminates the app, i= nstead offering to debug it.

So in WinHost.exe too.

 

That’s why I usually insert the code snippet = below to run into getchar()

when the program was started with the /debug comman= d line switch.

As long as the App waits for the next keystroke, I = can start the debugger (VS2019)

and connect to WinHost.exe process for debugging.

 

Do you have a better solution without modifying the= source code?

 

Thanks,

Kilian

    if(1){

        int i= ;

 

        SecPr= int ("################################################################= ######################################\n");

        SecPr= int ("add \"/debug\" command line switch, to connect to the = debugger at the very beginning of POST emulation\n");

        SecPr= int ("################################################################= ######################################\n");

 

        if(Ar= gc > 1){

        =     for(i =3D 1 ; i < Argc ; i++){=

        =         if(0 =3D=3D strcmp("/debug&= quot;, Argv[i])){

        =             &nb= sp;   //SecPrint("IF YOU WANT TO DEBUG from the very beginni= ng of the EMULATION:\n\t1. start the TASKMGR\n\t2. connect WinHost.exe to t= he debugger\n\t3. and press ENTER in this command box\nOR\n");

        =             &nb= sp;   SecPrint("\t1. start Visual Studio\n");

        =             &nb= sp;   SecPrint("\t2. DEBUG->ATTACH TO PROCESS (CTRL += ALT + P) --> WinHost.exe\n");

        =             &nb= sp;   SecPrint("\t3. Break All  (CTRL + ALT + B= reak) --> WinHost.exe\n");

        =              &n= bsp;  SecPrint("\t4. SET A SOFTWARE BREAKPOINT (F9) in line 445\n= ");

        =             &nb= sp;   SecPrint("\t5. and press ENTER in this command box\n&q= uot;);

        =             &nb= sp;   SecPrint("\t6. go back to Visual Studio an RUN/SINGLE = STEP the application\n");

        =             &nb= sp;   SecPrint("\t7. otherwise press enter to continue...\n&= quot;);

        =             &nb= sp;   getchar();

        =             &nb= sp;   //

        =             &nb= sp;   // 1. SET A SOFTWARE BREAKPOINT TO THE NEXT LINE of code be= low -->> SecPrint("");

        =             &nb= sp;   // 2. switch to the command box and press ENTER<= /b>

        =             &nb= sp;   // 3. start single stepping the entire boot/emulation proce= ss, good luck...

        =             &nb= sp;   //

        =             &nb= sp;   SecPrint("");//now you can single step the entire= boot/emulation process, good luck...

        =            }

        =     }

        }

    }

--_000_4A89E2EF3DFEDB4C8BFDE51014F606A14E534825SHSMSX104ccrcor_--