On Dec 13, 2013, at 2:03 PM, Carsey, Jaben <[email protected]> wrote:

> Under the debug menu there is "attach to process", then from the resultant 
> dialog box I select the "secmain.exe" image.
> 
> So maybe we need:
> 1. Open the source file in VS
> 2. Press F9 to set a breakpoint
> 3. Run 'build run' in the dos box
> 4. Attach the debugger to the running process from 3 above.
> 
> 

Yes the application is a Windows application so VS knows how to debug it. 

Tim brings up a good point that the code in SecMain that loads the DLL for 
debug depends on a debug directory entry being present in the PE/COFF image and 
the .DLL file must be sitting next to the .PDB file to get source level 
debugging to work properly. So you walk that code in 
https://svn.code.sf.net/p/edk2/code/trunk/edk2/Nt32Pkg/Sec/SecMain.c to see if 
the DLL is getting loaded for your application, and if it is you should get 
source level debugging. If it does not load then source level debugging will 
not work, and the actual .EFI will just run. 

Thanks,

Andrew Fish

> 
> -----Original Message-----
> From: Jordan Justen [mailto:[email protected]] 
> Sent: Friday, December 13, 2013 2:01 PM
> To: Carsey, Jaben
> Cc: Amit Kulkarni; [email protected]
> Subject: Re: [edk2] How to debug application running in secmain with 
> WinDbg/VS2010
> Importance: High
> 
> On Fri, Dec 13, 2013 at 1:47 PM, Carsey, Jaben <[email protected]> wrote:
>> In visual studio, you can press F9 and get a breakpoint on the line of 
>> code you cursor is on...  that way there is no "special" code to 
>> add/remove...
> 
> Right, but normally when you run 'build run' it is outside of VS, so how do 
> you get VS to debug SecMain.exe? I didn't think VS could set a breakpoint on 
> a line until it was debugging the process, or had somehow associated the code 
> with a particular executable that it expected to debug.
> 
> Anyway, the CpuBreakpoint was one way I knew to force it into the debugger. 
> It does seem likely that a more elegant solution exists. :)
> 
> I guess you are saying it is as simple as:
> 1. Open the source file in VS
> 2. Press F9 to set a breakpoint
> 3. Run 'build run' in the dos box
> 
> -Jordan
> 
>> -----Original Message-----
>> From: Jordan Justen [mailto:[email protected]]
>> Sent: Friday, December 13, 2013 1:01 PM
>> To: Carsey, Jaben
>> Cc: Amit Kulkarni; [email protected]
>> Subject: Re: [edk2] How to debug application running in secmain with 
>> WinDbg/VS2010
>> Importance: High
>> 
>> On Fri, Dec 13, 2013 at 12:40 PM, Carsey, Jaben <[email protected]> 
>> wrote:
>>> I have always found the following works for me.
>>> 
>>> 1)      Set the breakpoint
>> 
>> How did you set a breakpoint initially?
>> 
>> I seem to recall for NT32 I would add a call to CpuBreakpoint and then 
>> rebuild NT32. Then when 'build run' was executed an exception would happen. 
>> This would allow VS to open to debug the code, and it would have symbols 
>> available. VS debug could then set additional breakpoints in the code as 
>> usual.
>> 
>> I would imagine WinDbg could also be used to debug the application as well 
>> and it should be able to load the symbols like VS.
>> 
>> -Jordan
>> 
>>> 2)      Do the "build run"
>>> 
>>> 3)      I attach the debugger as soon as I can to secmain.exe
>>> 
>>> 
>>> 
>>> Then when the module with the breakpoint loads visual studio changes 
>>> the color of the breakpoint to indicate that it's possible to hit...
>>> 
>>> 
>>> 
>>> 
>>> 
>>> -Jaben
>>> 
>>> 
>>> 
>>> From: Andrew Fish [mailto:[email protected]]
>>> Sent: Friday, December 13, 2013 11:51 AM
>>> To: Amit Kulkarni; [email protected]
>>> Subject: Re: [edk2] How to debug application running in secmain with
>>> WinDbg/VS2010
>>> 
>>> 
>>> 
>>> 
>>> 
>>> On Dec 13, 2013, at 2:53 AM, Amit Kulkarni 
>>> <[email protected]>
>>> wrote:
>>> 
>>> 
>>> 
>>> Hi All,
>>> 
>>> 
>>> 
>>> I am trying to debug hello sample from EADK running in NT32(secmain) 
>>> using WinDbg & VS2010 but my breakpoint does not hit. I observed that 
>>> lm command does not show hello in loaded module list.
>>> 
>>> 
>>> 
>>> 
>>> 
>>> An Application loads, executes, and then unloads. So if the 
>>> Application is not running you will not see it in the list.
>>> 
>>> 
>>> 
>>> So is it possible to debug in NT32(secmain) using WinDbg/VS2010?
>>> Is there any way to do source level debugging while running in secmain?
>>> 
>>> 
>>> 
>>> 
>>> 
>>> So it's been a lot of years since I used Visual Studio, but NT32 is 
>>> just an application so you should be able to debug it directly with 
>>> VS2010. I'm guessing the default build of NT32 does not support 
>>> WinDbg as you need to do special magic(tm) to load symbols of EFI 
>>> modules in
>>> VS2010 (Thus the standard WinDbg serial stuff is probably not hooked 
>>> in). The LoadLibraryEx() call in SecNt32PeCoffRelocateImage in 
>>> https://svn.code.sf.net/p/edk2/code/trunk/edk2/Nt32Pkg/Sec/SecMain.c
>>> is what makes symbols visible to VS2010. SecMain is a Windows 
>>> Application so you should not have any issues debugging that directly with 
>>> VS2010.
>>> 
>>> 
>>> 
>>> To use WinDbg I think you need to use OVFM and establish a serial 
>>> connection with the VM.
>>> 
>>> 
>>> 
>>> Thanks,
>>> 
>>> 
>>> 
>>> Andrew Fish
>>> 
>>> 
>>> 
>>> Thanks & Regards,
>>> Amit Kulkarni.
>>> 
>>> ---------------------------------------------------------------------
>>> -
>>> -------- Rapidly troubleshoot problems before they affect your 
>>> business. Most IT organizations don't have a clear picture of how 
>>> application performance affects their revenue. With AppDynamics, you 
>>> get 100% visibility into your Java,.NET, & PHP application. Start 
>>> your 15-day FREE TRIAL of AppDynamics Pro!
>>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.
>>> c lktrk_______________________________________________
>>> edk2-devel mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>>> 
>>> 
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> -
>>> -------- Rapidly troubleshoot problems before they affect your 
>>> business. Most IT organizations don't have a clear picture of how 
>>> application performance affects their revenue. With AppDynamics, you 
>>> get 100% visibility into your Java,.NET, & PHP application. Start 
>>> your 15-day FREE TRIAL of AppDynamics Pro!
>>> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.
>>> c lktrk _______________________________________________
>>> edk2-devel mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>>> 
> 
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT 
> organizations don't have a clear picture of how application performance 
> affects their revenue. With AppDynamics, you get 100% visibility into your 
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to