/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <mdb/mdb_modapi.h>
struct aw_info {
const char *aw_elem_name;
void *aw_elem_check_arg;
};
/*
* common code used to find the addr of the the leftmost child below
* an AVL node
*/
static uintptr_t
const char *elem_name)
{
for (;;) {
return ((uintptr_t)-1L);
}
break;
}
return (addr);
}
/*
* initialize a forward walk thru an avl tree.
*
* begin and end optionally specify objects other than the first and last
* objects in the tree; either or both may be NULL (defaulting to first and
* last).
*
* avl_name and element_name specify command-specific labels other than
* "avl_tree_t" and "tree element" for use in error messages.
*
* element_check() returns -1, 1, or 0: abort the walk with an error, stop
* without an error, or allow the normal callback; arg is an optional user
* argument to element_check().
*/
int
const char *avl_name, const char *element_name,
{
avl_name = "avl_tree_t";
if (element_name == NULL)
element_name = "tree element";
/*
* allocate the AVL walk data
*/
/*
* get an mdb copy of the avl_tree_t being walked
*/
goto error;
}
mdb_warn("invalid avl_tree_t at %p, avl_size:%d, avl_offset:%d",
goto error;
}
/*
* allocate a buffer to hold the mdb copy of tree's structs
* "node" always points at the avl_node_t field inside the struct
*/
/*
* get the first avl_node_t address, use same algorithm
* as avl_start() -- leftmost child in tree from root
*/
return (WALK_NEXT);
}
goto error;
} else {
}
return (WALK_NEXT);
return (WALK_ERR);
}
int
{
}
int
const char *avl_name, const char *element_name)
{
}
int
const char *avl_name, const char *element_name,
{
element_check, arg));
}
/*
* At each step, visit (callback) the current node, then move to the next
* in the AVL tree. Uses the same algorithm as avl_walk().
*/
int
{
int status;
int was_child;
/*
* don't walk past the end of the tree!
*/
return (WALK_DONE);
return (WALK_DONE);
/*
* must read the current node for the call back to use
*/
return (WALK_ERR);
}
if (rc == -1)
return (WALK_ERR);
else if (rc == 1)
return (WALK_DONE);
}
/*
* do the call back
*/
return (status);
/*
* move to the next node....
* note we read in new nodes, so the pointer to the buffer is fixed
*/
/*
* if the node has a right child then go to it and then all the way
* thru as many left children as possible
*/
aw->aw_elem_name);
return (WALK_ERR);
/*
* othewise return to parent nodes, stopping if we ever return from
* a left child
*/
} else {
for (;;) {
break;
if (was_child == 0) /* stop on return from left child */
break;
mdb_warn("failed to read %s at %#lx",
return (WALK_ERR);
}
}
}
return (WALK_NEXT);
}
/*
* Release the memory allocated for the walk
*/
void
{
return;
}
/*
* This function is named avl_walk_mdb to avoid a naming conflict with the
* existing avl_walk function.
*/
int
{
int ret;
avl_walk_init(&ws);
continue;
avl_walk_fini(&ws);
return (ret);
}