Print this page
3946 ::gcore
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/mdb/common/modules/genunix/avl.c
          +++ new/usr/src/cmd/mdb/common/modules/genunix/avl.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
       25 +/*
       26 + * Copyright (c) 2013 by Delphix. All rights reserved.
       27 + */
  25   28  
  26      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  27      -
  28   29  #include <sys/avl.h>
  29   30  
  30   31  #include <mdb/mdb_modapi.h>
  31   32  
  32   33  struct aw_info {
  33   34          void *aw_buff;          /* buffer to hold tree element */
  34   35          avl_tree_t aw_tree;     /* copy of avl_tree_t being walked */
  35   36          uintptr_t aw_end;       /* last node in specified range */
  36   37          const char *aw_elem_name;
  37   38          int (*aw_elem_check)(void *, uintptr_t, void *);
↓ open down ↓ 237 lines elided ↑ open up ↑
 275  276  
 276  277          aw = (struct aw_info *)wsp->walk_data;
 277  278  
 278  279          if (aw == NULL)
 279  280                  return;
 280  281  
 281  282          if (aw->aw_buff != NULL)
 282  283                  mdb_free(aw->aw_buff, aw->aw_tree.avl_size);
 283  284  
 284  285          mdb_free(aw, sizeof (struct aw_info));
      286 +}
      287 +
      288 +/*
      289 + * This function is named avl_walk_mdb to avoid a naming conflict with the
      290 + * existing avl_walk function.
      291 + */
      292 +int
      293 +avl_walk_mdb(uintptr_t addr, mdb_walk_cb_t callback, void *cbdata)
      294 +{
      295 +        mdb_walk_state_t ws;
      296 +        int ret;
      297 +
      298 +        ws.walk_addr = addr;
      299 +        ws.walk_callback = callback;
      300 +        ws.walk_cbdata = cbdata;
      301 +
      302 +        avl_walk_init(&ws);
      303 +        while ((ret = avl_walk_step(&ws)) == WALK_NEXT)
      304 +                continue;
      305 +        avl_walk_fini(&ws);
      306 +
      307 +        return (ret);
 285  308  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX