Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems in carrying out the steps described in the manual #454

Closed
Ekopalypse opened this issue May 17, 2022 · 14 comments
Closed

Problems in carrying out the steps described in the manual #454

Ekopalypse opened this issue May 17, 2022 · 14 comments

Comments

@Ekopalypse
Copy link
Contributor

  1. Created a debug version with gcc
  2. Saved the current nppPluginList.json under ...\plugins\Config
  3. Edited as described in manual (hopefully)
  4. Started Npp and PluginAdmin but I don't see the plugin listed

What did I forget to do?

image

@Ekopalypse
Copy link
Contributor Author

It looks like the issue is that a debug build of gcc does not count as a debug version :-(

image

@rdipardo
Copy link
Contributor

It looks like the issue is that a debug build of gcc does not count as a debug version :-(

Did you define _DEBUG for the GCC compiler, the way the VC++ project file does for MSVC?

<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;NPPPLUGINLIST_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>

Other relevant info:

@Ekopalypse
Copy link
Contributor Author

Thank you for your interest in my problem.
It looks like gcc wants to see an environment variable called DEBUG with some value, so I defined DEBUG=1 and it creates a debug build. The file is > 100MB and I can use gdb to see the symbols.
For the build process I followed the instructions on how to build with gcc.
I opened a git-bash, exported DEBUG=1 and ran mingw32-make.
Don't be confused by the name, it still sees that I'm on x64 and builds a 64bit executable.

But you are right that DEBUG is not passed to the build. In the makefile would be a
CPP_DEFINE += DEBUG
but this is commented and if I comment it out then the build fails.
Probably the reason why it is commented.

@rdipardo
Copy link
Contributor

Sorry to ask another silly question, but did you also try editing the pl.x64.json manifest under src and recompiling nppPluginList.dll? Ordinarily the list is embedded as a resource string:

#ifdef _M_ARM64
#define PLJSON "pl.arm64.json"
#else
#define PLJSON "pl.x64.json"
#endif

To be honest, I wasn't aware you could edit an external manifest and have it dynamically loaded by the module 😊

@Ekopalypse
Copy link
Contributor Author

Don't be sorry - I'm grateful for any help I get.
No, I didn't, I followed the instruction from the manual ... hmm ... maybe that's one way to make it work.
I'll give it a try. Thank you very much. :-)

@rdipardo
Copy link
Contributor

I should have suggested this to start with, but if you check what the pre-processor emits in debug mode, you'll see the expected code path is actually getting compiled:

g++ -DDEBUG --std=c++17 -Wpedantic -Wall -g -DSCI_OWNREGEX \
-I../../scintilla/include -I../../lexilla/include -I../src \
-I../src/ScintillaComponent -I../src/TinyXml -I../src/TinyXml/tinyXmlA \
-I../src/MISC/Common -I../src//MISC/PluginsManager -I../src/MISC/Process \
-I../src/WinControls/AboutDlg -I../src/WinControls -I../src/WinControls/AnsiCharPanel \
-I../src/WinControls/ContextMenu -I../src/WinControls/ColourPicker \
-I../src/WinControls/TabBar -I../src/WinControls//ImageListSet \
-I../src/WinControls/StaticDialog -I../src/WinControls/shortcut \
-I../src/WinControls/ToolBar -I../src/json -I../../boostregex \
-E ../src/WinControls/PluginsAdmin/pluginsAdmin.cpp > pluginsAdmin.pre.processed.cpp

pluginsAdmin cpp debug path

That leaves the question of why GDB appeared to be stepping into the release code path in your screen capture. 🤔

@Ekopalypse
Copy link
Contributor Author

Ekopalypse commented May 18, 2022

Thank you for all the testing and research you do.
I have not used the VERBOSE environment variable before and yes, that makes it even more confusing ... we should assume it has DEBUG defined ... but I don't see the pre-processing step being done for me.

image

These are the only two instances of pluginsAdmin.cpp that I see, and I don't see any line with -E at all.

I do see a couple of lines starting with g++ -DDEBUG ... but not for pluginsAdmin.

@Ekopalypse
Copy link
Contributor Author

Btw ... I'm using g++.exe (MinGW-W64 x86_64-posix-seh, built by Brecht Sanders) 11.2.0
I think, that is the one you use as well, correct?

@chcg
Copy link
Contributor

chcg commented May 18, 2022

Maybe you want to check:
https://github.com/chcg/notepad-plus-plus/blob/master/PowerEditor/gcc/makefile#L63
unclear why it is commented out.

@Ekopalypse
Copy link
Contributor Author

Thanks - I tried that already, with the result that the compilation fails. I assume that is why it is commented.

@chcg
Copy link
Contributor

chcg commented May 18, 2022

Sorry I didn't spot it above.

@rdipardo
Copy link
Contributor

rdipardo commented May 18, 2022

@Ekopalypse,

I tried that already, with the result that the compilation fails.

In fact, it fails at exactly the code path you want: the call to PluginsAdminDlg::initFromJson():

../src/WinControls/PluginsAdmin/pluginsAdmin.cpp: In member function 'bool PluginsAdminDlg::initFromJson()':
../src/WinControls/PluginsAdmin/pluginsAdmin.cpp:709:55: error: no matching function for call to 'std::basic_ifstream<char>::basic_ifstream(generic_string&)'
  709 |         ifstream nppPluginListJson(_pluginListFullPath);
    |                                                       ^
In file included from ../src/WinControls/PluginsAdmin/pluginsAdmin.cpp:20:
c:\winlibs-mingw-msvcrt\current\include\c++\11.2.0\fstream:584:9: note: candidate: 'template<class _Path, class _Require> std::basic_ifstream<_CharT, _Traits>::basic_ifstream(const _Path&, std::ios_base::openmode) [with _Path = _Path; _Require = _Require; _CharT = char; _Traits = std::char_traits<char>]'
  584 |         basic_ifstream(const _Path& __s,
    |         ^~~~~~~~~~~~~~
c:\winlibs-mingw-msvcrt\current\include\c++\11.2.0\fstream:584:9: note:   template argument deduction/substitution failed:
c:\winlibs-mingw-msvcrt\current\include\c++\11.2.0\fstream:583:32: error: 'class std::__cxx11::basic_string<wchar_t>' has no member named 'make_preferred'
  583 |       template<typename _Path, typename _Require = _If_fs_path<_Path>>
    |                                ^~~~~~~~
c:\winlibs-mingw-msvcrt\current\include\c++\11.2.0\fstream:592:7: note: candidate: 'std::basic_ifstream<_CharT, _Traits>::basic_ifstream(std::basic_ifstream<_CharT, _Traits>&&) [with _CharT = char; _Traits = std::char_traits<char>]'
  592 |       basic_ifstream(basic_ifstream&& __rhs)
    |       ^~~~~~~~~~~~~~
c:\winlibs-mingw-msvcrt\current\include\c++\11.2.0\fstream:592:39: note:   no known conversion for argument 1 from 'generic_string' {aka 'std::__cxx11::basic_string<wchar_t>'} to 'std::basic_ifstream<char>&&'
  592 |       basic_ifstream(basic_ifstream&& __rhs)
    |                      ~~~~~~~~~~~~~~~~~^~~~~
c:\winlibs-mingw-msvcrt\current\include\c++\11.2.0\fstream:567:7: note: candidate: 'std::basic_ifstream<_CharT, _Traits>::basic_ifstream(const string&, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::string = std::__cxx11::basic_string<char>; std::ios_base::openmode = std::ios_base::openmode]'
  567 |       basic_ifstream(const std::string& __s,
    |       ^~~~~~~~~~~~~~
c:\winlibs-mingw-msvcrt\current\include\c++\11.2.0\fstream:567:41: note:   no known conversion for argument 1 from 'generic_string' {aka 'std::__cxx11::basic_string<wchar_t>'} to 'const string&' {aka 'const std::__cxx11::basic_string<char>&'}
  567 |       basic_ifstream(const std::string& __s,
    |                      ~~~~~~~~~~~~~~~~~~~^~~
c:\winlibs-mingw-msvcrt\current\include\c++\11.2.0\fstream:549:7: note: candidate: 'std::basic_ifstream<_CharT, _Traits>::basic_ifstream(const wchar_t*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::ios_base::openmode = std::ios_base::openmode]'
  549 |       basic_ifstream(const wchar_t* __s,
    |       ^~~~~~~~~~~~~~
c:\winlibs-mingw-msvcrt\current\include\c++\11.2.0\fstream:549:37: note:   no known conversion for argument 1 from 'generic_string' {aka 'std::__cxx11::basic_string<wchar_t>'} to 'const wchar_t*'
  549 |       basic_ifstream(const wchar_t* __s,
    |                      ~~~~~~~~~~~~~~~^~~
c:\winlibs-mingw-msvcrt\current\include\c++\11.2.0\fstream:534:7: note: candidate: 'std::basic_ifstream<_CharT, _Traits>::basic_ifstream(const char*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::ios_base::openmode = std::ios_base::openmode]'
  534 |       basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in)
    |       ^~~~~~~~~~~~~~
c:\winlibs-mingw-msvcrt\current\include\c++\11.2.0\fstream:534:34: note:   no known conversion for argument 1 from 'generic_string' {aka 'std::__cxx11::basic_string<wchar_t>'} to 'const char*'
  534 |       basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in)
    |                      ~~~~~~~~~~~~^~~
c:\winlibs-mingw-msvcrt\current\include\c++\11.2.0\fstream:523:7: note: candidate: 'std::basic_ifstream<_CharT, _Traits>::basic_ifstream() [with _CharT = char; _Traits = std::char_traits<char>]'
  523 |       basic_ifstream() : __istream_type(), _M_filebuf()
    |       ^~~~~~~~~~~~~~
c:\winlibs-mingw-msvcrt\current\include\c++\11.2.0\fstream:523:7: note:   candidate expects 0 arguments, 1 provided
mingw32-make[1]: *** [makefile:239: bin.x86_64-debug.build/WinControls/PluginsAdmin/pluginsAdmin.o] Error 1
mingw32-make[1]: *** Waiting for unfinished jobs....

Looks like an issue with MinGW's support of the C++17 standard.
As it currently makes debug builds impossible, there will definitely be a patch against N++ when this gets figured out.

@rdipardo
Copy link
Contributor

@Ekopalypse, does it work better like this?

diff --git a/PowerEditor/gcc/makefile b/PowerEditor/gcc/makefile
index 4f0ce59f..c97ced4d 100644
--- a/PowerEditor/gcc/makefile
+++ b/PowerEditor/gcc/makefile
@@ -60,7 +60,7 @@ else
 BUILD_TYPE := debug
 BUILD_SUFFIX := -debug
 CXXFLAGS += -Og -g -Wall -Wpedantic -Wconversion-null
-#CPP_DEFINE += DEBUG
+CPP_DEFINE += DEBUG
 endif
 
 #
diff --git a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp
index 8a091ad1..34f52373 100644
--- a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp
+++ b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp
@@ -706,7 +706,11 @@ bool PluginsAdminDlg::initFromJson()
 #ifdef DEBUG // if not debug, then it's release
 	
 	// load from nppPluginList.json instead of nppPluginList.dll
+#ifdef __MINGW32__
+	ifstream nppPluginListJson(_pluginListFullPath.c_str());
+#else
 	ifstream nppPluginListJson(_pluginListFullPath);
+#endif	
 	nppPluginListJson >> j;
 
 #else //RELEASE

0001-Fix-GCC-Debug-build.diff.txt

@Ekopalypse
Copy link
Contributor Author

Brilliant, YES, this works!!
Thank you very much.

image

Don't be confused by the "build time", it still shows yesterday's date because I replaced the existing exe with the newly created exe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants