Developing Linux Kernel with Netbeans

Introduction#

This tutorial shows how to develop Linux kernel with Netbeans. It contains not only information how to create simple "hello world" module, but complete step-by-step guide how-to:
  • build Kernel trunk for developing,
  • debug kernel start up,
  • debug parts of kernel.



Netbeans IDE#Pre requirements #

It's one of two most important thing :) you need to get it before proceed. Download IDE from  http://www.netbeans.org  (we use 7.0 version) - You don't need to download full version. After installation go to Tools -> Plugins  and install (if not installed) following additions:
  • C/C++
  • Gdbserver
Configuration#
Working with C/C++ projects may require tuning JVM, and assigning greater heap size. We use following options added in  <Netbeans Install Dir>/etc/netbeans.conf  under key  netbeans_default_options
-J-XX:+UseCompressedOops -J-XX:+UnlockExperimentalVMOptions -J-XX:+UseG1GC 
above will reduce memory usage in 64bit virtual machines (by using 32bit pointers), unlock experimental features, and turn on quite good G1 Garbage Collector
-J-mx1g -J-XX:MaxPermSize=412m -J-Xms512m
and those sets maximum heap size to 1GB, maximum Perm size to 412 MB, and initial heap size to 512 MB

Linux Kernel Sources#

This is 2nd most important things. You may download source archive, or grab current version from git (when we wrote this, we used this command)
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git linux-2.6
Configure kernel#
Execute
make oldconfig
to configure kernel as your current configuration.

Now open configuration editor, if you have Qt/KDE installed call

make xconfig
in other cases call
make menuconfig
Disable all unneeded features, drivers, etc. If you don't make this parsing of sources, and build time may drastically increase - remove such things like Blluetooth, WiFi, all file systems except Ext2/3/4, NFS, sound cards support, PPP support, etc. Just keep this what you need.
Select at least following options
Kernel hacking
|- Debug Filesystem
|- Kernel debugging
|- Verbose BUG() reporting
|- Compile the kernel with debug info
|- Compile the kernel with frame pointers
Options  Compile the kernel with debug info Compile the kernel with frame pointers  are crucial.

Additionally you make edit Makefile and replace all -O2 to -O1 to reduce optimization.

At this point Your kernel source should be ready for working, but do not open your project in Netbeans yet.

qEmu / KVM#

qEmu  or  KVM  are virtual machines, we will use to run kernel.  qEmu  mainly doesn't support hardware acceleration of virtualization tasks, but have ability to emulate more architectures.  KVM  may be faster, but will only emulate your host system architecture. At least one of this must be installed.
KVM - Hardware acceleration of virtualization#
KVM  stands for Kernel Virtual Machine; it uses processor extension, found on almost all Intel(r) and AMD(r), to speed up running in virtual machine. In order to give support for  KVM  You need to:
  • Compile kvm modules in your system kernel. Probably your host kernel has it, if not enable it in configuration editor, giving support for Intel or AMD or both technologies.
  • Load modules as root invoke commands modprobe kvm-intel, or modprobe kvm-amd.
  • You need to have special privileges to use KVM as normal user, in many systems add your user to
kvm  group (sometimes you will need to relog).

Please bear in mind, that depending on systems, kvm may be called by different commands:

kvm, quem-kvm    

Otehrs#

  • Set of developer tools - including gcc, make
  • small and fast Linux distribution - it will be used as our test environment, we prefer Gentoo stage 3,
because it starts fast and may be nicely customized form useless services or start options. But... the best distribution is always those you know!

Building with Netbeans#

Note
In this tutorial we use mainly  qemu-system-x86_64  command to invoke qemu/kvm virtual machine, both of those have same set of options (at least for this tutorial), depending on virtual machine You choose You may replace  qemu-system-x86_64 , by
kvm, qemu-kvm

Compile kernel#

You should first build your kernel. Go to source tree and invoke
    make -j5
The  -j5  informs  make  how much tasks should it span. We use 5 tasks, bear in mind following rule  number of task = number of CPU or cores + 1

Running QEmu#

We use following call (from kernel source directory)
qemu-system-x86_64 -hda /dev/zero -kernel arch/x86/boot/bzImage --no-acpi -s -S
options have following meaning:
-hda /dev/zero
Use  /dev/zero as your disk (at this moment we don't want usable hard disk)
-kernel arch/x86/boot/bzImage
Loads specified kernel
--no-acpi
Do not use ACPI
-S
Do not start CPU
-s
Open GDB server at port 1234
If you develop x86 (32 bit) you may call instead of  qemu-system-x86_64 , just  qemu

Now invoke above command without debug help (no -s -S). You should see how kernel starts, and crashes as it have no root file system.


Opening Linux kernel in Netbeans
#

  • Choose File -> New project, select C/C++ Project From Existing Sources, click Next.
  • Enter (or browse for) path where your kernel source exists.
  • Select Custom configuration. Click Next.
  • Disable Clean and Build after Finish (You have already kernel build). Click Next.
  • On Build actions step, point Build result to vmlinux file, which should resides in your source directory (after build). Click Next.
  • Click Next till last step. Do not finish yet!

You may need to do following action fast (to reduce Netbeans memory consumption on project parsing).

Right click on Your newly created project, Choose Code Assistance, unmark C/C++ Code Assistance.



Netbeans should not parse code, ok. Now, ight click on Your newly created project, Choose Code Assistance, and select Configure code assistance.

  • Choose Advance mode, click Next.
  • Select Explore executable or library file, click Next.
  • In Select executable or library file browse for vmlinux (like when you had configured project), click Next.
  • Select Configure Folder Properties, click Next, then Finish.
Now enable Code Assistance for this project (right click on Your newly created project, Choose  Code Assistance , mark  C/C++ Code Assistance ). Netbeans should start scanning and parsing.
Now You are ready to debug Linux kernel in Netbeans.

Lunching and debugging#

Actually I prefer building kernel in console instead of using Netbeans, but you may build it with Netbeans.
  • Open console and invoke qemu, this time use debugging switches (-s -S). Qemu should freeze.
  • Select Debug -> Attach debugger..., or click on small arrow on right of Debugging button on toolbar.
  • Select Gdbserver and enter Host: 127.0.0.1, Port: 1234


You attached to debugger - You should see Disassembly window and.

As the test, close Disassembly window, open ipc/shm.c, navigate to shm_init method, and put breakepoint on 1st line in this method. Click continue (or press F5). You should see result as on the top of this article!


 reference: Developing Linux Kernel with Netbeans

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
4S店客户管理小程序-毕业设计,基于微信小程序+SSM+MySql开发,源码+数据库+论文答辩+毕业论文+视频演示 社会的发展和科学技术的进步,互联网技术越来越受欢迎。手机也逐渐受到广大人民群众的喜爱,也逐渐进入了每个用户的使用。手机具有便利性,速度快,效率高,成本低等优点。 因此,构建符合自己要求的操作系统是非常有意义的。 本文从管理员、用户的功能要求出发,4S店客户管理系统中的功能模块主要是实现管理员服务端;首页、个人中心、用户管理、门店管理、车展管理、汽车品牌管理、新闻头条管理、预约试驾管理、我的收藏管理、系统管理,用户客户端:首页、车展、新闻头条、我的。门店客户端:首页、车展、新闻头条、我的经过认真细致的研究,精心准备和规划,最后测试成功,系统可以正常使用。分析功能调整与4S店客户管理系统实现的实际需求相结合,讨论了微信开发者技术与后台结合java语言和MySQL数据库开发4S店客户管理系统的使用。 关键字:4S店客户管理系统小程序 微信开发者 Java技术 MySQL数据库 软件的功能: 1、开发实现4S店客户管理系统的整个系统程序; 2、管理员服务端;首页、个人中心、用户管理、门店管理、车展管理、汽车品牌管理、新闻头条管理、预约试驾管理、我的收藏管理、系统管理等。 3、用户客户端:首页、车展、新闻头条、我的 4、门店客户端:首页、车展、新闻头条、我的等相应操作; 5、基础数据管理:实现系统基本信息的添加、修改及删除等操作,并且根据需求进行交流信息的查看及回复相应操作。
现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本微信小程序医院挂号预约系统就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此微信小程序医院挂号预约系统利用当下成熟完善的SSM框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的MySQL数据库进行程序开发。微信小程序医院挂号预约系统有管理员,用户两个角色。管理员功能有个人中心,用户管理,医生信息管理,医院信息管理,科室信息管理,预约信息管理,预约取消管理,留言板,系统管理。微信小程序用户可以注册登录,查看医院信息,查看医生信息,查看公告资讯,在科室信息里面进行预约,也可以取消预约。微信小程序医院挂号预约系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值