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: