Monday, February 25, 2008

Nice Try

Today I was trying to print some variables from the tg3 network driver in the running linux kernel, using GDB on /proc/kcore. Being the lazy type I tried to check kernel variable values though GDB instead of using /proc or /sys interface.

After printing the variables, I started a test to see how it would change. The test went to completion and surprize surprize the value never changed! I did not know what happened and re-ran the test, but no luck. Then I looked through the code and after making sure that the value absolutely has to change, I came to the conclusion that there was something wrong with GDB and restarted it, and presto the new values were visible.

After some googling it turned out that gdb tries to cache the values it retrieves from the core file. The intresting part was that, even though we indicate to GDB that the target is live it still does this. Anyway the solution, from LDD3, is to run "core-file /proc/kcore" everytime we want an updated value.

No comments: