Use a [break condition](
[To see links please register here]
) with `$_streq` (one of GDB's own [convenience functions](
[To see links please register here]
"current convenience functions online documentation")):
```gdb
break [where] if $_streq(x, "hello")
```
or, if your breakpoint already exists, add the condition to it:
```gdb
condition <breakpoint number> $_streq(x, "hello")
```
[Since GDB 7.5 (long ago)](
[To see links please register here]
"git commit, released 2012-08-17") you can use that and a handful of other native [convenience functions](
[To see links please register here]
"current online documentation") for various string matching, including `$_regex` which supports the [Python regex syntax](
[To see links please register here]
):
```gdb
$_memeq(buf1, buf2, length)
$_regex(str, regex)
$_streq(str1, str2)
$_strlen(str)
```
These are quite less problematic than having to execute the usual `strcmp()` injected to the process' stack, because that can have undesired side effects.
Alas, using the native functions is not always possible, because they rely on GDB being compiled with Python support. This is usually the default, but some constrained environments might not have it. To be sure, you can check it by running `show configuration` inside GDB and searching for `--with-python`. This shell oneliner does the trick, too:
```sh
gdb -n -quiet -batch -ex 'show configuration' | grep 'with-python'
```