Gdb: write something, not break it?

Is it possible that gdb will write something to the terminal, and not break it? For example, I would like to set a “breakpoint” on some method and have gdb print self, as well as parameters with every method call. Basically, I want to embed print statements in arbitrary places without recompiling.

thanks for any suggestions


This is what I still have after these useful comments:

define logFoo b fooMethod commands po self end end 

GDB does not seem to be like nested end statements. any thoughts?

+4
source share
3 answers

You can use the breakpoint command list . Here is an example of how to do this.

For example, here's how you could use break commands to print the value of x when entering foo whenever x is equally positive.

  break foo if x>0 commands silent printf "x is %d\n",x cont end 
+9
source

Use a breakpoint as usual and set the macro to register and continue:

  define c print "foo" cont c end 
+2
source

No, It is Immpossible. You can only connect to code and machine code characters. If you want to log output, you will need logging functions.

If you trace specific errors, try conditional breakpoints and watch for variables.

EDIT:

Even if it was not directly loggin, it might be an alternative to using GDB batch files

0
source

All Articles