How to find out which part of code is changing a particular data structure.
Hi folks, I have a memory location (One of the fields in a kernel data structure) and I want to track down the code that changes the value of that particular location. Some thing like a "watchpoint". And this is early while I am still booting up. Can some one tell me if it is possible to do so? Thanks, Rajat
You may attach debugger (like Lauterbach) and use its data breakpoint functionality. Thanks, Chetan Nanda On Fri, Nov 8, 2013 at 6:16 AM, Rajat Jain <rajatjain@juniper.net> wrote:
Hi folks,
I have a memory location (One of the fields in a kernel data structure) and I want to track down the code that changes the value of that particular location. Some thing like a "watchpoint".
And this is early while I am still booting up. Can some one tell me if it is possible to do so?
Thanks,
Rajat
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi Rjat, Can you define that location as read only(i.e constant)?. This is only for debug prupose, later you can remove. I am expecting kernel panic with this change. Regards, Kiran On Friday, 8 November 2013, 9:03, Chetan Nanda <chetannanda@gmail.com> wrote: You may attach debugger (like Lauterbach) and use its data breakpoint functionality. Thanks, Chetan Nanda On Fri, Nov 8, 2013 at 6:16 AM, Rajat Jain <rajatjain@juniper.net> wrote: Hi folks,
I have a memory location (One of the fields in a kernel data structure) and I want to track down the code that changes the value of that particular location. Some thing like a "watchpoint".
And this is early while I am still booting up. Can some one tell me if it is possible to do so?
Thanks,
Rajat
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
On Thu, 07 Nov 2013 23:23:18 -0800, kiran kumar said:
Can you define that location as read only(i.e constant)?. This is only for debug prupose, later you can remove.
Note that this requires 2 things: 1) A kernel built with CONFIG_DEBUG_RODATA=y 2) The structure needs to have a compile-time initializer: struct foo barbaz = { 5, 3, "quuz"}; Otherwise, your kernel will throw an oops when it tries to initialize the structure at runtime (which is almost certainly *not* the time that is causing the actual problem). Simply declaring it as 'const struct' may or may not help - this will catch at compile time lots of mistakes, but isn't guaranteed to stop all cases of buggy uses of miscast pointers, etc....
Rajat Jain <rajatjain@juniper.net> writes:
[...] I have a memory location (One of the fields in a kernel data structure) and I want to track down the code that changes the value of that particular location. Some thing like a "watchpoint".
See the register_wide_hw_breakpoint API. You could write a small module that runs early, and gets callbacks when a given address is modified.
And this is early while I am still booting up. Can some one tell me if it is possible to do so?
(Were it not for the 'while still booting up' part, I'd suggest trying systemtap's probe kernel.data("SYMBOL").write { } or probe kernel.data(0xDEADBEEF).write { } probes, but we haven't worked through initramfs'ifying the widget.) - FChE
participants (5)
-
Chetan Nanda -
fche@redhat.com -
kiran kumar -
Rajat Jain -
Valdis.Kletnieks@vt.edu