Author Topic: How to edit linux kernel sources with code::blocks ?  (Read 15876 times)

Offline Brane2

  • Multiple posting newcomer
  • *
  • Posts: 34
How to edit linux kernel sources with code::blocks ?
« on: December 05, 2007, 08:47:57 am »
I have tried to use CB for kernel sources exporation, but it seems I ahve been going about it in wrong way.

I have unpacked sources in some directory X, then made new empty project with root in that directory and then tried to recursively add kernel's files to that project.

It worked for a first few maps with sources in X, but when quantity of files reasched over 27 k files, CB have just froze. It just never finished scanning phase.

I tried also to recursively add map X to the project, with same results.

I'm not interested in using C::B for building kernel ( although that would be nice ), just for helping me navigate files and function/variable/etc search etc...

Offline Brane2

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: How to edit linux kernel sources with code::blocks ?
« Reply #1 on: July 23, 2008, 11:22:46 pm »
I am bumping OP now.

I am now at svn version 5159 and it still doesn't work . I can add recursively into the project several maps, but when number of project files get into 10.000 range Codeblcks freeezes.

Am I doing something wrong ? I just want to have kernel sources opened as a project in order to be able to quickly find function and variable declarations & definitions etc etc.

It is not as if I asked the IDE to open all the sources simulatneously, just to add them to the project.

I understand that IDE has to scan them in order to have "map of variables etc", but since I have QC machine with 4Gig of RAM and plenty of swap and since all the kernel files combined take some ~1G, I don't understand why the program is choking with that.

Any ideas  ?

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: How to edit linux kernel sources with code::blocks ?
« Reply #2 on: July 24, 2008, 11:43:22 am »
My guess would be that the code completion plugin runs out of physical memory, it uses quite a lot of memory even for significantly less than 27,000 files. Normally that doesn't matter, but Linux is a lot of stuff, obviously.
Try if you get farther after disabling the code completion plugin.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Brane2

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: How to edit linux kernel sources with code::blocks ?
« Reply #3 on: July 24, 2008, 03:23:47 pm »
Now, this totally baffles me.

I never thought that something might be wrong with plugins, so after peeking inside my script for setting things for configuring and compiling, I saw that I configured it with "--with-contrib-plugins=all" and I have all plugins active.

So I tried to disable them all, but CB then crashed n exit. So I disabled most of the plugins ( but left a few I felt are essential ) and everything started to work !

I could start empty project and import whole kernel sources into it ( some 20 k files ).

Funny thing is, code completion doesn't seem to be the culprit. Even more, even as I enabled all plugins back, emptied the project and reimported everything back, everything worked ! Import is slow, but once it is finished, it works. It seems that some of the plugins keep doing something in the background as CB starts eating some 5% CPU time for maybe 30sec every two minutes or so...

When starts, CB alone eats some 30MB. With all modules active that climbs to some 1.2G after importing whole kernel .

System works fine and not in any way pressed for memory - it seems that memory is swappable, so there seems to be no problem now...

Anyway, many thanks for the advice. It worked. I have no idea how, but the effect is certainly welcome ;o)



Offline Der Meister

  • Regular
  • ***
  • Posts: 307
Re: How to edit linux kernel sources with code::blocks ?
« Reply #4 on: July 24, 2008, 04:57:56 pm »
Just out of curiosity: Do you know which plugin is the problematic one? And if not, do you have any time to do some more testing? Would be quite helpfull to know the problematic plugin to remove this bottleneck, if possible.
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand.
Real Programmers don't write in BASIC. Actually, no programmers write in BASIC, after the age of 12.

Offline Brane2

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: How to edit linux kernel sources with code::blocks ?
« Reply #5 on: July 24, 2008, 05:49:52 pm »
No. After compiling, all plugins were enabled and that didn't work.

After that, I disabled many of them and things started to work.

I gradually enabled all of the plugins and CB still works.

It seems as if the error manifests itself at specific plugin loading sequence...

Offline Brane2

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: How to edit linux kernel sources with code::blocks ?
« Reply #6 on: July 25, 2008, 12:32:16 am »
I can't replicate starting condition.

I even unisntalled C::B, configured and compile dit again and it now works out of the box with all plugins enabled....  :? :)

Offline Brane2

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: How to edit linux kernel sources with code::blocks ?
« Reply #7 on: July 29, 2008, 05:19:13 am »
Hmm.

I have just noticed that I can't really disable "valgrind" plugin since C::B crashes immediatelly after that.
I have noticed that before, but have thought that maybe it's some system critical plugin, but after a second thought it doesn't seem logical.
I don't use valgrind.

Now I am using svn copy of C::B ( v5170 ATM), compiled with gcc-4.3.1 on Linux, but those two parameters don0t seem to be crucial for this error - e have seen it n previous svn versions, compiled with gcc-4.2.4

Offline Brane2

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: How to edit linux kernel sources with code::blocks ?
« Reply #8 on: June 08, 2009, 10:27:32 am »
Well, after bazzillion retries and even running whole thing under gdb all I can say it seems to be some race condition inside impore function.

I'm not much into C++ and wxwidgets and can not find my way through source, but:

- when it happens, error is manifested as an access to invalid memory location
- execution stack at error point never has any function that has to do with wxGTK whatsoever.
- error is not readily repeatable. Sometimes it happens, sometimes not. Sometimes it gets much more often if codeblocks is compiled with -O2 or higher, sometimes gcc version has significant difference ( it crashes more/less frequently etc)
-whatever I do, if I want to have a chance of succesfull kernel import, I have to have the system totally idle otherwise ( no browsing with Firefox, not even Firefox open, especially with some page with animation, javascripts etc).

Maybe it is due my Phenom with 4 cores and L3 cache ( if that makes any difference ).

Since that error started manifesting itself many months ago, I went through a few versions of practically every software I have on my machine ( Gentoo Linux 64bit , weekly update), so it is not likely that particular version of some system library is the culprit...


Offline Dr.Optix

  • Multiple posting newcomer
  • *
  • Posts: 30
  • I'm studying OS Developing.
    • DrOptix Blog
Re: How to edit linux kernel sources with code::blocks ?
« Reply #9 on: June 08, 2009, 11:58:56 am »
It may be the TODO List plugin who made your C::B freeze. I'm not sure but I've seen that for one of my projects (around 30 files in total) it took quite longer to parse all the files to find TODO NOTE or FIXME information.

~Dr.Optix
Occupation: Hobby Programmer
IDE: Code::Blocks Nightly / CodeLite Latest Stable
Compiler: TDM's GCC/mingw32
Blog: DrOptix.WordPress.Com

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: How to edit linux kernel sources with code::blocks ?
« Reply #10 on: June 08, 2009, 12:15:54 pm »
I just tested on my laptop (debian unstable/experimental, 64-bit, Core2Duo 2x2GHz, T7200, 3.3MB usable RAM, 4 MB Cache).
I created an empty project, clicked add files recursively adn left all as C::B has chosen, that means just the default filetypes were added.

I attach a screenshot of the code-stats ("only" a little more than 21k files here, debian linux source 2.6.29-5).

Here is the output:
Code: [Select]
Loading project file...
Parsing project file...
Loading target Debug
Loading target Release
Loading project files...
21644 files loaded
Done loading project in 13874ms
Project's base path: /home/jens/kernel-tmp/
Project's common toplevel path: /home/jens/kernel-tmp/
Add project test in parsing queue
Caching internal gcc dirs for adding to parser...
Caching GCC dir: /usr/include/c++/4.4
Caching GCC dir: /usr/include/c++/4.4/x86_64-linux-gnu
Caching GCC dir: /usr/include/c++/4.4/backward
Caching GCC dir: /usr/lib/gcc/x86_64-linux-gnu/4.4.0/include
Caching GCC dir: /usr/lib/gcc/x86_64-linux-gnu/4.4.0/include-fixed
Caching GCC dir: /usr/include/x86_64-linux-gnu
Caching GCC dir: /usr/include
Passing list of files to parse
Starting batch parsing
Parsing stage done (22380 total parsed files, 913739 tokens in 1 minute(s), 14.287 seconds).
Updating class browser...
Class browser updated.

svn r5616 against wxWidgets 2.8.10, build with gcc 4.3.2

All with ToDo-plugin enabled, but ToDo list closed and only parsing open files.
I tried to parse all project-files with ToDo-plugin, but cancelled, because it needs a really long time and does not make sense.

[attachment deleted by admin]

Offline Brane2

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: How to edit linux kernel sources with code::blocks ?
« Reply #11 on: June 08, 2009, 12:19:08 pm »
Nope. I've just checked and it's inactive.

Besides, I've tried to turn off everything I could and thing was still crashing.

Obviously, since code completion was the whole point, I've left that one on...

Offline Brane2

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: How to edit linux kernel sources with code::blocks ?
« Reply #12 on: June 08, 2009, 12:23:09 pm »
I just tested on my laptop (debian unstable/experimental, 64-bit, Core2Duo 2x2GHz, T7200, 3.3MB usable RAM, 4 MB Cache).
I created an empty project, clicked add files recursively adn left all as C::B has chosen, that means just the default filetypes were added.

I attach a screenshot of the code-stats ("only" a little more than 21k files here, debian linux source 2.6.29-5).


Have you waited just for the left window manager to show imported filenames or did you wait some more for C::B to finish scanning in the background and release CPU ?
Also, can you try saving the project and then reopen it a couple of times, preferably on somewhat loaded system ( e.g while playing some movie in vlc or somesuch ) ?

Offline Brane2

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: How to edit linux kernel sources with code::blocks ?
« Reply #13 on: June 08, 2009, 01:02:14 pm »
Hmm.

I have same OS ( Gentoo 64-bit) on my laptop ( Dell Inspiron 1720, CPU: Intel T8300 - 2.4GHz, 4GB RAM) and C::B works there flawlessly.

I have imported whole kernel, then saved project and then re-opened it some 5 times without any problem.

i'm beginnig to thint issue might be either some bug or feature in my Phenom 9950 in desktop or is it some issue with QC proc in general.

Could someone with Phenom or Intel QC chip try same thing ?
« Last Edit: June 08, 2009, 01:20:02 pm by Brane2 »

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: How to edit linux kernel sources with code::blocks ?
« Reply #14 on: June 08, 2009, 01:29:09 pm »
I tested again under heavy load (compiling 32- and 64-bit debian-packages of C::B at once in pbuilder chroots) and doing normal work.

3:50 min to load the project and end batch parsing if symbols browser is disabled (CC on) and 7:22 min if symbols browser is enabled and should show everything.

But system is stable and no additional latencies when working with other programs.
System memory used unless about 200~300  kb. As good as no swapping needed (140 kb of swap space used).