Skip to content

Commit

Permalink
Merge branch 'tf/LH-32v8/introduce-funcguard-category-setup'
Browse files Browse the repository at this point in the history
* tf/LH-32v8/introduce-funcguard-category-setup:
  funcguard: add Scintilla DllMain guard
  funcguard: add PowerEditor WinMain.cpp guards
  scintilla: add funcguard category setup
  common: make npp_debug common and add to Scintilla
  powereditor: introduce funcguard category setup

[#32]

Signed-off-by: Thell Fowler <git@tbfowler.name>
  • Loading branch information
Thell Fowler committed Oct 31, 2010
2 parents 07430ce + 36f8d10 commit e4d4c62
Show file tree
Hide file tree
Showing 20 changed files with 648 additions and 27 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Thumbs.db
[Bb]in
[Dd]ebug*/
!PowerEditor/src/MISC/Debug/
!scintilla/src/MISC/Debug/
!common/MISC/Debug/
*.lib
*.sbr
obj/
Expand Down
4 changes: 4 additions & 0 deletions PowerEditor/src/MISC/Debug/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FuncGuards.h
# Ignore developer's private funcguards templates
Templates/
*.tmp
62 changes: 62 additions & 0 deletions PowerEditor/src/MISC/Debug/FuncGuards.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// This file is part of Notepad++ Community Release's FuncGuard project.
// Copyright (C)2009 The Notepad++ Community
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

#include "precompiled_headers.h"
#include "MISC/Debug/FuncGuards.h"

///////////////////////////////////////////////////////////////////////////////
//
// This source enables/disables all functions guards based on whether or not
// the NPPCR_GUARD_... macro is defined in FuncGuards.h
//
// When new functions guards are created they should be added to this file
// in alphabetical order.
//
//
// IT IS RECOMMENDED TO USE THE POWERSHELL FUNCGUARD MODULE TO KEEP THE RELATED
// FILES IN SYNCH AND PROPERLY ORDERED!
//
//
// Any desired documentation for the function guard belongs in FuncGuards.h
//
///////////////////////////////////////////////////////////////////////////////

/*
Usage:
The entries in this file need to remain between the block start and block
end statements.
All entries need to follow the format and have a blank line above and below
the entry:
#ifdef FUNCGUARD_PREFIX_GUARDNAME
func_guard_enable_cat(guardName);
#else
func_guard_disable_cat(guardName);
#endif
*/

// FUNCGUARD_BLOCK_START << Do not alter or remove

#ifdef FUNCGUARD_NPPCR_WINMAIN
func_guard_enable_cat(guardWinMain);
#else
func_guard_disable_cat(guardWinMain);
#endif

// FUNCGUARD_BLOCK_END << Do not alter or remove
58 changes: 58 additions & 0 deletions PowerEditor/src/MISC/Debug/FuncGuardsImport.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// This file is part of Notepad++ Community Release's FuncGuard project.
// Copyright (C)2009 The Notepad++ Community
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

///////////////////////////////////////////////////////////////////////////////
//
// All function guards should be listed here to make them available in any
// source. The simplest method is by using the precompiled headers.
//
// When new functions guards are created they should be added to this file
// in alphabetical order.
//
//
// IT IS RECOMMENDED TO USE THE POWERSHELL FUNCGUARD MODULE TO KEEP THE RELATED
// FILES IN SYNCH AND PROPERLY ORDERED!
//
//
// Any desired documentation for the function guard belongs in FuncGuards.h
//
///////////////////////////////////////////////////////////////////////////////

/*
Usage:
- Entries in this file need to remain between the '#ifndef' and '#endif'
statements for FUNCGUARDIMPORT and should have no spacing between the
entries.
Example:
#ifndef MISC_DEBUG_FUNCGUARDIMPORT_H
#define MISC_DEBUG_FUNCGUARDIMPORT_H
func_guard_import_cat(guardClass1);
func_guard_import_cat(guardClass1Class2_Communications);
func_guard_import_cat(guardClass2);
#endif // MISC_DEBUG_FUNCGUARDS_H
*/

#ifndef MISC_DEBUG_FUNCGUARDIMPORT_H
#define MISC_DEBUG_FUNCGUARDIMPORT_H

func_guard_import_cat(guardWinMain);

#endif // MISC_DEBUG_FUNCGUARDS_H

91 changes: 91 additions & 0 deletions PowerEditor/src/MISC/Debug/FuncGuards_skel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// This file is part of Notepad++ Community Release's FuncGuard project.
// Copyright (C)2009 The Notepad++ Community
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

///////////////////////////////////////////////////////////////////////////////
//
// Uncomment/Comment out the desired guard definitions to enable/disable. Use
// the provided func_guard() statement in the functions you want to trace.
//
// When new functions guards are created they should be added to this file
// in alphabetical order.
//
//
// IT IS RECOMMENDED TO USE THE POWERSHELL FUNCGUARD MODULE TO KEEP THE RELATED
// FILES IN SYNCH AND PROPERLY ORDERED!
//
//
///////////////////////////////////////////////////////////////////////////////

/*
Usage:
This skeleton file should be copied to FuncGuards.h by a pre-build event when
FuncGuards.h doesn't exist. It serves as your projects 'tracked' version of
available function guards.
ALL FUNCTION GUARDS SHOULD BE DISABLED (commented out) IN THIS FILE
Notes:
- Every define and usage needs to start with '//'
- Cat is CamelCase with '_' spacing between either the filename or major
class category followed by a subclass or particular function area if
needed.
- This is the validation regex used by the Powershell FuncGuard module:
$Name -cmatch "^(\p{Lu}\p{Ll}+)+($|_((\p{Lu}\p{Ll}+)|\d)+|\d+)+$"
- Entries in this file need to remain between the '#ifndef SHIPPING' and
'#endif // SHIPPING' statements and should have a single line before and
after the entry.
- The format of the entries need to follow one of the following two
examples:
*/

// func_guard(guardClass1);
// Description: Used in tracing functions in the Class1 class.
// #define FUNCGUARD_PSUNIT_CLASS1

// func_guard(guardClass1Class2_Communications);
// Description: For tracing TestGuard1 and TestGuard2 communication.
/*
This enables tracing of _only_ the communication functions of the
TestGuard1 and TestGuard2 classes.
Modify the local function area to filter messages, to output use:
func_guard_debugf_cat(guardTestGuard_MultiClass);
Enable by adding to the current func_guard(#cat) statement.
example: func_guard(guardClass1 | guardClass1Class2_Communications);
If both TestGuard1 and TestGuard2 are active then enabling this is not
needed, but doesn't hurt anything.
*/
// #define FUNCGUARD_PSUNIT_CLASS1CLASS2_COMMUNICATIONS

#ifndef MISC_DEBUG_FUNCGUARD_H
#define MISC_DEBUG_FUNCGUARD_H

#ifndef SHIPPING

// func_guard(guardWinMain);
// Description: Function tracing in WinMain.cpp
//#define FUNCGUARD_NPPCR_WINMAIN

#endif // SHIPPING
#endif // MISC_DEBUG_FUNCGUARD_H
3 changes: 3 additions & 0 deletions PowerEditor/src/precompiled_headers.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@
// Power Editor
#include "MISC/Common/CommonGenerics.h"
#include "MISC/Debug/npp_debug.h"
#ifndef SHIPPING
#include "MISC/Debug/FuncGuardsImport.h"
#endif
#include "MISC/Common/Common.h"

#endif // PRECOMPILED_HEADERS_H
9 changes: 9 additions & 0 deletions PowerEditor/src/winmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
typedef std::vector<const TCHAR*> ParamVector;

bool checkSingleFile(const TCHAR * commandLine) {
func_guard(guardWinMain);
TCHAR fullpath[MAX_PATH];
::GetFullPathName(commandLine, MAX_PATH, fullpath, NULL);
if (::PathFileExists(fullpath)) {
Expand All @@ -43,6 +44,7 @@ bool checkSingleFile(const TCHAR * commandLine) {

//commandLine should contain path to n++ executable running
void parseCommandLine(TCHAR * commandLine, ParamVector & paramVector) {
func_guard(guardWinMain);
//params.erase(params.begin());
//remove the first element, since thats the path the the executable (GetCommandLine does that)
TCHAR stopChar = TEXT(' ');
Expand Down Expand Up @@ -106,6 +108,7 @@ void parseCommandLine(TCHAR * commandLine, ParamVector & paramVector) {

bool isInList(const TCHAR *token2Find, ParamVector & params) {
int nrItems = params.size();
func_guard(guardWinMain);

for (int i = 0; i < nrItems; i++)
{
Expand All @@ -120,6 +123,7 @@ bool isInList(const TCHAR *token2Find, ParamVector & params) {
bool getParamVal(TCHAR c, ParamVector & params, generic_string & value) {
value = TEXT("");
int nrItems = params.size();
func_guard(guardWinMain);

for (int i = 0; i < nrItems; i++)
{
Expand All @@ -134,13 +138,15 @@ bool getParamVal(TCHAR c, ParamVector & params, generic_string & value) {
}

LangType getLangTypeFromParam(ParamVector & params) {
func_guard(guardWinMain);
generic_string langStr;
if (!getParamVal('l', params, langStr))
return L_EXTERNAL;
return NppParameters::getLangIDFromStr(langStr.c_str());
};

int getNumberFromParam(char paramName, ParamVector & params, bool & isParamePresent) {
func_guard(guardWinMain);
generic_string numStr;
if (!getParamVal(paramName, params, numStr))
{
Expand Down Expand Up @@ -219,6 +225,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR /*cmdLineAnsi*/, int /*
}
#endif

func_guard(guardWinMain); // added after GTest check to not interfere with tests.

MiniDumper mdump; //for debugging purposes.

bool TheFirstOne = true;
Expand Down Expand Up @@ -448,6 +456,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR /*cmdLineAnsi*/, int /*
}

void doException(Notepad_plus_Window & notepad_plus_plus) {
func_guard(guardWinMain);
Win32Exception::removeHandler(); //disable exception handler after excpetion, we dont want corrupt data structurs to crash the exception handler
::MessageBox(Notepad_plus_Window::gNppHWND, TEXT("Notepad++ will attempt to save any unsaved data. However, dataloss is very likely."), TEXT("Recovery initiating"), MB_OK | MB_ICONINFORMATION);

Expand Down
40 changes: 32 additions & 8 deletions PowerEditor/visual.net/notepadPlus.8.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<Tool
Name="VCPreBuildEventTool"
Description="Runtime build and version generation."
CommandLine="CALL &quot;$(SolutionDir)\scripts\GIT-VS-VERSION-GEN.bat&quot; &quot;$(IntDir)\&quot; &quot;$(SolutionDir)PowerEditor\src\gen-versioninfo.h&quot;"
CommandLine="CALL &quot;$(SolutionDir)\scripts\GIT-VS-VERSION-GEN.bat&quot; &quot;$(IntDir)\&quot; &quot;$(SolutionDir)PowerEditor\src\gen-versioninfo.h&quot;&#x0D;&#x0A;IF NOT EXIST &quot;$(ProjectDir)..\src\MISC\Debug\FuncGuards.h&quot; copy &quot;$(ProjectDir)..\src\MISC\Debug\FuncGuards_skel.h&quot; &quot;$(ProjectDir)..\src\MISC\Debug\FuncGuards.h&quot;&#x0D;&#x0A;"
/>
<Tool
Name="VCCustomBuildTool"
Expand All @@ -44,7 +44,7 @@
Name="VCCLCompilerTool"
Optimization="0"
FavorSizeOrSpeed="0"
AdditionalIncludeDirectories="..\..\scintilla\include;..\src"
AdditionalIncludeDirectories="..\..\common;..\..\scintilla\include;..\src"
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;TIXML_USE_STL;TIXMLA_USE_STL"
MinimalRebuild="true"
ExceptionHandling="2"
Expand Down Expand Up @@ -123,7 +123,7 @@
<Tool
Name="VCPreBuildEventTool"
Description="Runtime build and version generation."
CommandLine="CALL $(SolutionDir)\scripts\GIT-VS-VERSION-GEN.bat &quot;$(IntDir)\&quot; &quot;$(SolutionDir)PowerEditor\src\gen-versioninfo.h&quot;"
CommandLine="CALL $(SolutionDir)\scripts\GIT-VS-VERSION-GEN.bat &quot;$(IntDir)\&quot; &quot;$(SolutionDir)PowerEditor\src\gen-versioninfo.h&quot;&#x0D;&#x0A;IF NOT EXIST &quot;$(ProjectDir)..\src\MISC\Debug\FuncGuards.h&quot; copy &quot;$(ProjectDir)..\src\MISC\Debug\FuncGuards_skel.h&quot; &quot;$(ProjectDir)..\src\MISC\Debug\FuncGuards.h&quot;&#x0D;&#x0A;"
/>
<Tool
Name="VCCustomBuildTool"
Expand All @@ -144,7 +144,7 @@
FavorSizeOrSpeed="1"
OmitFramePointers="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="..\..\scintilla\include;..\src"
AdditionalIncludeDirectories="..\..\common;..\..\scintilla\include;..\src"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;TIXML_USE_STL;TIXMLA_USE_STL;_CRT_SECURE_NO_DEPRECATE"
StringPooling="true"
ExceptionHandling="2"
Expand Down Expand Up @@ -244,7 +244,7 @@
FavorSizeOrSpeed="1"
OmitFramePointers="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="..\..\scintilla\include;..\src"
AdditionalIncludeDirectories="..\..\common;..\..\scintilla\include;..\src"
PreprocessorDefinitions="WIN32;NDEBUG;SHIPPING;_WINDOWS;TIXML_USE_STL;TIXMLA_USE_STL;_CRT_SECURE_NO_DEPRECATE"
StringPooling="true"
ExceptionHandling="2"
Expand Down Expand Up @@ -539,7 +539,19 @@
Name="Debug"
>
<File
RelativePath="..\src\MISC\Debug\npp_debug.cpp"
RelativePath="..\src\MISC\Debug\FuncGuards.cpp"
>
<FileConfiguration
Name="Shipping|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\common\MISC\Debug\npp_debug.cpp"
>
</File>
</Filter>
Expand Down Expand Up @@ -920,7 +932,7 @@
>
</File>
<File
RelativePath="..\src\MISC\Common\CommonGenerics.h"
RelativePath="..\..\common\MISC\Common\CommonGenerics.h"
>
</File>
<File
Expand All @@ -944,7 +956,19 @@
Name="Debug"
>
<File
RelativePath="..\src\MISC\Debug\npp_debug.h"
RelativePath="..\src\MISC\Debug\FuncGuards.h"
>
</File>
<File
RelativePath="..\src\MISC\Debug\FuncGuards_skel.h"
>
</File>
<File
RelativePath="..\src\MISC\Debug\FuncGuardsImport.h"
>
</File>
<File
RelativePath="..\..\common\MISC\Debug\npp_debug.h"
>
</File>
</Filter>
Expand Down

0 comments on commit e4d4c62

Please sign in to comment.