Skip to main content
Jump to: navigation, search

Difference between revisions of "HowTo use the CDT to navigate Linux kernel source"

(Simplified instructions, because of bug-ridden configuration management in Eclipse, and also used Advance Settings so as not to have to stop the indexing.)
Line 16: Line 16:
 
#Select '''Resource''' on the left, and then in the '''Text file encoding''' section, select '''Other''' and '''ISO-8859-1''' in the box, then click '''Apply'''
 
#Select '''Resource''' on the left, and then in the '''Text file encoding''' section, select '''Other''' and '''ISO-8859-1''' in the box, then click '''Apply'''
 
#Select '''C/C++ Build''' on the left.
 
#Select '''C/C++ Build''' on the left.
#Click the '''Manage Configurations''' at the top right.
 
#Click '''New...'''
 
#Give it a name like ''Linux config'' and a similar description, and click '''OK'''
 
#Select your new configuration, and click '''Set Active''' and then '''Apply'''
 
 
#Open the '''C/C++ General''' selection on the left.
 
#Open the '''C/C++ General''' selection on the left.
 
#Click on '''Indexer'''
 
#Click on '''Indexer'''
Line 25: Line 21:
 
#Uncheck '''Index source files not included in the build'''
 
#Uncheck '''Index source files not included in the build'''
 
#Clear out the '''Files to index up-front''' box.
 
#Clear out the '''Files to index up-front''' box.
#Select '''Use active build configuration''' at the bottom, and click '''Apply'''
 
 
#Click on '''Paths and Symbols''' on the left.  
 
#Click on '''Paths and Symbols''' on the left.  
 
#Select the '''Includes''' tab and then select '''GNU C'''  
 
#Select the '''Includes''' tab and then select '''GNU C'''  
Line 40: Line 35:
 
#Click '''Add Multiple...''' and then select all of the {{Code|arch/*}} directories in your kernel source that will not be used (i.e. all the ones that are not for the architecture you are using)  
 
#Click '''Add Multiple...''' and then select all of the {{Code|arch/*}} directories in your kernel source that will not be used (i.e. all the ones that are not for the architecture you are using)  
 
#Click '''OK''' and '''OK''' again to dismiss that dialog.  
 
#Click '''OK''' and '''OK''' again to dismiss that dialog.  
#Click '''OK''' on the Properties dialog.  
+
#Click '''OK''' on the Properties dialog.
#Right click on the project again and select '''Index''' then select '''Rebuild'''  
+
#Click '''Finish''' on the C Project dialog.
 +
#Right click on the project and select '''Index''' then select '''Rebuild'''  
 
#It will take about 20 minutes or so to complete.
 
#It will take about 20 minutes or so to complete.
  
 
Corey Ashford [mailto:cjashfor@us.ibm.com cjashfor@us.ibm.com]
 
Corey Ashford [mailto:cjashfor@us.ibm.com cjashfor@us.ibm.com]

Revision as of 17:55, 19 February 2010

Here are some steps that I've found to get the CDT to work well with the Linux kernel source. If you exclude some of these steps, it may still work to a large degree, but some things may not work exactly right; for example it may find the wrong include file for a C file.

Anyway, as you do these steps, I think you may understand how they assist the indexer to do a good job for the Linux kernel source.

Disclaimer: these steps were developed for Eclipse 3.5.1 + CDT 6.0.0.

  1. Download and install Eclipse plus the CDT.
  2. Configure and build your kernel. This can be done before or after downloading and installing Eclipse.
  3. Start up Eclipse.
  4. Click File->New->C Project
  5. Fill in a project name like my_kernel
  6. Uncheck the Use default location box and type in the root directory of your kernel into the Location box.
  7. In the Project type: pane, click the Makefile project and select Empty Project
  8. On the right side, select Linux GCC
  9. Click Advanced settings... and a Properties dialog will pop up.
  10. Select Resource on the left, and then in the Text file encoding section, select Other and ISO-8859-1 in the box, then click Apply
  11. Select C/C++ Build on the left.
  12. Open the C/C++ General selection on the left.
  13. Click on Indexer
  14. Checkmark the Enable project specific setttings box.
  15. Uncheck Index source files not included in the build
  16. Clear out the Files to index up-front box.
  17. Click on Paths and Symbols on the left.
  18. Select the Includes tab and then select GNU C
  19. Click Add...
  20. Click Workspace... then select your kernel's include directory
  21. Do another Add, Workspace and add arch/architecture/include, e.g., arch/powerpc/include
  22. Click the # Symbols tab
  23. Click Add...
  24. Set the name to __KERNEL__
  25. Set the value to 1 and click OK
  26. Click the Source Location tab
  27. Click the twisty for your project.
  28. Select the Filter item and click Edit Filter...
  29. Click Add Multiple... and then select all of the arch/* directories in your kernel source that will not be used (i.e. all the ones that are not for the architecture you are using)
  30. Click OK and OK again to dismiss that dialog.
  31. Click OK on the Properties dialog.
  32. Click Finish on the C Project dialog.
  33. Right click on the project and select Index then select Rebuild
  34. It will take about 20 minutes or so to complete.

Corey Ashford cjashfor@us.ibm.com

Back to the top