Discussion:
How to find out which part of code is changing a particular data structure.
Rajat Jain
2013-11-08 00:46:13 UTC
Permalink
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



--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Chetan Nanda
2013-11-08 03:31:56 UTC
Permalink
You may attach debugger (like Lauterbach) and use its data breakpoint
functionality.

Thanks,
Chetan Nanda
Post by Rajat Jain
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
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
kiran kumar
2013-11-08 07:23:18 UTC
Permalink
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 <***@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 <***@juniper.net> wrote:

Hi folks,
Post by Rajat Jain
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
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
V***@vt.edu
2013-11-08 14:51:54 UTC
Permalink
Post by kiran kumar
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....
Frank Ch. Eigler
2013-11-08 21:03:09 UTC
Permalink
[...] 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
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Continue reading on narkive:
Loading...