-
Notifications
You must be signed in to change notification settings - Fork 21
Add a whatis command to sdb #267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #267 +/- ##
==========================================
+ Coverage 87.51% 87.65% +0.13%
==========================================
Files 62 63 +1
Lines 2523 2551 +28
==========================================
+ Hits 2208 2236 +28
Misses 315 315
Continue to review full report at Codecov.
|
fce08f9 to
460170a
Compare
|
Looks like the CI is just waiting. I had a good run, made a few changes and re-pushed a few consecutive times, and it went into the waiting state. Can I trigger it to re-run? I already tried a trivial commit/push to change the commit hash. |
ahrens
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice functionality, thanks for contributing this!
ef08683 to
18a7787
Compare
|
drgn has modified its required version of libelf to 0.176. It looks like Ubuntu bionic only goes up to 0.170. |
a76d632 to
3163e75
Compare
|
I edited install-drgn.sh to work around the libelf version problem (git checkout older drgn). But that's not likely to be the ultimate solution. |
sdimitro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great and thank you for working on this!
Have you given any thoughts on how we can also check if the address provided is part of an independent zfs spl-cache? No worries if you haven't we can still go on with just linux-owned cache files. I was just curious.
sdb/commands/linux/whatis.py
Outdated
| def lookup_in_kmem(obj: drgn.Object) -> None: | ||
| pfn = mm.virt_to_pfn(sdb.get_prog(), obj) | ||
| page = mm.pfn_to_page(pfn) | ||
| try: | ||
| cache = page.slab_cache | ||
| cache_nm = cache.name.string_().decode('utf-8') | ||
| print(f"{hex(int(obj))} is allocated from {cache_nm}") | ||
| except drgn.FaultError: | ||
| print(f"{hex(int(obj))} does not map to a kmem_cache") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should do a couple of changes to this helper if we are to truly make it re-usable:
[1] Move it to sdb/commands/linux/internal/slub_helpers.py
[2] substitute the mm alias with the conventions of the above helper file (e.g. import virt_to_pfn and pfn_to_page at the top of that file and use them without mm).
[3] Change the functions signature:
def lookup_cache_by_address(obj: drgn.Object) -> Optional[drgn.Object]:
[4] Move the printing to the sdb command itself and have that helper method return the cache as a drgn.Object. If we get a FaultError because the page is not part of the cache we return None and the caller/command needs to handle it.
I had started down the road of building up a list of all the caches with their starting address and size, to see if the requested address fell within one of the ranges, and was thus from that kmem_cache. I wonder if there is a better way to see if the address is in a specific zfs spl-cache instead of a linux cache. |
| sudo apt install bison flex libelf-dev libdw-dev libomp5 libomp-dev | ||
|
|
||
| git clone https://github.com/osandov/drgn.git | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unneeded whitespace change
Pull request checklist
Please check if your PR fulfills the following requirements:
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
There is no whatis command in sdb.
Issue Number: 119
What is the new behavior?
sdb> whatis 0xfffffe06596e21b8
0xfffffe06596e21b8 is allocated from dmu_buf_impl_t
sdb> dbuf |head 1 |deref |member db_buf |whatis
0xffff8e804368ac80 is allocated from arc_buf_t
Does this introduce a breaking change?
Other information