Strange semantic error
Asked Answered
C

2

10

I have reinstalled emacs 24.2.50 on a new linux host and started a new dotEmacs config based on magnars emacs configuration. Since I have used CEDET to some success in my previous workflow I started configuring it. However, there is some strange behaviour whenever I load a C++ source file.

[This Part Is Solved]
As expected, semantic parses all included files (and during the initial setup parses all files specified by the semantic-add-system-include variables), but it prints this an error message that goes like this:

WARNING: semantic-find-file-noselect called for /usr/include/c++/4.7/vector while in set-auto-mode for /usr/include/c++/4.7/vector. You should call the responsible function into 'mode-local-init-hook'.

In the above example the error is printed for the STL vector but a corresponding error message is printed for every file included by the one I'm visiting and any subsequent includes. As a result it takes quite a long time to finish and unfortunately the process is repeated any type I open a new buffer.

[This Problem Is Solved Too]
Furthermore it looks like the parsing doesn't really work as when I place the point above a non-c primitive type (i.e. not int,double,float, etc) instead of printing the type's definition in the modeline an error message like

Idle Service Error semantic-idle-local-symbol-highlight-idle-function: "#<buffer DEPFETResolutionAnalysis.cc> - Wrong type argument: stringp, (((0) \"IndexMap\"))" Idle Service Error semantic-idle-summary-idle-function: "#<buffer DEPFETResolutionAnalysis.cc> - Wrong type argument: stringp, ((\"fXBetween\" 0 nil nil))"

where DEPFETResolutionAnalysis.cc is the file & buffer I'm currently editing and IndexMap and fXBetween are types defined in files included by the file I'm editing/some file included by the file I'm editing.

I have not tested any further features of CEDET/semantic as the problem is pretty annoying. My cedet config can be found here.

EDIT: With the help of Alex Ott I kinda solved the first problem. It was due to my horrible cedet initialisation. See his first answer for the proper way to configure CEDET!
There still remains the problem with the Idle Service Error (which, when enabling global-semantic-idle-local-symbol-highlight-mode, occurs permanently, not only when checking the definition of the type at point).
And there is the new problem of how to disable the site-wise init file(s).

EDIT2: I have executed semantic-debug-idle-function in a buffer where the problem occurs and it produces a ~700kb [sic!] output. It looks like it is performing some operations on a data container which, by the looks of it, contains information on all the symbols defined in the files parsed. As I have parsed a rather large package (~20Mb source files) this table is rather large. Can semantic handle a database that large or is this impossible and the reason of my problem?

EDIT3: Deleting the content of ~/.semanticdb and reparsing all includes did the trick. I still need to disable the site-wise init files but as this is not related to CEDET I will close this question (the question related to the site-wise init files can be found here).

Crumpler answered 4/11, 2012 at 17:24 Comment(2)
Please provide information on which version of CEDET you're using, etc. Please, also take into account, that you don't need to put lines 2-40 into hook. This task (loading of CEDET) should be done only once, not on opening of each C/C++ file. See gist.github.com/3930120 as example of CEDET's configurationNatalya
There are also other errors in your init - when you're using c-mode-common-hook, then it will be called for C, C++, etc., so there is no need to set it for C & C++ modes separately.Natalya
C
3

The first problem was solved by correctly configuring CEDET which is discribed on Alex Ott's homepage. His answer solves this first problem. The config file specified in his answer is a great start for a nice config; I have used the very same to config CEDET for my needs.

The second problem vanished once I updated CEDET from 1.1 to the bazaar (repository) version, which is explained here and in Alex' article. Additionaly one must delete the content of the directory ~/.semanticdb (which contains the semantic database and was corrupted I guess).

I'd like to thank Alex Ott for his help and sticking with me throughout my journey to the solution :)

Crumpler answered 5/11, 2012 at 13:34 Comment(0)
N
6

You need to change your init file so it will perform loading of CEDET only once, not in the hook that will be called for each .h/.hpp/.c/.cpp files. You can change this config as the base, and read more in following article.

The problem that you have is caused because Semantic is trying to analyze header files, and when it tries to open them, then its initialization routines are called again, and again...

Natalya answered 4/11, 2012 at 18:32 Comment(7)
There is no file named 'cedet-devel-load.el' in the cedet archive downloaded from the cedet homepage. When loading common/cedet.el (as per the simple setup guide from the cedet homepage) this error occurs when loading: error: EIEIO Version 1.3 already loaded; load CEDET at the beginning of your init file to avoid this.. I have identified that an eieio.elc exists at /usr/share/emacs/24.2.50/lisp/emacs-lisp/ which is required by auth-source.elc (Which is part of gnus).Crumpler
This is quite strange as I have not used gnus on this machine and consequently it is not configured... also, I don't understand why gnus/auth-source would require eieio which (as far as I understand) is used for UML diagrams and similar stuff.Crumpler
if you're using external CEDET, then you need to load it first, before built-in. It's also better to take fresh bzr snapshot & configure it as described in articleNatalya
The problem still remains that eieio is loaded by some other library (gnus/auth-source I think). Is there any way to find out which site-start file loads a library?Crumpler
gnus/auth-source should be autoloaded on first use. do you have site-wide site-init? Try to run Emacs with -q to see will this error happen or not. I'm using Debian + emacs-snapshot and have no problems with loading CEDET before everything.Natalya
I have not configured a site-wise init myself. I'm on Xubuntu 12.10 with emacs-snapshot (from this repo: launchpad.net/~cassou/+archive/emacs ). When executing emacs-snapshot-gtk -q the error does not occur but CEDET isn't loaded either. When I load cedet.el using load-file the same error is echoed. When looking into the variable load-history eieio is required once again by auth-source prior to loading CEDET.Crumpler
Okay... executing emacs-snapshot-gtk --no-site-file allows indeed loading of CEDET without errors (using the bzr version now). The parsing is done only once and the first of the two error types described above is gone. But there still remains the second error and the problem that I don't know how to permanently disable the site-wise init file... Thanks for your help so far Alex!Crumpler
C
3

The first problem was solved by correctly configuring CEDET which is discribed on Alex Ott's homepage. His answer solves this first problem. The config file specified in his answer is a great start for a nice config; I have used the very same to config CEDET for my needs.

The second problem vanished once I updated CEDET from 1.1 to the bazaar (repository) version, which is explained here and in Alex' article. Additionaly one must delete the content of the directory ~/.semanticdb (which contains the semantic database and was corrupted I guess).

I'd like to thank Alex Ott for his help and sticking with me throughout my journey to the solution :)

Crumpler answered 5/11, 2012 at 13:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.