public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* DEBUG() macros in DXE driver: can’t make it work in QEMU
@ 2017-02-14 17:55 Nikolay Bodunov
  2017-02-14 18:16 ` Laszlo Ersek
  0 siblings, 1 reply; 14+ messages in thread
From: Nikolay Bodunov @ 2017-02-14 17:55 UTC (permalink / raw)
  To: edk2-devel

Hello


I compiled DXE Driver, in DEBUG_GCC49 mode, but I can’t print any debug
message.
DEBUG((-1, “Print test”))  does nothing.  Exactly as
DebugPrint(EFI_D_ERROR, “Print Test);

However, I see “Print Test” string in my *.efi binary.
I use QEMU + OMVF (OVMF was also recompliled in DEBUG_GCC49 mode, to be
sure). Serial port output is redirected to a file:
qemu-system-x86_64 -L . --bios /…/FV/OVMF.fd -hda hdd.img -serial
file:./serial_file

All I see in output file is EFI shell output messages, include one that my
driver was succesfully loaded. But no messages from DEBUG().


My conditions:

MODULE_TYPE    = DXE_DRIVER


Debug Print Library:

DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf

(BaseDebugLibNull.inf is commented, of course)


DebugPrintEnabled() returns TRUE


I also tried to set some key options manually in MdeModulePkg.dsc
afterwards, but result didn’t change:


[Components]


  MdeModulePkg/CrScreenshotDxe/CrScreenshotDxe.inf  {


    <PcdsFixedAtBuild>


gEfiMdePkgTokenSpaceGuid.gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x07

      gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F

      gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000042



   <LibraryClasses>


DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf


   <BuildOptions>

      GCC:*_*_*_CC_FLAGS             = -UMDEPKG_NDEBUG

}


Code (I used it as a base): https://github.com/LongSoft/CrScreenshotDxe

Where I got wrong and what else could I try to make it work?

-- 
With best regards,
Nikolay Bodunov


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DEBUG() macros in DXE driver: can’t make it work in QEMU
  2017-02-14 17:55 DEBUG() macros in DXE driver: can’t make it work in QEMU Nikolay Bodunov
@ 2017-02-14 18:16 ` Laszlo Ersek
  2017-02-14 18:28   ` Kinney, Michael D
  0 siblings, 1 reply; 14+ messages in thread
From: Laszlo Ersek @ 2017-02-14 18:16 UTC (permalink / raw)
  To: Nikolay Bodunov, edk2-devel

Hi Nikolay,

On 02/14/17 18:55, Nikolay Bodunov wrote:
> Hello
> 
> 
> I compiled DXE Driver, in DEBUG_GCC49 mode, but I can’t print any debug
> message.
> DEBUG((-1, “Print test”))  does nothing.  Exactly as
> DebugPrint(EFI_D_ERROR, “Print Test);

(1) Please always terminate the debug message with a newline ("\n") once
you are done with it. (It's okay to format a single message with several
DEBUG calls of course, and terminate only the last DEBUG with a newline.)

(2) Please use DEBUG_ERROR as the symbolic constant for the error mask.

> 
> However, I see “Print Test” string in my *.efi binary.
> I use QEMU + OMVF (OVMF was also recompliled in DEBUG_GCC49 mode, to be
> sure). Serial port output is redirected to a file:
> qemu-system-x86_64 -L . --bios /…/FV/OVMF.fd -hda hdd.img -serial
> file:./serial_file

(3) DEBUG output from OVMF is by default not written to the serial port,
it is written to the QEMU debug port. Please consult OvmfPkg/README for
specifics, namely under "Capturing OVMF debug messages on qemu".

Hope this helps,
Laszlo

> 
> All I see in output file is EFI shell output messages, include one that my
> driver was succesfully loaded. But no messages from DEBUG().
> 
> 
> My conditions:
> 
> MODULE_TYPE    = DXE_DRIVER
> 
> 
> Debug Print Library:
> 
> DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
> 
> (BaseDebugLibNull.inf is commented, of course)
> 
> 
> DebugPrintEnabled() returns TRUE
> 
> 
> I also tried to set some key options manually in MdeModulePkg.dsc
> afterwards, but result didn’t change:
> 
> 
> [Components]
> 
> 
>   MdeModulePkg/CrScreenshotDxe/CrScreenshotDxe.inf  {
> 
> 
>     <PcdsFixedAtBuild>
> 
> 
> gEfiMdePkgTokenSpaceGuid.gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x07
> 
>       gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
> 
>       gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000042
> 
> 
> 
>    <LibraryClasses>
> 
> 
> DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
> 
> 
>    <BuildOptions>
> 
>       GCC:*_*_*_CC_FLAGS             = -UMDEPKG_NDEBUG
> 
> }
> 
> 
> Code (I used it as a base): https://github.com/LongSoft/CrScreenshotDxe
> 
> Where I got wrong and what else could I try to make it work?
> 



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DEBUG() macros in DXE driver: can’t make it work in QEMU
  2017-02-14 18:16 ` Laszlo Ersek
@ 2017-02-14 18:28   ` Kinney, Michael D
  2017-02-14 22:06     ` Nikolay Bodunov
  0 siblings, 1 reply; 14+ messages in thread
From: Kinney, Michael D @ 2017-02-14 18:28 UTC (permalink / raw)
  To: Laszlo Ersek, Nikolay Bodunov, edk2-devel@ml01.01.org,
	Kinney, Michael D

If you prefer debug messages on a serial port, you can 
add -D DEBUG_ON_SERIAL_PORT

Mike

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Laszlo Ersek
> Sent: Tuesday, February 14, 2017 10:17 AM
> To: Nikolay Bodunov <nikolay.bodunov@gmail.com>; edk2-devel@ml01.01.org
> Subject: Re: [edk2] DEBUG() macros in DXE driver: can’t make it work in QEMU
> 
> Hi Nikolay,
> 
> On 02/14/17 18:55, Nikolay Bodunov wrote:
> > Hello
> >
> >
> > I compiled DXE Driver, in DEBUG_GCC49 mode, but I can’t print any debug
> > message.
> > DEBUG((-1, “Print test”))  does nothing.  Exactly as
> > DebugPrint(EFI_D_ERROR, “Print Test);
> 
> (1) Please always terminate the debug message with a newline ("\n") once
> you are done with it. (It's okay to format a single message with several
> DEBUG calls of course, and terminate only the last DEBUG with a newline.)
> 
> (2) Please use DEBUG_ERROR as the symbolic constant for the error mask.
> 
> >
> > However, I see “Print Test” string in my *.efi binary.
> > I use QEMU + OMVF (OVMF was also recompliled in DEBUG_GCC49 mode, to be
> > sure). Serial port output is redirected to a file:
> > qemu-system-x86_64 -L . --bios /…/FV/OVMF.fd -hda hdd.img -serial
> > file:./serial_file
> 
> (3) DEBUG output from OVMF is by default not written to the serial port,
> it is written to the QEMU debug port. Please consult OvmfPkg/README for
> specifics, namely under "Capturing OVMF debug messages on qemu".
> 
> Hope this helps,
> Laszlo
> 
> >
> > All I see in output file is EFI shell output messages, include one that my
> > driver was succesfully loaded. But no messages from DEBUG().
> >
> >
> > My conditions:
> >
> > MODULE_TYPE    = DXE_DRIVER
> >
> >
> > Debug Print Library:
> >
> > DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
> >
> > (BaseDebugLibNull.inf is commented, of course)
> >
> >
> > DebugPrintEnabled() returns TRUE
> >
> >
> > I also tried to set some key options manually in MdeModulePkg.dsc
> > afterwards, but result didn’t change:
> >
> >
> > [Components]
> >
> >
> >   MdeModulePkg/CrScreenshotDxe/CrScreenshotDxe.inf  {
> >
> >
> >     <PcdsFixedAtBuild>
> >
> >
> > gEfiMdePkgTokenSpaceGuid.gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x07
> >
> >       gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
> >
> >       gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000042
> >
> >
> >
> >    <LibraryClasses>
> >
> >
> > DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
> >
> >
> >    <BuildOptions>
> >
> >       GCC:*_*_*_CC_FLAGS             = -UMDEPKG_NDEBUG
> >
> > }
> >
> >
> > Code (I used it as a base): https://github.com/LongSoft/CrScreenshotDxe
> >
> > Where I got wrong and what else could I try to make it work?
> >
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DEBUG() macros in DXE driver: can’t make it work in QEMU
  2017-02-14 18:28   ` Kinney, Michael D
@ 2017-02-14 22:06     ` Nikolay Bodunov
  2017-02-14 22:17       ` David A. Van Arnem
  2017-02-15 10:13       ` Laszlo Ersek
  0 siblings, 2 replies; 14+ messages in thread
From: Nikolay Bodunov @ 2017-02-14 22:06 UTC (permalink / raw)
  To: Kinney, Michael D; +Cc: Laszlo Ersek, edk2-devel@ml01.01.org

Thank you for the suggestions.

I tried to use them:

> (1) Please always terminate the debug message with a newline ("\n")
Done. No changes. Of course, I usually do it, but in that case all I needed
was to have any string on output. Sorry for bad programming style.

> (2) Please use DEBUG_ERROR as the symbolic constant for the error mask
Done. I think you meant in DEBUG() macros. No changes. Question about
style, too.

> (3) DEBUG output from OVMF is by default not written to the serial port
and
> add -D DEBUG_ON_SERIAL_PORT
Done. Recompiled OVMF with that option. I have now file "debug.log" 74415
bytes size that contains everything, include EFI Shell output, but except
my debug messages

BTW, QEMU option "-debugcon file:debug.log -global
isa-debugcon.iobase=0x402", recommended in OVMF README, did nothing -
"debug.log was empty.

Based on results, I suppose that the problem is not on OVMF side.
Hope you propose something else to try. Maybe I got something in a wrong
way.

Nikolay

2017-02-14 21:28 GMT+03:00 Kinney, Michael D <michael.d.kinney@intel.com>:

> If you prefer debug messages on a serial port, you can
> add -D DEBUG_ON_SERIAL_PORT
>
> Mike
>
> > -----Original Message-----
> > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Laszlo Ersek
> > Sent: Tuesday, February 14, 2017 10:17 AM
> > To: Nikolay Bodunov <nikolay.bodunov@gmail.com>; edk2-devel@ml01.01.org
> > Subject: Re: [edk2] DEBUG() macros in DXE driver: can’t make it work in
> QEMU
> >
> > Hi Nikolay,
> >
> > On 02/14/17 18:55, Nikolay Bodunov wrote:
> > > Hello
> > >
> > >
> > > I compiled DXE Driver, in DEBUG_GCC49 mode, but I can’t print any debug
> > > message.
> > > DEBUG((-1, “Print test”))  does nothing.  Exactly as
> > > DebugPrint(EFI_D_ERROR, “Print Test);
> >
> > (1) Please always terminate the debug message with a newline ("\n") once
> > you are done with it. (It's okay to format a single message with several
> > DEBUG calls of course, and terminate only the last DEBUG with a newline.)
> >
> > (2) Please use DEBUG_ERROR as the symbolic constant for the error mask.
> >
> > >
> > > However, I see “Print Test” string in my *.efi binary.
> > > I use QEMU + OMVF (OVMF was also recompliled in DEBUG_GCC49 mode, to be
> > > sure). Serial port output is redirected to a file:
> > > qemu-system-x86_64 -L . --bios /…/FV/OVMF.fd -hda hdd.img -serial
> > > file:./serial_file
> >
> > (3) DEBUG output from OVMF is by default not written to the serial port,
> > it is written to the QEMU debug port. Please consult OvmfPkg/README for
> > specifics, namely under "Capturing OVMF debug messages on qemu".
> >
> > Hope this helps,
> > Laszlo
> >
> > >
> > > All I see in output file is EFI shell output messages, include one
> that my
> > > driver was succesfully loaded. But no messages from DEBUG().
> > >
> > >
> > > My conditions:
> > >
> > > MODULE_TYPE    = DXE_DRIVER
> > >
> > >
> > > Debug Print Library:
> > >
> > > DebugLib|MdePkg/Library/BaseDebugLibSerialPort/
> BaseDebugLibSerialPort.inf
> > >
> > > (BaseDebugLibNull.inf is commented, of course)
> > >
> > >
> > > DebugPrintEnabled() returns TRUE
> > >
> > >
> > > I also tried to set some key options manually in MdeModulePkg.dsc
> > > afterwards, but result didn’t change:
> > >
> > >
> > > [Components]
> > >
> > >
> > >   MdeModulePkg/CrScreenshotDxe/CrScreenshotDxe.inf  {
> > >
> > >
> > >     <PcdsFixedAtBuild>
> > >
> > >
> > > gEfiMdePkgTokenSpaceGuid.gEfiMdePkgTokenSpaceGuid.
> PcdDebugPrintErrorLevel|0x07
> > >
> > >       gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
> > >
> > >       gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000042
> > >
> > >
> > >
> > >    <LibraryClasses>
> > >
> > >
> > > DebugLib|MdePkg/Library/BaseDebugLibSerialPort/
> BaseDebugLibSerialPort.inf
> > >
> > >
> > >    <BuildOptions>
> > >
> > >       GCC:*_*_*_CC_FLAGS             = -UMDEPKG_NDEBUG
> > >
> > > }
> > >
> > >
> > > Code (I used it as a base): https://github.com/LongSoft/
> CrScreenshotDxe
> > >
> > > Where I got wrong and what else could I try to make it work?
> > >
> >
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
>



-- 
With best regards,
Nikolay Bodunov


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DEBUG() macros in DXE driver: can’t make it work in QEMU
  2017-02-14 22:06     ` Nikolay Bodunov
@ 2017-02-14 22:17       ` David A. Van Arnem
  2017-02-14 22:36         ` Nikolay Bodunov
  2017-02-15 10:13       ` Laszlo Ersek
  1 sibling, 1 reply; 14+ messages in thread
From: David A. Van Arnem @ 2017-02-14 22:17 UTC (permalink / raw)
  To: Nikolay Bodunov, Kinney, Michael D; +Cc: edk2-devel@ml01.01.org, Laszlo Ersek

Hi,

From a quick look at your code, I'm not sure you want to make a
DXE_DRIVER.  The code looks more like a UEFI_APPLICATION.
CrScreenshotDxe.c should normally manage a device, for UEFI_DRIVERS it
will implement the Driver Binding Protocol functions Supported(),
Start(), and Stop().

Likely, the reason you aren't seeing any DEBUG() messages is because
your functions aren't being called.

Regards,
David

On 02/14/2017 03:06 PM, Nikolay Bodunov wrote:
> Thank you for the suggestions.
> 
> I tried to use them:
> 
>> (1) Please always terminate the debug message with a newline ("\n")
> Done. No changes. Of course, I usually do it, but in that case all I needed
> was to have any string on output. Sorry for bad programming style.
> 
>> (2) Please use DEBUG_ERROR as the symbolic constant for the error mask
> Done. I think you meant in DEBUG() macros. No changes. Question about
> style, too.
> 
>> (3) DEBUG output from OVMF is by default not written to the serial port
> and
>> add -D DEBUG_ON_SERIAL_PORT
> Done. Recompiled OVMF with that option. I have now file "debug.log" 74415
> bytes size that contains everything, include EFI Shell output, but except
> my debug messages
> 
> BTW, QEMU option "-debugcon file:debug.log -global
> isa-debugcon.iobase=0x402", recommended in OVMF README, did nothing -
> "debug.log was empty.
> 
> Based on results, I suppose that the problem is not on OVMF side.
> Hope you propose something else to try. Maybe I got something in a wrong
> way.
> 
> Nikolay
> 
> 2017-02-14 21:28 GMT+03:00 Kinney, Michael D <michael.d.kinney@intel.com>:
> 
>> If you prefer debug messages on a serial port, you can
>> add -D DEBUG_ON_SERIAL_PORT
>>
>> Mike
>>
>>> -----Original Message-----
>>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
>> Laszlo Ersek
>>> Sent: Tuesday, February 14, 2017 10:17 AM
>>> To: Nikolay Bodunov <nikolay.bodunov@gmail.com>; edk2-devel@ml01.01.org
>>> Subject: Re: [edk2] DEBUG() macros in DXE driver: can’t make it work in
>> QEMU
>>>
>>> Hi Nikolay,
>>>
>>> On 02/14/17 18:55, Nikolay Bodunov wrote:
>>>> Hello
>>>>
>>>>
>>>> I compiled DXE Driver, in DEBUG_GCC49 mode, but I can’t print any debug
>>>> message.
>>>> DEBUG((-1, “Print test”))  does nothing.  Exactly as
>>>> DebugPrint(EFI_D_ERROR, “Print Test);
>>>
>>> (1) Please always terminate the debug message with a newline ("\n") once
>>> you are done with it. (It's okay to format a single message with several
>>> DEBUG calls of course, and terminate only the last DEBUG with a newline.)
>>>
>>> (2) Please use DEBUG_ERROR as the symbolic constant for the error mask.
>>>
>>>>
>>>> However, I see “Print Test” string in my *.efi binary.
>>>> I use QEMU + OMVF (OVMF was also recompliled in DEBUG_GCC49 mode, to be
>>>> sure). Serial port output is redirected to a file:
>>>> qemu-system-x86_64 -L . --bios /…/FV/OVMF.fd -hda hdd.img -serial
>>>> file:./serial_file
>>>
>>> (3) DEBUG output from OVMF is by default not written to the serial port,
>>> it is written to the QEMU debug port. Please consult OvmfPkg/README for
>>> specifics, namely under "Capturing OVMF debug messages on qemu".
>>>
>>> Hope this helps,
>>> Laszlo
>>>
>>>>
>>>> All I see in output file is EFI shell output messages, include one
>> that my
>>>> driver was succesfully loaded. But no messages from DEBUG().
>>>>
>>>>
>>>> My conditions:
>>>>
>>>> MODULE_TYPE    = DXE_DRIVER
>>>>
>>>>
>>>> Debug Print Library:
>>>>
>>>> DebugLib|MdePkg/Library/BaseDebugLibSerialPort/
>> BaseDebugLibSerialPort.inf
>>>>
>>>> (BaseDebugLibNull.inf is commented, of course)
>>>>
>>>>
>>>> DebugPrintEnabled() returns TRUE
>>>>
>>>>
>>>> I also tried to set some key options manually in MdeModulePkg.dsc
>>>> afterwards, but result didn’t change:
>>>>
>>>>
>>>> [Components]
>>>>
>>>>
>>>>   MdeModulePkg/CrScreenshotDxe/CrScreenshotDxe.inf  {
>>>>
>>>>
>>>>     <PcdsFixedAtBuild>
>>>>
>>>>
>>>> gEfiMdePkgTokenSpaceGuid.gEfiMdePkgTokenSpaceGuid.
>> PcdDebugPrintErrorLevel|0x07
>>>>
>>>>       gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
>>>>
>>>>       gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000042
>>>>
>>>>
>>>>
>>>>    <LibraryClasses>
>>>>
>>>>
>>>> DebugLib|MdePkg/Library/BaseDebugLibSerialPort/
>> BaseDebugLibSerialPort.inf
>>>>
>>>>
>>>>    <BuildOptions>
>>>>
>>>>       GCC:*_*_*_CC_FLAGS             = -UMDEPKG_NDEBUG
>>>>
>>>> }
>>>>
>>>>
>>>> Code (I used it as a base): https://github.com/LongSoft/
>> CrScreenshotDxe
>>>>
>>>> Where I got wrong and what else could I try to make it work?
>>>>
>>>
>>> _______________________________________________
>>> edk2-devel mailing list
>>> edk2-devel@lists.01.org
>>> https://lists.01.org/mailman/listinfo/edk2-devel
>>
> 
> 
> 

-- 
Regards,
David Van Arnem
Development Engineer IV
Computer Measurement Laboratory, LLC



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DEBUG() macros in DXE driver: can’t make it work in QEMU
  2017-02-14 22:17       ` David A. Van Arnem
@ 2017-02-14 22:36         ` Nikolay Bodunov
  2017-02-14 23:14           ` David A. Van Arnem
  0 siblings, 1 reply; 14+ messages in thread
From: Nikolay Bodunov @ 2017-02-14 22:36 UTC (permalink / raw)
  To: David A. Van Arnem
  Cc: Kinney, Michael D, edk2-devel@ml01.01.org, Laszlo Ersek

Hi

I wrote "As a base". It's not my current code.
I called "DEBUG() directly, without any conditions. Of course, code on
given link won't call DEBUG() if no errors happen.
I understand that UEFI Appliction should work fine with usual print
functions, but now I want to know how to print debug message in DXE phase -
at any way.

Nikolay.

2017-02-15 1:17 GMT+03:00 David A. Van Arnem <dvanarnem@cmlab.biz>:

> Hi,
>
> From a quick look at your code, I'm not sure you want to make a
> DXE_DRIVER.  The code looks more like a UEFI_APPLICATION.
> CrScreenshotDxe.c should normally manage a device, for UEFI_DRIVERS it
> will implement the Driver Binding Protocol functions Supported(),
> Start(), and Stop().
>
> Likely, the reason you aren't seeing any DEBUG() messages is because
> your functions aren't being called.
>
> Regards,
> David
>
> On 02/14/2017 03:06 PM, Nikolay Bodunov wrote:
> > Thank you for the suggestions.
> >
> > I tried to use them:
> >
> >> (1) Please always terminate the debug message with a newline ("\n")
> > Done. No changes. Of course, I usually do it, but in that case all I
> needed
> > was to have any string on output. Sorry for bad programming style.
> >
> >> (2) Please use DEBUG_ERROR as the symbolic constant for the error mask
> > Done. I think you meant in DEBUG() macros. No changes. Question about
> > style, too.
> >
> >> (3) DEBUG output from OVMF is by default not written to the serial port
> > and
> >> add -D DEBUG_ON_SERIAL_PORT
> > Done. Recompiled OVMF with that option. I have now file "debug.log" 74415
> > bytes size that contains everything, include EFI Shell output, but except
> > my debug messages
> >
> > BTW, QEMU option "-debugcon file:debug.log -global
> > isa-debugcon.iobase=0x402", recommended in OVMF README, did nothing -
> > "debug.log was empty.
> >
> > Based on results, I suppose that the problem is not on OVMF side.
> > Hope you propose something else to try. Maybe I got something in a wrong
> > way.
> >
> > Nikolay
> >
> > 2017-02-14 21:28 GMT+03:00 Kinney, Michael D <michael.d.kinney@intel.com
> >:
> >
> >> If you prefer debug messages on a serial port, you can
> >> add -D DEBUG_ON_SERIAL_PORT
> >>
> >> Mike
> >>
> >>> -----Original Message-----
> >>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> >> Laszlo Ersek
> >>> Sent: Tuesday, February 14, 2017 10:17 AM
> >>> To: Nikolay Bodunov <nikolay.bodunov@gmail.com>;
> edk2-devel@ml01.01.org
> >>> Subject: Re: [edk2] DEBUG() macros in DXE driver: can’t make it work in
> >> QEMU
> >>>
> >>> Hi Nikolay,
> >>>
> >>> On 02/14/17 18:55, Nikolay Bodunov wrote:
> >>>> Hello
> >>>>
> >>>>
> >>>> I compiled DXE Driver, in DEBUG_GCC49 mode, but I can’t print any
> debug
> >>>> message.
> >>>> DEBUG((-1, “Print test”))  does nothing.  Exactly as
> >>>> DebugPrint(EFI_D_ERROR, “Print Test);
> >>>
> >>> (1) Please always terminate the debug message with a newline ("\n")
> once
> >>> you are done with it. (It's okay to format a single message with
> several
> >>> DEBUG calls of course, and terminate only the last DEBUG with a
> newline.)
> >>>
> >>> (2) Please use DEBUG_ERROR as the symbolic constant for the error mask.
> >>>
> >>>>
> >>>> However, I see “Print Test” string in my *.efi binary.
> >>>> I use QEMU + OMVF (OVMF was also recompliled in DEBUG_GCC49 mode, to
> be
> >>>> sure). Serial port output is redirected to a file:
> >>>> qemu-system-x86_64 -L . --bios /…/FV/OVMF.fd -hda hdd.img -serial
> >>>> file:./serial_file
> >>>
> >>> (3) DEBUG output from OVMF is by default not written to the serial
> port,
> >>> it is written to the QEMU debug port. Please consult OvmfPkg/README for
> >>> specifics, namely under "Capturing OVMF debug messages on qemu".
> >>>
> >>> Hope this helps,
> >>> Laszlo
> >>>
> >>>>
> >>>> All I see in output file is EFI shell output messages, include one
> >> that my
> >>>> driver was succesfully loaded. But no messages from DEBUG().
> >>>>
> >>>>
> >>>> My conditions:
> >>>>
> >>>> MODULE_TYPE    = DXE_DRIVER
> >>>>
> >>>>
> >>>> Debug Print Library:
> >>>>
> >>>> DebugLib|MdePkg/Library/BaseDebugLibSerialPort/
> >> BaseDebugLibSerialPort.inf
> >>>>
> >>>> (BaseDebugLibNull.inf is commented, of course)
> >>>>
> >>>>
> >>>> DebugPrintEnabled() returns TRUE
> >>>>
> >>>>
> >>>> I also tried to set some key options manually in MdeModulePkg.dsc
> >>>> afterwards, but result didn’t change:
> >>>>
> >>>>
> >>>> [Components]
> >>>>
> >>>>
> >>>>   MdeModulePkg/CrScreenshotDxe/CrScreenshotDxe.inf  {
> >>>>
> >>>>
> >>>>     <PcdsFixedAtBuild>
> >>>>
> >>>>
> >>>> gEfiMdePkgTokenSpaceGuid.gEfiMdePkgTokenSpaceGuid.
> >> PcdDebugPrintErrorLevel|0x07
> >>>>
> >>>>       gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
> >>>>
> >>>>       gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000042
> >>>>
> >>>>
> >>>>
> >>>>    <LibraryClasses>
> >>>>
> >>>>
> >>>> DebugLib|MdePkg/Library/BaseDebugLibSerialPort/
> >> BaseDebugLibSerialPort.inf
> >>>>
> >>>>
> >>>>    <BuildOptions>
> >>>>
> >>>>       GCC:*_*_*_CC_FLAGS             = -UMDEPKG_NDEBUG
> >>>>
> >>>> }
> >>>>
> >>>>
> >>>> Code (I used it as a base): https://github.com/LongSoft/
> >> CrScreenshotDxe
> >>>>
> >>>> Where I got wrong and what else could I try to make it work?
> >>>>
> >>>
> >>> _______________________________________________
> >>> edk2-devel mailing list
> >>> edk2-devel@lists.01.org
> >>> https://lists.01.org/mailman/listinfo/edk2-devel
> >>
> >
> >
> >
>
> --
> Regards,
> David Van Arnem
> Development Engineer IV
> Computer Measurement Laboratory, LLC
>
>


-- 
With best regards,
Nikolay Bodunov


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DEBUG() macros in DXE driver: can’t make it work in QEMU
  2017-02-14 22:36         ` Nikolay Bodunov
@ 2017-02-14 23:14           ` David A. Van Arnem
  2017-02-14 23:46             ` Nikolay Bodunov
  0 siblings, 1 reply; 14+ messages in thread
From: David A. Van Arnem @ 2017-02-14 23:14 UTC (permalink / raw)
  To: Nikolay Bodunov; +Cc: Kinney, Michael D, edk2-devel@ml01.01.org, Laszlo Ersek



On 02/14/2017 03:36 PM, Nikolay Bodunov wrote:
> Hi
> 
> I wrote "As a base". It's not my current code.
> I called "DEBUG() directly, without any conditions. Of course, code on
> given link won't call DEBUG() if no errors happen.
> I understand that UEFI Appliction should work fine with usual print
> functions, but now I want to know how to print debug message in DXE phase -
> at any way.

Ah, well I just dealt with this last week :-)

My solution was to link DebugLib to
MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf in the .dsc
file (in addition to setting the PCD values like you already did).  I
imagine this will also work with OVMF, but I'm not sure because I
haven't used it extensively.  There were some other solutions
recommended, the thread is here:

https://lists.01.org/pipermail/edk2-devel/2017-February/007191.html

Regards,
David

> 
> Nikolay.
> 
> 2017-02-15 1:17 GMT+03:00 David A. Van Arnem <dvanarnem@cmlab.biz>:
> 
>> Hi,
>>
>> From a quick look at your code, I'm not sure you want to make a
>> DXE_DRIVER.  The code looks more like a UEFI_APPLICATION.
>> CrScreenshotDxe.c should normally manage a device, for UEFI_DRIVERS it
>> will implement the Driver Binding Protocol functions Supported(),
>> Start(), and Stop().
>>
>> Likely, the reason you aren't seeing any DEBUG() messages is because
>> your functions aren't being called.
>>
>> Regards,
>> David
>>
>> On 02/14/2017 03:06 PM, Nikolay Bodunov wrote:
>>> Thank you for the suggestions.
>>>
>>> I tried to use them:
>>>
>>>> (1) Please always terminate the debug message with a newline ("\n")
>>> Done. No changes. Of course, I usually do it, but in that case all I
>> needed
>>> was to have any string on output. Sorry for bad programming style.
>>>
>>>> (2) Please use DEBUG_ERROR as the symbolic constant for the error mask
>>> Done. I think you meant in DEBUG() macros. No changes. Question about
>>> style, too.
>>>
>>>> (3) DEBUG output from OVMF is by default not written to the serial port
>>> and
>>>> add -D DEBUG_ON_SERIAL_PORT
>>> Done. Recompiled OVMF with that option. I have now file "debug.log" 74415
>>> bytes size that contains everything, include EFI Shell output, but except
>>> my debug messages
>>>
>>> BTW, QEMU option "-debugcon file:debug.log -global
>>> isa-debugcon.iobase=0x402", recommended in OVMF README, did nothing -
>>> "debug.log was empty.
>>>
>>> Based on results, I suppose that the problem is not on OVMF side.
>>> Hope you propose something else to try. Maybe I got something in a wrong
>>> way.
>>>
>>> Nikolay
>>>
>>> 2017-02-14 21:28 GMT+03:00 Kinney, Michael D <michael.d.kinney@intel.com
>>> :
>>>
>>>> If you prefer debug messages on a serial port, you can
>>>> add -D DEBUG_ON_SERIAL_PORT
>>>>
>>>> Mike
>>>>
>>>>> -----Original Message-----
>>>>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
>>>> Laszlo Ersek
>>>>> Sent: Tuesday, February 14, 2017 10:17 AM
>>>>> To: Nikolay Bodunov <nikolay.bodunov@gmail.com>;
>> edk2-devel@ml01.01.org
>>>>> Subject: Re: [edk2] DEBUG() macros in DXE driver: can’t make it work in
>>>> QEMU
>>>>>
>>>>> Hi Nikolay,
>>>>>
>>>>> On 02/14/17 18:55, Nikolay Bodunov wrote:
>>>>>> Hello
>>>>>>
>>>>>>
>>>>>> I compiled DXE Driver, in DEBUG_GCC49 mode, but I can’t print any
>> debug
>>>>>> message.
>>>>>> DEBUG((-1, “Print test”))  does nothing.  Exactly as
>>>>>> DebugPrint(EFI_D_ERROR, “Print Test);
>>>>>
>>>>> (1) Please always terminate the debug message with a newline ("\n")
>> once
>>>>> you are done with it. (It's okay to format a single message with
>> several
>>>>> DEBUG calls of course, and terminate only the last DEBUG with a
>> newline.)
>>>>>
>>>>> (2) Please use DEBUG_ERROR as the symbolic constant for the error mask.
>>>>>
>>>>>>
>>>>>> However, I see “Print Test” string in my *.efi binary.
>>>>>> I use QEMU + OMVF (OVMF was also recompliled in DEBUG_GCC49 mode, to
>> be
>>>>>> sure). Serial port output is redirected to a file:
>>>>>> qemu-system-x86_64 -L . --bios /…/FV/OVMF.fd -hda hdd.img -serial
>>>>>> file:./serial_file
>>>>>
>>>>> (3) DEBUG output from OVMF is by default not written to the serial
>> port,
>>>>> it is written to the QEMU debug port. Please consult OvmfPkg/README for
>>>>> specifics, namely under "Capturing OVMF debug messages on qemu".
>>>>>
>>>>> Hope this helps,
>>>>> Laszlo
>>>>>
>>>>>>
>>>>>> All I see in output file is EFI shell output messages, include one
>>>> that my
>>>>>> driver was succesfully loaded. But no messages from DEBUG().
>>>>>>
>>>>>>
>>>>>> My conditions:
>>>>>>
>>>>>> MODULE_TYPE    = DXE_DRIVER
>>>>>>
>>>>>>
>>>>>> Debug Print Library:
>>>>>>
>>>>>> DebugLib|MdePkg/Library/BaseDebugLibSerialPort/
>>>> BaseDebugLibSerialPort.inf
>>>>>>
>>>>>> (BaseDebugLibNull.inf is commented, of course)
>>>>>>
>>>>>>
>>>>>> DebugPrintEnabled() returns TRUE
>>>>>>
>>>>>>
>>>>>> I also tried to set some key options manually in MdeModulePkg.dsc
>>>>>> afterwards, but result didn’t change:
>>>>>>
>>>>>>
>>>>>> [Components]
>>>>>>
>>>>>>
>>>>>>   MdeModulePkg/CrScreenshotDxe/CrScreenshotDxe.inf  {
>>>>>>
>>>>>>
>>>>>>     <PcdsFixedAtBuild>
>>>>>>
>>>>>>
>>>>>> gEfiMdePkgTokenSpaceGuid.gEfiMdePkgTokenSpaceGuid.
>>>> PcdDebugPrintErrorLevel|0x07
>>>>>>
>>>>>>       gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
>>>>>>
>>>>>>       gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000042
>>>>>>
>>>>>>
>>>>>>
>>>>>>    <LibraryClasses>
>>>>>>
>>>>>>
>>>>>> DebugLib|MdePkg/Library/BaseDebugLibSerialPort/
>>>> BaseDebugLibSerialPort.inf
>>>>>>
>>>>>>
>>>>>>    <BuildOptions>
>>>>>>
>>>>>>       GCC:*_*_*_CC_FLAGS             = -UMDEPKG_NDEBUG
>>>>>>
>>>>>> }
>>>>>>
>>>>>>
>>>>>> Code (I used it as a base): https://github.com/LongSoft/
>>>> CrScreenshotDxe
>>>>>>
>>>>>> Where I got wrong and what else could I try to make it work?
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> edk2-devel mailing list
>>>>> edk2-devel@lists.01.org
>>>>> https://lists.01.org/mailman/listinfo/edk2-devel
>>>>
>>>
>>>
>>>
>>
>> --
>> Regards,
>> David Van Arnem
>> Development Engineer IV
>> Computer Measurement Laboratory, LLC
>>
>>
> 
> 

-- 
Regards,
David Van Arnem
Development Engineer IV
Computer Measurement Laboratory, LLC



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DEBUG() macros in DXE driver: can’t make it work in QEMU
  2017-02-14 23:14           ` David A. Van Arnem
@ 2017-02-14 23:46             ` Nikolay Bodunov
  2017-02-15  0:00               ` David A. Van Arnem
  0 siblings, 1 reply; 14+ messages in thread
From: Nikolay Bodunov @ 2017-02-14 23:46 UTC (permalink / raw)
  To: David A. Van Arnem
  Cc: Kinney, Michael D, edk2-devel@ml01.01.org, Laszlo Ersek

Hi

I red this topic before asking the question in the maillist. Unfortunately,
it's not for DXE phase.
I even tried to use it and recieved expected compiler error:

error 1001: Module type [PEIM] is not supported by library instance
[/home/nick/src/edk2/MdePkg/Library/UefiDebugLibConOut/
UefiDebugLibConOut.inf]
    consumed by [/home/nick/src/edk2/MdeModulePkg/Bus/Pci/
SdMmcPciHcPei/SdMmcPciHcPei.inf]

Nikolay

2017-02-15 2:14 GMT+03:00 David A. Van Arnem <dvanarnem@cmlab.biz>:

>
>
> On 02/14/2017 03:36 PM, Nikolay Bodunov wrote:
> > Hi
> >
> > I wrote "As a base". It's not my current code.
> > I called "DEBUG() directly, without any conditions. Of course, code on
> > given link won't call DEBUG() if no errors happen.
> > I understand that UEFI Appliction should work fine with usual print
> > functions, but now I want to know how to print debug message in DXE
> phase -
> > at any way.
>
> Ah, well I just dealt with this last week :-)
>
> My solution was to link DebugLib to
> MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf in the .dsc
> file (in addition to setting the PCD values like you already did).  I
> imagine this will also work with OVMF, but I'm not sure because I
> haven't used it extensively.  There were some other solutions
> recommended, the thread is here:
>
> https://lists.01.org/pipermail/edk2-devel/2017-February/007191.html
>
> Regards,
> David
>
> >
> > Nikolay.
> >
> > 2017-02-15 1:17 GMT+03:00 David A. Van Arnem <dvanarnem@cmlab.biz>:
> >
> >> Hi,
> >>
> >> From a quick look at your code, I'm not sure you want to make a
> >> DXE_DRIVER.  The code looks more like a UEFI_APPLICATION.
> >> CrScreenshotDxe.c should normally manage a device, for UEFI_DRIVERS it
> >> will implement the Driver Binding Protocol functions Supported(),
> >> Start(), and Stop().
> >>
> >> Likely, the reason you aren't seeing any DEBUG() messages is because
> >> your functions aren't being called.
> >>
> >> Regards,
> >> David
> >>
> >> On 02/14/2017 03:06 PM, Nikolay Bodunov wrote:
> >>> Thank you for the suggestions.
> >>>
> >>> I tried to use them:
> >>>
> >>>> (1) Please always terminate the debug message with a newline ("\n")
> >>> Done. No changes. Of course, I usually do it, but in that case all I
> >> needed
> >>> was to have any string on output. Sorry for bad programming style.
> >>>
> >>>> (2) Please use DEBUG_ERROR as the symbolic constant for the error mask
> >>> Done. I think you meant in DEBUG() macros. No changes. Question about
> >>> style, too.
> >>>
> >>>> (3) DEBUG output from OVMF is by default not written to the serial
> port
> >>> and
> >>>> add -D DEBUG_ON_SERIAL_PORT
> >>> Done. Recompiled OVMF with that option. I have now file "debug.log"
> 74415
> >>> bytes size that contains everything, include EFI Shell output, but
> except
> >>> my debug messages
> >>>
> >>> BTW, QEMU option "-debugcon file:debug.log -global
> >>> isa-debugcon.iobase=0x402", recommended in OVMF README, did nothing -
> >>> "debug.log was empty.
> >>>
> >>> Based on results, I suppose that the problem is not on OVMF side.
> >>> Hope you propose something else to try. Maybe I got something in a
> wrong
> >>> way.
> >>>
> >>> Nikolay
> >>>
> >>> 2017-02-14 21:28 GMT+03:00 Kinney, Michael D <
> michael.d.kinney@intel.com
> >>> :
> >>>
> >>>> If you prefer debug messages on a serial port, you can
> >>>> add -D DEBUG_ON_SERIAL_PORT
> >>>>
> >>>> Mike
> >>>>
> >>>>> -----Original Message-----
> >>>>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf
> Of
> >>>> Laszlo Ersek
> >>>>> Sent: Tuesday, February 14, 2017 10:17 AM
> >>>>> To: Nikolay Bodunov <nikolay.bodunov@gmail.com>;
> >> edk2-devel@ml01.01.org
> >>>>> Subject: Re: [edk2] DEBUG() macros in DXE driver: can’t make it work
> in
> >>>> QEMU
> >>>>>
> >>>>> Hi Nikolay,
> >>>>>
> >>>>> On 02/14/17 18:55, Nikolay Bodunov wrote:
> >>>>>> Hello
> >>>>>>
> >>>>>>
> >>>>>> I compiled DXE Driver, in DEBUG_GCC49 mode, but I can’t print any
> >> debug
> >>>>>> message.
> >>>>>> DEBUG((-1, “Print test”))  does nothing.  Exactly as
> >>>>>> DebugPrint(EFI_D_ERROR, “Print Test);
> >>>>>
> >>>>> (1) Please always terminate the debug message with a newline ("\n")
> >> once
> >>>>> you are done with it. (It's okay to format a single message with
> >> several
> >>>>> DEBUG calls of course, and terminate only the last DEBUG with a
> >> newline.)
> >>>>>
> >>>>> (2) Please use DEBUG_ERROR as the symbolic constant for the error
> mask.
> >>>>>
> >>>>>>
> >>>>>> However, I see “Print Test” string in my *.efi binary.
> >>>>>> I use QEMU + OMVF (OVMF was also recompliled in DEBUG_GCC49 mode, to
> >> be
> >>>>>> sure). Serial port output is redirected to a file:
> >>>>>> qemu-system-x86_64 -L . --bios /…/FV/OVMF.fd -hda hdd.img -serial
> >>>>>> file:./serial_file
> >>>>>
> >>>>> (3) DEBUG output from OVMF is by default not written to the serial
> >> port,
> >>>>> it is written to the QEMU debug port. Please consult OvmfPkg/README
> for
> >>>>> specifics, namely under "Capturing OVMF debug messages on qemu".
> >>>>>
> >>>>> Hope this helps,
> >>>>> Laszlo
> >>>>>
> >>>>>>
> >>>>>> All I see in output file is EFI shell output messages, include one
> >>>> that my
> >>>>>> driver was succesfully loaded. But no messages from DEBUG().
> >>>>>>
> >>>>>>
> >>>>>> My conditions:
> >>>>>>
> >>>>>> MODULE_TYPE    = DXE_DRIVER
> >>>>>>
> >>>>>>
> >>>>>> Debug Print Library:
> >>>>>>
> >>>>>> DebugLib|MdePkg/Library/BaseDebugLibSerialPort/
> >>>> BaseDebugLibSerialPort.inf
> >>>>>>
> >>>>>> (BaseDebugLibNull.inf is commented, of course)
> >>>>>>
> >>>>>>
> >>>>>> DebugPrintEnabled() returns TRUE
> >>>>>>
> >>>>>>
> >>>>>> I also tried to set some key options manually in MdeModulePkg.dsc
> >>>>>> afterwards, but result didn’t change:
> >>>>>>
> >>>>>>
> >>>>>> [Components]
> >>>>>>
> >>>>>>
> >>>>>>   MdeModulePkg/CrScreenshotDxe/CrScreenshotDxe.inf  {
> >>>>>>
> >>>>>>
> >>>>>>     <PcdsFixedAtBuild>
> >>>>>>
> >>>>>>
> >>>>>> gEfiMdePkgTokenSpaceGuid.gEfiMdePkgTokenSpaceGuid.
> >>>> PcdDebugPrintErrorLevel|0x07
> >>>>>>
> >>>>>>       gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
> >>>>>>
> >>>>>>       gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000042
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>    <LibraryClasses>
> >>>>>>
> >>>>>>
> >>>>>> DebugLib|MdePkg/Library/BaseDebugLibSerialPort/
> >>>> BaseDebugLibSerialPort.inf
> >>>>>>
> >>>>>>
> >>>>>>    <BuildOptions>
> >>>>>>
> >>>>>>       GCC:*_*_*_CC_FLAGS             = -UMDEPKG_NDEBUG
> >>>>>>
> >>>>>> }
> >>>>>>
> >>>>>>
> >>>>>> Code (I used it as a base): https://github.com/LongSoft/
> >>>> CrScreenshotDxe
> >>>>>>
> >>>>>> Where I got wrong and what else could I try to make it work?
> >>>>>>
> >>>>>
> >>>>> _______________________________________________
> >>>>> edk2-devel mailing list
> >>>>> edk2-devel@lists.01.org
> >>>>> https://lists.01.org/mailman/listinfo/edk2-devel
> >>>>
> >>>
> >>>
> >>>
> >>
> >> --
> >> Regards,
> >> David Van Arnem
> >> Development Engineer IV
> >> Computer Measurement Laboratory, LLC
> >>
> >>
> >
> >
>
> --
> Regards,
> David Van Arnem
> Development Engineer IV
> Computer Measurement Laboratory, LLC
>
>


-- 
With best regards,
Nikolay Bodunov


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DEBUG() macros in DXE driver: can’t make it work in QEMU
  2017-02-14 23:46             ` Nikolay Bodunov
@ 2017-02-15  0:00               ` David A. Van Arnem
  2017-02-15 12:39                 ` Laszlo Ersek
  0 siblings, 1 reply; 14+ messages in thread
From: David A. Van Arnem @ 2017-02-15  0:00 UTC (permalink / raw)
  To: edk2-devel



On 02/14/2017 04:46 PM, Nikolay Bodunov wrote:
> Hi
> 
> I red this topic before asking the question in the maillist. Unfortunately,
> it's not for DXE phase.
> I even tried to use it and recieved expected compiler error:
> 
> error 1001: Module type [PEIM] is not supported by library instance
> [/home/nick/src/edk2/MdePkg/Library/UefiDebugLibConOut/
> UefiDebugLibConOut.inf]
>     consumed by [/home/nick/src/edk2/MdeModulePkg/Bus/Pci/
> SdMmcPciHcPei/SdMmcPciHcPei.inf]

Hi,

MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf lists
DXE_DRIVER in its [Defines] section under LIBRARY_CLASS, so it is
compatible with DXE_DRIVER module types (I have used it this way).
However, if I'm reading your output correctly, you are trying to build a
PEI module which is why you are getting the error.  PEI is outside of my
knowledge.

Regards,
David

> 
> Nikolay
> 
> 2017-02-15 2:14 GMT+03:00 David A. Van Arnem <dvanarnem@cmlab.biz>:
> 
>>
>>
>> On 02/14/2017 03:36 PM, Nikolay Bodunov wrote:
>>> Hi
>>>
>>> I wrote "As a base". It's not my current code.
>>> I called "DEBUG() directly, without any conditions. Of course, code on
>>> given link won't call DEBUG() if no errors happen.
>>> I understand that UEFI Appliction should work fine with usual print
>>> functions, but now I want to know how to print debug message in DXE
>> phase -
>>> at any way.
>>
>> Ah, well I just dealt with this last week :-)
>>
>> My solution was to link DebugLib to
>> MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf in the .dsc
>> file (in addition to setting the PCD values like you already did).  I
>> imagine this will also work with OVMF, but I'm not sure because I
>> haven't used it extensively.  There were some other solutions
>> recommended, the thread is here:
>>
>> https://lists.01.org/pipermail/edk2-devel/2017-February/007191.html
>>
>> Regards,
>> David
>>
>>>
>>> Nikolay.
>>>
>>> 2017-02-15 1:17 GMT+03:00 David A. Van Arnem <dvanarnem@cmlab.biz>:
>>>
>>>> Hi,
>>>>
>>>> From a quick look at your code, I'm not sure you want to make a
>>>> DXE_DRIVER.  The code looks more like a UEFI_APPLICATION.
>>>> CrScreenshotDxe.c should normally manage a device, for UEFI_DRIVERS it
>>>> will implement the Driver Binding Protocol functions Supported(),
>>>> Start(), and Stop().
>>>>
>>>> Likely, the reason you aren't seeing any DEBUG() messages is because
>>>> your functions aren't being called.
>>>>
>>>> Regards,
>>>> David
>>>>
>>>> On 02/14/2017 03:06 PM, Nikolay Bodunov wrote:
>>>>> Thank you for the suggestions.
>>>>>
>>>>> I tried to use them:
>>>>>
>>>>>> (1) Please always terminate the debug message with a newline ("\n")
>>>>> Done. No changes. Of course, I usually do it, but in that case all I
>>>> needed
>>>>> was to have any string on output. Sorry for bad programming style.
>>>>>
>>>>>> (2) Please use DEBUG_ERROR as the symbolic constant for the error mask
>>>>> Done. I think you meant in DEBUG() macros. No changes. Question about
>>>>> style, too.
>>>>>
>>>>>> (3) DEBUG output from OVMF is by default not written to the serial
>> port
>>>>> and
>>>>>> add -D DEBUG_ON_SERIAL_PORT
>>>>> Done. Recompiled OVMF with that option. I have now file "debug.log"
>> 74415
>>>>> bytes size that contains everything, include EFI Shell output, but
>> except
>>>>> my debug messages
>>>>>
>>>>> BTW, QEMU option "-debugcon file:debug.log -global
>>>>> isa-debugcon.iobase=0x402", recommended in OVMF README, did nothing -
>>>>> "debug.log was empty.
>>>>>
>>>>> Based on results, I suppose that the problem is not on OVMF side.
>>>>> Hope you propose something else to try. Maybe I got something in a
>> wrong
>>>>> way.
>>>>>
>>>>> Nikolay
>>>>>
>>>>> 2017-02-14 21:28 GMT+03:00 Kinney, Michael D <
>> michael.d.kinney@intel.com
>>>>> :
>>>>>
>>>>>> If you prefer debug messages on a serial port, you can
>>>>>> add -D DEBUG_ON_SERIAL_PORT
>>>>>>
>>>>>> Mike
>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf
>> Of
>>>>>> Laszlo Ersek
>>>>>>> Sent: Tuesday, February 14, 2017 10:17 AM
>>>>>>> To: Nikolay Bodunov <nikolay.bodunov@gmail.com>;
>>>> edk2-devel@ml01.01.org
>>>>>>> Subject: Re: [edk2] DEBUG() macros in DXE driver: can’t make it work
>> in
>>>>>> QEMU
>>>>>>>
>>>>>>> Hi Nikolay,
>>>>>>>
>>>>>>> On 02/14/17 18:55, Nikolay Bodunov wrote:
>>>>>>>> Hello
>>>>>>>>
>>>>>>>>
>>>>>>>> I compiled DXE Driver, in DEBUG_GCC49 mode, but I can’t print any
>>>> debug
>>>>>>>> message.
>>>>>>>> DEBUG((-1, “Print test”))  does nothing.  Exactly as
>>>>>>>> DebugPrint(EFI_D_ERROR, “Print Test);
>>>>>>>
>>>>>>> (1) Please always terminate the debug message with a newline ("\n")
>>>> once
>>>>>>> you are done with it. (It's okay to format a single message with
>>>> several
>>>>>>> DEBUG calls of course, and terminate only the last DEBUG with a
>>>> newline.)
>>>>>>>
>>>>>>> (2) Please use DEBUG_ERROR as the symbolic constant for the error
>> mask.
>>>>>>>
>>>>>>>>
>>>>>>>> However, I see “Print Test” string in my *.efi binary.
>>>>>>>> I use QEMU + OMVF (OVMF was also recompliled in DEBUG_GCC49 mode, to
>>>> be
>>>>>>>> sure). Serial port output is redirected to a file:
>>>>>>>> qemu-system-x86_64 -L . --bios /…/FV/OVMF.fd -hda hdd.img -serial
>>>>>>>> file:./serial_file
>>>>>>>
>>>>>>> (3) DEBUG output from OVMF is by default not written to the serial
>>>> port,
>>>>>>> it is written to the QEMU debug port. Please consult OvmfPkg/README
>> for
>>>>>>> specifics, namely under "Capturing OVMF debug messages on qemu".
>>>>>>>
>>>>>>> Hope this helps,
>>>>>>> Laszlo
>>>>>>>
>>>>>>>>
>>>>>>>> All I see in output file is EFI shell output messages, include one
>>>>>> that my
>>>>>>>> driver was succesfully loaded. But no messages from DEBUG().
>>>>>>>>
>>>>>>>>
>>>>>>>> My conditions:
>>>>>>>>
>>>>>>>> MODULE_TYPE    = DXE_DRIVER
>>>>>>>>
>>>>>>>>
>>>>>>>> Debug Print Library:
>>>>>>>>
>>>>>>>> DebugLib|MdePkg/Library/BaseDebugLibSerialPort/
>>>>>> BaseDebugLibSerialPort.inf
>>>>>>>>
>>>>>>>> (BaseDebugLibNull.inf is commented, of course)
>>>>>>>>
>>>>>>>>
>>>>>>>> DebugPrintEnabled() returns TRUE
>>>>>>>>
>>>>>>>>
>>>>>>>> I also tried to set some key options manually in MdeModulePkg.dsc
>>>>>>>> afterwards, but result didn’t change:
>>>>>>>>
>>>>>>>>
>>>>>>>> [Components]
>>>>>>>>
>>>>>>>>
>>>>>>>>   MdeModulePkg/CrScreenshotDxe/CrScreenshotDxe.inf  {
>>>>>>>>
>>>>>>>>
>>>>>>>>     <PcdsFixedAtBuild>
>>>>>>>>
>>>>>>>>
>>>>>>>> gEfiMdePkgTokenSpaceGuid.gEfiMdePkgTokenSpaceGuid.
>>>>>> PcdDebugPrintErrorLevel|0x07
>>>>>>>>
>>>>>>>>       gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
>>>>>>>>
>>>>>>>>       gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000042
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>    <LibraryClasses>
>>>>>>>>
>>>>>>>>
>>>>>>>> DebugLib|MdePkg/Library/BaseDebugLibSerialPort/
>>>>>> BaseDebugLibSerialPort.inf
>>>>>>>>
>>>>>>>>
>>>>>>>>    <BuildOptions>
>>>>>>>>
>>>>>>>>       GCC:*_*_*_CC_FLAGS             = -UMDEPKG_NDEBUG
>>>>>>>>
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>> Code (I used it as a base): https://github.com/LongSoft/
>>>>>> CrScreenshotDxe
>>>>>>>>
>>>>>>>> Where I got wrong and what else could I try to make it work?
>>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> edk2-devel mailing list
>>>>>>> edk2-devel@lists.01.org
>>>>>>> https://lists.01.org/mailman/listinfo/edk2-devel
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> Regards,
>>>> David Van Arnem
>>>> Development Engineer IV
>>>> Computer Measurement Laboratory, LLC
>>>>
>>>>
>>>
>>>
>>
>> --
>> Regards,
>> David Van Arnem
>> Development Engineer IV
>> Computer Measurement Laboratory, LLC
>>
>>
> 
> 

-- 
Regards,
David Van Arnem
Development Engineer IV
Computer Measurement Laboratory, LLC



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DEBUG() macros in DXE driver: can’t make it work in QEMU
  2017-02-14 22:06     ` Nikolay Bodunov
  2017-02-14 22:17       ` David A. Van Arnem
@ 2017-02-15 10:13       ` Laszlo Ersek
  2017-02-15 17:19         ` Nikolay Bodunov
  1 sibling, 1 reply; 14+ messages in thread
From: Laszlo Ersek @ 2017-02-15 10:13 UTC (permalink / raw)
  To: Nikolay Bodunov; +Cc: Kinney, Michael D, edk2-devel@ml01.01.org

On 02/14/17 23:06, Nikolay Bodunov wrote:
> Thank you for the suggestions.
> 
> I tried to use them:
> 
>> (1) Please always terminate the debug message with a newline ("\n")
> Done. No changes. Of course, I usually do it, but in that case all I
> needed was to have any string on output. Sorry for bad programming style.
> 
>> (2) Please use DEBUG_ERROR as the symbolic constant for the error mask
> Done. I think you meant in DEBUG() macros. No changes. Question about
> style, too.
> 
>> (3) DEBUG output from OVMF is by default not written to the serial port
> and
>> add -D DEBUG_ON_SERIAL_PORT
> Done. Recompiled OVMF with that option. I have now file "debug.log"
> 74415 bytes size that contains everything, include EFI Shell output, but
> except my debug messages
> 
> BTW, QEMU option "-debugcon file:debug.log -global
> isa-debugcon.iobase=0x402", recommended in OVMF README, did nothing -
> "debug.log was empty.

I think you have it mixed up a little. The README covers this, but it
might not be very approachable.

So: if you do *not* specify -D DEBUG_ON_SERIAL_PORT when you build OVMF,
then the debug messages will go to the QEMU debug port. And, if you want
to capture the QEMU debug port in a file, then you should pass
"-debugcon file:debug.log -global isa-debugcon.iobase=0x402" on the QEMU
command line.

Conversely, if you *do* specify -D DEBUG_ON_SERIAL_PORT when building
OVMF, then debug messages will go to the emulated serial port (and
they'll be intermixed with any serial terminal output, which is why this
setting is not the default). In this case, the -debugcon etc. settings
are useless, because the QEMU debug port is not used.

> 
> Based on results, I suppose that the problem is not on OVMF side.
> Hope you propose something else to try. Maybe I got something in a wrong
> way.

Are you sure that when you build your module, it links against the right
DebugLib instance?

If you pass -D DEBUG_ON_SERIAL_PORT when you build OVMF, that switches
the library class resolution for DebugLib from the default

  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf

to

  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf

for all module types. However, for this library class resolution to take
effect for your own module as well, you should either add your module
directly to OvmfPkg*.dsc, or else implement the exact same library
resolution for your module (in the external DSC file where your module
is listed). Library instances are statically linked into driver and
application modules in edk2.

In other words, if you *separately* build your driver or application
module with a DebugLib class resolution that points to, say, the

  MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf

library instance, then you won't see any DEBUG output whatsoever,
regardless of how you build OVMF (*separately* again), and how you
configure QEMU. At that point, a "null" DebugLib instance will have been
statically linked into your driver or application, and it will produce
no output.

Thanks
Laszlo

> 
> Nikolay
> 
> 2017-02-14 21:28 GMT+03:00 Kinney, Michael D <michael.d.kinney@intel.com
> <mailto:michael.d.kinney@intel.com>>:
> 
>     If you prefer debug messages on a serial port, you can
>     add -D DEBUG_ON_SERIAL_PORT
> 
>     Mike
> 
>     > -----Original Message-----
>     > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org
>     <mailto:edk2-devel-bounces@lists.01.org>] On Behalf Of Laszlo Ersek
>     > Sent: Tuesday, February 14, 2017 10:17 AM
>     > To: Nikolay Bodunov <nikolay.bodunov@gmail.com
>     <mailto:nikolay.bodunov@gmail.com>>; edk2-devel@ml01.01.org
>     <mailto:edk2-devel@ml01.01.org>
>     > Subject: Re: [edk2] DEBUG() macros in DXE driver: can’t make it
>     work in QEMU
>     >
>     > Hi Nikolay,
>     >
>     > On 02/14/17 18:55, Nikolay Bodunov wrote:
>     > > Hello
>     > >
>     > >
>     > > I compiled DXE Driver, in DEBUG_GCC49 mode, but I can’t print
>     any debug
>     > > message.
>     > > DEBUG((-1, “Print test”))  does nothing.  Exactly as
>     > > DebugPrint(EFI_D_ERROR, “Print Test);
>     >
>     > (1) Please always terminate the debug message with a newline
>     ("\n") once
>     > you are done with it. (It's okay to format a single message with
>     several
>     > DEBUG calls of course, and terminate only the last DEBUG with a
>     newline.)
>     >
>     > (2) Please use DEBUG_ERROR as the symbolic constant for the error
>     mask.
>     >
>     > >
>     > > However, I see “Print Test” string in my *.efi binary.
>     > > I use QEMU + OMVF (OVMF was also recompliled in DEBUG_GCC49
>     mode, to be
>     > > sure). Serial port output is redirected to a file:
>     > > qemu-system-x86_64 -L . --bios /…/FV/OVMF.fd -hda hdd.img -serial
>     > > file:./serial_file
>     >
>     > (3) DEBUG output from OVMF is by default not written to the serial
>     port,
>     > it is written to the QEMU debug port. Please consult
>     OvmfPkg/README for
>     > specifics, namely under "Capturing OVMF debug messages on qemu".
>     >
>     > Hope this helps,
>     > Laszlo
>     >
>     > >
>     > > All I see in output file is EFI shell output messages, include
>     one that my
>     > > driver was succesfully loaded. But no messages from DEBUG().
>     > >
>     > >
>     > > My conditions:
>     > >
>     > > MODULE_TYPE    = DXE_DRIVER
>     > >
>     > >
>     > > Debug Print Library:
>     > >
>     > >
>     DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
>     > >
>     > > (BaseDebugLibNull.inf is commented, of course)
>     > >
>     > >
>     > > DebugPrintEnabled() returns TRUE
>     > >
>     > >
>     > > I also tried to set some key options manually in MdeModulePkg.dsc
>     > > afterwards, but result didn’t change:
>     > >
>     > >
>     > > [Components]
>     > >
>     > >
>     > >   MdeModulePkg/CrScreenshotDxe/CrScreenshotDxe.inf  {
>     > >
>     > >
>     > >     <PcdsFixedAtBuild>
>     > >
>     > >
>     > >
>     gEfiMdePkgTokenSpaceGuid.gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x07
>     > >
>     > >       gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
>     > >
>     > >       gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000042
>     > >
>     > >
>     > >
>     > >    <LibraryClasses>
>     > >
>     > >
>     > >
>     DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
>     > >
>     > >
>     > >    <BuildOptions>
>     > >
>     > >       GCC:*_*_*_CC_FLAGS             = -UMDEPKG_NDEBUG
>     > >
>     > > }
>     > >
>     > >
>     > > Code (I used it as a base):
>     https://github.com/LongSoft/CrScreenshotDxe
>     <https://github.com/LongSoft/CrScreenshotDxe>
>     > >
>     > > Where I got wrong and what else could I try to make it work?
>     > >
>     >
>     > _______________________________________________
>     > edk2-devel mailing list
>     > edk2-devel@lists.01.org <mailto:edk2-devel@lists.01.org>
>     > https://lists.01.org/mailman/listinfo/edk2-devel
>     <https://lists.01.org/mailman/listinfo/edk2-devel>
> 
> 
> 
> 
> -- 
> With best regards,
> Nikolay Bodunov



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DEBUG() macros in DXE driver: can’t make it work in QEMU
  2017-02-15  0:00               ` David A. Van Arnem
@ 2017-02-15 12:39                 ` Laszlo Ersek
  2017-02-16 18:05                   ` Andrew Fish
  0 siblings, 1 reply; 14+ messages in thread
From: Laszlo Ersek @ 2017-02-15 12:39 UTC (permalink / raw)
  To: David A. Van Arnem, edk2-devel

On 02/15/17 01:00, David A. Van Arnem wrote:
> 
> 
> On 02/14/2017 04:46 PM, Nikolay Bodunov wrote:
>> Hi
>>
>> I red this topic before asking the question in the maillist. Unfortunately,
>> it's not for DXE phase.
>> I even tried to use it and recieved expected compiler error:
>>
>> error 1001: Module type [PEIM] is not supported by library instance
>> [/home/nick/src/edk2/MdePkg/Library/UefiDebugLibConOut/
>> UefiDebugLibConOut.inf]
>>     consumed by [/home/nick/src/edk2/MdeModulePkg/Bus/Pci/
>> SdMmcPciHcPei/SdMmcPciHcPei.inf]
> 
> Hi,
> 
> MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf lists
> DXE_DRIVER in its [Defines] section under LIBRARY_CLASS, so it is
> compatible with DXE_DRIVER module types (I have used it this way).
> However, if I'm reading your output correctly, you are trying to build a
> PEI module which is why you are getting the error.  PEI is outside of my
> knowledge.

In the PEI phase, no such thing exists as "system console" (that's a
UEFI construct), hence the fact that UefiDebugLibConOut (which prints to
said console) rejects being linked into PEIMs (PEI modules) is justified.

Again, a suitable DebugLib instance should be chosen (in the DSC file
where the PEIM in question is listed too, resolving the DebugLib class
for PEIMs), and DEBUG() macros should be used for logging.

Thanks
Laszlo



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DEBUG() macros in DXE driver: can’t make it work in QEMU
  2017-02-15 10:13       ` Laszlo Ersek
@ 2017-02-15 17:19         ` Nikolay Bodunov
  0 siblings, 0 replies; 14+ messages in thread
From: Nikolay Bodunov @ 2017-02-15 17:19 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: Kinney, Michael D, edk2-devel@ml01.01.org

Hi Laszlo

First of all, great thanks to you and all others for spending your time for
explanations!

I fixed it. A problem was, as you suggested, in setting different DebugLib
implementarions in OVMF and my DXE driver.

First, I compiled my DXE driver together with OVMF, to guarantee that
DebugLib implementation will be the same (PlatformDebugLibIoPort), and got
DEBUG()'s strings in output file.
Second, I set same DebudLib implementation for MdeModulePkg and got same
results.

All I want now is to redirect DEBUG() output in other file, than one with
kernel messages, for simplify reading, but I think it shouldn't be too
complex now.

Thank you one more time!

With best regards,
Nikolay

2017-02-15 13:13 GMT+03:00 Laszlo Ersek <lersek@redhat.com>:

> On 02/14/17 23:06, Nikolay Bodunov wrote:
> > Thank you for the suggestions.
> >
> > I tried to use them:
> >
> >> (1) Please always terminate the debug message with a newline ("\n")
> > Done. No changes. Of course, I usually do it, but in that case all I
> > needed was to have any string on output. Sorry for bad programming style.
> >
> >> (2) Please use DEBUG_ERROR as the symbolic constant for the error mask
> > Done. I think you meant in DEBUG() macros. No changes. Question about
> > style, too.
> >
> >> (3) DEBUG output from OVMF is by default not written to the serial port
> > and
> >> add -D DEBUG_ON_SERIAL_PORT
> > Done. Recompiled OVMF with that option. I have now file "debug.log"
> > 74415 bytes size that contains everything, include EFI Shell output, but
> > except my debug messages
> >
> > BTW, QEMU option "-debugcon file:debug.log -global
> > isa-debugcon.iobase=0x402", recommended in OVMF README, did nothing -
> > "debug.log was empty.
>
> I think you have it mixed up a little. The README covers this, but it
> might not be very approachable.
>
> So: if you do *not* specify -D DEBUG_ON_SERIAL_PORT when you build OVMF,
> then the debug messages will go to the QEMU debug port. And, if you want
> to capture the QEMU debug port in a file, then you should pass
> "-debugcon file:debug.log -global isa-debugcon.iobase=0x402" on the QEMU
> command line.
>
> Conversely, if you *do* specify -D DEBUG_ON_SERIAL_PORT when building
> OVMF, then debug messages will go to the emulated serial port (and
> they'll be intermixed with any serial terminal output, which is why this
> setting is not the default). In this case, the -debugcon etc. settings
> are useless, because the QEMU debug port is not used.
>
> >
> > Based on results, I suppose that the problem is not on OVMF side.
> > Hope you propose something else to try. Maybe I got something in a wrong
> > way.
>
> Are you sure that when you build your module, it links against the right
> DebugLib instance?
>
> If you pass -D DEBUG_ON_SERIAL_PORT when you build OVMF, that switches
> the library class resolution for DebugLib from the default
>
>   DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/
> PlatformDebugLibIoPort.inf
>
> to
>
>   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/
> BaseDebugLibSerialPort.inf
>
> for all module types. However, for this library class resolution to take
> effect for your own module as well, you should either add your module
> directly to OvmfPkg*.dsc, or else implement the exact same library
> resolution for your module (in the external DSC file where your module
> is listed). Library instances are statically linked into driver and
> application modules in edk2.
>
> In other words, if you *separately* build your driver or application
> module with a DebugLib class resolution that points to, say, the
>
>   MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
>
> library instance, then you won't see any DEBUG output whatsoever,
> regardless of how you build OVMF (*separately* again), and how you
> configure QEMU. At that point, a "null" DebugLib instance will have been
> statically linked into your driver or application, and it will produce
> no output.
>
> Thanks
> Laszlo
>
> >
> > Nikolay
> >
> > 2017-02-14 21:28 GMT+03:00 Kinney, Michael D <michael.d.kinney@intel.com
> > <mailto:michael.d.kinney@intel.com>>:
> >
> >     If you prefer debug messages on a serial port, you can
> >     add -D DEBUG_ON_SERIAL_PORT
> >
> >     Mike
> >
> >     > -----Original Message-----
> >     > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org
> >     <mailto:edk2-devel-bounces@lists.01.org>] On Behalf Of Laszlo Ersek
> >     > Sent: Tuesday, February 14, 2017 10:17 AM
> >     > To: Nikolay Bodunov <nikolay.bodunov@gmail.com
> >     <mailto:nikolay.bodunov@gmail.com>>; edk2-devel@ml01.01.org
> >     <mailto:edk2-devel@ml01.01.org>
> >     > Subject: Re: [edk2] DEBUG() macros in DXE driver: can’t make it
> >     work in QEMU
> >     >
> >     > Hi Nikolay,
> >     >
> >     > On 02/14/17 18:55, Nikolay Bodunov wrote:
> >     > > Hello
> >     > >
> >     > >
> >     > > I compiled DXE Driver, in DEBUG_GCC49 mode, but I can’t print
> >     any debug
> >     > > message.
> >     > > DEBUG((-1, “Print test”))  does nothing.  Exactly as
> >     > > DebugPrint(EFI_D_ERROR, “Print Test);
> >     >
> >     > (1) Please always terminate the debug message with a newline
> >     ("\n") once
> >     > you are done with it. (It's okay to format a single message with
> >     several
> >     > DEBUG calls of course, and terminate only the last DEBUG with a
> >     newline.)
> >     >
> >     > (2) Please use DEBUG_ERROR as the symbolic constant for the error
> >     mask.
> >     >
> >     > >
> >     > > However, I see “Print Test” string in my *.efi binary.
> >     > > I use QEMU + OMVF (OVMF was also recompliled in DEBUG_GCC49
> >     mode, to be
> >     > > sure). Serial port output is redirected to a file:
> >     > > qemu-system-x86_64 -L . --bios /…/FV/OVMF.fd -hda hdd.img -serial
> >     > > file:./serial_file
> >     >
> >     > (3) DEBUG output from OVMF is by default not written to the serial
> >     port,
> >     > it is written to the QEMU debug port. Please consult
> >     OvmfPkg/README for
> >     > specifics, namely under "Capturing OVMF debug messages on qemu".
> >     >
> >     > Hope this helps,
> >     > Laszlo
> >     >
> >     > >
> >     > > All I see in output file is EFI shell output messages, include
> >     one that my
> >     > > driver was succesfully loaded. But no messages from DEBUG().
> >     > >
> >     > >
> >     > > My conditions:
> >     > >
> >     > > MODULE_TYPE    = DXE_DRIVER
> >     > >
> >     > >
> >     > > Debug Print Library:
> >     > >
> >     > >
> >     DebugLib|MdePkg/Library/BaseDebugLibSerialPort/
> BaseDebugLibSerialPort.inf
> >     > >
> >     > > (BaseDebugLibNull.inf is commented, of course)
> >     > >
> >     > >
> >     > > DebugPrintEnabled() returns TRUE
> >     > >
> >     > >
> >     > > I also tried to set some key options manually in MdeModulePkg.dsc
> >     > > afterwards, but result didn’t change:
> >     > >
> >     > >
> >     > > [Components]
> >     > >
> >     > >
> >     > >   MdeModulePkg/CrScreenshotDxe/CrScreenshotDxe.inf  {
> >     > >
> >     > >
> >     > >     <PcdsFixedAtBuild>
> >     > >
> >     > >
> >     > >
> >     gEfiMdePkgTokenSpaceGuid.gEfiMdePkgTokenSpaceGuid.
> PcdDebugPrintErrorLevel|0x07
> >     > >
> >     > >       gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
> >     > >
> >     > >       gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|
> 0x80000042
> >     > >
> >     > >
> >     > >
> >     > >    <LibraryClasses>
> >     > >
> >     > >
> >     > >
> >     DebugLib|MdePkg/Library/BaseDebugLibSerialPort/
> BaseDebugLibSerialPort.inf
> >     > >
> >     > >
> >     > >    <BuildOptions>
> >     > >
> >     > >       GCC:*_*_*_CC_FLAGS             = -UMDEPKG_NDEBUG
> >     > >
> >     > > }
> >     > >
> >     > >
> >     > > Code (I used it as a base):
> >     https://github.com/LongSoft/CrScreenshotDxe
> >     <https://github.com/LongSoft/CrScreenshotDxe>
> >     > >
> >     > > Where I got wrong and what else could I try to make it work?
> >     > >
> >     >
> >     > _______________________________________________
> >     > edk2-devel mailing list
> >     > edk2-devel@lists.01.org <mailto:edk2-devel@lists.01.org>
> >     > https://lists.01.org/mailman/listinfo/edk2-devel
> >     <https://lists.01.org/mailman/listinfo/edk2-devel>
> >
> >
> >
> >
> > --
> > With best regards,
> > Nikolay Bodunov
>
>


-- 
With best regards,
Nikolay Bodunov


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DEBUG() macros in DXE driver: can’t make it work in QEMU
  2017-02-15 12:39                 ` Laszlo Ersek
@ 2017-02-16 18:05                   ` Andrew Fish
  2017-02-16 18:59                     ` Laszlo Ersek
  0 siblings, 1 reply; 14+ messages in thread
From: Andrew Fish @ 2017-02-16 18:05 UTC (permalink / raw)
  To: David A. Van Arnem; +Cc: edk2-devel@lists.01.org, Laszlo Ersek


> On Feb 15, 2017, at 4:39 AM, Laszlo Ersek <lersek@redhat.com> wrote:
> 
> On 02/15/17 01:00, David A. Van Arnem wrote:
>> 
>> 
>> On 02/14/2017 04:46 PM, Nikolay Bodunov wrote:
>>> Hi
>>> 
>>> I red this topic before asking the question in the maillist. Unfortunately,
>>> it's not for DXE phase.
>>> I even tried to use it and recieved expected compiler error:
>>> 
>>> error 1001: Module type [PEIM] is not supported by library instance
>>> [/home/nick/src/edk2/MdePkg/Library/UefiDebugLibConOut/
>>> UefiDebugLibConOut.inf]
>>>    consumed by [/home/nick/src/edk2/MdeModulePkg/Bus/Pci/
>>> SdMmcPciHcPei/SdMmcPciHcPei.inf]
>> 
>> Hi,
>> 
>> MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf lists
>> DXE_DRIVER in its [Defines] section under LIBRARY_CLASS, so it is
>> compatible with DXE_DRIVER module types (I have used it this way).
>> However, if I'm reading your output correctly, you are trying to build a
>> PEI module which is why you are getting the error.  PEI is outside of my
>> knowledge.
> 
> In the PEI phase, no such thing exists as "system console" (that's a
> UEFI construct), hence the fact that UefiDebugLibConOut (which prints to
> said console) rejects being linked into PEIMs (PEI modules) is justified.
> 
> Again, a suitable DebugLib instance should be chosen (in the DSC file
> where the PEIM in question is listed too, resolving the DebugLib class
> for PEIMs), and DEBUG() macros should be used for logging.
> 

The build system is very flexible and can be a bit confusing. I find it useful to generate a report by passing --report-file=REPORTFILE  to the build command. This will generate a report that will tell you per driver what libraries actually got linked (include libraries that libraries depend on). it will show all the fixed PCD settings as visible to the driver. If an FV was constructed it will also show the Depex that determines dispatch order, and again this can be changed by the libraries that get used. 

The idea behind the flexibility was that a chip or card vendor could write code using #include <Library/DebugLib.h> and link against DebugLib and it would work for any platform. Actually you could have multiple platforms in a single repository that share that code that all use different debug strategies, without the need to change chip or card vendor code. Thus we kind of had a push the configuration choices into the platform build kind of mind set.

Well the problem with flexibility is complexity, and that is what the build logs help with.

Thanks,

Andrew Fish

> Thanks
> Laszlo
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org <mailto:edk2-devel@lists.01.org>
> https://lists.01.org/mailman/listinfo/edk2-devel <https://lists.01.org/mailman/listinfo/edk2-devel>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: DEBUG() macros in DXE driver: can’t make it work in QEMU
  2017-02-16 18:05                   ` Andrew Fish
@ 2017-02-16 18:59                     ` Laszlo Ersek
  0 siblings, 0 replies; 14+ messages in thread
From: Laszlo Ersek @ 2017-02-16 18:59 UTC (permalink / raw)
  To: Andrew Fish, David A. Van Arnem; +Cc: edk2-devel@lists.01.org

On 02/16/17 19:05, Andrew Fish wrote:
> 
>> On Feb 15, 2017, at 4:39 AM, Laszlo Ersek <lersek@redhat.com
>> <mailto:lersek@redhat.com>> wrote:
>>
>> On 02/15/17 01:00, David A. Van Arnem wrote:
>>>
>>>
>>> On 02/14/2017 04:46 PM, Nikolay Bodunov wrote:
>>>> Hi
>>>>
>>>> I red this topic before asking the question in the maillist.
>>>> Unfortunately,
>>>> it's not for DXE phase.
>>>> I even tried to use it and recieved expected compiler error:
>>>>
>>>> error 1001: Module type [PEIM] is not supported by library instance
>>>> [/home/nick/src/edk2/MdePkg/Library/UefiDebugLibConOut/
>>>> UefiDebugLibConOut.inf]
>>>>    consumed by [/home/nick/src/edk2/MdeModulePkg/Bus/Pci/
>>>> SdMmcPciHcPei/SdMmcPciHcPei.inf]
>>>
>>> Hi,
>>>
>>> MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf lists
>>> DXE_DRIVER in its [Defines] section under LIBRARY_CLASS, so it is
>>> compatible with DXE_DRIVER module types (I have used it this way).
>>> However, if I'm reading your output correctly, you are trying to build a
>>> PEI module which is why you are getting the error.  PEI is outside of my
>>> knowledge.
>>
>> In the PEI phase, no such thing exists as "system console" (that's a
>> UEFI construct), hence the fact that UefiDebugLibConOut (which prints to
>> said console) rejects being linked into PEIMs (PEI modules) is justified.
>>
>> Again, a suitable DebugLib instance should be chosen (in the DSC file
>> where the PEIM in question is listed too, resolving the DebugLib class
>> for PEIMs), and DEBUG() macros should be used for logging.
>>
> 
> The build system is very flexible and can be a bit confusing. I find it
> useful to generate a report by passing --report-file=REPORTFILE  to the
> build command. This will generate a report that will tell you per driver
> what libraries actually got linked (include libraries that libraries
> depend on). it will show all the fixed PCD settings as visible to the
> driver. If an FV was constructed it will also show the Depex that
> determines dispatch order, and again this can be changed by the
> libraries that get used. 
> 
> The idea behind the flexibility was that a chip or card vendor could
> write code using #include <Library/DebugLib.h> and link against DebugLib
> and it would work for any platform. Actually you could have multiple
> platforms in a single repository that share that code that all use
> different debug strategies, without the need to change chip or card
> vendor code. Thus we kind of had a push the configuration choices into
> the platform build kind of mind set.
> 
> Well the problem with flexibility is complexity, and that is what the
> build logs help with.

I agree. I don't know why I failed to mention the report file, as it is
part of my OvmfPkg / ArmVirtPkg build wrapper scripts. The report file
is super useful; I frequently consult it. (For PCDs too.)

Thanks!
Laszlo


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2017-02-16 18:59 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-14 17:55 DEBUG() macros in DXE driver: can’t make it work in QEMU Nikolay Bodunov
2017-02-14 18:16 ` Laszlo Ersek
2017-02-14 18:28   ` Kinney, Michael D
2017-02-14 22:06     ` Nikolay Bodunov
2017-02-14 22:17       ` David A. Van Arnem
2017-02-14 22:36         ` Nikolay Bodunov
2017-02-14 23:14           ` David A. Van Arnem
2017-02-14 23:46             ` Nikolay Bodunov
2017-02-15  0:00               ` David A. Van Arnem
2017-02-15 12:39                 ` Laszlo Ersek
2017-02-16 18:05                   ` Andrew Fish
2017-02-16 18:59                     ` Laszlo Ersek
2017-02-15 10:13       ` Laszlo Ersek
2017-02-15 17:19         ` Nikolay Bodunov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox