public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Kilian Kegel" <KILIAN_KEGEL@OUTLOOK.COM>
To: "liming.gao@intel.com" <liming.gao@intel.com>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Richardson, Brian" <brian.richardson@intel.com>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>
Subject: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
Date: Tue, 5 Nov 2019 17:36:21 +0000	[thread overview]
Message-ID: <VI1PR0502MB3968E000F5D41982DE3A4F66EB7E0@VI1PR0502MB3968.eurprd05.prod.outlook.com> (raw)
In-Reply-To: <VI1PR0502MB3968C24D22A8A203539AC905EB660@VI1PR0502MB3968.eurprd05.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 4916 bytes --]

Hi Liming,
>Kilian: can you send the patch to edk2 mail list for code review?
Regards,
Kilian

https://bugzilla.tianocore.org/show_bug.cgi?id=2319

diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c
index 62a89f7617..53cda86f9a 100644
--- a/EmulatorPkg/Win/Host/WinHost.c
+++ b/EmulatorPkg/Win/Host/WinHost.c
@@ -409,7 +409,30 @@ Returns:
   FirmwareVolumesStr = (CHAR16 *) PcdGetPtr (PcdEmuFirmwareVolume);
   SecPrint ("\n\rEDK II WIN Host Emulation Environment from http://www.tianocore.org/edk2/\n\r");
-
+
+  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 your debug engine\n");
+          SecPrint("\t2. attache to process WinHost.exe\n");
+          SecPrint("\t4. SET A SOFTWARE BREAKPOINT (F9) in line 431\n");
+          SecPrint("\t5. and press ENTER in the WinHost command box\n");
+          SecPrint("\t6. go back to the debug engine and RUN/SINGLE STEP the application\n");
+          SecPrint("\t7. otherwise press enter to continue...\n");
+
+          getchar();    //wait for keyboard input
+
+          SecPrint("");//now you can single step the entire boot/emulation process, good luck...
+        }
+      }
+    }
+  }
   //
   // Determine the first thread available to this process.
   //


________________________________
From: Kilian Kegel <kilian_kegel@outlook.com>
Sent: Monday, October 28, 2019 2:01:23 PM
To: liming.gao@intel.com <liming.gao@intel.com>
Cc: devel@edk2.groups.io <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...

                   }

            }

        }

    }

[-- Attachment #2: Type: text/html, Size: 14750 bytes --]

  parent reply	other threads:[~2019-11-05 17:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-25  9:24 [edk2-devel] [edk2] If use prebuild tools, not need install python 2.7 anymore? Tiger Liu(BJ-RD)
2019-10-28  5:26 ` Liming Gao
2019-10-28 13:01   ` [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak() Kilian Kegel
2019-10-30  5:33     ` Liming Gao
2019-10-30  9:16       ` Kilian Kegel
2019-10-30 15:03         ` Liming Gao
2019-10-30 15:22           ` Minnow Ware
2019-10-30 15:23             ` Liming Gao
2019-10-30 16:16           ` Michael D Kinney
2019-10-30 16:56             ` Andrew Fish
2019-11-05 17:36     ` Kilian Kegel [this message]
2019-11-13  1:06       ` [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint Liming Gao
2019-11-13  2:27         ` Ni, Ray
2019-11-14  5:23           ` Kilian Kegel
2019-11-14  6:57             ` Ni, Ray
2019-11-15  9:56               ` Kilian Kegel

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-list 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=VI1PR0502MB3968E000F5D41982DE3A4F66EB7E0@VI1PR0502MB3968.eurprd05.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /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