Configure Netbeans / Eclipse for Linux Kernel Development

I am developing a Linux kernel and I am trying to use Netbeans. Despite the announced support for Make-based C-based projects, I cannot create a fully functional Netbeans project. This is despite the fact that Netbeans is parsing the kernel binary, which has been compiled with full debugging information. The problems include:

  • Files are mistakenly excluded . Some files are incorrectly deleted in the project, which means that Netbeans does not consider that they should be included in the project when in fact they are compiled into the kernel. The main problem is that Netbeans will skip any definitions that exist in these files, such as data structures and functions, but also skip the macro definitions.
  • cannot find a definition . Pretty clear. Often, Netbeans cannot find a definition of something. This is partly the result of the above problem.
  • can't find header files : by itself

I am wondering if anyone had success with configuring Netbeans to develop the Linux kernel, and if so, what settings did they use. Ultimately, I am looking for Netbeans to be able to either parse the Makefile (preferred) or extract debugging information from a binary file (less desirable, since this can slow down compilation significantly) and automatically determine which files are actually compiled and which macros are actually defined. Then, based on this, I would like to find definitions of any data structure, variables, functions, etc. And have full autocomplete.

Let me pose this question with some points:

  • I'm not interested in Vim / Emacs related solutions. I know people like them, but I'm not one of them.
  • As the name suggests, I would also be happy to know how to configure Eclipse to do what I need.
  • Although I would prefer the perfect coverage, one that only misses one in a million definitions is obviously fine.

SO the useful function "Related Questions" informed me that the following question is related: https://stackoverflow.com/questions/149321/what-ide-would-be-good-for-linux-kernel-driver-development . On reading, this question is rather comparable between the IDEs, while I'm looking for how to set up a specific IDE. Despite this, the Wade Mealing user seems to have experience with Eclipse in this development, so I will certainly be grateful for his (and, of course, all your) answers.

Greetings

+6
c eclipse linux-kernel
source share
6 answers

I wrote an answer earlier. Now I have come up with all the details of the solution and would like to share it. Unfortunately, stackoverflow does not allow me to edit the previous answer. Therefore, I am writing this in this new answer.

It includes several steps.


[1] The first step is to modify the linux scripts to leave the define files. By default, after they are used in the assembly, these deletion files are deleted. These dep files contain accurate dependency information that other files depend on. We need them to create a list of all the files involved in the assembly. Thus, modify the files under linux-xyz / scripts so that they do not delete the depot files:

linux-3.1.2/scripts Kbuild.include: echo do_not_rm1 rm -f $(depfile); Makefile.build: echo do_not_rm2 rm -f $(depfile); 

Other steps are described in detail in my github code project file https://github.com/minghuascode/Nbk/blob/master/note-nbkparse . About you:

[2] Customize using your customization method, but be sure to use the "O =" option to assemble the obj files in a separate directory.

[3] Then use the same option "O =" and "V = 1" to build linux and save the output to a file.

[4] Run my nbkparse script from the above github project. It does: [4.1] Read in the log file and depot files. Create a mirroring command. [4.2] Run the mirror command to hardlink the corresponding source files to a separate tree and create a make-log file for NetBeans.


Now create a NetBeans C project using the source mirror tree and the generated log file. NetBeans should be able to resolve all kernel characters. And you will see only the files involved in the assembly.

+2
source share

The Eclipse wiki has a page about this: HowTo use CDT to navigate the source of the Linux kernel

+1
source share

I am developing embedded linux. Including the development of the kernel module and importing all the source code of the Linux kernel into Eclipse, as a separate project. I have already built the kernel outside of Eclipse (for now), but I have no reason why I cannot configure the build environment in Eclipse to build the kernel. For my projects, while I'm setting up the PATH properties to point to the appropriate Linux source, including directories, it seems like it's pretty good to complete the name for structure fields, etc.

I cannot comment if he selects the correct definitions and does not select the appropriate sections, since I did not really pay much attention to the files inside the kernel itself. (till)

I was also interested in using Netbeans as the linux IDE, since I prefer developing Netbean for the Java GUI.

0
source share

I think this would work (each step for different projects):

[1] Modify kernel build scripts to leave .d files. By default, they are deleted. [2] Write the build process to a file. [3] Write a script to parse the build log. [3.1] From the build log you know all the .c files. [3.2] From the .c file, you know what the corresponding .d file is. [3.3] Browse .d files for all included .h files. [3.4] Create a complete list of .c and .h files. [4] Now create a new directory and use "ln -s" or "ln" to select the files of interest.

Now create a Netbeans project for existing source code in [4]. Configure code support to use the make-log file. You should see a precisely efficient source code, as when you created it in [2].

Some clarifications to the steps above:

In [2], perform a real build, so the log file contains the exact files and flags of interest. Netbeans will later be able to use exact flags for parsing.

In [4], select only the files you want to view. Including the entire kernel tree in netbeans will be impractical.

There is a trick for parsing .d files. Many of the dependent elements are not real paths to the .h file; they are a modified entry for part of the Linux configuration sections in the automatic configuration file. You may need to reverse the modification to determine what is the real header file.

There is actually a topic on the netbeans website. This is the discussion URL: http://forums.netbeans.org/ntopic3075.html . And there is a wiki page related to the discussion: wiki.netbeans.org/CNDLinuxKernel. Basically, it asks you for the make prefix with CFLAGS = "- g3 -gdwarf-2".

0
source share

I found this link very useful when setting up proper indexing in Eclipse. To do this, you need to run a script to change the Eclipse environment to fit your kernel parameters, in my case

$ autoconf-to-eclipse.py. / include / generated / autoconf.h.

Illustrated linux kernel indexing guide in eclipse

0
source share

All Articles