Author Topic: Code Completion & Workspace  (Read 30948 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: 5916
  • 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: 5916
  • 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: 5916
  • 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: 5916
  • 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: 5916
  • 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.