Day: February 12, 2013

Using conditional breakpoint on GDB

Yes, GDB has support to conditional breakpoint, then you can get a function fired only when it has right criteria.

In this example I want a breakpoint issued only when my file descriptor (parameter save at r0) is equal to 12:

(gdb) br write if $r0==12
Ponto de parada 2 at 0xab50

In theory it should accept even more elaborated implementations like this:

(gdb) br open64 if strcmp(*((char**)($r0)),"/dev/ttyS1")==0
Ponto de parada 1 at 0xb144

But it didn’t work for me. I also tried replacing by:

(gdb) br open64 if strcmp(*($r0),"/dev/ttyS1")==0

No way, didn’t work either.

I got the idea from this site: http://whats.all.this.brouhaha.com/2007/10/21/reverse-engineering-a-binary-only-linux-library-and-executable/

Error “SIOCSIFFLAGS: Invalid argument” when executing ifconfig

I noticed this error when executing ifconfig just after turning VStarCam H6837WI on:

# ifconfig eth0 192.168.1.126 up                                           
ifconfig: SIOCSIFFLAGS: Invalid argument                                        
#

I didn’t investigate what is the root cause of this error, but I noticed if I execute /mnt/system/bin/encoder and reboot the board next it it will work.

Then I suspect there is some ethernet Micrel KSZ8851 PHY initialization done by encoder application.

Updating and Repacking Camera Filesystem

My camera was failing to start-up video streamer (daemon and encoder was failing to run), but fortunately NickE noticed I was using init=/sbin/init instead of init=/init (this is a script to setup PATH and LD_LIBRARY_PATH).

Now I’m debugging to discover what daemon and encoder are doing, but it is very difficult to debug, because they call reboot command every time it notices the camera is not working correctly.

Then I decide to remove reboot command from root file system, then it will not reboot during my debug tests.

This is the way I did:

# mkdir /tmp/rootfs
# mkdir /tmp/ipcam
# mount -t cramfs -n mtd3_RootFS.img /tmp/rootfs
# cp -a /tmp/rootfs/* /tmp/ipcam/
==> Do your modifications on rootfs <==
# mkcramfs /tmp/ipcam mtd3_RootFS_new.img

You could also use cramfsck with -x parameter to extract cramfs as NickE suggested me.