Archive for the ‘Windows’ Category
For my C projects I was using Notepad++ as my editor/IDE for some time. Although notepad++ is good, it is lacking the integration with a code browser, source control and debugger. I came to know about a new IDE – CodeLitewhen I was searching for ctags for windows. It has integrated support for Subversion, ctags, gdb.
Since it is advertised to have multi-platform GUI, I was little reluctant to install and try(I have tried lot of multi-platform GUI applications and never satisfied with the look and feel of them). But wxWidgets makes the CodeLite to look like native windows application. CodeLite has lot of features and it looks very similar to Microsoft VC++ IDE.
Code browsing is very easy with CodeLite. It is has a very light explorer and also workspace view through which you can browse your project “easily”. You can switch between header and c file “easily” using the “Swap Header/implementation file” in the context menu. Context menus “Goto declaration” and “Goto Implementation” are handy to browse through code quickly.
If you are using cygwin and custom makefile – you can use a script as custom build command – see Notepad++ as IDE post for more details.
I use the following command to build(because I use gcc cross compiler)
c:\cygwin\bin\bash -l -c 'cd $ACE_ROOT/src;PATH=/usr/cross/i586-elf/bin/:$PATH:;make 2> err; sed -e "s@\(\/cygdrive\/\)\([a-zA-Z]\)@\2:@g" err; rm err’.
And the following command to clean
c:\cygwin\bin\bash -l -c 'cd $ACE_ROOT/src;PATH=/usr/cross/i586-elf/bin/:$PATH:;make clean’
Codelite supports debugging through gdb; embedded and remote targets also supported. Since I am using a emulator to test my kernel, I have to use remote debugging in GDB to test my OS. Codelite integrates well with GDB remote debugging. I use the following GDB commands as startup gdb commands.
set print pretty on directory src/kernel symbol obj/kernel.sys source img/gdb/general.gdb source img/gdb/stack.gdb source img/gdb/vm.gdb
If SVN is configured, using codelite you can see difference between two versions of a same file.
By default codelite uses the default diff viewer.
It can be changed from Plugins menu -> Subversion->Options and setting the value appropriately.
I use WinMerge to see difference of source files and have the following settings:
External Diff viewer: C:\Program Files\WinMerge\WinMergeU.exe
Arguments : /dl %bname /dr %mname %base %mine
Another good thing about CodeLite is it is under development and your bug report/feature requests are solved within short time frame.
You can download CodeLite from www.codelite.org. It has installer for Windows and Linux also.
In UNIX environment there is the famous “cscope”, to browse the source code and make changes. Using cscope it is easy to browse/edit the source code, cross reference all the functions calling a function, including a file etc.
In windows, I was using notepad++’s find files options browse C source code. Today I decided to find an open source full fledged source navigator for windows.
I started with notepad++ plugin – “Function List”. But it is just not enough for a project source browsing. Google searches gave me cscope port of windows(http://cscope.sourceforge.net/). However I wanted more – the GUI. With few more searches I found Source Navigator – http://sourcenav.sourceforge.net/
Soucrce Navigator is very useful, I just added my project and it give me full list of symbols. Editing a function is just clicking it. Since I am using notepad++ for editing anything, I changed the editor preference to notepad++. To do go to Source Navigator->File menu->Project Preference->Edit-> External editor and give the following line
“C:\Program Files\Notepad++\notepad++.exe” -n%l
Now I can easily browse the source code in Source Navigator and edit it in Notepad++ with few keystrokes.
After creating Ace bootable CD, I decided to try to make Ace bootable from network also to completely avoid creation of disk images. Network booting also helps to boot test machine (real machine) on the same network with ease.
Earlier I had grub installed (on a disk) on a test machine (real machine) with network support. Grub can get the kernel using tftp and boots the system.
Now I wanted to avoid installing grub on a disk. So I had only one option diskless boot. So I decided to use PXE(Preboot eXecution Environment).
To make PXE work, I needed a DHCP server and TFTP server. There are lot of tools available for Linux but for Windows, very very less tools available. After some internet searches, I found and downloaded perfect tools: Dual Server http://sourceforge.net/projects/dhcp-dns-server/ and TFTP Server http://sourceforge.net/projects/tftp-server/ both projects are developed and maintained by Achal Dhir. The other tftp/dhcp servers available windows doesn’t have large set of options provided by Dual Server and TFTP server.
Since I wanted to try PXE boot on emulators, I needed to create software network tap adapter. Without software tap adapter, emulated network card cant talk to the physical network. So I downloaded OpenVPN, which has tool to create tap devices from http://openvpn.net/index.php/downloads.html
If you are using real machine, you may need to download and install PXE roms from etherboot.org http://rom-o-matic.net/
To boot from network, grub should be compiled with appropriate network driver and other flags. Since grub has some problem with compiling under Windows, I used a Linux machine to compile.
cvs -z3 -d:pserver:email@example.com:/sources/grub co grub
./configure –-enable-diskless –-enable-pxe –-enable-rtl8139
You might want to compile in the preset menu also using the –preset option.
Now configure Dual DHCP server to provide IP address, boot file information to qemu
Then configure TFTP server for the correct tftp home folder.
Now it is time to run, Qemu. Note – Windows port of Qemu 0.9.0 has some problem with obtaining DHCP, so install Qemu 0.9.1 and run the following command, it will boot from network.
qemu -L “$QEMU_BIOS_DIR” -M pc -m 32 -no-kqemu -hdc c.img -boot n -net nic,model=ne2k_pci,macaddr=52:54:00:12:34:56,vlan=0 -net tap,vlan=0,ifname=tap0
I am able to PXE boot qemu only with NE2000 cards, for other cards it failing. PXE boot on vmware only works if I configure grub using ifconfig command. Otherwise vmware machines get assigned with some wrong gateway address. No luck to PXE boot Ace on bochs.
For booting my test machine(real machine), I setup my router (DD-WRT box) with boot-dhcp option in DNSMasq.
Today I was trying to setup ACPI-CA source tree in my computer using the following command
git clone http://www.acpica.org/repos/acpica.git
but it gave me error when connecting to the site. I knew it was problem with my cygwin network settings. Since I have a proxy server in between, connections internet was failing.
Googleing internet for how to configure cygwin to use proxy didn’t yield any result. Two of my friends with Linux knowledge advised me to set an environment variable (http_proxy) to connect. After exporting it, everything worked fine.
I have been using Noetpad++ for more than 2 years. It is a wonderful editor – it is very light and feature rich. I use it for editing any text files (txt, ini, C, C++, html, css..). I was happy with Notepad++ for editing my C project source files. Only thing I didn’t like was, to compile I have to go to command prompt and then to correct errors I have to note down the line numbers and open notepad++ modify….
Yesterday, I started searching for a new notepad replacement cum IDE for my Ace(C on cygwin) project. Dev-Cpp and PSPad were IDEs I got. I downloaded and installed both of them. Here comes the problem, both are heavier than notepad++. I might have not explored well, both don’t have option to run cygwin make and capture output and process it.
So I decided to create a notepad++ plugin for my need. But before that wanted to try existing plug-ins and found NppExec. This plug-in allows to run command inside notepad++ and captures the output. It also opens a C file and goto line numbers if it was in the error output if you double click on a line containing “error:” or “warning:” string (I found this one accidently). Downloaded NppExec and ran “make” inside it; but got what I really expected. The output of cygwin “make” has relative path.
i386/io.c:19: error: `Port’ undeclared (first use in this function)
make: *** [i386/io.o] Error 1
make: *** [kernel] Error 2
Since my project make works by invoking “make” inside each directory, relative path will be little complicated – so decided to use absolute path in the output of gcc warning and errors. So modified the explicit rule like following.
$(CC) -c $(abspath $I./include $(CFLAGS)
Out of topic – good make file http://make.paulandlesley.org/autodep.html
Now the output is like the following
/cygdrive/e/sam/Ace3/src/kernel/i386/io.c:19: error: `Port’ undeclared (first use in this function) make: *** [i386/io.o] Error 1 make: *** [kernel] Error 2
This output was not enough because, if I double click this line, notepad tries to open c:/ /cygdrive/e/sam/Ace3/src/kernel/i386/io.c instead of e:/sam/Ace3/src/kernel/i386/io.c.
To solve this problem the I used the following script in notepad++ run command(hotkey – F6)
c:\cygwin\bin\bash -l -c ‘cd src;make 2> err; sed -e “s@\(\/cygdrive\/\)\([a-zA-Z]\)@\2:@g” err; rm err’
Explanation of this command:
c:\cygwin\bin\bash -l –c
Tells NppExec to execute bash and capture its ouput. –l means login and execute bash scripts and profile – I need this for setup my make environment. –c means execute the commands given as argument and exit. Each command is separated by semi-colon.
cd src; – needs no explanation – not needed may be in your case.
make 2> err; – run make and redirect errors to “err” file.
sed -e “s@\(\/cygdrive\/\)\([a-zA-Z]\)@\2:@g” err; – find the pattern /cygdrive/? And replace it with /cygdrive/?:
rm err – remove the error file.
If double clicking on the error/warning message is not opening the file, then try configuring NppExec’s console output filter by using the following %ABSFILE%:%LINE%: warning:* and %ABSFILE%:%LINE%: error:*