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:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s