I have a following function and I want to stop for debugging inside of it depending on content of variable arguments passed to it.
int
my_fprintf (const char *format, ...)
{
va_list arg_list;
...
va_start (arg_list, format);
result = vfprintf (stream, indent_str, arg_list);
va_end (arg_list);
...
return result;
}
What I want is to put a breakpoint in it to stop if the call is my_fprintf ("%s", "hello") for example (so breakpoint condition would be as close as possible to a <smth> == "hello").
Is it possible to do that?
Updates:
- Debugger is gdb.
- I know how to set conditional breakpoints, I want to know, that the condition should be in this case.
gdb can do that. You just need a variable (
pin the following snippet) that you can check. To successfully obtainp, you would need more goo, namely, checking that the first argument of arg2 is a char* within reason, done here by checking thatformatcontains%sfor example (though %s is not sufficient, as someone may use %.*s or something).Replace 1234 by the line number of
p=va_arg....Edited: unshadow p and put have_string into the break cond.