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

Offline Brane2

  • Multiple posting newcomer
  • *
  • Posts: 39
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: 39
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: 39
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: 39
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: 39
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: 39
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: 39
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 Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
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
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: 39
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: 39
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: 39
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 Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
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).

Offline Brane2

  • Multiple posting newcomer
  • *
  • Posts: 39
Re: How to edit linux kernel sources with code::blocks ?
« Reply #15 on: August 06, 2009, 06:47:53 am »
I have got myself Phenom II X4 955 and recompiled whole Gentoo system.

Error is still here. It feels like a race condition of some sort and it seems it is specific aither to AMD or native Quad Core machines.

Can anyone try this on similar machine ?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to edit linux kernel sources with code::blocks ?
« Reply #16 on: August 06, 2009, 01:22:29 pm »
Are you sure, that you system is stable? You can try prime95 (emerge gimple if I remember correctly) for some hours and memtest86.
But if you have done emerge -e world --jobs=5 successfully, I would say that your system is stable.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Brane2

  • Multiple posting newcomer
  • *
  • Posts: 39
Re: How to edit linux kernel sources with code::blocks ?
« Reply #17 on: August 06, 2009, 01:38:58 pm »
System is stable.

I have done memtest86+ checking over night, and reemerged everything with :

emerge -eD --jobs=32 world (MAKEOPTS= -j9)

without a problem.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How to edit linux kernel sources with code::blocks ?
« Reply #18 on: August 06, 2009, 05:05:54 pm »
Can you provide a backtrace if C::B crashes, or do you have a debug report in "/tmp/codeblocks-dbg..." or something like this (don't know the exact location at the moment) ?
If yes please attach it.

Offline Brane2

  • Multiple posting newcomer
  • *
  • Posts: 39
Re: How to edit linux kernel sources with code::blocks ?
« Reply #19 on: August 07, 2009, 06:42:01 am »
When it crashes, it (sometimes) manages to write report in /tmp/codeblocks_dbgrpt_XXXX:200908ddTzzzzzz.

I recompiled glibc,glib,gtk+ and wxGTK with -ggdb in order to get debug symbols.

I ran it under gdb, but since C::B opens a few threads, it is unclear to me which thread did trigger SIGSEGV (Segmentation fault), altough my bet would be on default, 6-th thread:


Quote
(gdb) info threads
  7 Thread 0x7f8ac505d910 (LWP 22977)  0x00007f8adc9c4fe9 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
* 6 Thread 0x7f8ace048910 (LWP 22974)  0x00007f8adccca0cb in wxEvent::wxEvent () from /usr/lib/libwx_baseu-2.8.so.0
  5 Thread 0x7f8acfef1910 (LWP 22973)  0x00007f8adc9c4fe9 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  4 Thread 0x7f8ad06f2910 (LWP 22972)  0x00007f8adc9c4fe9 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  3 Thread 0x7f8ad0ef3910 (LWP 22971)  0x00007f8adc9c4fe9 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  2 Thread 0x7f8ad16f4910 (LWP 22970)  0x00007f8adc9c4fe9 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
  1 Thread 0x7f8adf4f77a0 (LWP 22947)  0x00007f8ad63a4327 in _XPutXCBBuffer () from /usr/lib/libX11.so.6

Here are frames of all threads:

thread 1:

Quote
(gdb) info stack
#0  0x00007f8ad63a4327 in _XPutXCBBuffer () from /usr/lib/libX11.so.6
#1  0x00007f8ad63a4855 in ?? () from /usr/lib/libX11.so.6
#2  0x00007f8ad637b02e in XDefineCursor () from /usr/lib/libX11.so.6
#3  0x00007f8adb49ac29 in ?? () from /usr/lib/libgdk-x11-2.0.so.0
#4  0x00007f8add79561a in wxWindow::OnInternalIdle () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#5  0x00007f8add7fc7bd in wxAppBase::SendIdleEvents () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#6  0x00007f8add7fc7f4 in wxAppBase::SendIdleEvents () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#7  0x00007f8add7fc7f4 in wxAppBase::SendIdleEvents () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#8  0x00007f8add7fc7f4 in wxAppBase::SendIdleEvents () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#9  0x00007f8add7fc7f4 in wxAppBase::SendIdleEvents () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#10 0x00007f8add7fca54 in wxAppBase::ProcessIdle () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#11 0x00007f8add76bae3 in ?? () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#12 0x00007f8ad993ddc3 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#13 0x00007f8ad99413f0 in ?? () from /usr/lib/libglib-2.0.so.0
#14 0x00007f8ad99417f5 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
#15 0x00007f8adb801a6f in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
#16 0x00007f8add78305a in wxEventLoop::Run () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#17 0x00007f8add7fc88c in wxAppBase::MainLoop () from /usr/lib/libwx_gtk2u_core-2.8.so.0
#18 0x0000000000431db0 in CodeBlocksApp::OnRun (this=0x807458) at app.cpp:765
#19 0x00007f8adcc6faac in wxEntry () from /usr/lib/libwx_baseu-2.8.so.0
#20 0x0000000000431972 in main (argc=1, argv=0x0) at app.cpp:256

thread 2:

Quote
(gdb) info stack
#0  0x00007f8adc9c4fe9 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
#1  0x00007f8adccc7c93 in wxConditionInternal::Wait () from /usr/lib/libwx_baseu-2.8.so.0
#2  0x00007f8adccc8cd9 in wxSemaphoreInternal::Wait () from /usr/lib/libwx_baseu-2.8.so.0
#3  0x00007f8adef3ae49 in BackgroundThread::Entry (this=0xc77178) at ./backgroundthread.h:151
#4  0x00007f8adccc99c1 in wxThreadInternal::PthreadStart () from /usr/lib/libwx_baseu-2.8.so.0
#5  0x00007f8adc9c0644 in start_thread () from /lib/libpthread.so.0
#6  0x00007f8adbd8436d in clone () from /lib/libc.so.6
#7  0x0000000000000000 in ?? ()

thread 3:
Quote
(gdb) info stack
#0  0x00007f8adc9c4fe9 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
#1  0x00007f8adccc7c93 in wxConditionInternal::Wait () from /usr/lib/libwx_baseu-2.8.so.0
#2  0x00007f8adccc8cd9 in wxSemaphoreInternal::Wait () from /usr/lib/libwx_baseu-2.8.so.0
#3  0x00007f8adef3ae49 in BackgroundThread::Entry (this=0xc771b0) at ./backgroundthread.h:151
#4  0x00007f8adccc99c1 in wxThreadInternal::PthreadStart () from /usr/lib/libwx_baseu-2.8.so.0
#5  0x00007f8adc9c0644 in start_thread () from /lib/libpthread.so.0
#6  0x00007f8adbd8436d in clone () from /lib/libc.so.6
#7  0x0000000000000000 in ?? ()

thread 4:

Quote
(gdb) info stack
#0  0x00007f8adc9c4fe9 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
#1  0x00007f8adccc7c93 in wxConditionInternal::Wait () from /usr/lib/libwx_baseu-2.8.so.0
#2  0x00007f8adccc8cd9 in wxSemaphoreInternal::Wait () from /usr/lib/libwx_baseu-2.8.so.0
#3  0x00007f8adef3ae49 in BackgroundThread::Entry (this=0xc771e8) at ./backgroundthread.h:151
#4  0x00007f8adccc99c1 in wxThreadInternal::PthreadStart () from /usr/lib/libwx_baseu-2.8.so.0
#5  0x00007f8adc9c0644 in start_thread () from /lib/libpthread.so.0
#6  0x00007f8adbd8436d in clone () from /lib/libc.so.6
#7  0x0000000000000000 in ?? ()


thread 5:

Quote
(gdb) info stack
#0  0x00007f8adc9c4fe9 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
#1  0x00007f8adccc7c93 in wxConditionInternal::Wait () from /usr/lib/libwx_baseu-2.8.so.0
#2  0x00007f8adccc8cd9 in wxSemaphoreInternal::Wait () from /usr/lib/libwx_baseu-2.8.so.0
#3  0x00007f8adef3ae49 in BackgroundThread::Entry (this=0xc77220) at ./backgroundthread.h:151
#4  0x00007f8adccc99c1 in wxThreadInternal::PthreadStart () from /usr/lib/libwx_baseu-2.8.so.0
#5  0x00007f8adc9c0644 in start_thread () from /lib/libpthread.so.0
#6  0x00007f8adbd8436d in clone () from /lib/libc.so.6
#7  0x0000000000000000 in ?? ()

thread 6:

Quote
(gdb) info stack
#0  0x00007f8adccca0cb in wxEvent::wxEvent () from /usr/lib/libwx_baseu-2.8.so.0
#1  0x00007f8adefb7694 in CodeBlocksEvent::Clone (this=0x7f8ace047f20) at /usr/include/wx-2.8/wx/event.h:526
#2  0x00007f8adccca714 in wxEvtHandler::AddPendingEvent () from /usr/lib/libwx_baseu-2.8.so.0
#3  0x00007f8adeec952d in cbThreadPool::TaskDone (this=0x109ddf0, thread=<value optimized out>) at /usr/include/wx-2.8/wx/event.h:2570
#4  0x00007f8adeec999f in cbThreadPool::cbWorkerThread::Entry (this=0x10664e0) at cbthreadpool.cpp:236
#5  0x00007f8adccc99c1 in wxThreadInternal::PthreadStart () from /usr/lib/libwx_baseu-2.8.so.0
#6  0x00007f8adc9c0644 in start_thread () from /lib/libpthread.so.0
#7  0x00007f8adbd8436d in clone () from /lib/libc.so.6
#8  0x0000000000000000 in ?? ()

thread 7:

Quote
(gdb) info stack
#0  0x00007f8adc9c4fe9 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
#1  0x00007f8adccc7c93 in wxConditionInternal::Wait () from /usr/lib/libwx_baseu-2.8.so.0
#2  0x00007f8adccc8cd9 in wxSemaphoreInternal::Wait () from /usr/lib/libwx_baseu-2.8.so.0
#3  0x00007f8ace097be2 in ClassBrowserBuilderThread::Entry (this=0x18ffcc0) at classbrowserbuilderthread.cpp:121
#4  0x00007f8adccc99c1 in wxThreadInternal::PthreadStart () from /usr/lib/libwx_baseu-2.8.so.0
#5  0x00007f8adc9c0644 in start_thread () from /lib/libpthread.so.0
#6  0x00007f8adbd8436d in clone () from /lib/libc.so.6
#7  0x0000000000000000 in ?? ()


I have also attached also a couple of xml bug_reports ( renamed to txt to get by forum filters ).





[attachment deleted by admin]

Offline Brane2

  • Multiple posting newcomer
  • *
  • Posts: 39
Re: How to edit linux kernel sources with code::blocks ?
« Reply #20 on: October 01, 2009, 09:27:52 pm »
I've tried to crack this with gdb, but failed so far.

Latest changes in svn tree seem to have fixed it, whatever it was.

I have imported whole tree into an empty project, saved it, closed it and opened itd. Several times, without failure.

It seems that it is working now. It is slooooow as molasses, but it works.

BTW: Maybe endless object creation and destruction in C++ isn't such good idea after all ?

Same thing, written in decent C would simply fly...