February 18, 2008

Inspecting a Live ruby process

Once it happened to me, a ruby application which i wrote took 100% CPU (sometimes) and it hangs the other processes too. Now i need to figure out, where ?. Since it happens once in a while, i could not able to simulate it. Then i search for "inspecting a live ruby process", and i got a very wonderful,useful article

Inspecting Live Ruby Process

To make it easier, u can save the following few lines of code, to a file (say gdb_inspect.sh)

set $ary = (int)backtrace(-1)
set $count = *($ary+8)
set $index = 0
while $index < $count
    x/1s *((int)rb_ary_entry($ary, $index)+12)
    set $index = $index + 1
end
now start the gdb, 

$gdb ruby <pid>

which starts a gdb session,

(gdb) source path/to/gdb_inspect.sh
.
.This shows currently, where the control resides.
.
(gdb)

In addition to this,Its also possible to inspect the value of a variable,
which is also explained in that article. After running the same 2-3 times with the pid of my ruby app.
i figured out the problem.

Disabling show-password in Firefox 2.x

In Firefox, though we have set master-password, it is possible to view the saved passwords through show passwords.Think if, that button itself disabled.
After surfing the net, i got a solution

1) Add the following 2 lines of code in a file named mozilla.txt

//
lockPref("pref.privacy.disable_button.view_passwords", true);

Note: This is an example, which helps to lockdown show-password. You can find more options by browsing the "about:config" page

2) Now this has to be encoded. Here is the online encoder  (Byteshift 13). Save it as mozilla.cfg

3) Edit the file "Mozilla Firefox\greprefs\all.js" by adding the following to the end of it:

pref("general.config.filename", "mozilla.cfg");
$ locate all.js
/usr/share/firefox/greprefs/all.js
/usr/share/firefox/greprefs/xpinstall.js
$ echo "pref(\"general.config.filename\", \"mozilla.cfg\");" >>
/usr/share/firefox/greprefs/all.js

4) Copy the new file "mozilla.cfg" to Mozilla Firefox directory:
eg : cp mozilla.cfg /usr/lib/firefox
Here you can see the "Show passwords" disabled. Also if you browse for "about:config"

Sho_pwd

Reference : Locking Firefox Settings

Blog powered by TypePad