* Re: [edk2-devel] [edk2] If use prebuild tools, not need install python 2.7 anymore?
@ 2019-10-25 9:24 Tiger Liu(BJ-RD)
2019-10-28 5:26 ` Liming Gao
0 siblings, 1 reply; 16+ messages in thread
From: Tiger Liu(BJ-RD) @ 2019-10-25 9:24 UTC (permalink / raw)
To: devel@edk2.groups.io, liming.gao@intel.com
[-- Attachment #1: Type: text/plain, Size: 5135 bytes --]
Hi, Liming:
There is some Python tips as descripted below during udk compiling process.
……
--- Logging error ---
Traceback (most recent call last):
File "C:\Users\Lion\AppData\Local\Programs\Python\Python37\lib\logging\__init__.py", line 1028, in emit
stream.write(msg + self.terminator)
UnicodeEncodeError: 'gbk' codec can't encode character '\u0478' in position 0: illegal multibyte sequence
Call stack:
File "C:\Users\ Lion \AppData\Local\Programs\Python\Python37\lib\threading.py", line 890, in _bootstrap
self._bootstrap_inner()
File "C:\Users\ Lion \AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\ Lion \AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "Y:\BaseTools\Source\Python\build\build.py", line 179, in ReadMessage
To(Line.rstrip().decode(encoding='utf-8', errors='ignore'))
……
So, Is it OK?
Thanks
发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Liming Gao
发送时间: 2019年8月21日 14:48
收件人: devel@edk2.groups.io; Tiger Liu(BJ-RD) <TigerLiu@zhaoxin.com>
主题: Re: [edk2-devel] [edk2] If use prebuild tools, not need install python 2.7 anymore?
Tiger:
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> [mailto:devel@edk2.groups.io] On Behalf Of Tiger Liu(BJ-RD)
Sent: Tuesday, August 20, 2019 1:01 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Gao, Liming <liming.gao@intel.com<mailto:liming.gao@intel.com>>
Subject: 答复: [edk2-devel] [edk2] If use prebuild tools, not need install python 2.7 anymore?
Hi, Liming:
Based on the below web info:
https://github.com/tianocore/tianocore.github.io/wiki/Edk2-buildtools
[Liming] This page is out of date. buildtools-BaseTools is DEPRECATED. Use BaseTools under EDK II instead.
The python tools are used to compile the building tools written by python.
https://github.com/tianocore/tianocore.github.io/wiki/BuildTool-Setup-Guide
in the above web, it said:
“The tools in this section are NOT required to build the EDK II project; they are needed to compile the BaseTools used to build the EDK II project.”
[Liming] Thanks for your point. I will update this wiki page.
If I used the Prebuilt Windows tools (Win32 binaries), then I don’t need install python package anymore?
Or, current UDK source code doesn’t support prebuilt tools binary, it always need installing Python to compile python build tools every time.
[Liming] Now, edk2 requires Python3.x for build. This change happened one year ago. Please see https://edk2.groups.io/g/devel/message/29436.
Liming
Thanks
发件人: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> 代表 Liming Gao
发送时间: 2019年8月19日 22:46
收件人: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Tiger Liu(BJ-RD) <TigerLiu@zhaoxin.com<mailto:TigerLiu@zhaoxin.com>>
主题: Re: [edk2-devel] [edk2] If use prebuild tools, not need install python 2.7 anymore?
Now, edk2 stable tag release is https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Release-Planning
After edk2-stable201903 tag, edk2 supports Python3. User needs to install Python3.x, doesn’t need to set PYTHON path.
Thanks
Liming
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> [mailto:devel@edk2.groups.io] On Behalf Of Tiger Liu(BJ-RD)
Sent: Monday, August 19, 2019 4:56 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Subject: [edk2-devel] [edk2] If use prebuild tools, not need install python 2.7 anymore?
Hello,
I have a question about needing install python 2.7
If user wants to setup udk compiling environment, he needs install python 2.7.
When running build command every time, it always check python tool path.
Why?
If I compiled basetools before, and use the prebuilt basetools package, then I don’t need install python 2.7 package?
Thanks
保密声明:
本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。
CONFIDENTIAL NOTE:
This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or forwarding of this email or the content of this email is strictly prohibited.
保密声明:
本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。
CONFIDENTIAL NOTE:
This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or forwarding of this email or the content of this email is strictly prohibited.
保密声明:
本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。
CONFIDENTIAL NOTE:
This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or forwarding of this email or the content of this email is strictly prohibited.
[-- Attachment #2: Type: text/html, Size: 21182 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2] If use prebuild tools, not need install python 2.7 anymore?
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
0 siblings, 1 reply; 16+ messages in thread
From: Liming Gao @ 2019-10-28 5:26 UTC (permalink / raw)
To: devel@edk2.groups.io, tigerliu@zhaoxin.com
[-- Attachment #1: Type: text/plain, Size: 5662 bytes --]
Where do you get BaseTools source code? Please clone the latest Edk2 (git@github.com:tianocore/edk2.git) and get BaseTools.
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Tiger Liu(BJ-RD)
Sent: Friday, October 25, 2019 5:24 PM
To: devel@edk2.groups.io; Gao, Liming <liming.gao@intel.com>
Subject: Re: [edk2-devel] [edk2] If use prebuild tools, not need install python 2.7 anymore?
Hi, Liming:
There is some Python tips as descripted below during udk compiling process.
……
--- Logging error ---
Traceback (most recent call last):
File "C:\Users\Lion\AppData\Local\Programs\Python\Python37\lib\logging\__init__.py", line 1028, in emit
stream.write(msg + self.terminator)
UnicodeEncodeError: 'gbk' codec can't encode character '\u0478' in position 0: illegal multibyte sequence
Call stack:
File "C:\Users\ Lion \AppData\Local\Programs\Python\Python37\lib\threading.py", line 890, in _bootstrap
self._bootstrap_inner()
File "C:\Users\ Lion \AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\ Lion \AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "Y:\BaseTools\Source\Python\build\build.py", line 179, in ReadMessage
To(Line.rstrip().decode(encoding='utf-8', errors='ignore'))
……
So, Is it OK?
Thanks
发件人: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> 代表 Liming Gao
发送时间: 2019年8月21日 14:48
收件人: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Tiger Liu(BJ-RD) <TigerLiu@zhaoxin.com<mailto:TigerLiu@zhaoxin.com>>
主题: Re: [edk2-devel] [edk2] If use prebuild tools, not need install python 2.7 anymore?
Tiger:
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> [mailto:devel@edk2.groups.io] On Behalf Of Tiger Liu(BJ-RD)
Sent: Tuesday, August 20, 2019 1:01 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Gao, Liming <liming.gao@intel.com<mailto:liming.gao@intel.com>>
Subject: 答复: [edk2-devel] [edk2] If use prebuild tools, not need install python 2.7 anymore?
Hi, Liming:
Based on the below web info:
https://github.com/tianocore/tianocore.github.io/wiki/Edk2-buildtools
[Liming] This page is out of date. buildtools-BaseTools is DEPRECATED. Use BaseTools under EDK II instead.
The python tools are used to compile the building tools written by python.
https://github.com/tianocore/tianocore.github.io/wiki/BuildTool-Setup-Guide
in the above web, it said:
“The tools in this section are NOT required to build the EDK II project; they are needed to compile the BaseTools used to build the EDK II project.”
[Liming] Thanks for your point. I will update this wiki page.
If I used the Prebuilt Windows tools (Win32 binaries), then I don’t need install python package anymore?
Or, current UDK source code doesn’t support prebuilt tools binary, it always need installing Python to compile python build tools every time.
[Liming] Now, edk2 requires Python3.x for build. This change happened one year ago. Please see https://edk2.groups.io/g/devel/message/29436.
Liming
Thanks
发件人: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> 代表 Liming Gao
发送时间: 2019年8月19日 22:46
收件人: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Tiger Liu(BJ-RD) <TigerLiu@zhaoxin.com<mailto:TigerLiu@zhaoxin.com>>
主题: Re: [edk2-devel] [edk2] If use prebuild tools, not need install python 2.7 anymore?
Now, edk2 stable tag release is https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Release-Planning
After edk2-stable201903 tag, edk2 supports Python3. User needs to install Python3.x, doesn’t need to set PYTHON path.
Thanks
Liming
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> [mailto:devel@edk2.groups.io] On Behalf Of Tiger Liu(BJ-RD)
Sent: Monday, August 19, 2019 4:56 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Subject: [edk2-devel] [edk2] If use prebuild tools, not need install python 2.7 anymore?
Hello,
I have a question about needing install python 2.7
If user wants to setup udk compiling environment, he needs install python 2.7.
When running build command every time, it always check python tool path.
Why?
If I compiled basetools before, and use the prebuilt basetools package, then I don’t need install python 2.7 package?
Thanks
保密声明:
本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。
CONFIDENTIAL NOTE:
This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or forwarding of this email or the content of this email is strictly prohibited.
保密声明:
本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。
CONFIDENTIAL NOTE:
This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or forwarding of this email or the content of this email is strictly prohibited.
保密声明:
本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。
CONFIDENTIAL NOTE:
This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or forwarding of this email or the content of this email is strictly prohibited.
[-- Attachment #2: Type: text/html, Size: 22721 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
2019-10-28 5:26 ` Liming Gao
@ 2019-10-28 13:01 ` Kilian Kegel
2019-10-30 5:33 ` Liming Gao
2019-11-05 17:36 ` [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint Kilian Kegel
0 siblings, 2 replies; 16+ messages in thread
From: Kilian Kegel @ 2019-10-28 13:01 UTC (permalink / raw)
To: liming.gao@intel.com
Cc: devel@edk2.groups.io, Richardson, Brian, Kinney, Michael D
[-- Attachment #1: Type: text/plain, Size: 2472 bytes --]
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: 9916 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
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-11-05 17:36 ` [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint Kilian Kegel
1 sibling, 1 reply; 16+ messages in thread
From: Liming Gao @ 2019-10-30 5:33 UTC (permalink / raw)
To: devel@edk2.groups.io, KILIAN_KEGEL@OUTLOOK.COM
Cc: Richardson, Brian, Kinney, Michael D
[-- Attachment #1: Type: text/plain, Size: 2977 bytes --]
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...
}
}
}
}
[-- Attachment #2: Type: text/html, Size: 10227 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
2019-10-30 5:33 ` Liming Gao
@ 2019-10-30 9:16 ` Kilian Kegel
2019-10-30 15:03 ` Liming Gao
0 siblings, 1 reply; 16+ messages in thread
From: Kilian Kegel @ 2019-10-30 9:16 UTC (permalink / raw)
To: Gao, Liming, devel@edk2.groups.io; +Cc: Richardson, Brian, Kinney, Michael D
[-- Attachment #1.1: Type: text/plain, Size: 4437 bytes --]
Hi Liming,
CpuBreakPoint() is the same as __debugbreak() on Microsoft Compiler and generates INT 3 DebugTrap.
Yes, that procedure has worked in the past and I have used it in the same way as you do.
But with newer Windows versions, Windows just terminates the “exceptional” process that emits
INT 3 or any other violation trap and does not offer to debug the process – surly for security reasons…
For debugging purpose on newer Windows 10 versions I always insert the code snippet below.
It gives the developer the chance to connect VS to the process to be debugged, while waiting on keyboard input.
(ALT-CTRL-P attach to process)
After that, with the debuggee is connected to VS _before_ the debug trap appears. VS is now
available for debugging the process with full source code.
The EmulatorPkg (and Nt32Pkg) was the most helpful tool to understand and debug UEFI internals for me.
EmulatorPkg should also usable and helpful for other devolpers.
Can you please insert the code snippet into main() from WinHost.c?
Thanks,
Kilian
From: Gao, Liming<mailto:liming.gao@intel.com>
Sent: Wednesday, October 30, 2019 06:33 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; KILIAN_KEGEL@OUTLOOK.COM<mailto:KILIAN_KEGEL@OUTLOOK.COM>
Cc: Richardson, Brian<mailto:brian.richardson@intel.com>; Kinney, Michael D<mailto:michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
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...
}
}
}
}
[-- Attachment #1.2: Type: text/html, Size: 12321 bytes --]
[-- Attachment #2: 84E6CE3361ED498BA9AC3CEA8ECF7B11.png --]
[-- Type: image/png, Size: 144 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
2019-10-30 9:16 ` Kilian Kegel
@ 2019-10-30 15:03 ` Liming Gao
2019-10-30 15:22 ` Minnow Ware
2019-10-30 16:16 ` Michael D Kinney
0 siblings, 2 replies; 16+ messages in thread
From: Liming Gao @ 2019-10-30 15:03 UTC (permalink / raw)
To: devel@edk2.groups.io, KILIAN_KEGEL@OUTLOOK.COM
Cc: Richardson, Brian, Kinney, Michael D, Ni, Ray
[-- Attachment #1: Type: text/plain, Size: 5303 bytes --]
Kilian:
I think this idea is good. It can be enabled when the developer wants to do the source level debug. So, one PCD may be introduced to control the logic. By default, there is no change. When PCD is enabled, WinHost will wait for the developer input.
Can you submit BZ for this request, and prepare the patch for the change?
Thanks
Liming
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Kilian Kegel
Sent: Wednesday, October 30, 2019 5:17 PM
To: Gao, Liming <liming.gao@intel.com>; devel@edk2.groups.io
Cc: Richardson, Brian <brian.richardson@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
Hi Liming,
CpuBreakPoint() is the same as __debugbreak() on Microsoft Compiler and generates INT 3 DebugTrap.
Yes, that procedure has worked in the past and I have used it in the same way as you do.
But with newer Windows versions, Windows just terminates the "exceptional" process that emits
INT 3 or any other violation trap and does not offer to debug the process - surly for security reasons...
For debugging purpose on newer Windows 10 versions I always insert the code snippet below.
It gives the developer the chance to connect VS to the process to be debugged, while waiting on keyboard input.
(ALT-CTRL-P attach to process)
After that, with the debuggee is connected to VS _before_ the debug trap appears. VS is now
available for debugging the process with full source code.
The EmulatorPkg (and Nt32Pkg) was the most helpful tool to understand and debug UEFI internals for me.
EmulatorPkg should also usable and helpful for other devolpers.
Can you please insert the code snippet into main() from WinHost.c?
Thanks,
Kilian
From: Gao, Liming<mailto:liming.gao@intel.com>
Sent: Wednesday, October 30, 2019 06:33 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; KILIAN_KEGEL@OUTLOOK.COM<mailto:KILIAN_KEGEL@OUTLOOK.COM>
Cc: Richardson, Brian<mailto:brian.richardson@intel.com>; Kinney, Michael D<mailto:michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
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> [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<mailto:liming.gao@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Richardson, Brian <brian.richardson@intel.com<mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto: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: 17374 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
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
1 sibling, 1 reply; 16+ messages in thread
From: Minnow Ware @ 2019-10-30 15:22 UTC (permalink / raw)
To: devel@edk2.groups.io, liming.gao@intel.com,
KILIAN_KEGEL@OUTLOOK.COM
Cc: Richardson, Brian, Kinney, Michael D, Ni, Ray
[-- Attachment #1: Type: text/plain, Size: 6126 bytes --]
Hi Liming,
1. when you invoke WINHOST.EXE /debug, it waits for developer input
2. otherwise default behavior
A PCD is needless.
Regards,
Kilian
________________________________
From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Liming Gao <liming.gao@intel.com>
Sent: Wednesday, October 30, 2019 4:03:13 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>; KILIAN_KEGEL@OUTLOOK.COM <KILIAN_KEGEL@OUTLOOK.COM>
Cc: Richardson, Brian <brian.richardson@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Ni, Ray <ray.ni@intel.com>
Subject: Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
Kilian:
I think this idea is good. It can be enabled when the developer wants to do the source level debug. So, one PCD may be introduced to control the logic. By default, there is no change. When PCD is enabled, WinHost will wait for the developer input.
Can you submit BZ for this request, and prepare the patch for the change?
Thanks
Liming
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Kilian Kegel
Sent: Wednesday, October 30, 2019 5:17 PM
To: Gao, Liming <liming.gao@intel.com>; devel@edk2.groups.io
Cc: Richardson, Brian <brian.richardson@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
Hi Liming,
CpuBreakPoint() is the same as __debugbreak() on Microsoft Compiler and generates INT 3 DebugTrap.
Yes, that procedure has worked in the past and I have used it in the same way as you do.
But with newer Windows versions, Windows just terminates the “exceptional” process that emits
INT 3 or any other violation trap and does not offer to debug the process – surly for security reasons…
For debugging purpose on newer Windows 10 versions I always insert the code snippet below.
It gives the developer the chance to connect VS to the process to be debugged, while waiting on keyboard input.
(ALT-CTRL-P attach to process)
After that, with the debuggee is connected to VS _before_ the debug trap appears. VS is now
available for debugging the process with full source code.
The EmulatorPkg (and Nt32Pkg) was the most helpful tool to understand and debug UEFI internals for me.
EmulatorPkg should also usable and helpful for other devolpers.
Can you please insert the code snippet into main() from WinHost.c?
Thanks,
Kilian
From: Gao, Liming<mailto:liming.gao@intel.com>
Sent: Wednesday, October 30, 2019 06:33 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; KILIAN_KEGEL@OUTLOOK.COM<mailto:KILIAN_KEGEL@OUTLOOK.COM>
Cc: Richardson, Brian<mailto:brian.richardson@intel.com>; Kinney, Michael D<mailto:michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
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> [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<mailto:liming.gao@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Richardson, Brian <brian.richardson@intel.com<mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto: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: 19310 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
2019-10-30 15:22 ` Minnow Ware
@ 2019-10-30 15:23 ` Liming Gao
0 siblings, 0 replies; 16+ messages in thread
From: Liming Gao @ 2019-10-30 15:23 UTC (permalink / raw)
To: Minnow Ware, devel@edk2.groups.io, KILIAN_KEGEL@OUTLOOK.COM
Cc: Richardson, Brian, Kinney, Michael D, Ni, Ray
[-- Attachment #1: Type: text/plain, Size: 7047 bytes --]
OK. I see now. This way is better.
Thanks
Liming
From: Minnow Ware <minnowware@outlook.com>
Sent: Wednesday, October 30, 2019 11:22 PM
To: devel@edk2.groups.io; Gao, Liming <liming.gao@intel.com>; KILIAN_KEGEL@OUTLOOK.COM
Cc: Richardson, Brian <brian.richardson@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Ni, Ray <ray.ni@intel.com>
Subject: RE: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
Hi Liming,
1. when you invoke WINHOST.EXE /debug, it waits for developer input
2. otherwise default behavior
A PCD is needless.
Regards,
Kilian
________________________________
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> on behalf of Liming Gao <liming.gao@intel.com<mailto:liming.gao@intel.com>>
Sent: Wednesday, October 30, 2019 4:03:13 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; KILIAN_KEGEL@OUTLOOK.COM<mailto:KILIAN_KEGEL@OUTLOOK.COM> <KILIAN_KEGEL@OUTLOOK.COM<mailto:KILIAN_KEGEL@OUTLOOK.COM>>
Cc: Richardson, Brian <brian.richardson@intel.com<mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>; Ni, Ray <ray.ni@intel.com<mailto:ray.ni@intel.com>>
Subject: Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
Kilian:
I think this idea is good. It can be enabled when the developer wants to do the source level debug. So, one PCD may be introduced to control the logic. By default, there is no change. When PCD is enabled, WinHost will wait for the developer input.
Can you submit BZ for this request, and prepare the patch for the change?
Thanks
Liming
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Kilian Kegel
Sent: Wednesday, October 30, 2019 5:17 PM
To: Gao, Liming <liming.gao@intel.com<mailto:liming.gao@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Cc: Richardson, Brian <brian.richardson@intel.com<mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
Hi Liming,
CpuBreakPoint() is the same as __debugbreak() on Microsoft Compiler and generates INT 3 DebugTrap.
Yes, that procedure has worked in the past and I have used it in the same way as you do.
But with newer Windows versions, Windows just terminates the "exceptional" process that emits
INT 3 or any other violation trap and does not offer to debug the process - surly for security reasons...
For debugging purpose on newer Windows 10 versions I always insert the code snippet below.
It gives the developer the chance to connect VS to the process to be debugged, while waiting on keyboard input.
(ALT-CTRL-P attach to process)
After that, with the debuggee is connected to VS _before_ the debug trap appears. VS is now
available for debugging the process with full source code.
The EmulatorPkg (and Nt32Pkg) was the most helpful tool to understand and debug UEFI internals for me.
EmulatorPkg should also usable and helpful for other devolpers.
Can you please insert the code snippet into main() from WinHost.c?
Thanks,
Kilian
From: Gao, Liming<mailto:liming.gao@intel.com>
Sent: Wednesday, October 30, 2019 06:33 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; KILIAN_KEGEL@OUTLOOK.COM<mailto:KILIAN_KEGEL@OUTLOOK.COM>
Cc: Richardson, Brian<mailto:brian.richardson@intel.com>; Kinney, Michael D<mailto:michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
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> [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<mailto:liming.gao@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Richardson, Brian <brian.richardson@intel.com<mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto: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: 24951 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
2019-10-30 15:03 ` Liming Gao
2019-10-30 15:22 ` Minnow Ware
@ 2019-10-30 16:16 ` Michael D Kinney
2019-10-30 16:56 ` Andrew Fish
1 sibling, 1 reply; 16+ messages in thread
From: Michael D Kinney @ 2019-10-30 16:16 UTC (permalink / raw)
To: Gao, Liming, devel@edk2.groups.io, KILIAN_KEGEL@OUTLOOK.COM,
Kinney, Michael D
Cc: Richardson, Brian, Ni, Ray
[-- Attachment #1: Type: text/plain, Size: 6094 bytes --]
Liming,
This may be something that is better with a command line option when WinHost.exe is started instead of a PCD.
I also think there is a way to run VS first and start a process from VS and do an initial BP. Does that work with latest Windows 10?
Mike
From: Gao, Liming <liming.gao@intel.com>
Sent: Wednesday, October 30, 2019 8:03 AM
To: devel@edk2.groups.io; KILIAN_KEGEL@OUTLOOK.COM
Cc: Richardson, Brian <brian.richardson@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Ni, Ray <ray.ni@intel.com>
Subject: RE: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
Kilian:
I think this idea is good. It can be enabled when the developer wants to do the source level debug. So, one PCD may be introduced to control the logic. By default, there is no change. When PCD is enabled, WinHost will wait for the developer input.
Can you submit BZ for this request, and prepare the patch for the change?
Thanks
Liming
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Kilian Kegel
Sent: Wednesday, October 30, 2019 5:17 PM
To: Gao, Liming <liming.gao@intel.com<mailto:liming.gao@intel.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Cc: Richardson, Brian <brian.richardson@intel.com<mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
Hi Liming,
CpuBreakPoint() is the same as __debugbreak() on Microsoft Compiler and generates INT 3 DebugTrap.
Yes, that procedure has worked in the past and I have used it in the same way as you do.
But with newer Windows versions, Windows just terminates the "exceptional" process that emits
INT 3 or any other violation trap and does not offer to debug the process - surly for security reasons...
For debugging purpose on newer Windows 10 versions I always insert the code snippet below.
It gives the developer the chance to connect VS to the process to be debugged, while waiting on keyboard input.
(ALT-CTRL-P attach to process)
After that, with the debuggee is connected to VS _before_ the debug trap appears. VS is now
available for debugging the process with full source code.
The EmulatorPkg (and Nt32Pkg) was the most helpful tool to understand and debug UEFI internals for me.
EmulatorPkg should also usable and helpful for other devolpers.
Can you please insert the code snippet into main() from WinHost.c?
Thanks,
Kilian
From: Gao, Liming<mailto:liming.gao@intel.com>
Sent: Wednesday, October 30, 2019 06:33 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; KILIAN_KEGEL@OUTLOOK.COM<mailto:KILIAN_KEGEL@OUTLOOK.COM>
Cc: Richardson, Brian<mailto:brian.richardson@intel.com>; Kinney, Michael D<mailto:michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
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> [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<mailto:liming.gao@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Richardson, Brian <brian.richardson@intel.com<mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto: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: 57954 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
2019-10-30 16:16 ` Michael D Kinney
@ 2019-10-30 16:56 ` Andrew Fish
0 siblings, 0 replies; 16+ messages in thread
From: Andrew Fish @ 2019-10-30 16:56 UTC (permalink / raw)
To: devel, Mike Kinney
Cc: Gao, Liming, KILIAN_KEGEL@OUTLOOK.COM, Richardson, Brian, Ni, Ray
[-- Attachment #1: Type: text/plain, Size: 7695 bytes --]
Mike,
On the Unix side the strategy was to launch via the debugger [1], and also pass EFI specific debugger scripts into the debuggers on launch.
I've played with trick with OS apps by using CpuDeadLoop(). To get unstuck you just need to update Index to be non Zero. I've also used this technique for JTAG debuggers. For an EFI App I generally use CpuBreakpoint(). The advantage to using getchar() is the "otherwise press enter to continue..." path. So I agree the command line option seems like a reasonable thing to do.
The other trick I played in this area was to have both a `run` and `lldb` option to the script. The `run` option launches the debugger, the 'lldb' (or gdb) option drops you into a debugger prompt so you can set breakpoints early in boot.
Long term maybe we could have a common Python based build commands for both Windows and Unix and at that point we could move to launching via the debugger for all paths?
[1] https://github.com/tianocore/edk2/blob/master/EmulatorPkg/build.sh#L221
Thanks,
Andrew Fish
> On Oct 30, 2019, at 9:16 AM, Michael D Kinney <michael.d.kinney@intel.com> wrote:
>
> Liming,
>
> This may be something that is better with a command line option when WinHost.exe is started instead of a PCD.
>
> I also think there is a way to run VS first and start a process from VS and do an initial BP. Does that work with latest Windows 10?
>
> Mike
>
> From: Gao, Liming <liming.gao@intel.com <mailto:liming.gao@intel.com>>
> Sent: Wednesday, October 30, 2019 8:03 AM
> To: devel@edk2.groups.io <mailto:devel@edk2.groups.io>; KILIAN_KEGEL@OUTLOOK.COM <mailto:KILIAN_KEGEL@OUTLOOK.COM>
> Cc: Richardson, Brian <brian.richardson@intel.com <mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com <mailto:michael.d.kinney@intel.com>>; Ni, Ray <ray.ni@intel.com <mailto:ray.ni@intel.com>>
> Subject: RE: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
>
> Kilian:
> I think this idea is good. It can be enabled when the developer wants to do the source level debug. So, one PCD may be introduced to control the logic. By default, there is no change. When PCD is enabled, WinHost will wait for the developer input.
>
> Can you submit BZ for this request, and prepare the patch for the change?
>
> Thanks
> Liming
> <>From: devel@edk2.groups.io <mailto:devel@edk2.groups.io> <devel@edk2.groups.io <mailto:devel@edk2.groups.io>> On Behalf Of Kilian Kegel
> Sent: Wednesday, October 30, 2019 5:17 PM
> To: Gao, Liming <liming.gao@intel.com <mailto:liming.gao@intel.com>>; devel@edk2.groups.io <mailto:devel@edk2.groups.io>
> Cc: Richardson, Brian <brian.richardson@intel.com <mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com <mailto:michael.d.kinney@intel.com>>
> Subject: Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
>
> Hi Liming,
>
> CpuBreakPoint() is the same as __debugbreak() on Microsoft Compiler and generates INT 3 DebugTrap.
>
> Yes, that procedure has worked in the past and I have used it in the same way as you do.
>
> But with newer Windows versions, Windows just terminates the “exceptional” process that emits
> INT 3 or any other violation trap and does not offer to debug the process – surly for security reasons…
>
> For debugging purpose on newer Windows 10 versions I always insert the code snippet below.
>
> It gives the developer the chance to connect VS to the process to be debugged, while waiting on keyboard input.
> (ALT-CTRL-P attach to process)
>
> After that, with the debuggee is connected to VS _before_ the debug trap appears. VS is now
> available for debugging the process with full source code.
>
> The EmulatorPkg (and Nt32Pkg) was the most helpful tool to understand and debug UEFI internals for me.
>
> EmulatorPkg should also usable and helpful for other devolpers.
> Can you please insert the code snippet into main() from WinHost.c?
>
> Thanks,
> Kilian
>
>
> From: Gao, Liming <mailto:liming.gao@intel.com>
> Sent: Wednesday, October 30, 2019 06:33 AM
> To: devel@edk2.groups.io <mailto:devel@edk2.groups.io>; KILIAN_KEGEL@OUTLOOK.COM <mailto:KILIAN_KEGEL@OUTLOOK.COM>
> Cc: Richardson, Brian <mailto:brian.richardson@intel.com>; Kinney, Michael D <mailto:michael.d.kinney@intel.com>
> Subject: RE: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
>
> 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> [mailto: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 <mailto:liming.gao@intel.com>>
> Cc: devel@edk2.groups.io <mailto:devel@edk2.groups.io>; Richardson, Brian <brian.richardson@intel.com <mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com <mailto: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: 32040 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
2019-10-28 13:01 ` [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak() Kilian Kegel
2019-10-30 5:33 ` Liming Gao
@ 2019-11-05 17:36 ` Kilian Kegel
2019-11-13 1:06 ` Liming Gao
1 sibling, 1 reply; 16+ messages in thread
From: Kilian Kegel @ 2019-11-05 17:36 UTC (permalink / raw)
To: liming.gao@intel.com
Cc: devel@edk2.groups.io, Richardson, Brian, Kinney, Michael D
[-- 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 --]
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
2019-11-05 17:36 ` [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint Kilian Kegel
@ 2019-11-13 1:06 ` Liming Gao
2019-11-13 2:27 ` Ni, Ray
0 siblings, 1 reply; 16+ messages in thread
From: Liming Gao @ 2019-11-13 1:06 UTC (permalink / raw)
To: devel@edk2.groups.io, KILIAN_KEGEL@OUTLOOK.COM
Cc: Richardson, Brian, Kinney, Michael D, Gao, Liming
[-- Attachment #1: Type: text/plain, Size: 5822 bytes --]
Kilian:
Can you create the patch with the commit message?
For the patch, I add my comments.
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Kilian Kegel
Sent: Wednesday, November 06, 2019 1:36 AM
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] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
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<http://www.tianocore.org/edk2/n/r>");
-
+
+ if (1) {
Please use TRUE instead of 1
+ int i;
Please define it in the begin of the function, and use edk2 data type and coding style, such as UINTN Index.
+ 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])) {
How about use strncmp?
Thanks
Liming
+ //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<mailto:kilian_kegel@outlook.com>>
Sent: Monday, October 28, 2019 2:01:23 PM
To: liming.gao@intel.com<mailto:liming.gao@intel.com> <liming.gao@intel.com<mailto:liming.gao@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Richardson, Brian <brian.richardson@intel.com<mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto: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: 17136 bytes --]
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
2019-11-13 1:06 ` Liming Gao
@ 2019-11-13 2:27 ` Ni, Ray
2019-11-14 5:23 ` Kilian Kegel
0 siblings, 1 reply; 16+ messages in thread
From: Ni, Ray @ 2019-11-13 2:27 UTC (permalink / raw)
To: devel@edk2.groups.io, Gao, Liming, KILIAN_KEGEL@OUTLOOK.COM
Cc: Richardson, Brian, Kinney, Michael D
[-- Attachment #1: Type: text/plain, Size: 6790 bytes --]
Kilian,
Thank you very much for enabling the better VS debugging experience.
Minor comments below.
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Liming Gao
Sent: Wednesday, November 13, 2019 9:07 AM
To: devel@edk2.groups.io; KILIAN_KEGEL@OUTLOOK.COM
Cc: Richardson, Brian <brian.richardson@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: Re: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
Kilian:
Can you create the patch with the commit message?
For the patch, I add my comments.
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> [mailto:devel@edk2.groups.io] On Behalf Of Kilian Kegel
Sent: Wednesday, November 06, 2019 1:36 AM
To: Gao, Liming <liming.gao@intel.com<mailto:liming.gao@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Richardson, Brian <brian.richardson@intel.com<mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
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<http://www.tianocore.org/edk2/n/r>");
-
+
+ if (1) {
Please use TRUE instead of 1
[Ray] 1. Can you remove "if(1)"?
+ int i;
Please define it in the begin of the function, and use edk2 data type and coding style, such as UINTN Index.
+ 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])) {
How about use strncmp?
[Ray] 2. strncmp assumes user may input "/debugxxxxx". Is that a valid assumption? I thought we only accept "/debug" the whole word as input parameter to trigger debugging.
Thanks
Liming
+ //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");
[Ray] 3. I prefer to break the long string to multiple lines of SecPrint() call as what the code does in below.
+ 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<mailto:kilian_kegel@outlook.com>>
Sent: Monday, October 28, 2019 2:01:23 PM
To: liming.gao@intel.com<mailto:liming.gao@intel.com> <liming.gao@intel.com<mailto:liming.gao@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Richardson, Brian <brian.richardson@intel.com<mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto: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: 18984 bytes --]
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
2019-11-13 2:27 ` Ni, Ray
@ 2019-11-14 5:23 ` Kilian Kegel
2019-11-14 6:57 ` Ni, Ray
0 siblings, 1 reply; 16+ messages in thread
From: Kilian Kegel @ 2019-11-14 5:23 UTC (permalink / raw)
To: Ni, Ray, devel@edk2.groups.io, Gao, Liming
Cc: Richardson, Brian, Kinney, Michael D
[-- Attachment #1.1: Type: text/plain, Size: 9617 bytes --]
Hi Ray,
[Ray] 1. Can you remove “if(1)”?:
DONE
Please define it in the begin of the function, and use edk2 data type and coding style, such as UINTN Index.
DONE
[Ray] 2. strncmp assumes user may input “/debugxxxxx”. Is that a valid assumption? I thought we only accept “/debug” the whole word as input parameter to trigger debugging.
I have no preference at all here. We can also consider to use a stricmp() to be case-in-sensitive…
[Ray] 3. I prefer to break the long string to multiple lines of SecPrint() call as what the code does in below.
Removed the entire string, that came in per accident and was a comment only “//”
Thanks,
Kilian
diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c
index 62a89f7617..0eeb5979ff 100644
--- a/EmulatorPkg/Win/Host/WinHost.c
+++ b/EmulatorPkg/Win/Host/WinHost.c
@@ -394,6 +394,7 @@ Returns:
UINTN ProcessAffinityMask;
UINTN SystemAffinityMask;
INT32 LowBit;
+ INT32 i;
//
// Enable the privilege so that RTC driver can successfully run SetTime()
@@ -410,6 +411,26 @@ Returns:
SecPrint ("\n\rEDK II WIN Host Emulation Environment from http://www.tianocore.org/edk2/\n\r");
+ 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("\t1. start your debug engine\n");
+ SecPrint("\t2. attach 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: Ni, Ray<mailto:ray.ni@intel.com>
Sent: Wednesday, November 13, 2019 03:27 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Gao, Liming<mailto:liming.gao@intel.com>; KILIAN_KEGEL@OUTLOOK.COM<mailto:KILIAN_KEGEL@OUTLOOK.COM>
Cc: Richardson, Brian<mailto:brian.richardson@intel.com>; Kinney, Michael D<mailto:michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
Kilian,
Thank you very much for enabling the better VS debugging experience.
Minor comments below.
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Liming Gao
Sent: Wednesday, November 13, 2019 9:07 AM
To: devel@edk2.groups.io; KILIAN_KEGEL@OUTLOOK.COM
Cc: Richardson, Brian <brian.richardson@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: Re: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
Kilian:
Can you create the patch with the commit message?
For the patch, I add my comments.
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> [mailto:devel@edk2.groups.io] On Behalf Of Kilian Kegel
Sent: Wednesday, November 06, 2019 1:36 AM
To: Gao, Liming <liming.gao@intel.com<mailto:liming.gao@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Richardson, Brian <brian.richardson@intel.com<mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
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<http://www.tianocore.org/edk2/n/r>");
-
+
+ if (1) {
Please use TRUE instead of 1
[Ray] 1. Can you remove “if(1)”?
+ int i;
Please define it in the begin of the function, and use edk2 data type and coding style, such as UINTN Index.
+ 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])) {
How about use strncmp?
[Ray] 2. strncmp assumes user may input “/debugxxxxx”. Is that a valid assumption? I thought we only accept “/debug” the whole word as input parameter to trigger debugging.
Thanks
Liming
+ //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");
[Ray] 3. I prefer to break the long string to multiple lines of SecPrint() call as what the code does in below.
+ 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<mailto:kilian_kegel@outlook.com>>
Sent: Monday, October 28, 2019 2:01:23 PM
To: liming.gao@intel.com<mailto:liming.gao@intel.com> <liming.gao@intel.com<mailto:liming.gao@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Richardson, Brian <brian.richardson@intel.com<mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto: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 #1.2: Type: text/html, Size: 23968 bytes --]
[-- Attachment #2: 74255A10120D420EB8522DEBF7EC5C88.png --]
[-- Type: image/png, Size: 144 bytes --]
[-- Attachment #3: 0D9AA6AECAB349549FF9F835489DA942.png --]
[-- Type: image/png, Size: 144 bytes --]
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
2019-11-14 5:23 ` Kilian Kegel
@ 2019-11-14 6:57 ` Ni, Ray
2019-11-15 9:56 ` Kilian Kegel
0 siblings, 1 reply; 16+ messages in thread
From: Ni, Ray @ 2019-11-14 6:57 UTC (permalink / raw)
To: Kilian Kegel, devel@edk2.groups.io, Gao, Liming
Cc: Richardson, Brian, Kinney, Michael D
[-- Attachment #1.1: Type: text/plain, Size: 10112 bytes --]
Kilian,
Thank you very much. Comments below.
From: Kilian Kegel <kilian_kegel@outlook.com>
Sent: Thursday, November 14, 2019 1:24 PM
To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io; Gao, Liming <liming.gao@intel.com>
Cc: Richardson, Brian <brian.richardson@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
I have no preference at all here. We can also consider to use a stricmp() to be case-in-sensitive...
[Ray] I am ok to either case sensitive or insensitive.
Thanks,
Kilian
diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c
index 62a89f7617..0eeb5979ff 100644
--- a/EmulatorPkg/Win/Host/WinHost.c
+++ b/EmulatorPkg/Win/Host/WinHost.c
@@ -394,6 +394,7 @@ Returns:
UINTN ProcessAffinityMask;
UINTN SystemAffinityMask;
INT32 LowBit;
+ INT32 i;
[Ray] 1. Can you please rename it to "Index" to align the coding style?
//
// Enable the privilege so that RTC driver can successfully run SetTime()
@@ -410,6 +411,26 @@ Returns:
SecPrint ("\n\rEDK II WIN Host Emulation Environment from http://www.tianocore.org/edk2/\n\r<http://www.tianocore.org/edk2/n/r>");
+ 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) {
[Ray] 2. Can you remove the if check? It's unnecessary because of below for-loop.
+ for (i = 1; i < Argc; i++) {
+ if (0 == strcmp("/debug", Argv[i])) {
+ SecPrint("\t1. start your debug engine\n");
+ SecPrint("\t2. attach to process WinHost.exe\n");
[Ray] 3. I don't think it's proper to hardcode line number in code because that will cause this debug message is changed in future.
Can you remove the line number?
+ 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: Ni, Ray<mailto:ray.ni@intel.com>
Sent: Wednesday, November 13, 2019 03:27 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Gao, Liming<mailto:liming.gao@intel.com>; KILIAN_KEGEL@OUTLOOK.COM<mailto:KILIAN_KEGEL@OUTLOOK.COM>
Cc: Richardson, Brian<mailto:brian.richardson@intel.com>; Kinney, Michael D<mailto:michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
Kilian,
Thank you very much for enabling the better VS debugging experience.
Minor comments below.
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Liming Gao
Sent: Wednesday, November 13, 2019 9:07 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; KILIAN_KEGEL@OUTLOOK.COM<mailto:KILIAN_KEGEL@OUTLOOK.COM>
Cc: Richardson, Brian <brian.richardson@intel.com<mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>; Gao, Liming <liming.gao@intel.com<mailto:liming.gao@intel.com>>
Subject: Re: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
Kilian:
Can you create the patch with the commit message?
For the patch, I add my comments.
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> [mailto:devel@edk2.groups.io] On Behalf Of Kilian Kegel
Sent: Wednesday, November 06, 2019 1:36 AM
To: Gao, Liming <liming.gao@intel.com<mailto:liming.gao@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Richardson, Brian <brian.richardson@intel.com<mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
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<http://www.tianocore.org/edk2/n/r>");
-
+
+ if (1) {
Please use TRUE instead of 1
[Ray] 1. Can you remove "if(1)"?
+ int i;
Please define it in the begin of the function, and use edk2 data type and coding style, such as UINTN Index.
+ 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])) {
How about use strncmp?
[Ray] 2. strncmp assumes user may input "/debugxxxxx". Is that a valid assumption? I thought we only accept "/debug" the whole word as input parameter to trigger debugging.
Thanks
Liming
+ //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");
[Ray] 3. I prefer to break the long string to multiple lines of SecPrint() call as what the code does in below.
+ 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<mailto:kilian_kegel@outlook.com>>
Sent: Monday, October 28, 2019 2:01:23 PM
To: liming.gao@intel.com<mailto:liming.gao@intel.com> <liming.gao@intel.com<mailto:liming.gao@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Richardson, Brian <brian.richardson@intel.com<mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto: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 #1.2: Type: text/html, Size: 26877 bytes --]
[-- Attachment #2: image001.png --]
[-- Type: image/png, Size: 144 bytes --]
[-- Attachment #3: image002.png --]
[-- Type: image/png, Size: 144 bytes --]
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
2019-11-14 6:57 ` Ni, Ray
@ 2019-11-15 9:56 ` Kilian Kegel
0 siblings, 0 replies; 16+ messages in thread
From: Kilian Kegel @ 2019-11-15 9:56 UTC (permalink / raw)
To: Ni, Ray, devel@edk2.groups.io, Gao, Liming
Cc: Richardson, Brian, Kinney, Michael D
[-- Attachment #1.1: Type: text/plain, Size: 12321 bytes --]
Ray,
thank you for your patience.
Kilian
diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c
index 62a89f7617..b47a1fa8dd 100644
--- a/EmulatorPkg/Win/Host/WinHost.c
+++ b/EmulatorPkg/Win/Host/WinHost.c
@@ -394,6 +394,7 @@ Returns:
UINTN ProcessAffinityMask;
UINTN SystemAffinityMask;
INT32 LowBit;
+ INT32 index;
//
// Enable the privilege so that RTC driver can successfully run SetTime()
@@ -410,6 +411,24 @@ Returns:
SecPrint ("\n\rEDK II WIN Host Emulation Environment from http://www.tianocore.org/edk2/\n\r");
+ SecPrint ("######################################################################################################\n");
+ SecPrint ("add \"/debug\" command line switch, to connect to the debugger at the very beginning of POST emulation\n");
+ SecPrint ("######################################################################################################\n");
+ for (index = 1; index < Argc; index++) {
+ if (0 == strcmp("/debug", Argv[index])) {
+ SecPrint("\t1. start your debug engine\n");
+ SecPrint("\t2. attach to process WinHost.exe\n");
+ SecPrint("\t4. set software breakpoints as needed in your debug session\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: Ni, Ray<mailto:ray.ni@intel.com>
Sent: Thursday, November 14, 2019 07:57 AM
To: Kilian Kegel<mailto:kilian_kegel@outlook.com>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Gao, Liming<mailto:liming.gao@intel.com>
Cc: Richardson, Brian<mailto:brian.richardson@intel.com>; Kinney, Michael D<mailto:michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
Kilian,
Thank you very much. Comments below.
From: Kilian Kegel <kilian_kegel@outlook.com>
Sent: Thursday, November 14, 2019 1:24 PM
To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io; Gao, Liming <liming.gao@intel.com>
Cc: Richardson, Brian <brian.richardson@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
I have no preference at all here. We can also consider to use a stricmp() to be case-in-sensitive…
[Ray] I am ok to either case sensitive or insensitive.
Thanks,
Kilian
diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c
index 62a89f7617..0eeb5979ff 100644
--- a/EmulatorPkg/Win/Host/WinHost.c
+++ b/EmulatorPkg/Win/Host/WinHost.c
@@ -394,6 +394,7 @@ Returns:
UINTN ProcessAffinityMask;
UINTN SystemAffinityMask;
INT32 LowBit;
+ INT32 i;
[Ray] 1. Can you please rename it to “Index” to align the coding style?
//
// Enable the privilege so that RTC driver can successfully run SetTime()
@@ -410,6 +411,26 @@ Returns:
SecPrint ("\n\rEDK II WIN Host Emulation Environment from http://www.tianocore.org/edk2/\n\r<http://www.tianocore.org/edk2/n/r>");
+ 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) {
[Ray] 2. Can you remove the if check? It’s unnecessary because of below for-loop.
+ for (i = 1; i < Argc; i++) {
+ if (0 == strcmp("/debug", Argv[i])) {
+ SecPrint("\t1. start your debug engine\n");
+ SecPrint("\t2. attach to process WinHost.exe\n");
[Ray] 3. I don’t think it’s proper to hardcode line number in code because that will cause this debug message is changed in future.
Can you remove the line number?
+ 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: Ni, Ray<mailto:ray.ni@intel.com>
Sent: Wednesday, November 13, 2019 03:27 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Gao, Liming<mailto:liming.gao@intel.com>; KILIAN_KEGEL@OUTLOOK.COM<mailto:KILIAN_KEGEL@OUTLOOK.COM>
Cc: Richardson, Brian<mailto:brian.richardson@intel.com>; Kinney, Michael D<mailto:michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
Kilian,
Thank you very much for enabling the better VS debugging experience.
Minor comments below.
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Liming Gao
Sent: Wednesday, November 13, 2019 9:07 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; KILIAN_KEGEL@OUTLOOK.COM<mailto:KILIAN_KEGEL@OUTLOOK.COM>
Cc: Richardson, Brian <brian.richardson@intel.com<mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>; Gao, Liming <liming.gao@intel.com<mailto:liming.gao@intel.com>>
Subject: Re: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
Kilian:
Can you create the patch with the commit message?
For the patch, I add my comments.
From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> [mailto:devel@edk2.groups.io] On Behalf Of Kilian Kegel
Sent: Wednesday, November 06, 2019 1:36 AM
To: Gao, Liming <liming.gao@intel.com<mailto:liming.gao@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Richardson, Brian <brian.richardson@intel.com<mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint
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<http://www.tianocore.org/edk2/n/r>");
-
+
+ if (1) {
Please use TRUE instead of 1
[Ray] 1. Can you remove “if(1)”?
+ int i;
Please define it in the begin of the function, and use edk2 data type and coding style, such as UINTN Index.
+ 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])) {
How about use strncmp?
[Ray] 2. strncmp assumes user may input “/debugxxxxx”. Is that a valid assumption? I thought we only accept “/debug” the whole word as input parameter to trigger debugging.
Thanks
Liming
+ //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");
[Ray] 3. I prefer to break the long string to multiple lines of SecPrint() call as what the code does in below.
+ 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<mailto:kilian_kegel@outlook.com>>
Sent: Monday, October 28, 2019 2:01:23 PM
To: liming.gao@intel.com<mailto:liming.gao@intel.com> <liming.gao@intel.com<mailto:liming.gao@intel.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; Richardson, Brian <brian.richardson@intel.com<mailto:brian.richardson@intel.com>>; Kinney, Michael D <michael.d.kinney@intel.com<mailto: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 #1.2: Type: text/html, Size: 29865 bytes --]
[-- Attachment #2: image001.png --]
[-- Type: image/png, Size: 144 bytes --]
[-- Attachment #3: image002.png --]
[-- Type: image/png, Size: 144 bytes --]
^ permalink raw reply related [flat|nested] 16+ messages in thread
end of thread, other threads:[~2019-11-15 9:56 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint Kilian Kegel
2019-11-13 1:06 ` 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox