Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

CC upper limits ? BUT for sure BUGs

<< < (3/8) > >>

killerbot:
Attached archive, contains a workspace containing 3 projects :

- Dummy
- NamingService  (the header only, nearly no more code in it, and where parsing stops upon)
- Dummy2

Here's the log :


--- Code: ---Opening /home/killerbot/Projects/CC-bug/libraries/common/Dummy/Project/Dummy.cbp
Done.
Opening /home/killerbot/Projects/CC-bug/libraries/common/NamingService/Project/NamingService.cbp
Done.
Opening /home/killerbot/Projects/CC-bug/libraries/common/Dummy2/Project/Dummy2.cbp
Done.
NativeParser::CreateParser(): Finish creating a new parser for project 'Dummy'
NativeParser::OnParserEnd(): Project 'Dummy' parsing stage done!
NativeParser::AddProjectToParser(): Add project (NamingService) to parser


--- End code ---

ollydbg:
Hi, killerbot and Jens, thanks.

I just tried the sample workspace supplied by killerbot, but I still couldn't reproduce this bug. I'm using the nightly build 9605 on WinXP.

See my log when open this workspace.
C::B log:

--- Quote ---Opening E:\cc-bug\libraries\common\Dummy\Project\Dummy.cbp
Done.
Opening E:\cc-bug\libraries\common\NamingService\Project\NamingService.cbp
Done.
Opening E:\cc-bug\libraries\common\Dummy2\Project\Dummy2.cbp
Done.
NativeParser::CreateParser(): Finish creating a new parser for project 'Dummy'
NativeParser::OnParserEnd(): Project 'Dummy' parsing stage done!
NativeParser::AddProjectToParser(): Add project (NamingService) to parser
NativeParser::OnParserEnd(): Project 'NamingService' parsing stage done!
NativeParser::AddProjectToParser(): Add project (Dummy2) to parser
NativeParser::OnParserEnd(): Project 'Dummy2' parsing stage done!


--- End quote ---

C::B debug log:

--- Quote ---Loading workspace "E:\cc-bug\test.workspace"
Loading project file...
Parsing project file...
Loading target GnuDebug
Loading target GnuRelease
Loading target powerpc-linux-gnu-ltibDebug
Loading target powerpc-linux-gnu-ltibRelease
Loading target ClangDebug
Loading target ClangRelease
Loading project files...
2 files loaded
Done loading project in 0ms
Project's base path: E:\cc-bug\libraries\common\Dummy\Project\
Project's common toplevel path: E:\cc-bug\libraries\common\Dummy\
Loading project file...
Parsing project file...
Loading target GnuDebug
Loading target GnuRelease
Loading target powerpc-linux-gnu-ltibDebug
Loading target powerpc-linux-gnu-ltibRelease
Loading project files...
1 files loaded
Done loading project in 0ms
Project's base path: E:\cc-bug\libraries\common\NamingService\Project\
Project's common toplevel path: E:\cc-bug\libraries\common\NamingService\
Loading project file...
Parsing project file...
Loading target GnuDebug
Loading target GnuRelease
Loading target powerpc-linux-gnu-ltibDebug
Loading target powerpc-linux-gnu-ltibRelease
Loading target ClangDebug
Loading target ClangRelease
Loading project files...
2 files loaded
Done loading project in 16ms
Project's base path: E:\cc-bug\libraries\common\Dummy2\Project\
Project's common toplevel path: E:\cc-bug\libraries\common\Dummy2\
Workspace layout file doesn't exist "E:\cc-bug\test.workspace.layout"
EnvVars: Obtained 'default' as active envvar set from config.
EnvVars: Set 'default' will not be applied (already active).
NativeParser::DoFullParsing(): Adding three kind of files to batch-parser
NativeParser::DoFullParsing(): Add priority header file: 'D:\mingw-builds\473\mingw32\lib\gcc\i686-w64-mingw32\4.7.3\include\c++\cstddef'
NativeParser::DoFullParsing(): Add priority header file: 'D:\mingw-builds\473\mingw32\i686-w64-mingw32\include\w32api.h'
NativeParser::DoFullParsing(): Add 2 priority file(s) for project 'Dummy'...
NativeParser::DoFullParsing(): Added 2 header&source file(s) for project 'Dummy' to batch-parser...
NativeParser::CreateParser(): Finish creating a new parser for project 'Dummy'
ClassBrowser::OnThreadEvent(): Updating class browser...
ClassBrowser::OnThreadEvent(): Class browser updated.
NativeParser::OnParserStart(): Starting batch parsing for project 'Dummy'...
NativeParser::OnParserEnd(): Project 'Dummy' parsing stage done!
Project 'Dummy' parsing stage done (75 total parsed files, 3462 tokens in 0 minute(s), 0.578 seconds).
ClassBrowser::OnThreadEvent(): Updating class browser...
ClassBrowser::OnThreadEvent(): Class browser updated.
NativeParser::AddProjectToParser(): Add project (NamingService) to parser
NativeParser::AddProjectToParser(): Done adding 0 files of project (NamingService) to parser.
NativeParser::OnParsingOneByOneTimer(): Add additional (next) project to parser.
NativeParser::OnParserStart(): Starting batch parsing for project 'NamingService'...
NativeParser::OnParserEnd(): Project 'NamingService' parsing stage done!
Project 'NamingService' parsing stage done (75 total parsed files, 3462 tokens in 0 minute(s), 0.000 seconds).
ClassBrowser::OnThreadEvent(): Updating class browser...
ClassBrowser::OnThreadEvent(): Class browser updated.
NativeParser::AddProjectToParser(): Add project (Dummy2) to parser
NativeParser::AddProjectToParser(): Done adding 2 files of project (Dummy2) to parser.
NativeParser::OnParsingOneByOneTimer(): Add additional (next) project to parser.
NativeParser::OnParserStart(): Starting batch parsing for project 'Dummy2'...
NativeParser::OnParserEnd(): Project 'Dummy2' parsing stage done!
Project 'Dummy2' parsing stage done (77 total parsed files, 3465 tokens in 0 minute(s), 0.062 seconds).
ClassBrowser::OnThreadEvent(): Updating class browser...
ClassBrowser::OnThreadEvent(): Class browser updated.


--- End quote ---

So, I guess this is the bug happens under Linux?

killerbot:
yes I am on linux.

killerbot:
tried in on my win virtual box (winxp) :



--- Code: ---Opening C:\Projects\cc-bug\libraries\common\Dummy\Project\Dummy.cbp
Done.
Opening C:\Projects\cc-bug\libraries\common\NamingService\Project\NamingService.cbp
Done.
Opening C:\Projects\cc-bug\libraries\common\Dummy2\Project\Dummy2.cbp
Done.
NativeParser::CreateParser(): Finish creating a new parser for project 'Dummy'
NativeParser::OnParserEnd(): Project 'Dummy' parsing stage done!
NativeParser::AddProjectToParser(): Add project (NamingService) to parser
NativeParser::OnParserEnd(): Project 'NamingService' parsing stage done!
NativeParser::AddProjectToParser(): Add project (Dummy2) to parser
NativeParser::OnParserEnd(): Project 'Dummy2' parsing stage done!

--- End code ---

So seems it is a linux only issue.

ollydbg:

--- Quote from: killerbot on January 27, 2014, 08:56:03 am ---tried in on my win virtual box (winxp) :



--- Code: ---Opening C:\Projects\cc-bug\libraries\common\Dummy\Project\Dummy.cbp
Done.
Opening C:\Projects\cc-bug\libraries\common\NamingService\Project\NamingService.cbp
Done.
Opening C:\Projects\cc-bug\libraries\common\Dummy2\Project\Dummy2.cbp
Done.
NativeParser::CreateParser(): Finish creating a new parser for project 'Dummy'
NativeParser::OnParserEnd(): Project 'Dummy' parsing stage done!
NativeParser::AddProjectToParser(): Add project (NamingService) to parser
NativeParser::OnParserEnd(): Project 'NamingService' parsing stage done!
NativeParser::AddProjectToParser(): Add project (Dummy2) to parser
NativeParser::OnParserEnd(): Project 'Dummy2' parsing stage done!

--- End code ---

So seems it is a linux only issue.

--- End quote ---
This is quite strange. Can you try the CC patch below to see whether it works OK under Linux? Thanks.


--- Code: ---c423a5611f77ecc95925e3fb7d75042cbcbfb83b
 src/plugins/codecompletion/nativeparser.cpp | 23 +++++++++++++++++------
 src/plugins/codecompletion/nativeparser.h   |  4 ++--
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/plugins/codecompletion/nativeparser.cpp b/src/plugins/codecompletion/nativeparser.cpp
index c3d659e..cded451 100644
--- a/src/plugins/codecompletion/nativeparser.cpp
+++ b/src/plugins/codecompletion/nativeparser.cpp
@@ -2643,12 +2643,18 @@ void NativeParser::OnParsingOneByOneTimer(cb_unused wxTimerEvent& event)
             else
             {
                 ProjectsArray* projs = Manager::Get()->GetProjectManager()->GetProjects();
+                // loop on the whole workspace, and only add a new project to the parser
+                // here the "new" means a project haven't been parsed. Once it was parsed, it is
+                // added to the m_ParsedProjects
                 for (size_t i = 0; i < projs->GetCount(); ++i)
                 {
                     // Only add, if the project is not already parsed
                     if (m_ParsedProjects.find(projs->Item(i)) == m_ParsedProjects.end())
                     {
-                        AddProjectToParser(projs->Item(i));
+                        // if total files of current project were already parsed, we should try the next project
+                        int actualAddFileNumber = AddProjectToParser(projs->Item(i));
+                        if (!actualAddFileNumber)
+                            continue;
                         CCLogger::Get()->DebugLog(_T("NativeParser::OnParsingOneByOneTimer(): Add additional (next) project to parser."));
                         break;
                     }
@@ -2763,24 +2769,24 @@ void NativeParser::InitCCSearchVariables()
     Reset();
 }
 
-void NativeParser::AddProjectToParser(cbProject* project)
+int NativeParser::AddProjectToParser(cbProject* project)
 {
     wxString prj = (project ? project->GetTitle() : _T("*NONE*"));
     ParserBase* parser = GetParserByProject(project);
     if (parser)
-        return;
+        return 0;
 
     if (m_ParsedProjects.empty())
-        return;
+        return 0;
 
     m_ParsedProjects.insert(project);
     parser = GetParserByProject(project);
     if (!parser)
-        return;
+        return 0;
     else if (!parser->UpdateParsingProject(project))
     {
         m_ParsedProjects.erase(project);
-        return;
+        return 0;
     }
 
     // TODO (ollydbg#1#) did exactly the same thing as the function NativeParser::DoFullParsing()?
@@ -2820,6 +2826,9 @@ void NativeParser::AddProjectToParser(cbProject* project)
         }
 
         CCLogger::Get()->DebugLog(F(_("NativeParser::AddProjectToParser(): Done adding %lu files of project (%s) to parser."), static_cast<unsigned long>(fileCount), prj.wx_str()));
+
+        // in some cases, all the files were already be parsed, so fileCount is still 0
+        return fileCount;
     }
     else
     {
@@ -2831,8 +2840,10 @@ void NativeParser::AddProjectToParser(cbProject* project)
             m_StandaloneFiles.Add(editor->GetFilename());
 
             CCLogger::Get()->DebugLog(F(_("NativeParser::AddProjectToParser(): Done adding stand-alone file (%s) of editor to parser."), editor->GetFilename().wx_str()));
+            return 1;
         }
     }
+    return 0;
 }
 
 bool NativeParser::RemoveProjectFromParser(cbProject* project)
diff --git a/src/plugins/codecompletion/nativeparser.h b/src/plugins/codecompletion/nativeparser.h
index 333166e..48b65a4 100644
--- a/src/plugins/codecompletion/nativeparser.h
+++ b/src/plugins/codecompletion/nativeparser.h
@@ -416,8 +416,8 @@ private:
     /** Init cc search member variables */
     void InitCCSearchVariables();
 
-    /** Add all project files to parser */
-    void AddProjectToParser(cbProject* project);
+    /** Add all project's files to parser */
+    int AddProjectToParser(cbProject* project);
 
     /** Remove cbp from the common parser, this only happens in one parser for whole workspace mode
      * when a parser is removed from the workspace, we should remove the project from the parser


--- End code ---

The description of the patch is:

--- Quote ---* CC: Fix a bug in the one parser for the whole workspace mode, if a project's file was already parsed by previous projects, then this project don't actually run a parsing tasks (for parsing source files), thus there is not ParserEnd event happened.

The general logic are below:

thread pool done-> send event to Parser object
Parser::OnAllThreadsDone(CodeBlocksEvent& event) -> send a Parser End event
NativeParser::OnParserEnd -> m_TimerParsingOneByOne.Start(500, wxTIMER_ONE_SHOT);
NativeParser::OnParsingOneByOneTimer -> AddProjectToParser(projs->Item(i)); (adding the next project)

But if AddProjectToParser() add nothing to the Task pool, there will be no "thread pool done" again, so all the remaining projects has no chance to be done.

So, I simply let the AddProjectToParser() function return actually added file numbers, if it is zero, we try to parse the next project.


--- End quote ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version