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.
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.
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.
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.
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.
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.
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.
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 <pzuchowski@datto.com> 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 pzuchowski@datto.com
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