Why does a GDB watchpoint not trigger when cast to std::array's value type?

0

Using GDB 10.1, I set a watchpoint like this on std::array<Data, 1024> m_slots:

(gdb) print &m_slots[0]
$1 = (std::array<Data, 1024>::value_type *) 0xdeadbeef
(gdb) watch *(Data*) 0xdeadbeef

where Data is a struct. GDB can print sizeof(Data) = 32 and successfully sets the (hardware) watchpoint. The watchpoint fires when the object is constructed/assigned for each field. The watchpoint does not fire when individual fields are updated otherwise. If instead I do either:

(gdb) watch -l m_slots[0]

or

(gdb) watch *(std::array<Data, 1024>::value_type *) 0xdeadbeef

then the watchpoint fires on changes to fields. It seems to me that std::array<Data, 1024>::value_type is exactly Data. Why is the behaviour different?

c++
gdb
watchpoint
asked on Stack Overflow Feb 23, 2021 by Sam Brightman • edited Feb 23, 2021 by Sam Brightman

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0