Re: [edk2] Removal of DEBUG_CODE in RELEASE Builds

2014-08-12 Thread Gao, Liming
Hi,
  This design depends on compiler optimization. If the compiler is smart, it 
knows DebugCodeEnabled() always return False and remove the unreachable code.

Thanks
Liming
From: Alexei Fedorov [mailto:alexei.fedo...@arm.com]
Sent: Tuesday, August 12, 2014 10:59 PM
To: edk2-devel@lists.sourceforge.net
Subject: [edk2] Removal of DEBUG_CODE in RELEASE Builds

Hi All,

The description of DEBUG_CODE_BEGIN() and DEBUG_CODE_END() macros in 
edk2\MdePkg\Include\Library\DebugLib.h reads:

/**
  Macro that marks the beginning of debug source code.
  If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set,
  then this macro marks the beginning of source code that is included in a 
module.
  Otherwise, the source lines between DEBUG_CODE_BEGIN() and DEBUG_CODE_END()
  are not included in a module.
**/
#define DEBUG_CODE_BEGIN()  do { if (DebugCodeEnabled ()) { UINT8  
__DebugCodeLocal

Actually this is not correct because code between DEBUG_CODE_BEGIN() / 
DEBUG_CODE_END() is still being compiled & present in the output binary code 
for RELEASE builds with DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit not set in 
PcdDebugProperyMask.
This is because in BaseDebugLibNull library DebugCodeEnabled () is still a 
run-time function call, see
edk2_new\edk2\MdePkg\Library\BaseDebugLibNull\DebugLib.c:

BOOLEAN
EFIAPI
DebugCodeEnabled (
  VOID
  )
{
  return FALSE;
}

As a workaround DebugCodeEnabled() function can be replaced with a similar 
macro definition as in
edk2\EdkCompatibilityPkg\Foundation\Library\EdkIIGlueLib\Include\Library\EdkIIGlueDebugLib.h:
//
// Use the following 4 macros to save size
//
#define DebugCodeEnabled()
((BOOLEAN)((__EDKII_GLUE_PCD_PcdDebugPropertyMask__ & 
DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0))

like:

#define DebugCodeEnabled()   ((_PCD_VALUE_PcdDebugPropertyMask__ & 
DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0)

& removal of DebugCodeEnabled () declaration from 
\BaseDebugLibSerialPort\DebugLib.c & BaseDebugLibNull\DebugLib.c.

gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask should added in [FixedPcd] 
section of modules' .INF files which use DEBUG_CODE_BEGIN() / DEBUG_CODE_END() 
in their sources.

Can anyone comment on that?

Thanks.
Alexei.




-- IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.

ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered 
in England & Wales, Company No: 2557590
ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, 
Registered in England & Wales, Company No: 2548782
--
___
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel


Re: [edk2] Removal of DEBUG_CODE in RELEASE Builds

2014-08-12 Thread Olivier Martin
That's correct. That was I was starting to write.
Toolchain with LTO (Linker Time Optimization) should remove this code. It is 
the same issue as FeaturePcd reported a couple of month ago.

From: Tim Lewis [mailto:tim.le...@insyde.com]
Sent: 12 August 2014 16:21
To: edk2-devel@lists.sourceforge.net
Subject: Re: [edk2] Removal of DEBUG_CODE in RELEASE Builds

Alexei -

I'm not sure about GCC, but in Visual Studio 2013 with LTCG turned on, the 
binary code will not appear in the output file because link-time code 
generation detects the cross-module optimization and removes the code correctly.

Tim

From: Alexei Fedorov [mailto:alexei.fedo...@arm.com]
Sent: Tuesday, August 12, 2014 7:59 AM
To: edk2-devel@lists.sourceforge.net<mailto:edk2-devel@lists.sourceforge.net>
Subject: [edk2] Removal of DEBUG_CODE in RELEASE Builds

Hi All,

The description of DEBUG_CODE_BEGIN() and DEBUG_CODE_END() macros in 
edk2\MdePkg\Include\Library\DebugLib.h reads:

/**
  Macro that marks the beginning of debug source code.
  If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set,
  then this macro marks the beginning of source code that is included in a 
module.
  Otherwise, the source lines between DEBUG_CODE_BEGIN() and DEBUG_CODE_END()
  are not included in a module.
**/
#define DEBUG_CODE_BEGIN()  do { if (DebugCodeEnabled ()) { UINT8  
__DebugCodeLocal

Actually this is not correct because code between DEBUG_CODE_BEGIN() / 
DEBUG_CODE_END() is still being compiled & present in the output binary code 
for RELEASE builds with DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit not set in 
PcdDebugProperyMask.
This is because in BaseDebugLibNull library DebugCodeEnabled () is still a 
run-time function call, see
edk2_new\edk2\MdePkg\Library\BaseDebugLibNull\DebugLib.c:

BOOLEAN
EFIAPI
DebugCodeEnabled (
  VOID
  )
{
  return FALSE;
}

As a workaround DebugCodeEnabled() function can be replaced with a similar 
macro definition as in
edk2\EdkCompatibilityPkg\Foundation\Library\EdkIIGlueLib\Include\Library\EdkIIGlueDebugLib.h:
//
// Use the following 4 macros to save size
//
#define DebugCodeEnabled()
((BOOLEAN)((__EDKII_GLUE_PCD_PcdDebugPropertyMask__ & 
DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0))

like:

#define DebugCodeEnabled()   ((_PCD_VALUE_PcdDebugPropertyMask__ & 
DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0)

& removal of DebugCodeEnabled () declaration from 
\BaseDebugLibSerialPort\DebugLib.c & BaseDebugLibNull\DebugLib.c.

gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask should added in [FixedPcd] 
section of modules' .INF files which use DEBUG_CODE_BEGIN() / DEBUG_CODE_END() 
in their sources.

Can anyone comment on that?

Thanks.
Alexei.




-- IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.

ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered 
in England & Wales, Company No: 2557590
ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, 
Registered in England & Wales, Company No: 2548782

-- IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.

ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered 
in England & Wales, Company No: 2557590
ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, 
Registered in England & Wales, Company No: 2548782--
___
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel


Re: [edk2] Removal of DEBUG_CODE in RELEASE Builds

2014-08-12 Thread Tim Lewis
Alexei -

I'm not sure about GCC, but in Visual Studio 2013 with LTCG turned on, the 
binary code will not appear in the output file because link-time code 
generation detects the cross-module optimization and removes the code correctly.

Tim

From: Alexei Fedorov [mailto:alexei.fedo...@arm.com]
Sent: Tuesday, August 12, 2014 7:59 AM
To: edk2-devel@lists.sourceforge.net
Subject: [edk2] Removal of DEBUG_CODE in RELEASE Builds

Hi All,

The description of DEBUG_CODE_BEGIN() and DEBUG_CODE_END() macros in 
edk2\MdePkg\Include\Library\DebugLib.h reads:

/**
  Macro that marks the beginning of debug source code.
  If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set,
  then this macro marks the beginning of source code that is included in a 
module.
  Otherwise, the source lines between DEBUG_CODE_BEGIN() and DEBUG_CODE_END()
  are not included in a module.
**/
#define DEBUG_CODE_BEGIN()  do { if (DebugCodeEnabled ()) { UINT8  
__DebugCodeLocal

Actually this is not correct because code between DEBUG_CODE_BEGIN() / 
DEBUG_CODE_END() is still being compiled & present in the output binary code 
for RELEASE builds with DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit not set in 
PcdDebugProperyMask.
This is because in BaseDebugLibNull library DebugCodeEnabled () is still a 
run-time function call, see
edk2_new\edk2\MdePkg\Library\BaseDebugLibNull\DebugLib.c:

BOOLEAN
EFIAPI
DebugCodeEnabled (
  VOID
  )
{
  return FALSE;
}

As a workaround DebugCodeEnabled() function can be replaced with a similar 
macro definition as in
edk2\EdkCompatibilityPkg\Foundation\Library\EdkIIGlueLib\Include\Library\EdkIIGlueDebugLib.h:
//
// Use the following 4 macros to save size
//
#define DebugCodeEnabled()
((BOOLEAN)((__EDKII_GLUE_PCD_PcdDebugPropertyMask__ & 
DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0))

like:

#define DebugCodeEnabled()   ((_PCD_VALUE_PcdDebugPropertyMask__ & 
DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0)

& removal of DebugCodeEnabled () declaration from 
\BaseDebugLibSerialPort\DebugLib.c & BaseDebugLibNull\DebugLib.c.

gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask should added in [FixedPcd] 
section of modules' .INF files which use DEBUG_CODE_BEGIN() / DEBUG_CODE_END() 
in their sources.

Can anyone comment on that?

Thanks.
Alexei.




-- IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.

ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered 
in England & Wales, Company No: 2557590
ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, 
Registered in England & Wales, Company No: 2548782
--
___
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel


[edk2] Removal of DEBUG_CODE in RELEASE Builds

2014-08-12 Thread Alexei Fedorov
Hi All,

The description of DEBUG_CODE_BEGIN() and DEBUG_CODE_END() macros in 
edk2\MdePkg\Include\Library\DebugLib.h reads:

/**
  Macro that marks the beginning of debug source code.
  If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set,
  then this macro marks the beginning of source code that is included in a 
module.
  Otherwise, the source lines between DEBUG_CODE_BEGIN() and DEBUG_CODE_END()
  are not included in a module.
**/
#define DEBUG_CODE_BEGIN()  do { if (DebugCodeEnabled ()) { UINT8  
__DebugCodeLocal

Actually this is not correct because code between DEBUG_CODE_BEGIN() / 
DEBUG_CODE_END() is still being compiled & present in the output binary code 
for RELEASE builds with DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit not set in 
PcdDebugProperyMask.
This is because in BaseDebugLibNull library DebugCodeEnabled () is still a 
run-time function call, see
edk2_new\edk2\MdePkg\Library\BaseDebugLibNull\DebugLib.c:

BOOLEAN
EFIAPI
DebugCodeEnabled (
  VOID
  )
{
  return FALSE;
}

As a workaround DebugCodeEnabled() function can be replaced with a similar 
macro definition as in
edk2\EdkCompatibilityPkg\Foundation\Library\EdkIIGlueLib\Include\Library\EdkIIGlueDebugLib.h:
//
// Use the following 4 macros to save size
//
#define DebugCodeEnabled()
((BOOLEAN)((__EDKII_GLUE_PCD_PcdDebugPropertyMask__ & 
DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0))

like:

#define DebugCodeEnabled()   ((_PCD_VALUE_PcdDebugPropertyMask__ & 
DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0)

& removal of DebugCodeEnabled () declaration from 
\BaseDebugLibSerialPort\DebugLib.c & BaseDebugLibNull\DebugLib.c.

gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask should added in [FixedPcd] 
section of modules' .INF files which use DEBUG_CODE_BEGIN() / DEBUG_CODE_END() 
in their sources.

Can anyone comment on that?

Thanks.
Alexei.




-- IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.

ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered 
in England & Wales, Company No: 2557590
ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, 
Registered in England & Wales, Company No: 2548782--
___
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel