Search code examples
c++clinuxgdb

Program doesn't run when using GDB watchpoint


For some reason, when I do a basic watch var and run in GDB, GDB just prints the Starting program: blah blah and nothing happens. GDB reports that Hardware watchpoint 1: var, so I don't think it's just being slow since hardware watchpoints are supposed to be fast and I ran it for a few minutes with no output.

When I Ctrl-C to abort I usually get an error like

dl_new_hash (s=0xf7e189d4 "0EE24_M_initialize_moneypunctEP15__locale_structPKc") at dl-lookup.c:577
577     dl-lookup.c: No such file or directory.

which to me seems like a error finding a shared lib? But GDB works fine with regular breakpoints, it's just watchpoints that are messing up.

My version is

$ gdb --version
GNU gdb (GDB) Red Hat Enterprise Linux 8.2-18.el8
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Which looks similar to this post, but my program doesn't show any

[1]+  Stopped                 gdb MyProgram

there's no output at all.

Has anybody come across this?


Solution

  • As it turns out, the variable I was trying to watch was a massive struct. I only had to watch a specific field of the struct, so I was able to basically just call watch var.foo and it worked fine. I'm rather surprised that GDB still marked it as a hardware watchpoint, but the more you know I guess.