Popular Posts
-
I spent a scary night yesterday trying to fix my Ubuntu installation. I was a victim for the bug related to libc6. The problem is that afte...
-
http://healthcareitnews.eu/content/view/1068/43/
-
This an excellent article released recently by embedded.com: http://www.embedded.com/design/opensource/208404045?pgno=1 The article is a bit...
-
Today is my lucky day :) I found two free books about Qt and Design Patterns. The first book is C++ GUI Programming with Qt 4 The first edit...
Thursday, December 25, 2008
union, struct, and bit fields in C and C++
First, for the definition of unions and structs, take a look at this link:
http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=/com.ibm.xlcpp8a.doc/language/ref/strct.htm
Unions could be used together with structs to reinterpret the same location in memory with different interpretations (similar in spirit to the C++ reinterpret_cast). For examples on this see:
http://www.anyexample.com/programming/cplusplus/example_of_using_union_in_cplusplus.xml
C++ extends the unions and structs, for example see:
http://www.yolinux.com/TUTORIALS/LinuxTutorialC++Structures.html
Bit fields are used to define special-sized integers. This is useful for packing data (e.g. flags) together into one memory location. This, however, is a bad habit and should be avoided as the compiler-generated code to access bit fields is usually inefficient! For more examples on this, see:
http://en.wikipedia.org/wiki/Bit_field
http://publib.boulder.ibm.com/infocenter/macxhelp/v6v81/index.jsp?topic=/com.ibm.vacpp6m.doc/language/ref/clrc03defbitf.htm
http://www.cs.cf.ac.uk/Dave/C/node13.html
http://www.daniweb.com/forums/thread55765.html
http://blogs.msdn.com/oldnewthing/archive/2008/11/26/9143050.aspx
http://osr507doc.sco.com/en/tools/ANSI_F.3.9_Structs.unions.html
Finally, unions and structs could be anonymous! You do not have to give a name to a union. In this case its members become directly accessible within the same scope. Wikipedia calls this "untagged union". For an example see:
http://www.velocityreviews.com/forums/t286529-union-with-anonymous-struct.html
Tuesday, December 23, 2008
Debugging, Profiling, Memory Leaks and more!
For static code analysis I found:
CppCheck (http://en.wikipedia.org/wiki/Cppcheck)
I used it to its full power by invoking (at the top level of the project):
cppcheck --recursive --all --errorsonly --style
Also, SPlint (http://en.wikipedia.org/wiki/SPlint) seems promising, though it is for C code only (no C++).
A comprehensive list of static code analysis could be found in Wikipedia:
http://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis
About application profiling, the GNU Profiler (gprof) does a good job. It is light-weight and has support in GCC. This is an excellent article about using gprof:
- Programmer's Toolkit: Profiling programs using gprof(http://linuxgazette.net/100/vinayak.html)
Memory leak detection has many options. Of the best is using Valgrind(http://valgrind.org/). However, I found an interesting and promising feature that has been added to the gcc. This feature is called Mudflap. It is easy to use as a compiler flag and adds memory debugging support directly into your application using libmudflap. More interesting information could be found here:
http://gcc.gnu.org/wiki/Mudflap_Pointer_Debugging
http://gcc.fyxm.net/summit/2003/mudflap.pdf
It is so promising that it will be integrated into the QNX IDE:
http://qnxdevtools.blogspot.com/2008/02/mudflap.html
It can print the memory leaks on program exit via the (-print-leaks) option
Memory debugging tools are so many. There is a list on Wikipedia article:
http://en.wikipedia.org/wiki/Memory_debugger
The task of memory leak detection is achievable using lightwieght tools. These tools basically replaces the default C library malloc() and free() with special debugging implementations. Notable is mtrace(), the memory debugger built in the GNU C library:
http://en.wikipedia.org/wiki/Mtrace
A good article about memory leak detection in C++:
http://www.linuxjournal.com/article/6556
And finally, all what you can dream of are collected in one article, in the GRASS wiki here:
http://josef.fsv.cvut.cz/WIKI/grass-osgeo/index.php/GRASS_Debugging
Hope you find this useful!
Monday, December 22, 2008
Guide to start using Linux in ARABIC
http://ia310803.us.archive.org/2/items/Practical_Guide_to_use_ubuntu_linux_Arabic_344/Practical_Guide_to_use_ubuntu_linux_arabic.pdf
Wednesday, November 12, 2008
Thursday, October 16, 2008
Monday, October 13, 2008
Some stuff about finance and investment
Saturday, October 4, 2008
Comics about SW Development
http://contikistrip.kjempekjekt.com/index.php?p=1
Saturday, September 27, 2008
Buffer Overflow Exploits
You can dig for it too ;-)
check the Wikipedia article,
http://en.wikipedia.org/wiki/Buffer_overflow
and the excellent book of Programming from the Ground Up, for much better understanding of Assembly:
http://savannah.nongnu.org/projects/pgubook/
Enjoy!
Wednesday, September 3, 2008
Thursday, August 21, 2008
GNU/Linux from eight miles high
http://www.embedded.com/design/opensource/208404045?pgno=1
The article is a bit advanced. But anyone with good understanding of computer architecture should be able to go through it!
Wednesday, August 13, 2008
A Good article about ECG Signal Processing from LabVIEW
http://zone.ni.com/devzone/cda/tut/p/id/6349
Friday, August 1, 2008
GUC Students' Blogs
http://husfahmy.blogspot.com/
http://thoughtsandtips.blogspot.com/
http://lewjee.blogspot.com/
Wednesday, July 16, 2008
Sunday, July 6, 2008
Add Circular Scrolling (and more!) to your laptop touchpad
http://www.chineselinuxuniversity.net/articles/13049.shtml
Add to /etc/X11/xorg.conf (or whatever your xorg.conf is at)
Section "InputDevice"
Identifier "Synaptics Touchpad"
Driver "synaptics"
Option "SendCoreEvents" "true"
Option "Device" "/dev/psaux"
Option "Protocol" "auto-dev"
Option "CircularScrolling" "on"
Option "CircScrollTrigger" "3"
EndSection
Be sure to have Synaptics added to the Server Layout
Section "ServerLayout"
Identifier "Default Layout"
Screen "Default Screen"
InputDevice "Generic Keyboard"
InputDevice "Configured Mouse"
InputDevice "Synaptics Touchpad"
EndSection
Tuesday, July 1, 2008
Dealing with Debian source packages
The dpkg-source utility is found in dpkg-dev package.apt-get build-dep glibc
apt-get source -b glibc
should work
or, if you already have the build-dependencies and source files
downloaded (.orig.tar.gz, .diff.gz, and .dsc):
dpkg-source -x glibc*.dsc
cd glibc-*
make -f debian/rules build
randolph
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
Sunday, June 29, 2008
Compiling over NFS
On the NFS server
add the following line to /etc/exports (Debian/Ubuntu systems)
/path/to/exported/directory *(rw,no_subtree_check,insecure,no_root_squash)
On the client machine (the one that will compile)
add the following line to /etc/fstab
10.0.2.2:/path/to/exported/directory /path/to/mnt/point nfs user,rw,exec 0 0
Note: replace 10.0.2.2 with the server IP or hostname
Warning: this setup is TOTALLY INSECURE!!
but who cares ;-)
Thursday, June 26, 2008
Monday, June 23, 2008
Contributors Needed!
Biomedical Engineering: A Roadmap
Don't forget to add your name to the authors list ;-)
Tuesday, June 17, 2008
What is linux-gate.so.1?
http://www.trilithium.com/johan/2005/08/linux-gate/
Thursday, June 12, 2008
BUG! -- the Biomedical Unix Geeks club
This club is for all biomedical engineers who love Unix, Software Engineering and Computer Science.
IMHO, Unix provides the best environment for the study of algorithms and computer science. The Unix tools and development also implements important point of the software engineering. Hence, came the idea of this club.
Please share your ideas with me on how this should go!
Tuesday, June 10, 2008
Puppy Linux trials with the eBox series
http://www.murga-linux.com/puppy/viewtopic.php?t=21864
eBox 2300
http://www.murga-linux.com/puppy/viewtopic.php?search_id=21059625&t=13722
http://www.murga-linux.com/puppy/viewtopic.php?t=14719&search_id=21059625
eBox 4300
http://www.murga-linux.com/puppy/viewtopic.php?search_id=21059625&t=26982
Friday, June 6, 2008
Mixing C and C++
Just check:
http://developers.sun.com/solaris/articles/mixing.html
http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html
Sunday, May 18, 2008
Tuesday, May 6, 2008
Computer Vision in Hardware
Automotive vision system recognizes road signs: Part 1 - Basic functions
Thursday, April 17, 2008
Name Mangling
Sunday, April 13, 2008
Cross Compiling the hard way...
http://www.landley.net/ols/ols2007/tutorial.txt
Predefined Macros in gcc
-dCHARS
CHARS is a sequence of one or more of the following characters, and must not be preceded by a space. Other characters are interpreted by the compiler proper, or reserved for future versions of GCC, and so are silently ignored. If you specify characters whose behavior conflicts, the result is undefined.
M Instead of the normal output, generate a list of #define directives for all the macros defined during the execution of the preprocessor, including predefined macros. This gives you a way of finding out what is predefined in your version of the preprocessor. Assuming you have no file foo.h, the commandtouch foo.h; cpp -dM foo.h
will show all the predefined macros.
Compiling 32-bit Applications on 64-bit Linux Hosts
$ gcc -o hello -m32 hello.c
the -m32 flag tells the compiler to target the 32-bit architecture instead of the 64-bit architecture
Also, you may need to take a look at this looooooong discussion:
http://ubuntuforums.org/showthread.php?t=24575
For kernel compiling, you will need to explicitly specify the architecture:
$ make ARCH=i386 menuconfig
$ make ARCH=i386 bzImage
Happy compiling :)
*** Returning to this issue with Makefiles
just run:
$make CFLAGS=-m32 LDFLAGS=-m32
this adds the -m32 option to both the compiler flags and the linker flags
Monday, April 7, 2008
iwl3945 Finally Working :)
http://ubuntuforums.org/showthread.php?p=4612681
Saturday, April 5, 2008
PDF Multiple Page Per Sheet in Linux
$pdfnup --nup 1x2 input.pdf
Friday, March 14, 2008
My Ubuntu Sytem borke :(
Almost every single application is depending on the standard C library (glibc/libc6/GNU C Library). The fact that the libc6 is not functioning means the system is now totally unstable! Error message of the sort 'null pointer reference' began to show everywhere. I can't start any kind of terminal. Even logging into the Virtual Consoles failed and just thrown some 0x777FFD... addresses on me. I had no access to any package manager and I cannot undo the buggy installation. Even starting a browser to search for the problem failed! I had no other option but to restart and login using a liveCD.
After a lot of searching for the problem, I came across this bug description.
I have learnt a lot :)
To break the normal boot process you need to boot with the kernel option:
break=bottom
This puts you into the initial ram filesystem prompt (initramfs) just before starting the init-bottom scripts
To unpack a .deb archive:
ar -x *.deb
This leaves you with two tarball control.tar.gz and data.tar.gz. I used this to unpack the libc6 deb archive by hand and copy the necessary data.tar.gz files into their correct locations; thus replacing the buggy libc6 installation with a correct installation.
When you 'chroot' into your Ubuntu installation and get the message: 'Unable to execute /bin/bash: Permission Denied'. And even 'chroot /path/to/your/rfs /usr/sbin/apt-get' fails for the same reason. Then most probably the 'ld*' files in /lib/ and /sbin/ldconfig are not give the execute permission.
'chmod +x /lib/ld*' and 'chmod +x /sbin/ldconfig' corrected the problem.
Notice that ld* is the dynamic link loader and is needed by almost every executable file in your system. Also, 'ldconfig' is needed by dpkg, apt, aptitude and all package managers to be able to process your packaging system.
Thursday, March 6, 2008
Wednesday, February 27, 2008
Probability ABC
http://blogs.jhu.edu/sukye/2008/probability-abc/
``A priori probability is the probability estimate prior to receiving new information.
Posterior probability is a revised probability that takes into account new available information. For example, let there be two urns, urn A having 5 black balls and 10 red balls and urn B having 10 black balls and 5 red balls. Now if an urn is selected at random, the probability that urn A is chosen is 0.5. This is the a priori probability. If we are given an additional piece of information that a ball was drawn at random from the selected urn, and that ball was black, what is the probability that the chosen urn is urn A? Posterior probability takes into account this additional information and revises the probability downward from 0.5 to 0.333 according to Bayes’ theorem, because a black ball is more probable from urn B than urn A.
Bayes’ Theorem:
Bayes theorem is a formula for revising a priori probabilities after receiving new information. The revised probabilities are called posterior probabilities. For example, consider the probability that you will develop a specific cancer in the next year. An estimate of this probability based on general population data would be a prior estimate; a revised (posterior) estimate would be based on both on the population data and the results of a specific test for cancer.
The best way to understand the terms is to look at an example. Consider a screening test for intestinal tumors. Let Ai = A1 = the event “tumor present”, “B” the event “screening test positive” and “A2″ the event “tumor not present” with no further A’s.
If you have a tumor, the screening test has an 85% chance of catching it — P(B|A1) = .85. However, it also has a 10% chance of falsely indicating “tumor present” when there is no tumor P(B|A2) = .10. The probability of a person having a tumor is .02 P(A1) = .02.
If the screening test is positive, what is the probability that you have a tumor?
.02*.85/(.02*.85+.98*.10)
= .017/(.017+ .098)
= .148''
Monday, February 25, 2008
Wednesday, February 20, 2008
My Ubuntu :)
ftp://ftpserv.tudelft.nl/pub/Linux/archive.ubuntu.com/