Author Topic: Code Completion & Workspace  (Read 30922 times)

Offline seb_seb0

  • Almost regular
  • **
  • Posts: 166
Code Completion & Workspace
« on: May 02, 2011, 09:39:36 pm »
Hello,

I have a problem with CodeCompletion, in a workspace containing 3 libs + 1 executable using the 3 libs
Configuration: svn7075, Windows 7

I define the function DoSomething in the library.
In the executable, when I use DoSomething, it is not recognized by the code completion. When I say "is not recognized", it means:
   - the name of the class, function or method does not appear in the list
   - when I use the menu command "Find Declaration of DoSomething", I get the message that the function cannot be found
   - I do not have tooltip for parameter list.

The problem is random, and does not happen for all symbols.

I am unable to reproduce the problem on a simple workspace.
Since my project is a bit large (800 000 lines of code, roughly), I believe that I may have hit a limitation in total amount of symbols (not sure if it is that, thought).

I have tried to enable the settings / editor / Code Completion / C++ Parser / "Forced to use 1 parser per whole workspace", but it is worse: the code completion does not work anymore.

Do you have any tips  ?

Best regards,

Sebastien

PS: I will try to make a minimal example reproducing the problem, if I can. For now, I did not succeed.
« Last Edit: May 02, 2011, 09:47:32 pm by seb_seb0 »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Code Completion & Workspace
« Reply #1 on: May 02, 2011, 09:42:22 pm »
Have you tried one of the latest nightlies?
I think a new feature have been implemented to parse all projects in the workspace.
The older version parsed only the current active project.
(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 seb_seb0

  • Almost regular
  • **
  • Posts: 166
Re: Code Completion & Workspace
« Reply #2 on: May 02, 2011, 09:47:01 pm »
Have you tried one of the latest nightlies?
I think a new feature have been implemented to parse all projects in the workspace.
The older version parsed only the current active project.

That was fast !
I am using the last nightly (svn 7075) on Windows 7 (sorry, I forgot to say that)


Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Code Completion & Workspace
« Reply #3 on: May 02, 2011, 10:05:22 pm »
Hm, probably this is a bug.

The is "Maximum allowed parsers", option, have you tried to increase it?

Loaden, Ollydbg: what is the purpose of this option?
(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 seb_seb0

  • Almost regular
  • **
  • Posts: 166
Re: Code Completion & Workspace
« Reply #4 on: May 02, 2011, 10:13:44 pm »
The is "Maximum allowed parsers", option, have you tried to increase it?

Loaden, Ollydbg: what is the purpose of this option?

Currently, it is set to 5.
I will try with different values (1,2 and 10 for a start). I will report back. Meanwhile, if you have other tips, do not hesitate !


Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code Completion & Workspace
« Reply #5 on: May 03, 2011, 02:46:36 am »
The is "Maximum allowed parsers", option, have you tried to increase it?
Loaden, Ollydbg: what is the purpose of this option?
this value=n means keep the latest nth c::b projects' symbol databases in memory. the older ones will be removed. One database for each c::b project.

If you select "Forced to use 1 parser per whole workspace" option, this means all the c::b projects' symbol under the current workspace will be stored in one symbol databases.
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 seb_seb0

  • Almost regular
  • **
  • Posts: 166
Re: Code Completion & Workspace
« Reply #6 on: May 03, 2011, 10:07:19 pm »
So, I have tried different settings:

  max parser = 1: the problem is not corrected , even after waiting 20 minutes. Even worse, Code::Blocks crashes (I forgot to copy a RPT file from my work computer. However, the crash occured when I switched files in the editor by clicking on a tab. The RPT shows several calls to codecompletion::onplugindetach (do not remember the exact name).

  max parser = 2 : same as for max parser = 5 (my default setting)

  max parser = 10 : no improvement as well

I have noticed as well several things that may help you:
  1 - the symbol browser displays all symbols, and when I use it to jump to declaration or implementation of a method, it works all the time (yeah !)
       When I said "list" in my original post, I was speaking about the popup list appearing while typing
  2 - the failure occurs only when I use the context menu in the editor, and selecting "Find Declaration" or "Find Implementation". I get the message "Not found : function name"
  3 - the problem occurs for derived class from pure virtual class (A is virtual and declares the interface, B derives from A and implements the interface.)
       Consider this:
 
Code
class A
{
    public:
      A();
      ~A();
      virtual void DoSomething(void) = 0; //interface
};

class B : public class A
{
     public:
       B();
       ~B();
       virtual void DoSomething(void) {}; //implementation
};

void AFunction(A* pPointer)
{
     pPointer->DoSomething(); //no tooltip here, no suggestion when typing "->", no parameter lists
};

    4 - all my classes are defined in a namespace. In the symbol browser, if I select "View all local symbols (workspace)", only symbols from the active project appear, even if I select "1 parser" or "force 1 parser per workspace"
         If I select "everything", then all symbols appear, including the one defined in my libs.

I hope it will help you to solve the problem.

Sebastien

EDIT: I still cannot get a minimal example workspace displaying the problem. There is probably a problem of too many symbols, or there is a function somewhere which break the codecompletion. I will try to simplify my workspace and see if I can narrow down the problem to a manageable size
« Last Edit: May 03, 2011, 10:14:19 pm by seb_seb0 »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code Completion & Workspace
« Reply #7 on: May 04, 2011, 03:13:06 am »
answer 3:

It seem both suggestion list and call tip works fine in your test code, see the screen shot below:



and

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 oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Code Completion & Workspace
« Reply #8 on: May 04, 2011, 08:38:53 am »
Ollydbg, you should put A, B, AFunction in different projects.
(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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code Completion & Workspace
« Reply #9 on: May 10, 2011, 03:51:19 pm »
Ollydbg, you should put A, B, AFunction in different projects.
it works fine.
I just got some time to separate "A", "B", and "AFunction" in three cbp, and only allow one tokenstree for the whole workspace.
And I can have "DoSomething" in the auto suggestion list after "pPointer->". :D

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 seb_seb0

  • Almost regular
  • **
  • Posts: 166
Re: Code Completion & Workspace
« Reply #10 on: May 11, 2011, 09:42:50 pm »
Ollydbg, you should put A, B, AFunction in different projects.
it works fine.
I just got some time to separate "A", "B", and "AFunction" in three cbp, and only allow one tokenstree for the whole workspace.
And I can have "DoSomething" in the auto suggestion list after "pPointer->". :D



Yes, for simple projects, it works. But for my project, it fails, and I cannot pinpoint the problem yet. Give me a bit of time, and I will post you a minimal test case. The code I have posted is a typical case where it fails (implementation of a virtual interface, and calling it from somewhere else)
Thanks for the help.

BTW, here is a crash dump which occurs when max parsers thread are set to 1:

Code
D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\codeblocks.exe caused an Access Violation at location 65f12fae in module D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\share\codeblocks\plugins\codecompletion.dll Reading from location 00000000.

Registers:
eax=00000000 ebx=00000000 ecx=0000006d edx=00000000 esi=00000312 edi=0241b120
eip=65f12fae esp=0022eed8 ebp=0022eed8 iopl=0         nv up ei pl nz na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010202

Call stack:
65F12FAE  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\share\codeblocks\plugins\codecompletion.dll:65F12FAE  _ZN8cbPlugin9OnReleaseEb
65F13015  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\share\codeblocks\plugins\codecompletion.dll:65F13015  _ZN8cbPlugin9OnReleaseEb
65F12FFD  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\share\codeblocks\plugins\codecompletion.dll:65F12FFD  _ZN8cbPlugin9OnReleaseEb
65F09005  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\share\codeblocks\plugins\codecompletion.dll:65F09005  _ZN12cbToolPlugin9BuildMenuEP9wxMenuBar
65F0FAD0  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\share\codeblocks\plugins\codecompletion.dll:65F0FAD0  _ZN8cbPlugin9OnReleaseEb
65ED7F8E  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\share\codeblocks\plugins\codecompletion.dll:65ED7F8E
65EC1B27  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\share\codeblocks\plugins\codecompletion.dll:65EC1B27
65EC071E  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\share\codeblocks\plugins\codecompletion.dll:65EC071E
65EAADBE  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\share\codeblocks\plugins\codecompletion.dll:65EAADBE
65F0A614  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\share\codeblocks\plugins\codecompletion.dll:65F0A614  _ZN12cbToolPlugin9BuildMenuEP9wxMenuBar
618744D0  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\codeblocks.dll:618744D0  _ZN7Manager12ProcessEventER15CodeBlocksEvent
6188B20C  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\codeblocks.dll:6188B20C  _ZN13PluginManager13NotifyPluginsER15CodeBlocksEvent
618A911E  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\codeblocks.dll:618A911E  _ZN14ProjectManager10SetProjectEP9cbProjectb
618B998A  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\codeblocks.dll:618B998A  _ZN14ProjectManager19EndLoadingWorkspaceEv
618AE517  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\codeblocks.dll:618AE517  _ZN14ProjectManager13LoadWorkspaceERK8wxString
0042C476  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\codeblocks.exe:0042C476
0042FDC5  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\codeblocks.exe:0042FDC5
6CCC7670  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\wxmsw28u_gcc_cb.dll:6CCC7670  _ZN12wxEvtHandler21ProcessEventIfMatchesERK21wxEventTableEntryBasePS_R7wxEvent
6CCC77A9  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\wxmsw28u_gcc_cb.dll:6CCC77A9  _ZN16wxEventHashTable11HandleEventER7wxEventP12wxEvtHandler
6CCC7B74  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\wxmsw28u_gcc_cb.dll:6CCC7B74  _ZN12wxEvtHandler12ProcessEventER7wxEvent
6CCC7528  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\wxmsw28u_gcc_cb.dll:6CCC7528  _ZN12wxEvtHandler20ProcessPendingEventsEv
6CC417AE  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\wxmsw28u_gcc_cb.dll:6CC417AE  _ZN12wxAppConsole20ProcessPendingEventsEv
6D05E549  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\wxmsw28u_gcc_cb.dll:6D05E549  _ZN18wxIconLocationBaseC2ERK8wxString
7E42B372  C:\WINNT\system32\USER32.dll:7E42B372  MoveWindow
7E42B317  C:\WINNT\system32\USER32.dll:7E42B317  MoveWindow
7E4278D0  C:\WINNT\system32\USER32.dll:7E4278D0  GetWindowTextLengthW
7C90E473  C:\WINNT\system32\ntdll.dll:7C90E473  KiUserCallbackDispatcher
6CCF569A  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\wxmsw28u_gcc_cb.dll:6CCF569A  _ZN11wxEventLoop8DispatchEv
6CD8D518  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\wxmsw28u_gcc_cb.dll:6CD8D518  _ZN17wxEventLoopManual3RunEv
6CD6BB19  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\wxmsw28u_gcc_cb.dll:6CD6BB19  _ZN9wxAppBase8MainLoopEv
004058C4  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\codeblocks.exe:004058C4
6CC73248  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\wxmsw28u_gcc_cb.dll:6CC73248  _Z14wxUninitializev
6CCCD392  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\wxmsw28u_gcc_cb.dll:6CCCD392  _Z7wxEntryP11HINSTANCE__S0_Pci
00401D71  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\codeblocks.exe:00401D71
004627C6  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\codeblocks.exe:004627C6
004010DB  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\codeblocks.exe:004010DB
00401158  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\codeblocks.exe:00401158
7C817077  C:\WINNT\system32\kernel32.dll:7C817077  RegisterWaitForInputIdle


-------------------

Error occured on Wednesday, May 4, 2011 at 10:50:15.

D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\codeblocks.exe caused an Access Violation at location 7c919af2 in module C:\WINNT\system32\ntdll.dll Writing to location 00000146.

Registers:
eax=00000136 ebx=00000000 ecx=0000036c edx=01326250 esi=01326240 edi=00000000
eip=7c919af2 esp=0022f8e4 ebp=0022f958 iopl=0         nv up ei pl zr na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010246

Call stack:
7C919AF2  C:\WINNT\system32\ntdll.dll:7C919AF2  RtlpWaitForCriticalSection
7C901046  C:\WINNT\system32\ntdll.dll:7C901046  RtlEnterCriticalSection
6CCC7566  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\wxmsw28u_gcc_cb.dll:6CCC7566  _ZN12wxEvtHandler20ProcessPendingEventsEv
6CC417AE  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\wxmsw28u_gcc_cb.dll:6CC417AE  _ZN12wxAppConsole20ProcessPendingEventsEv
6D05E549  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\wxmsw28u_gcc_cb.dll:6D05E549  _ZN18wxIconLocationBaseC2ERK8wxString
7E42B372  C:\WINNT\system32\USER32.dll:7E42B372  MoveWindow
7E42B317  C:\WINNT\system32\USER32.dll:7E42B317  MoveWindow
7E4278D0  C:\WINNT\system32\USER32.dll:7E4278D0  GetWindowTextLengthW
7C90E473  C:\WINNT\system32\ntdll.dll:7C90E473  KiUserCallbackDispatcher
6CCF569A  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\wxmsw28u_gcc_cb.dll:6CCF569A  _ZN11wxEventLoop8DispatchEv
6CD8D518  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\wxmsw28u_gcc_cb.dll:6CD8D518  _ZN17wxEventLoopManual3RunEv
6CD6BB19  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\wxmsw28u_gcc_cb.dll:6CD6BB19  _ZN9wxAppBase8MainLoopEv
004058C4  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\codeblocks.exe:004058C4
6CC73248  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\wxmsw28u_gcc_cb.dll:6CC73248  _Z14wxUninitializev
6CCCD392  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\wxmsw28u_gcc_cb.dll:6CCCD392  _Z7wxEntryP11HINSTANCE__S0_Pci
00401D71  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\codeblocks.exe:00401D71
004627C6  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\codeblocks.exe:004627C6
004010DB  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\codeblocks.exe:004010DB
00401158  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\codeblocks.exe:00401158
7C817077  C:\WINNT\system32\kernel32.dll:7C817077  RegisterWaitForInputIdle


Sebastien

Offline seb_seb0

  • Almost regular
  • **
  • Posts: 166
Re: Code Completion & Workspace
« Reply #11 on: May 11, 2011, 10:33:23 pm »
The project is too complex, and I cannot find a minimal test case.
I can see the virtual class in the symbol browser, but the context menu "find declaration" does not work.
In the workspace, if I have projects A + B + C, the bug occurs. If I have A + B, or A + C, or B+C, it works fine...

Consider the 2 images here:
http://img833.imageshack.us/g/test1ms.png/

In the 1st image, consider the virtual class L3D_IRenderSystem.
L3D_IRenderSystem is defined in the lib, and I use a pointer to it in the main program.
I can see it in the symbol browser, but when I right click on "Find the Declaration of : 'L3D_IRenderSystem'", I get the error message "Not found ..."

In the 2nd image, you can see that the parser seems to be stuck somewhere (it can stay a whole day in this state).
Do you have some special tricks to debug the codecompletion plugin ?

Regards,

Sebastien

[attachment deleted by admin]
« Last Edit: May 11, 2011, 10:56:15 pm by seb_seb0 »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code Completion & Workspace
« Reply #12 on: May 12, 2011, 03:45:31 am »
Quote
In the 1st image, consider the virtual class L3D_IRenderSystem.
L3D_IRenderSystem is defined in the lib, and I use a pointer to it in the main program.
I can see it in the symbol browser, but when I right click on "Find the Declaration of : 'L3D_IRenderSystem'", I get the error message "Not found ..."
"Find the Declaration" is just doing a scope match. I wrote this in the wiki, see:
6 Automatic Code Completion

and about debugging cc plugin, there are two kind of tracer
1, if you want to debug the parser, you can simply follow this:
7 Code completion debugging support

2, if you want to see how "find the declaration works", you should enable the
7.4 Debug Smart Sense log output
Note that CC does not do "full preprocessor" and "type check", so it may failed in parsing something. But if the parser is running endlessly, it mostly has a infinite loop bug, this bug should be fixed.

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: Code Completion & Workspace
« Reply #13 on: May 12, 2011, 02:34:12 pm »
For the record, the issue you are experiencing and show in "Images.7z" is really a bug. I experience this myself on certain projects, hence I don't know how to reproduce because in fact it does work sometimes and sometimes it does not. :?

It seems (however) not related to the number of parsers or to the option "one parser per workspace".

There are actually two bugs here:
1.) If a parser fails CC should not completely be broken, or at least this parser should be able to re-start / invalidate.
2.) The actual error might be caused by a parser bug, but I do have my doubts here as it sometimes works!

The projects where I am facing this issue have the following structure:
WS:
  PRJ(1..N): A library with default / debug target, virtual target "All"
  PRJ(N+1): A project that creates several executables using the libraries as DLL (debug/release, different setup of compiler flags)
  PRJ(N+2): A project that creates several executables using the libraries statically (debug/release, different setup of compiler flags)
  PRJ(N+3): A testing project
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code Completion & Workspace
« Reply #14 on: May 12, 2011, 04:41:48 pm »
There are actually two bugs here:
1.) If a parser fails CC should not completely be broken, or at least this parser should be able to re-start / invalidate.
2.) The actual error might be caused by a parser bug, but I do have my doubts here as it sometimes works!
How does a parser know itself get failed? We say a parser get failed mostly because it exit DoParse() function too early, or internally it just Skip to the EOF.

I guess mostly the bug was caused by not correctly beginning search scopes.
e.g.
Code
...
using namespace std;
...
vector<int> a;
If we try to resolve the "type" of the variable "a", we need to resolve the type string "vector < int >". Then the first step was try to resolve the string "vector". But if "std" is not in the beginning search scope, then we may failed in resolving the "vector" type. :D. This is my guess until a test code to reproduce it.
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code Completion & Workspace
« Reply #15 on: May 12, 2011, 04:44:25 pm »
Quote
Call stack:
65F12FAE  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\share\codeblocks\plugins\codecompletion.dll:65F12FAE  _ZN8cbPlugin9OnReleaseEb
65F13015  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\share\codeblocks\plugins\codecompletion.dll:65F13015  _ZN8cbPlugin9OnReleaseEb
65F12FFD  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\share\codeblocks\plugins\codecompletion.dll:65F12FFD  _ZN8cbPlugin9OnReleaseEb
65F09005  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\share\codeblocks\plugins\codecompletion.dll:65F09005  _ZN12cbToolPlugin9BuildMenuEP9wxMenuBar
65F0FAD0  D:\WORK\03_MISSIONS\00_SDK\IDE\CODEBLOCKS\share\codeblocks\plugins\codecompletion.dll:65F0FAD0  _ZN8cbPlugin9OnReleaseEb
I have no idea why the crash call stack was pointing to a function named "_ZN8cbPlugin9OnReleaseEb"??? :(, it seems like that the crash caused on the plugin release?
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: Code Completion & Workspace
« Reply #16 on: May 12, 2011, 04:57:53 pm »
I have no idea why the crash call stack was pointing to a function named "_ZN8cbPlugin9OnReleaseEb"??? :(, it seems like that the crash caused on the plugin release?
I know what causes this and it happens occasionally to me, too.

I traced it back to void Parser::OnAllThreadsDone(CodeBlocksEvent& event). This line:
Code
            parseEndLog.Printf(_T("Project '%s' parsing stage done (%d total parsed files, ")
                               _T("%d tokens in %ld minute(s), %ld.%03ld seconds)."),
                               m_Project    ? m_Project->GetTitle().wx_str()  : _T("*NONE*"),
                               m_TokensTree ? m_TokensTree->m_FilesMap.size() : 0,
                               m_TokensTree ? m_TokensTree->realsize()        : 0,
                               (m_LastStopWatchTime / 60000),
                               (m_LastStopWatchTime / 1000) % 60,
                               (m_LastStopWatchTime % 1000) );
...crashes C::B. Notice that actually access is protected by a wxCriticalSectionLocker and also, there are NULL pointer checks (done by me as I was hoping that would fix the crash). For the moment I don't know what actually might be the issue. Again: That's one of the bugs not reproducible. :-(
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code Completion & Workspace
« Reply #17 on: May 12, 2011, 05:03:35 pm »
@MortenMacFly
Does this crash happen on the batch parse stage?  As far as I know, void Parser::OnAllThreadsDone() was called when the batch parse finishes.
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: Code Completion & Workspace
« Reply #18 on: May 12, 2011, 05:05:29 pm »
@MortenMacFly
Does this crash happen on the batch parse stage?
I don't know to be honest. It could be that it happens when I close C::B quickly (and parsing did not complete). I'll try to pay attention to this.
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 seb_seb0

  • Almost regular
  • **
  • Posts: 166
Re: Code Completion & Workspace
« Reply #19 on: May 12, 2011, 09:34:45 pm »
Hi,

I have found the exact cause (of my parsing bug), and I have done a minimal project.
As OllyDbg said in his last post, this is a problem with namespace scope resolution.

See the Workspace attached.
Inside, you have 2 projects: a lib and an executable (no need to compile anything).
The lib is encapsulated in a namespace LIB_NS
In the executable, you have: main.h and main.cpp

In main.h, you have only 2 lines:
Code
#include "lib.h"

using namespace LIB_NS; //this line can cause trouble

when the "using namespace" clause is defined in the header file, the bug occurs.
The bug does NOT occur when:
    1 - the using namespace clause is the cpp file
    2 - an explicit scope resolution is done in the source (ex: LIB_NS:: )

I hope this helps.
Best regards,

Sebastien

[attachment deleted by admin]
« Last Edit: May 12, 2011, 09:43:33 pm by seb_seb0 »

Offline seb_seb0

  • Almost regular
  • **
  • Posts: 166
Re: Code Completion & Workspace
« Reply #20 on: May 12, 2011, 09:42:40 pm »
Quote
In the 1st image, consider the virtual class L3D_IRenderSystem.
L3D_IRenderSystem is defined in the lib, and I use a pointer to it in the main program.
I can see it in the symbol browser, but when I right click on "Find the Declaration of : 'L3D_IRenderSystem'", I get the error message "Not found ..."
"Find the Declaration" is just doing a scope match. I wrote this in the wiki, see:
6 Automatic Code Completion

and about debugging cc plugin, there are two kind of tracer
1, if you want to debug the parser, you can simply follow this:
7 Code completion debugging support

2, if you want to see how "find the declaration works", you should enable the
7.4 Debug Smart Sense log output
Note that CC does not do "full preprocessor" and "type check", so it may failed in parsing something. But if the parser is running endlessly, it mostly has a infinite loop bug, this bug should be fixed.



Thanks for the info, I will use it, and I will let you know if I find something.
To sum up what has been said, there are 3 bugs :
   1 - a problem with namespace scope resolution - see my last post with a minimal test project
   2 - a problem of Parser Thread blocked in an endless loop => I will try to see what I can find
   3 - a crash problem : for me, it occured when switching to another opened file, by clicking on an editor tab (that means several files are opened).
                                   It did not occured while trying to quit CB.

On the bright side: since the bugs are identified, we can solve them !

Sebastien

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Code Completion & Workspace
« Reply #21 on: May 12, 2011, 10:49:13 pm »
Quote
when the "using namespace" clause is defined in the header file, the bug occurs.

CC should not fail on that. Agreed, but the only advice I can give you : just don't do this. That is not the intention of namespaces, actually this is killing the entire purpose of namespaces .
See also books of Meyers, Sutter, ...

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code Completion & Workspace
« Reply #22 on: May 13, 2011, 06:04:35 am »
Quote
when the "using namespace" clause is defined in the header file, the bug occurs.
The bug does NOT occur when:
    1 - the using namespace clause is the cpp file
    2 - an explicit scope resolution is done in the source (ex: LIB_NS:: )
True, the current implementation has this bug. Mostly because we do NOT expand the #include directive.
In-fact, we have very limited preprocessor directive handling.

We only collect the "using namespace xxx" directive in the current file. So, as you said, if the "using namespace clause" was in other header files, surely they will be ignored, and this bug will occur.

see:6.1 Find the search scope, I have explained the method on how to correct a initial search scope.

BTW: If we do a full preprocessor handling, we are nearly design a full compiler front end. :D
« Last Edit: May 13, 2011, 08:18:49 am by ollydbg »
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: Code Completion & Workspace
« Reply #23 on: May 13, 2011, 07:55:44 am »
  2 - a problem of Parser Thread blocked in an endless loop => I will try to see what I can find
I finally have a test case for this.

In the attached project, if you inspect the log it never stop parsing the second project. You have to ensure, that you have *one* parser for the whole workspace to reproduce. Notice that both projects are the same, except that the second one compiles/links statically. Thu they use different #defines, but for the same sources (wx). Maybe that's the issue - reminds me to try what happens if I disable the complex macro parsing...
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code Completion & Workspace
« Reply #24 on: May 13, 2011, 08:14:57 am »
  2 - a problem of Parser Thread blocked in an endless loop => I will try to see what I can find
I finally have a test case for this.

In the attached project, if you inspect the log it never stop parsing the second project. You have to ensure, that you have *one* parser for the whole workspace to reproduce. Notice that both projects are the same, except that the second one compiles/links statically. Thu they use different #defines, but for the same sources (wx). Maybe that's the issue - reminds me to try what happens if I disable the complex macro parsing...
the attachment zip file has not cpp files in it? did you forget attach them?
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: Code Completion & Workspace
« Reply #25 on: May 13, 2011, 08:17:22 am »
the attachment zip file has not cpp files in it? did you forget attach them?
No, that is on purpose. It's enough, if CC tries to parse the "up-front" headers (wx in this case).
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code Completion & Workspace
« Reply #26 on: May 13, 2011, 08:27:22 am »
Here is the log in my PC:
Quote
Loading workspace "F:\cb\test_code\Demo\Demo.workspace"
Loading project file...
Parsing project file...
Loading target default
Loading project files...
1 files loaded
Done loading project in 31ms
Project's base path: F:\cb\test_code\Demo\
Project's common toplevel path: F:\cb\test_code\Demo\
Loading project file...
Parsing project file...
Loading target default
Loading project files...
1 files loaded
Done loading project in 0ms
Project's base path: F:\cb\test_code\Demo\
Project's common toplevel path: F:\cb\test_code\Demo\
Caching GCC dir: D:\code\mingw_gcc4.5.4.20110428_static_win32\MinGW\lib\gcc\i686-pc-mingw32\4.5.4\include\c++
Caching GCC dir: D:\code\mingw_gcc4.5.4.20110428_static_win32\MinGW\lib\gcc\i686-pc-mingw32\4.5.4\include\c++\i686-pc-mingw32
Caching GCC dir: D:\code\mingw_gcc4.5.4.20110428_static_win32\MinGW\lib\gcc\i686-pc-mingw32\4.5.4\include\c++\backward
Caching GCC dir: D:\code\mingw_gcc4.5.4.20110428_static_win32\MinGW\include
Caching GCC dir: D:\code\mingw_gcc4.5.4.20110428_static_win32\MinGW\lib\gcc\i686-pc-mingw32\4.5.4\include
Caching GCC dir: D:\code\mingw_gcc4.5.4.20110428_static_win32\MinGW\lib\gcc\i686-pc-mingw32\4.5.4\include-fixed
Caching GCC dir: D:\code\mingw_gcc4.5.4.20110428_static_win32\MinGW\i686-pc-mingw32\include
Passing list of files to batch-parser.
Header to parse up-front: 'D:\code\mingw_gcc4.5.4.20110428_static_win32\MinGW\lib\gcc\i686-pc-mingw32\4.5.4\include\c++\cstddef'
Header to parse up-front: 'D:\code\mingw_gcc4.5.4.20110428_static_win32\MinGW\i686-pc-mingw32\include\w32api.h'
Header to parse up-front: 'D:\code\wxWidgets-2.8.12\include\wx\defs.h'
Header to parse up-front: 'D:\code\wxWidgets-2.8.12\include\wx\dlimpexp.h'
Header to parse up-front: 'D:\code\wxWidgets-2.8.12\include\wx\toplevel.h'
Add up-front parsing 5 file(s) for project 'Demo'...
Add batch-parsing 1 file(s) for project 'Demo'...
Create new parser for project 'Demo'
Starting batch parsing for project 'Demo'...
Project 'Demo' parsing stage done (141 total parsed files, 12725 tokens in 0 minute(s), 12.562 seconds).
Updating class browser...
Class browser updated.
Add project (Demo (static)) to parser
Get Headers: D:\code\wxWidgets-2.8.12\include\ , 688
Get Headers: D:\code\wxWidgets-2.8.12\lib\gcc_dll\mswu\ , 2
Get Headers: D:\code\mingw_gcc4.5.4.20110428_static_win32\MinGW\lib\gcc\i686-pc-mingw32\4.5.4\include\c++\ , 611
Get Headers: D:\code\mingw_gcc4.5.4.20110428_static_win32\MinGW\lib\gcc\i686-pc-mingw32\4.5.4\include\c++\i686-pc-mingw32\ , 23
Get Headers: D:\code\mingw_gcc4.5.4.20110428_static_win32\MinGW\lib\gcc\i686-pc-mingw32\4.5.4\include\c++\backward\ , 8
Get Headers: D:\code\mingw_gcc4.5.4.20110428_static_win32\MinGW\include\ , 5
Get Headers: D:\code\mingw_gcc4.5.4.20110428_static_win32\MinGW\lib\gcc\i686-pc-mingw32\4.5.4\include\ , 39
Get Headers: D:\code\mingw_gcc4.5.4.20110428_static_win32\MinGW\lib\gcc\i686-pc-mingw32\4.5.4\include-fixed\ , 3
Get Headers: D:\code\mingw_gcc4.5.4.20110428_static_win32\MinGW\i686-pc-mingw32\include\ , 1231
Get the system header file path: 9


looks like there should be a log saying that, but in-fact no such log message, that's strange.
Quote
Project 'Demo static' parsing stage done.....

edit: the CPU usage is quite low (<5%), it seems CC was not in a infinite loop.
« Last Edit: May 13, 2011, 08:29:00 am by ollydbg »
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: Code Completion & Workspace
« Reply #27 on: May 13, 2011, 08:49:36 am »
edit: the CPU usage is quite low (<5%), it seems CC was not in a infinite loop.
It's not an "infinite loop" in a sense that it eats CPU. But it never returns and so all CC actions will report "parser still parsing files" forever.

IMHO the parser fails silently with an error and this is not handeled correctly.
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code Completion & Workspace
« Reply #28 on: May 13, 2011, 08:54:52 am »
Quote
It's not an "infinite loop" in a sense that it eats CPU. But it never returns and so all CC actions will report "parser still parsing files" forever.

IMHO the parser fails silently with an error and this is not handeled correctly.
Yes, I think I will take some time to trace the bug. (not right now :D) I suspect that when batch parsing the second project, no parserthread object was created(all the necessary files were already parsed in the first project) and no files were put into the thread pool, so maybe the "End of batch parse Event" never triggered. :D
« Last Edit: May 13, 2011, 08:56:27 am by ollydbg »
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 Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Code Completion & Workspace
« Reply #29 on: May 13, 2011, 09:55:47 am »
The BUG maybe related with memory pool.
Please trying REV7122: "CC: Disable memory pool again, avoid possible crash".

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Code Completion & Workspace
« Reply #30 on: May 13, 2011, 09:56:35 am »
Please trying REV7122: "CC: Disable memory pool again, avoid possible crash".
That's the version I am using. But I really doubt that's the reason. In the initial (first project) parser run it#s just about ~60000 symbols
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 Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Code Completion & Workspace
« Reply #31 on: May 13, 2011, 11:05:19 am »
Please trying REV7122: "CC: Disable memory pool again, avoid possible crash".
That's the version I am using. But I really doubt that's the reason. In the initial (first project) parser run it#s just about ~60000 symbols
Try to disable symbols browser.
I think now the symbols browser is *NOT* thread safe.
Maybe this is the final reason.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Code Completion & Workspace
« Reply #32 on: May 13, 2011, 03:08:00 pm »
Try to disable symbols browser.
I think now the symbols browser is *NOT* thread safe.
Maybe this is the final reason.
I'll try, but actually I doubt this will be the reason, too. I am using one parser per WS only, so only one parser feeds the symbol browser. This should not fail and progressing is basically serialised.

I believe it's related to the different set of macros. What happens e.g. if the same wx file is parsed with different #defines? Imagine you have a project (target) using ANSI and one using Unicode. What will be added to the (internal/symbol) tree?

Similar is the case in the sample I provided: static and dynamic linking requires different #defines. All other projects I had in this WS (before stripping it down to what it is now) caused no problems. Just these two.
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 seb_seb0

  • Almost regular
  • **
  • Posts: 166
Re: Code Completion & Workspace
« Reply #33 on: May 13, 2011, 10:32:15 pm »
Quote
when the "using namespace" clause is defined in the header file, the bug occurs.

CC should not fail on that. Agreed, but the only advice I can give you : just don't do this. That is not the intention of namespaces, actually this is killing the entire purpose of namespaces .
See also books of Meyers, Sutter, ...
I also agree, but I never pretended I was the perfect programmer :-) . The "using" is actually practical for simple test programs, and it keeps the code more readable IMHO.

However, thanks everybody for the information provided. Now I know where the cause of my problem lies, and I have a way to correct the problem (use full scope qualification).

Sebastien