Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Linux Kernel Module Development
Linux Kernel Module Development [message #235581] Tue, 07 July 2009 19:26 Go to next message
DB Mising name is currently offline DB Mising nameFriend
Messages: 11
Registered: July 2009
Junior Member
I'm using CDT 6 with latest Eclipse. Is there editor support for
development of Kernel Modules / Drivers?

I'm able to make my drivers, and using an Eclipse Makefile project, I'm
able to build the modules fine, and run them from terminal. My problem is
that the Eclipse editor is underlining a lot of things with "Syntax
Error". For example:

[...]
printk(KERN_ALERT "Init - Cannot Allocate Buffers");
[...]

or

static int __init driver_init(void) {
[...]
}


The error messages don't say much, but, I assume in the 1st case it
doesn't like the single dual-argument printk takes. In the 2nd case it
doesn't like the "__init".

I've included the correct "kernel/include" folder, and all my headers are
found. I'm able to, for example, right click the "__init" and "Open
Declaration" on it, and it correctly open's the "linux/init.h" file with
the correct macro highlighted.

Also the Error Parcers are working fine; all errors from the Makefile get
correctly put in the "Problems" view, and double clicking works on them.


So my only problem is the massive amount of "Syntax errors" I get with my
module. The syntax errors don't show up in problems view, and cleaning
the project doesn't remove them. Would anyone have any suggestions, I am
hoping for something like one of the following two solutions:

1. Plugin / Option / Project Type / etc, setting that I need to change so
that the Eclipse Editor recognizes the syntax.

2. A way to turn off the syntax error checking so that my file isn't
polluted with so much underlined yellow while I'm trying to develop,
however, keep the makefile error parcing.

Thanks in advance for any help/suggestions. I don't need any debug
support, just wish to be able to build in the IDE with some of the common
features (which are already working fine for me).
Re: Linux Kernel Module Development [message #235592 is a reply to message #235581] Tue, 07 July 2009 20:07 Go to previous messageGo to next message
Andrew Gvozdev is currently offline Andrew GvozdevFriend
Messages: 257
Registered: July 2009
Senior Member
DB wrote:

> printk(KERN_ALERT "Init - Cannot Allocate Buffers");
> or
> static int __init driver_init(void) {
>
> The error messages don't say much, but, I assume in the 1st case it
> doesn't like the single dual-argument printk takes. In the 2nd case it
> doesn't like the "__init".
>
> I've included the correct "kernel/include" folder, and all my headers are
> found. I'm able to, for example, right click the "__init" and "Open
> Declaration" on it, and it correctly open's the "linux/init.h" file with
> the correct macro highlighted.

Did you add your includes in "Paths and Symbols" correctly? It sounds like
you have a problem there. The fact that you able to navigate does not
prove that as it may use heuristics or the total index to find macros. You
defined it for C and C++, not for Assembler I hope.

> So my only problem is the massive amount of "Syntax errors" I get with my
> module. The syntax errors don't show up in problems view, and cleaning
> the project doesn't remove them. Would anyone have any suggestions, I am
> hoping for something like one of the following two solutions:

There are a few tricks to mitigate the annoyance.

> 1. Plugin / Option / Project Type / etc, setting that I need to change so
> that the Eclipse Editor recognizes the syntax.

You can "#define" the offending macros for the indexer to empty using
"Paths and Symbols" Symbols tab. Again, this setting is per language.

> 2. A way to turn off the syntax error checking so that my file isn't
> polluted with so much underlined yellow while I'm trying to develop,
> however, keep the makefile error parcing.

You can suppress indexer annotations via Preferences>General>Editors>Text
Editors>Annotations>C/C++ Indexer markers. I would disable Vertical and
Overview ruler but keep squiggly line for legitimate syntax errors. You
can change the color to less intrusive.

But this should not be necessary if include paths are set properly. CDT
should be able to parse the macros just fine if it is C syntax.

> Thanks in advance for any help/suggestions. I don't need any debug
> support, just wish to be able to build in the IDE with some of the common
> features (which are already working fine for me).


Thanks,
Andrew
Re: Linux Kernel Module Development [message #235598 is a reply to message #235592] Tue, 07 July 2009 22:58 Go to previous messageGo to next message
DB Mising name is currently offline DB Mising nameFriend
Messages: 11
Registered: July 2009
Junior Member
Andrew Gvozdev wrote:

> Did you add your includes in "Paths and Symbols" correctly? It sounds like
> you have a problem there. The fact that you able to navigate does not
> prove that as it may use heuristics or the total index to find macros. You
> defined it for C and C++, not for Assembler I hope.

I hope I did. I have it set for C & C++, and not Assembler. I should of
posted an example project in the first e-mail. Here is it:

http://www.mediafire.com/file/ohmdjdynzyy/hello_printk.zip

All I did was take the a "hello_printk.c / Makefile" I found online, added
to an Empty C eclipse makefile project and added
"/lib/modules/2.6.28-13-generic/build/include" as an include path for
C/C++. It compiles the "helloworld_printk.ko" file, and it works like
it's suppose to, however, you'll notice squiggly lines at various placing,
the most annoying being every line (even comments) in the init/exit
function's.

This is for a Ubuntu 9.04 Machine with Latest Eclipse and CDT 6.0. If
anyone knows my problem, any help would be appreciated.


The turn off annotation's works great as a temp solution in hiding the
problem. Thank you.

PS: My main development is modules for embedded devices, so the included
kernel source folder isn't in the same location as above, however, they
both have the exact same problem in eclipse.
Re: Linux Kernel Module Development [message #509037 is a reply to message #235598] Thu, 21 January 2010 09:08 Go to previous message
Shaun  is currently offline Shaun Friend
Messages: 3
Registered: November 2009
Junior Member
I had the same problem. I think it comes about because the Eclipse Indexer doesn't seem to import Makefile defines, and of course the kernel Makefile defines __KERNEL__. Simply add __KERNEL__ to your list of symbols (Project->Properties->C/C++ General->Paths and Symbols->#Symbols).

I've also added the kernel include directory to the project' Paths and Symbols 'GNU C' includes.
Previous Topic:Where do I go to get help with CDT?
Next Topic:Binary parser only works with linked output dirs
Goto Forum:
  


Current Time: Fri Dec 06 18:27:19 GMT 2019

Powered by FUDForum. Page generated in 0.01663 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top