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 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@intel.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, instead 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 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 debugger at the very beginning of POST emulation\n");

        SecPrint ("######################################################################################################\n");

 

        if(Argc > 1){

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

                if(0 == strcmp("/debug", Argv[i])){

                        //SecPrint("IF YOU WANT TO DEBUG from the very beginning 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 + ALT + P) --> WinHost.exe\n");

                        SecPrint("\t3. Break All  (CTRL + ALT + Break) --> WinHost.exe\n");

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

                        SecPrint("\t5. and press ENTER in this command box\n");

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

                        SecPrint("\t7. otherwise press enter to continue...\n");

                        getchar();

                        //

                        // 1. SET A SOFTWARE BREAKPOINT TO THE NEXT LINE of code below -->> SecPrint("");

                        // 2. switch to the command box and press ENTER

                        // 3. start single stepping the entire boot/emulation process, good luck...

                        //

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

                   }

            }

        }

    }