Author Topic: codecompletion parser stops parsing  (Read 11765 times)

Offline Martin K.

  • Multiple posting newcomer
  • *
  • Posts: 86
codecompletion parser stops parsing
« on: November 22, 2012, 01:30:50 pm »
Hi,

Ich have the problem that the command completion parser stops parsing on one of my workspace project.
I don't know why, the debug log of codeblocks shows that the parser stops with:

Add project (prjname) to parser
Done adding 0 files of project (prjname) to parser.
Add additional (next) project to parser.
Unexpected behaviour! in project 'prjname'

there is in fact one source file in this project.
Any ideas? when does this debug log message (Unexpected behaviour!) is thrown?

Martin

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: codecompletion parser stops parsing
« Reply #1 on: November 22, 2012, 02:36:41 pm »
there is in fact one source file in this project.
Any ideas? when does this debug log message (Unexpected behaviour!) is thrown?
Can you provide the whole project here (maybe stripped to a minimal example to reproduce?).

This error is thrown by CC and should actually really never happen?! Do you have an either super-fast or super-slow PC? What yre the specs? (PC, OS/C::B version...).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Martin K.

  • Multiple posting newcomer
  • *
  • Posts: 86
Re: codecompletion parser stops parsing
« Reply #2 on: November 22, 2012, 03:04:35 pm »
there is in fact one source file in this project.
Any ideas? when does this debug log message (Unexpected behaviour!) is thrown?
Can you provide the whole project here (maybe stripped to a minimal example to reproduce?).

This error is thrown by CC and should actually really never happen?! Do you have an either super-fast or super-slow PC? What yre the specs? (PC, OS/C::B version...).

Code::Blocks rev8500, wxwidgets 2.8.12, self compiled, Windows 7 X64, INtel Core i5-2500 @ 3.30GHz

I can't post the project, i will try to create some dummy project for this.
But this is a workspace with 23 projects, mixed c and c++. Two of these projects are containing only one c-source file and both are including the same file.

Martin

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: codecompletion parser stops parsing
« Reply #3 on: November 22, 2012, 03:24:58 pm »
Does it break the same if you put the project in a new workspace alone?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Martin K.

  • Multiple posting newcomer
  • *
  • Posts: 86
Re: codecompletion parser stops parsing
« Reply #4 on: November 22, 2012, 04:31:32 pm »
Does it break the same if you put the project in a new workspace alone?

No

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: codecompletion parser stops parsing
« Reply #5 on: November 22, 2012, 05:03:40 pm »
The error message comes from the source below:

Code
void Parser::OnBatchTimer(cb_unused wxTimerEvent& event)
{
    if (Manager::IsAppShuttingDown())
        return;

    // Current batch parser is already exists
    if (ParserCommon::s_CurrentParser && ParserCommon::s_CurrentParser != this)
    {
        m_BatchTimer.Start(1000, wxTIMER_ONE_SHOT);
        return;
    }

    bool sendStartParseEvent = false;

    CC_LOCKER_TRACK_P_MTX_LOCK(ParserCommon::s_ParserMutex)

    if (!m_StopWatchRunning)
        StartStopWatch();

    bool send_event = true;
    if (!m_PoolTask.empty())
    {
        m_Pool.BatchBegin();

        PTVector& v = m_PoolTask.front();
        for (PTVector::const_iterator it = v.begin(); it != v.end(); ++it)
            m_Pool.AddTask(*it, true);
        m_PoolTask.pop();

        m_Pool.BatchEnd();
        send_event = false; // error
    }
    else if (   !m_PriorityHeaders.empty()
             || !m_BatchParseFiles.empty()
             || !m_PredefinedMacros.IsEmpty() )
    {
        ParserThreadedTask* thread = new ParserThreadedTask(this, ParserCommon::s_ParserMutex);
        m_Pool.AddTask(thread, true);

        // Have not done any batch parsing
        if (ParserCommon::s_CurrentParser)
            send_event = false; // error
        else
        {
            ParserCommon::s_CurrentParser = this;
            m_StopWatch.Start(); // reset timer
            sendStartParseEvent = true;
        }
    }

    CC_LOCKER_TRACK_P_MTX_UNLOCK(ParserCommon::s_ParserMutex)

    if (send_event)
    {
        if (sendStartParseEvent)
            ProcessParserEvent(m_ParserState, ParserCommon::idParserStart);
        else
            ProcessParserEvent(ParserCommon::ptUndefined, ParserCommon::idParserStart, _T("Unexpected behaviour!"));
    }
}
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: codecompletion parser stops parsing
« Reply #6 on: November 22, 2012, 07:44:51 pm »
Having a look at the code it means that the only reason would be if:
m_PoolTask.empty() && m_PriorityHeaders.empty() && m_BatchParseFiles.empty() && m_PredefinedMacros.IsEmpty()
Well we can make another else-if tree for that particular case but I wonder how this can happen...?! It would mean that nothing has to be done at all - as if there would be not a single file to be parsed, including no priority headers, which is usually never the case.

@Martin K.: What are your CC settings, can you post a screenshot of all CC settings tabs?
Can you try to strip down the WS first project by projects and the file by file to (maybe) get a minimal example? If you want to, contact me via PM so I can provide you with a personal email address if you have concerns to post it here. But maybe (if possible) you can really strip it down to a non-secret minimalist example. It must not even compile - just to reproduce this state.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Martin K.

  • Multiple posting newcomer
  • *
  • Posts: 86
Re: codecompletion parser stops parsing
« Reply #7 on: November 22, 2012, 08:26:27 pm »
Having a look at the code it means that the only reason would be if:
m_PoolTask.empty() && m_PriorityHeaders.empty() && m_BatchParseFiles.empty() && m_PredefinedMacros.IsEmpty()
Well we can make another else-if tree for that particular case but I wonder how this can happen...?! It would mean that nothing has to be done at all - as if there would be not a single file to be parsed, including no priority headers, which is usually never the case.

@Martin K.: What are your CC settings, can you post a screenshot of all CC settings tabs?
Can you try to strip down the WS first project by projects and the file by file to (maybe) get a minimal example? If you want to, contact me via PM so I can provide you with a personal email address if you have concerns to post it here. But maybe (if possible) you can really strip it down to a non-secret minimalist example. It must not even compile - just to reproduce this state.

I have a demo, and i hope that it fails on your system also, it was a lot of probing, testing, changing the project and workspace.

This problem comes into place when i use several different compiler and no GCC (in this example MSVC2003 and MSVC2010).

Martin


Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: codecompletion parser stops parsing
« Reply #8 on: November 23, 2012, 07:56:55 am »
I have a demo, and i hope that it fails on your system also, [...]
Funny.

But seriously: It works for me. So I need your CC settings. I guess it has to do with it...
Settings -> Editor -> Code Completion -> all 4 tabs
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: codecompletion parser stops parsing
« Reply #9 on: November 23, 2012, 08:34:24 am »
Probably the full default.conf should be needed.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: codecompletion parser stops parsing
« Reply #10 on: November 23, 2012, 08:47:01 am »
Probably the full default.conf should be needed.
I think I am able to reproduce meanwhile. I switched to "one parser per WS" and now I see this, too.

However: If your projects use several compilers its not wise to do that. The reason is simple: The parser will ix #includes from different compilers then and the CC you get might be wrong.

So, although we still need to fix this later on, for you (Martin K.) a probably solution is to switch to "one parser per project", which should also be the default option.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Martin K.

  • Multiple posting newcomer
  • *
  • Posts: 86
Re: codecompletion parser stops parsing
« Reply #11 on: November 23, 2012, 09:15:05 am »
Probably the full default.conf should be needed.
I think I am able to reproduce meanwhile. I switched to "one parser per WS" and now I see this, too.

However: If your projects use several compilers its not wise to do that. The reason is simple: The parser will ix #includes from different compilers then and the CC you get might be wrong.

So, although we still need to fix this later on, for you (Martin K.) a probably solution is to switch to "one parser per project", which should also be the default option.

Switching to "one parser per project" toggles another problem: CC parses only the active project or the project wich was double clicked in the projects view. When i expand a not active project in the project s view to show me one source file and open this source file, then (sometimes!) no parsing of this project is triggered and i cannot find any declaration/implementation/... of any object in this opened source file.

Martin
« Last Edit: November 23, 2012, 09:16:58 am by Martin K. »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: codecompletion parser stops parsing
« Reply #12 on: November 23, 2012, 09:54:56 am »
then (sometimes!) no parsing of this project is triggered and i cannot find any declaration/implementation/... of any object in this opened source file.
This "sometimes" worries me a bit ???, but you can adjust the behaviour by simply allowing more parsers.

This settings depends on the workspace/project layout you are used to use. For some people, what you call "project" are targets. Thus, having many of these parsers may not be wise for them. For you, having more projects, but rather small ones with less targets, you can safely increase the number of parsers per project and the issue should be gone.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Martin K.

  • Multiple posting newcomer
  • *
  • Posts: 86
Re: codecompletion parser stops parsing
« Reply #13 on: November 23, 2012, 10:09:09 am »
then (sometimes!) no parsing of this project is triggered and i cannot find any declaration/implementation/... of any object in this opened source file.
This "sometimes" worries me a bit ???, but you can adjust the behaviour by simply allowing more parsers.

This settings depends on the workspace/project layout you are used to use. For some people, what you call "project" are targets. Thus, having many of these parsers may not be wise for them. For you, having more projects, but rather small ones with less targets, you can safely increase the number of parsers per project and the issue should be gone.

I haven't had a deeper look inside CC but in the "on parser per project" mode it seems to parse a project if:

- the active project changes and this project was not scanned before
- a "double click" on a project node occurs and this project was not scanned before
- any source of a not scanned project opens and this project was not scanned before

but when i have a workspace with more than one project inside and several project are sharing one or more source files, than this "shared" sourcefile triggers the parser process only at the first time it opens. When i select the same source file inside of another - not scanned - project, than this doens't trigger a new parser process.

Is this understandable? I should really work on my english.

Martin
« Last Edit: November 23, 2012, 12:56:56 pm by Martin K. »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: codecompletion parser stops parsing
« Reply #14 on: November 23, 2012, 10:25:15 am »
I haven't had a deeper look inside CC but in the "on parser per project" mod it seems to parse a project/target if:
- the active target changes and this target was not scanned before
- a "double click" on a target node occurs  and this target was not scanned before
- any source of a not scanned target opens and this target was not scanned before
I'm confused. look at the image below, and it looks like your "target" means a c::b project? ;)

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.