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


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  23  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2013 Joyent, Inc. All rights reserved.

  25  */
  26 
  27 #include <mdb/mdb_param.h>
  28 #include <mdb/mdb_modapi.h>
  29 #include <mdb/mdb_ks.h>
  30 #include <mdb/mdb_ctf.h>
  31 
  32 #include <sys/types.h>
  33 #include <sys/thread.h>
  34 #include <sys/session.h>
  35 #include <sys/user.h>
  36 #include <sys/proc.h>
  37 #include <sys/var.h>
  38 #include <sys/t_lock.h>
  39 #include <sys/callo.h>
  40 #include <sys/priocntl.h>
  41 #include <sys/class.h>
  42 #include <sys/regset.h>
  43 #include <sys/stack.h>
  44 #include <sys/cpuvar.h>


  58 #include <sys/cred_impl.h>
  59 #include <sys/zone.h>
  60 #include <sys/panic.h>
  61 #include <regex.h>
  62 #include <sys/port_impl.h>
  63 
  64 #include "avl.h"
  65 #include "bio.h"
  66 #include "bitset.h"
  67 #include "combined.h"
  68 #include "contract.h"
  69 #include "cpupart_mdb.h"
  70 #include "cred.h"
  71 #include "ctxop.h"
  72 #include "cyclic.h"
  73 #include "damap.h"
  74 #include "ddi_periodic.h"
  75 #include "devinfo.h"
  76 #include "findstack.h"
  77 #include "fm.h"

  78 #include "group.h"
  79 #include "irm.h"
  80 #include "kgrep.h"
  81 #include "kmem.h"
  82 #include "ldi.h"
  83 #include "leaky.h"
  84 #include "lgrp.h"
  85 #include "list.h"
  86 #include "log.h"
  87 #include "mdi.h"
  88 #include "memory.h"
  89 #include "mmd.h"
  90 #include "modhash.h"
  91 #include "ndievents.h"
  92 #include "net.h"
  93 #include "netstack.h"
  94 #include "nvpair.h"
  95 #include "pg.h"
  96 #include "rctl.h"
  97 #include "sobj.h"


4171         /* from typegraph.c */
4172         { "findlocks", ":", "find locks held by specified thread", findlocks },
4173         { "findfalse", "?[-v]", "find potentially falsely shared structures",
4174                 findfalse },
4175         { "typegraph", NULL, "build type graph", typegraph },
4176         { "istype", ":type", "manually set object type", istype },
4177         { "notype", ":", "manually clear object type", notype },
4178         { "whattype", ":", "determine object type", whattype },
4179 #endif
4180 
4181         /* from vfs.c */
4182         { "fsinfo", "?[-v]", "print mounted filesystems", fsinfo },
4183         { "pfiles", ":[-fp]", "print process file information", pfiles,
4184                 pfiles_help },
4185 
4186         /* from zone.c */
4187         { "zone", "?[-r [-v]]", "display kernel zone(s)", zoneprt },
4188         { "zsd", ":[-v] [zsd_key]", "display zone-specific-data entries for "
4189             "selected zones", zsd },
4190 





4191         { NULL }
4192 };
4193 
4194 static const mdb_walker_t walkers[] = {
4195 
4196         /* from genunix.c */
4197         { "callouts_bytime", "walk callouts by list chain (expiration time)",
4198                 callout_walk_init, callout_walk_step, callout_walk_fini,
4199                 (void *)CALLOUT_WALK_BYLIST },
4200         { "callouts_byid", "walk callouts by id hash chain",
4201                 callout_walk_init, callout_walk_step, callout_walk_fini,
4202                 (void *)CALLOUT_WALK_BYID },
4203         { "callout_list", "walk a callout list", callout_list_walk_init,
4204                 callout_list_walk_step, callout_list_walk_fini },
4205         { "callout_table", "walk callout table array", callout_table_walk_init,
4206                 callout_table_walk_step, callout_table_walk_fini },
4207         { "cpu", "walk cpu structures", cpu_walk_init, cpu_walk_step },
4208         { "ereportq_dump", "walk list of ereports in dump error queue",
4209                 ereportq_dump_walk_init, ereportq_dump_walk_step, NULL },
4210         { "ereportq_pend", "walk list of ereports in pending error queue",


4588 static void
4589 genunix_statechange_cb(void *ignored)
4590 {
4591         /*
4592          * Force ::findleaks and ::stacks to let go any cached state.
4593          */
4594         leaky_cleanup(1);
4595         stacks_cleanup(1);
4596 
4597         kmem_statechange();     /* notify kmem */
4598 }
4599 
4600 const mdb_modinfo_t *
4601 _mdb_init(void)
4602 {
4603         kmem_init();
4604 
4605         (void) mdb_callback_add(MDB_CALLBACK_STCHG,
4606             genunix_statechange_cb, NULL);
4607 




4608         return (&modinfo);
4609 }
4610 
4611 void
4612 _mdb_fini(void)
4613 {
4614         leaky_cleanup(1);
4615         stacks_cleanup(1);
4616 }


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  23  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2013 Joyent, Inc. All rights reserved.
  25  * Copyright (c) 2013 by Delphix. All rights reserved.
  26  */
  27 
  28 #include <mdb/mdb_param.h>
  29 #include <mdb/mdb_modapi.h>
  30 #include <mdb/mdb_ks.h>
  31 #include <mdb/mdb_ctf.h>
  32 
  33 #include <sys/types.h>
  34 #include <sys/thread.h>
  35 #include <sys/session.h>
  36 #include <sys/user.h>
  37 #include <sys/proc.h>
  38 #include <sys/var.h>
  39 #include <sys/t_lock.h>
  40 #include <sys/callo.h>
  41 #include <sys/priocntl.h>
  42 #include <sys/class.h>
  43 #include <sys/regset.h>
  44 #include <sys/stack.h>
  45 #include <sys/cpuvar.h>


  59 #include <sys/cred_impl.h>
  60 #include <sys/zone.h>
  61 #include <sys/panic.h>
  62 #include <regex.h>
  63 #include <sys/port_impl.h>
  64 
  65 #include "avl.h"
  66 #include "bio.h"
  67 #include "bitset.h"
  68 #include "combined.h"
  69 #include "contract.h"
  70 #include "cpupart_mdb.h"
  71 #include "cred.h"
  72 #include "ctxop.h"
  73 #include "cyclic.h"
  74 #include "damap.h"
  75 #include "ddi_periodic.h"
  76 #include "devinfo.h"
  77 #include "findstack.h"
  78 #include "fm.h"
  79 #include "gcore.h"
  80 #include "group.h"
  81 #include "irm.h"
  82 #include "kgrep.h"
  83 #include "kmem.h"
  84 #include "ldi.h"
  85 #include "leaky.h"
  86 #include "lgrp.h"
  87 #include "list.h"
  88 #include "log.h"
  89 #include "mdi.h"
  90 #include "memory.h"
  91 #include "mmd.h"
  92 #include "modhash.h"
  93 #include "ndievents.h"
  94 #include "net.h"
  95 #include "netstack.h"
  96 #include "nvpair.h"
  97 #include "pg.h"
  98 #include "rctl.h"
  99 #include "sobj.h"


4173         /* from typegraph.c */
4174         { "findlocks", ":", "find locks held by specified thread", findlocks },
4175         { "findfalse", "?[-v]", "find potentially falsely shared structures",
4176                 findfalse },
4177         { "typegraph", NULL, "build type graph", typegraph },
4178         { "istype", ":type", "manually set object type", istype },
4179         { "notype", ":", "manually clear object type", notype },
4180         { "whattype", ":", "determine object type", whattype },
4181 #endif
4182 
4183         /* from vfs.c */
4184         { "fsinfo", "?[-v]", "print mounted filesystems", fsinfo },
4185         { "pfiles", ":[-fp]", "print process file information", pfiles,
4186                 pfiles_help },
4187 
4188         /* from zone.c */
4189         { "zone", "?[-r [-v]]", "display kernel zone(s)", zoneprt },
4190         { "zsd", ":[-v] [zsd_key]", "display zone-specific-data entries for "
4191             "selected zones", zsd },
4192 
4193 #ifndef _KMDB
4194         { "gcore", NULL, "generate a user core for the given process",
4195             gcore_dcmd },
4196 #endif
4197 
4198         { NULL }
4199 };
4200 
4201 static const mdb_walker_t walkers[] = {
4202 
4203         /* from genunix.c */
4204         { "callouts_bytime", "walk callouts by list chain (expiration time)",
4205                 callout_walk_init, callout_walk_step, callout_walk_fini,
4206                 (void *)CALLOUT_WALK_BYLIST },
4207         { "callouts_byid", "walk callouts by id hash chain",
4208                 callout_walk_init, callout_walk_step, callout_walk_fini,
4209                 (void *)CALLOUT_WALK_BYID },
4210         { "callout_list", "walk a callout list", callout_list_walk_init,
4211                 callout_list_walk_step, callout_list_walk_fini },
4212         { "callout_table", "walk callout table array", callout_table_walk_init,
4213                 callout_table_walk_step, callout_table_walk_fini },
4214         { "cpu", "walk cpu structures", cpu_walk_init, cpu_walk_step },
4215         { "ereportq_dump", "walk list of ereports in dump error queue",
4216                 ereportq_dump_walk_init, ereportq_dump_walk_step, NULL },
4217         { "ereportq_pend", "walk list of ereports in pending error queue",


4595 static void
4596 genunix_statechange_cb(void *ignored)
4597 {
4598         /*
4599          * Force ::findleaks and ::stacks to let go any cached state.
4600          */
4601         leaky_cleanup(1);
4602         stacks_cleanup(1);
4603 
4604         kmem_statechange();     /* notify kmem */
4605 }
4606 
4607 const mdb_modinfo_t *
4608 _mdb_init(void)
4609 {
4610         kmem_init();
4611 
4612         (void) mdb_callback_add(MDB_CALLBACK_STCHG,
4613             genunix_statechange_cb, NULL);
4614 
4615 #ifndef _KMDB
4616         gcore_init();
4617 #endif
4618 
4619         return (&modinfo);
4620 }
4621 
4622 void
4623 _mdb_fini(void)
4624 {
4625         leaky_cleanup(1);
4626         stacks_cleanup(1);
4627 }