Debugging - detect a function writing a memory location
我需要知道是否有Linux调试器gdb可以检测特定C ++类(由文件Chord.cc表示)的函数(任何函数)是否访问特定的内存位置(例如0xffffbc)。
那对我有很大帮助。
谢谢。
您正在寻找GDB观察点:
从该页面引用:
You can use a watchpoint to stop execution whenever the value of an
expression changes, without having to predict a particular place where
this may happen. (This is sometimes called a data breakpoint.) The
expression may be as simple as the value of a single variable, or as
complex as many variables combined by operators. Examples include:
- A reference to the value of a single variable.
- An address cast to an appropriate data type. For example, `*(int
*)0x12345678' will watch a 4-byte region at the specified address (assuming an int occupies 4 bytes).
然后,您可以尝试将本文中的技术应用于有条件的观察点,并查看是否可以找到一种方法来将其限制为来自该类的特定函数调用。 您可能还会发现与此相关的讨论。