[if gte mso 9]>

Re: [edk2] [Patch]ShellPkg: Remove 'STATIC' from function declarations to avoid source level debugging problem

Subject: Re: [edk2] [Patch]ShellPkg: Remove 'STATIC' from function declarations to avoid source level debugging problem

From: "Scott Duplichan" <scott@notabs.org>

To: <edk2-devel@lists.sourceforge.net>

Date: 2014-09-02 07:49:01

Andrew Fish [mailto:afish@apple.com]  wrote:

On Aug 28, 2014, at 9:11 PM, Scott Duplichan <scott@notabs.org> wrote:



Hello Deric,

 

You are right about the possibility of redefining STATIC. The problem with doing so is that STATIC is used in 3 unrelated ways:

 

1) static functions

2) static variables declared inside of a function

 

Maybe we should just use static for this. 

 

That sounds good. Because of the 3 or 4 different ways static is used in C code, it is hard to imagine how STATIC defined to something other than static could be useful.


3) static variables declared outside of functions

 

If STATIC is defined as nothing, all 3 uses have problems:

 

1) The few static (STATIC) functions that remain in EDK2 become public functions and can clash with existing public functions with the same name. Example: AllocateMemoryBelow4G() in LockBoxDxe.c becomes public and clashes with the one in AcpiS3SaveDxe.lib.

2) Static variables declared inside a function become local variables, something entirely different than intended. Example, line 48 of EmbeddedPkg\Ebl\HwDebug.c.

3) Static variables declared outside of functions become public, making a clash possible.

 

 

The global variable naming convention should prevent this, if followed. Prefix m or g on the global. 



A workaround would be to make a new preprocessor macro name such as STATIC_FUNCTION:

 

#if defined (WORKAROUND)

#define STATIC_FUNCTION

#else

#define STATIC_FUNCTION static

#endif

 

STATIC_FUNCTION void helper (void)

    {

    }

 

Workable, but pretty ugly to look at.

 

 

Maybe we should figure out if any currently supported debuggers have an issue with static, and if they don’t drop the STATIC from the coding style requirements.

 

That sounds like a good approach to me. 

 

For Xcode/clang, I know that lldb does not have any issues debugging static functions for global variables.

 

That is good to hear.

 

Thanks,

Scott 

 

Thanks,

 

Andrew Fish



Thanks,

Scott

 

From: Deric Cole [mailto:Deric_Cole@phoenix.com] 
Sent: Thursday, August 28, 2014 04:08 PM
To: edk2-devel@lists.sourceforge.net; Qiu, Shumin
Subject: Re: [edk2] [Patch]ShellPkg: Remove 'STATIC' from function declarations to avoid source level debugging problem

 

Is this the whole point of defining “STATIC” rather than using the keyword “static”, that it can be redefined (locally) if it causes problems like this?

 

 

From: Carsey, Jaben [mailto:jaben.carsey@intel.com] 
Sent: Thursday, August 28, 2014 1:11 PM
To: Qiu, Shumin
Cc: edk2-devel@lists.sourceforge.net
Subject: Re: [edk2] [Patch]ShellPkg: Remove 'STATIC' from function declarations to avoid source level debugging problem

 

Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com>

 

From: Qiu, Shumin 
Sent: Wednesday, August 27, 2014 7:40 PM
To: Carsey, Jaben
Cc: edk2-devel@lists.sourceforge.net
Subject: [edk2][Patch]ShellPkg: Remove 'STATIC' from function declarations to avoid source level debugging problem
Importance: High

 

Hi Jaben,

Can you help to review this patch? Internal linkage (ie. STATIC) functions have caused problems with source level debugging before, so we generally avoid STATIC in ShellPkg.

 

Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>

 

Thanks

Shumin

 

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel