Hi Eric,

Here is my CEDET setup (pretty much the same with Alex): emacs-rc-cedet.el
My init.el that calls emacs-rc-cedet.el: init.el

To do the testing, I removed everything in my .emacs.d, except for emacs-rc-cedet.el and init.el, and init.el only loads emacs-rc-cedet.el. I also have latest CEDET, cloned from the github mirror: https://github.com/alexott/cedet . I opened standalone (not in linux source tree) jiffies.h, run "semantic-lex-test". Strangely, it works fine this time. I cloned my .emacs.d directory again and tested one more time, this file with the jiffies.h in the kernel source tree, located at ~/linux/include/linux/jiffies.h (as you can see I added "linux/" directory to semantic-system-include in my emacs-rc-cedet.el.

I got the error at line 256:

#if !((((NSEC_PER_SEC << 2) / TICK_NSEC) << (SEC_JIFFIE_SC - 2)) & 0x80000000)

The error is:

Idle Parse Error: "#<buffer jiffies.h> - Arithmetic error"
Parsing jiffies.h (LL)... [3 times]
Mark set
Parsing jiffies.h (LL)...
Error running timer `semantic-idle-scheduler-function': (arith-error)

To test it further, I deleted that CEDET and downloaded the one from bzr and setup as above. The result is the same.

I also tested with stock CEDET bundled with my Emacs: GNU Emacs (x86_64-unknown-linux-gnu, GTK+ Version 3.10.8) of 2014-05-05 on xtuudoo-Satellite-L640

I guess if I can parse once, reparsing won't have any error. When CEDET successfully parsed the standalone file jiffies.h not in linux source tree, it can successfully parse jiffies.h in the linux source tree.

I think it's best if you can reproduce the error directly using my .emacs.d. Please clone it:

git clone https://bitbucket.org/hoangtu/my-emacs-prelude.git .emacs.d

My repository is battery included, so after your cloned it, you only need to run your emacs as normal. Note that you must use emacs from trunk, not even the pre-test version. Otherwise, there will be error when loading compiled packages. External dependency is GNU Global, and that's it. After you clone my repo, please try it on the two files again.

One more thing: Is this how you setup CEDET with gcc?

(require 'semantic/bovine/gcc)

After setting up, does CEDET use GCC for parsing?

Lastly, after applying your patch, the error goes away.

Thanks for your detailed response.



On Tue, Jun 3, 2014 at 7:58 AM, Eric M. Ludlam <eric@siege-engine.com> wrote:
Hi Tu

Thanks for the misc emails on parsing problems from linux headers.

I tried parsing your attached files, and they seemed to parse ok with no errors for me.  For your earlier linux_banner related issue, I don't have the exact same header, but the one I do have (linux-headers-3.13.0-27) parsed and completed ok.

This means you have something in your default macro table list that I don't that is somehow messing it up, or you have some version of hideif that is not what I have, or you have an old version of CEDET and we happen to have fixed that already.

The easy question then is if you are using the latest version of CEDET from the cedet bzr repository?

Next, lets see how you can debug these issues, and perhaps we can focus in on the issue.  For example, perhaps my found macros from GCC force CEDET to skip parsing the code that you parsed and had bugs in.

I guess the easiest thing would be to create a new buggy.h, and copy in the code you found that is throwing the error.  To zoom in on that, load in you file, such as jiffies.h, and put the cursor at the beginning, and do:

M-x semantic-lex-test RET

I think if it bails with an error, that should drop you in the right spot.

You can then copy over the bogus code into buggy.h and try it stand alone.   If the code you found (some #if statements I assume) you may need to also copy in any reference macros to make it work / fail.

This reduced case will then avoid anything that might be forcing my version to skip over the buggy code so I can see what the problem might be.

The code I think you are running into is related to the Emacs package "hideif" which is a handy tool for evaluating CPP macros for hiding/showing sections of code.

In case this is the problem, I have attached a patch that wraps up the code that hideif generates to capture errors.  This patch is against the latest version of CEDET, so if you are running something else, it should be easy to just copy it in to what you have.

I hope this helps.

On 05/30/2014 01:49 PM, Tu Do wrote:
Sorry I forgot to attach *jiffies.h


On Sat, May 31, 2014 at 12:48 AM, Tu Do <tuhdo1710@gmail.com
<mailto:tuhdo1710@gmail.com>> wrote:

    One file is in
    */usr/include/x86_64-linux-gnu/c++/4.8/ext/opt_random.h* from the

    previous email I sent Alex.

    One file is in *linux/include/linux/jiffies.h* . I got the following

    error parsing this file:

     > Parsing jiffies.h (LL)...
     > Idle Work Parse Error: "#<buffer jiffies.h> - Arithmetic error"
    When I tried to execute *bovinate*, I got this error:

     > hif-shiftleft: Arithmetic error
    *linux* is the linux kernel source tree.

    I attached both files here. It seems CEDET having problem parsing
    macros with arithmetic operations in it.



        While I was making CEDET parse /usr/include, it cannot parse
        this particular file:

        I got this error:

            Error running timer `semantic-idle-scheduler-function':
            (wrong-type-argument number-or-marker-p

        When I tried `bovinate`, I got this error:

            eval: Wrong type argument: number-or-marker-p,

        Since Semantic got stuck on this particular file, it cannot
        continue. I think CEDET devs should implement a recovery mechanism.



Time is money. Stop wasting it! Get your web API in 5 minutes.

Cedet-devel mailing list