-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add nvlist command to sdb #288
base: master
Are you sure you want to change the base?
Conversation
sdb/command.py
Outdated
err_msg = "invalid memory access while handling object " | ||
err_msg += "at address {hex(obj.address_of_().value_())}" | ||
err_msg = "invalid memory access while handling object at address %s" % ( | ||
hex(obj.address_of_().value_())) |
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're preferring to use "f-strings" as we do a couple lines above
hex(obj.address_of_().value_())) | |
f"at address {hex(obj.address_of_().value_())}" |
sdb/commands/nvpair/nvpair.py
Outdated
self.name_size = int(nvp.nvp_name_sz) | ||
self.data_ptr = self.addr + ((self.nvp_size_ + self.name_size + 7) & ~7) | ||
|
||
def get_type(self, strip: int = 0) -> str: |
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.
My python has gotten rusty... would something like strip: bool = false
work?
"nvi_nvp") | ||
curr = sdb.create_object("i_nvp_t *", curr_addr) | ||
|
||
if priv.nvp_curr == curr or Nvlist.nvlist_contains_nvp(nvl, nvp): |
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.
Is the nvlist_contains_nvp() check really necessary? Seems like it would make overall iteration O(N^2) since every call to next_nvpair() will iterate the whole nvlist. Maybe this isn't a big deal as long as your list isn't TOO long (<1000?)
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.
Good question. I basically ported
https://src.illumos.org/source/xref/illumos-gate/usr/src/common/nvpair/nvpair.c?r=b8a5bee1#1431
Let me do some experiments to see if or how often nvlist_contains_nvp is needed.
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 the extra check is there in case the nvlist is having element(s) removed while we're traversing it.
name=seconds_of_rewind type=DATA_TYPE_INT64 value=-1575588901 | ||
name=verify_data_errors type=DATA_TYPE_UINT64 value=0 | ||
---- | ||
sdb: nvlist: invalid memory access while handling object at address 0xffffa089413b8138 |
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.
is this because there's actual a problem with the example dump, or is this a nvlist data type that we don't understand?
Thanks for taking a look @ahrens I'll dig into your comments. |
if sdb.is_null(nvl) or sdb.is_null(nvl.nvl_priv): | ||
return None | ||
priv = drgn.cast("nvpriv_t *", nvl.nvl_priv) | ||
return priv.nvp_list.nvi_nvp |
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.
It turns out that priv.nvp_list can be NULL, which is why the test output has the FaultError warning. Will fix.
Print all the nvpair_t in the passed nvlist_t. Handle basic types, array types, and nvlist_t types. Signed-off-by: Paul Zuchowski <[email protected]> Fixes delphix#26
Print all the nvpair_t in the passed nvlist_t. Handle basic types,
array types, and nvlist_t types.
Signed-off-by: Paul Zuchowski [email protected]
Fixes #26
= Problem
nvlist are difficult to display using crash or sdb. Develop a dcmd for displaying all the nvpair in the given nvlist.
= Solution
Develop a SingleInputCommand for nvlist, that displays the various nvpair types, including when the nvpair is nvlist type.
Note the small change to Command, to fix the formatting when a FaultError occurs.
Closes #26