From a7f3caf8d02308af2ba8b743a6ddfc60c920c853 Mon Sep 17 00:00:00 2001 From: Serapheim Dimitropoulos Date: Tue, 20 Dec 2022 09:17:16 -0500 Subject: [PATCH 1/4] Fix Walk command message error = Testing ``` sdb> walk The following types have walkers: WALKER TYPE spl_list list_t * multilist multilist_t * slub_cache struct kmem_cache * spl_cache spl_kmem_cache_t * avl avl_tree_t * zfs_btree zfs_btree_t * ``` = Github Issue Tracker Automation Closes #296 --- sdb/command.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdb/command.py b/sdb/command.py index fd69c82..017f98c 100644 --- a/sdb/command.py +++ b/sdb/command.py @@ -587,9 +587,9 @@ def _help_message(input_type: drgn.Type = None) -> str: if input_type is not None: msg += f"no walker found for input of type {input_type}\n" msg += "The following types have walkers:\n" - msg += f"\t{'WALKER':-20s} {'TYPE':-20s}\n" + msg += f"\t{'WALKER':<20s} {'TYPE':<20s}\n" for type_, class_ in Walker.allWalkers.items(): - msg += f"\t{class_.names[0]:-20s} {type_:-20s}\n" + msg += f"\t{class_.names[0]:<20s} {type_:<20s}\n" return msg def _call(self, objs: Iterable[drgn.Object]) -> Iterable[drgn.Object]: From 3851d9667d4b1ef422bb85c0fa6d8134024597f2 Mon Sep 17 00:00:00 2001 From: Serapheim Dimitropoulos Date: Tue, 20 Dec 2022 09:44:48 -0500 Subject: [PATCH 2/4] Fix mypy errors Original Errors: ``` sdb/commands/linux/process.py:59: error: Module has no attribute "find_pid" [attr-defined] sdb/commands/linux/process.py:90: error: Module has no attribute "find_task" [attr-defined] Found 2 errors in 1 file (checked 64 source files) ``` --- sdb/commands/linux/process.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sdb/commands/linux/process.py b/sdb/commands/linux/process.py index 25ac983..80c798f 100644 --- a/sdb/commands/linux/process.py +++ b/sdb/commands/linux/process.py @@ -22,6 +22,8 @@ import drgn import sdb +from drgn.helpers.linux.pid import find_pid, find_task + class FindPid(sdb.Command): """ @@ -56,7 +58,7 @@ def _init_parser(cls, name: str) -> argparse.ArgumentParser: def _call(self, objs: Iterable[drgn.Object]) -> Iterable[drgn.Object]: for pid in self.args.pid: - yield drgn.helpers.linux.pid.find_pid(sdb.get_prog(), pid) + yield find_pid(sdb.get_prog(), pid) class FindTask(sdb.Command): @@ -87,4 +89,4 @@ def _init_parser(cls, name: str) -> argparse.ArgumentParser: def _call(self, objs: Iterable[drgn.Object]) -> Iterable[drgn.Object]: for pid in self.args.pid: - yield drgn.helpers.linux.pid.find_task(sdb.get_prog(), pid) + yield find_task(sdb.get_prog(), pid) From 3befd19a118f423ee9c77f75c2d2c47e4a62e974 Mon Sep 17 00:00:00 2001 From: Serapheim Dimitropoulos Date: Tue, 20 Dec 2022 10:06:58 -0500 Subject: [PATCH 3/4] Fix B-Tree Walker = Testing Before: ``` File "/usr/lib/python3/dist-packages/sdb/command.py", line 651, in _call yield from self.walk(obj) File "/usr/lib/python3/dist-packages/sdb/commands/zfs/btree.py", line 86, in walk yield from self._helper(obj.bt_root) File "/usr/lib/python3/dist-packages/sdb/commands/zfs/btree.py", line 70, in _helper if node.bth_core: AttributeError: 'zfs_btree_hdr_t' has no member 'bth_core' ---------------------------------------------------------- Link: https://github.com/delphix/sdb/issues/new ``` After: ``` sdb> spa | vdev 0 | metaslab | member ms_allocatable.rt_root | filter "obj.bt_num_elems != 0" | head 1 | zfs_btree (void *)0xffff9cfb9a44a010 (void *)0xffff9cfb9a44a018 (void *)0xffff9cfb9a44a020 (void *)0xffff9cfb9a44a028 (void *)0xffff9cfb9a44a030 ``` = Github Issue Tracker Automation Closes #297 --- sdb/commands/zfs/btree.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sdb/commands/zfs/btree.py b/sdb/commands/zfs/btree.py index fd170a7..4b5798d 100644 --- a/sdb/commands/zfs/btree.py +++ b/sdb/commands/zfs/btree.py @@ -66,8 +66,17 @@ def _helper(self, node: drgn.Object) -> Iterable[drgn.Object]: if not node: return + # + # We check both members of the node because of the change introdcued in + # https://github.com/delphix/zfs/commit/c0bf952c846100750f526c2a32ebec17694a201b + # + try: + recurse = int(node.bth_first) == -1 + except AttributeError: + recurse = node.bth_core + count = node.bth_count - if node.bth_core: + if recurse: # alterate recursive descent on the children and generating core objects core = drgn.cast('struct zfs_btree_core *', node) for i in range(count): From 1f5021b7c9b91bb45d669cb73a10419ec681ca4b Mon Sep 17 00:00:00 2001 From: Serapheim Dimitropoulos Date: Tue, 20 Dec 2022 10:23:56 -0500 Subject: [PATCH 4/4] Fix incorrect example in spl_cache = Testing ``` sdb> man spl_cache SUMMARY spl_cache [-h] ...... EXAMPLES Print all the objects in the ddt_cache: sdb> spl_kmem_caches | filter 'obj.skc_name == "ddt_cache"' | spl_cache (void *)0xffffa08937e80040 (void *)0xffffa08937e86180 (void *)0xffffa08937e8c2c0 (void *)0xffffa08937e92400 ... ``` = Github Issue Tracker Automation Closes #295 --- sdb/commands/spl/spl_kmem_caches.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdb/commands/spl/spl_kmem_caches.py b/sdb/commands/spl/spl_kmem_caches.py index ff41743..639d3ea 100644 --- a/sdb/commands/spl/spl_kmem_caches.py +++ b/sdb/commands/spl/spl_kmem_caches.py @@ -212,7 +212,7 @@ class SplKmemCacheWalker(sdb.Walker): EXAMPLES Print all the objects in the ddt_cache: - sdb> spl_kmem_caches | filter obj.skc_name == "ddt_cache" | spl_cache + sdb> spl_kmem_caches | filter 'obj.skc_name == "ddt_cache"' | spl_cache (void *)0xffffa08937e80040 (void *)0xffffa08937e86180 (void *)0xffffa08937e8c2c0