Sunday, April 21, 2013

Eclipse Tricks

Hide closed projects

In "Project Explorer" ->"View Menu" - > Select "Filters" -> Enable "Closed projects"

 

Disable Spring source Dashboard

"Window" -> "Preferences" -> "SpringSource" -> "Dashboard" ->uncheck "Show Dashboard On Startup"

Tuesday, September 07, 2010

Grub Error 15 File Not Found

Recently, I updated my Ubuntu 8.04LTS with Ubuntu 10.04 LTS. After completing the full installation and reboot, grub started giving me error

"
Error 15 File Not Found
Press any key to continue..."

After searching through a lot of forums I came to know that, this happens if either the file is missing or the hard drive is changed.
http://ubuntuforums.org/showthread.php?t=644773
http://forums.techarena.in/operating-systems/1144094.htm

But, this was NOT the case here. The problem was that I have two Linux installed on my system
1. Suse
2. Ubuntu

Now, the upgrade process did changed the /boot/grub/menu.lst file, but of incorrect grub. It updated the Ubuntu's where as the grub I was using of Suse.

After some juggling and fight I came to know this.
1. Booted the system in Suse.
2. mounted the ubuntu drive in Suse. mount /dev/sda3 /mnt
3. Open /mnt/boot/grub/menu.lst
4. Copy the new listings from ubuntu's menu.lst
5. Open the Suse's /boot/grub/menu.lst
6. Paste the copied listings here.
7. Save the file
8. Reboot.

There you go. You can see the list of Ubuntu 10.04 installed.

Tuesday, February 23, 2010

Debug information for distribution builds

The Protocol: Release binaries should not have debug information with them to prevent malicious users from reverse engineering the code.

Issues: When issue comes in field from customer it becomes difficult for the developer to crack the issue without proper debug symbols.

Resolution:
1. Generate distribution builds with debug information.
2. Separate the debug information from release builds and store them for future in a file.
3. Ship the stripped binary.
4. For external issues use the debug information separated earlier to debug the issue.

Windows (PDB)
With Visual Studio (Windows) its easy. VS provides the facility to create Program Database (PDB) files to store the debug information.

A program database (PDB) file holds debugging and project state information that allows incremental linking of a Debug configuration of your program. A PDB file is created when you compile a C/C++ program with /ZI or /Zi.

In Visual C++, the /Fd option names the PDB file created by the compiler.

Example:
cl.exe /Zi /Fd"Test.pdb" Test.cpp

Linux (objcopy)
In Linux objcopy command can be used to achieve the same results.
1. Generate distribution builds with debug information
Use compiler flag -g while building the libs and binaries.

2. Separate the debug information from release builds and store them for future in a file.
Run objcopy --only-keep-debug test.dbg to create a file containing the debugging info.

3. Remove the symbol information from the executable
Run objcopy --strip-all test to create a stripped executable.

4. Creates a .gnu_debuglink section which contains a reference to debug file in executable
Run objcopy --add-gnu-debuglink=test.dbg test to add a link to the debugging info into the stripped executable.

Monday, February 22, 2010

Generating hang dumps in Linux (gcore)

Last week encountered a process hang on Linux; well the need arises to take the dump of the process. You can generate the dumps of a running process on Linux in two ways.

1. gcore
- The gcore utility creates a core image of the specified process.

gcore [-s] pid
-s Stop the process while gathering the core image, and resume it when done. This guarantees that the resulting core dump will be in a consistent state. The process is resumed even if it was already stopped.

$ gcore -s 547
...
...
Saved corefile core.547

2. Using gdb

First attach gdb to the running process.
$ gdb - 547 # note the - has spaces on both sides.
Or
You can use gdb's attach command.
$ gdb
(gdb) attach 547

Once you are attached to the running process, you can take the dump using generate-core-file(gcore) command.
(gdb) generate-core-file
Saved corefile core.547

Tuesday, February 09, 2010

In memory FileSystem

Linux(tmpfs and ramfs)
In Linux, you can convert part of your physical memory to be used as a disk partition. In this partition you can read/write files just like any other file on disk, but as the read/writes are done in memory they are really fast.

This partition is useful for applications which at run-time create lots of temporary files & have high IO on these files. For example, installers, extractor tools.

In Linux, we have tmpfs and ramfs mounts that provide the power to create in-memory file system for fast reading and writing files from and to the primary memory.

How to create and mount tmpfs

# mkdir -p /mnt/tmpfs


# mount -t tmpfs -o size=200m tmpfs /mnt/tmpfs
This will create a tmpfs partition of 200MB.

You can view the partition with
# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 125641908 99794556 19515336 84% /
tmpfs 1557024 40000 1517024 3% /lib/modules/2.6.24-27-generic/volatile
tmpfs 204800 0 204800 0% /tmp/tmpfs


How to create and mount ramfs

# mkdir -p /mnt/ramfs

# mount -t ramfs -o size=200m ramfs /mnt/ramfs

You can view the partition with
# mount

/dev/sda3 on / type ext3 (rw,relatime,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)

/sys on /sys type sysfs (rw,noexec,nosuid,nodev)

varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755)

varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)

udev on /dev type tmpfs (rw,mode=0755)

devshm on /dev/shm type tmpfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

lrm on /lib/modules/2.6.24-23-generic/volatile type tmpfs (rw)

securityfs on /sys/kernel/security type securityfs (rw)

none on /proc/fs/vmblock/mountPoint type vmblock (rw)

tmpfs on /lib/modules/2.6.24-27-generic/volatile type tmpfs (rw,mode=0755)

tmpfs on /tmp/tmpfs type tmpfs (rw,size=200m)

ramfs on /mnt/ramfs type ramfs (rw,size=200m)



ramfs vs tmpfs
Basically the same with minor differences:
* ramfs can grow dynamically, tmpfs can not.
This means that in ramfs you can keep on writing beyond the maximum size of your partition, the system will not stop you. So you need your application to keep track of the size.
Where as, tmpfs will not grow dynamically. It may give errors similar to “No space left on device”, when you hit the maximum size of partition.

* tmpfs uses swap, ramfs doesn't.

* Both are volatile file system. So on system shutdown/crash you lose the data.

Microsoft Windows
Windows systems have a rough analog to tmpfs in the form of "temporary files". Files created with both FILE_ATTRIBUTE_TEMPORARY and FILE_FLAG_DELETE_ON_CLOSE are held in memory and only written to disk if the system experiences low memory pressure. In this way they behave like tmpfs, except the files are written to the specified path during low memory situations rather than swap space.

Friday, June 19, 2009

Which folders are shared from my computer?

I had one shared folder that had kept me wondering for sometime. I was not able to find it on my disk.
Actually you can see all you shared folders, with their location using 'Computer Management' utility.

1. Right click My Computers
2. Select Manage option.
3. Go to Shared Folders.
4. Then go to Shares.

OR
use Start->Run-> fsmgmt.msc

There you are.

Using this I found that my drives are also shared. This is a problem if someone knows that they can access the computers drives, they can get hold of all your information and data.
I disabled the sharing of drives, using the same utility.

Thursday, June 18, 2009

Dear Norton,
1. Don't block my network and ask me to provide a remote access.
2. For a change, install successfully in one shot.
3. Reimburse the money I pay because of you, for my system's repair.
4. Never, never, never slow down my system boot.
5. Update the software, but don't stop me from working.
6. Make the subscription possible.
7. Provide efficient support, if any. Else declare you have none.
8. You know there are free AV programs available, that are better than you.