Print this page
9210 remove KMDB branch debugging support
9211 ::crregs could do with cr2/cr3 support
9209 ::ttrace should be able to filter by thread
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Yuri Pankov <yuripv@yuripv.net>


   4  * The contents of this file are subject to the terms of the
   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 2008 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.


  24  */
  25 
  26 #pragma ident   "%Z%%M% %I%     %E% SMI"
  27 
  28 /*
  29  * Kernel Process View Target
  30  *
  31  * The kproc target is activated when the user is debugging a kernel using the
  32  * kvm target and executes a ::context dcmd to change the debugger view to one
  33  * of the running processes.  The kvm target's t_setcontext operation will
  34  * create and activate a kproc target in response to this call.  The kproc
  35  * target itself is built upon the kvm target's libkvm cookie and the ability
  36  * to read information from the kernel itself and the ability to read the
  37  * address space of a particular user process with kvm_aread().  It also relies
  38  * on a special set of functions provided by the kvm target's mdb_ks support
  39  * module in order to bootstrap: specifically, given the initial proc pointer,
  40  * mdb_ks provides functions to return the set of address space mappings, the
  41  * address space pointer itself, the aux vector vector saved in the u-area,
  42  * and the process data model.  The kproc target maintains a list of address
  43  * space mappings (kp_map_t) and load objects (kp_file_t), and for each load
  44  * object will attempt to read the corresponding dynamic symbol table.  In
  45  * order to bootstrap, the target uses the AT_BASE and AT_ENTRY aux vector
  46  * elements to locate the dynamic linker and executable mappings.  With these
  47  * mappings in place, we initialize a librtld_db agent on the target (see


 902         (ssize_t (*)()) mdb_tgt_notsup,         /* t_pread */
 903         (ssize_t (*)()) mdb_tgt_notsup,         /* t_pwrite */
 904         (ssize_t (*)()) mdb_tgt_notsup,         /* t_fread */
 905         (ssize_t (*)()) mdb_tgt_notsup,         /* t_fwrite */
 906         (ssize_t (*)()) mdb_tgt_notsup,         /* t_ioread */
 907         (ssize_t (*)()) mdb_tgt_notsup,         /* t_iowrite */
 908         kp_vtop,                                /* t_vtop */
 909         kp_lookup_by_name,                      /* t_lookup_by_name */
 910         kp_lookup_by_addr,                      /* t_lookup_by_addr */
 911         kp_symbol_iter,                         /* t_symbol_iter */
 912         kp_mapping_iter,                        /* t_mapping_iter */
 913         kp_object_iter,                         /* t_object_iter */
 914         kp_addr_to_map,                         /* t_addr_to_map */
 915         kp_name_to_map,                         /* t_name_to_map */
 916         (struct ctf_file *(*)()) mdb_tgt_null,  /* t_addr_to_ctf */
 917         (struct ctf_file *(*)()) mdb_tgt_null,  /* t_name_to_ctf */
 918         kp_status,                              /* t_status */
 919         (int (*)()) mdb_tgt_notsup,             /* t_run */
 920         (int (*)()) mdb_tgt_notsup,             /* t_step */
 921         (int (*)()) mdb_tgt_notsup,             /* t_step_out */
 922         (int (*)()) mdb_tgt_notsup,             /* t_step_branch */
 923         (int (*)()) mdb_tgt_notsup,             /* t_next */
 924         (int (*)()) mdb_tgt_notsup,             /* t_cont */
 925         (int (*)()) mdb_tgt_notsup,             /* t_signal */
 926         (int (*)()) mdb_tgt_null,               /* t_add_sbrkpt */
 927         (int (*)()) mdb_tgt_null,               /* t_add_vbrkpt */
 928         (int (*)()) mdb_tgt_null,               /* t_add_pwapt */
 929         (int (*)()) mdb_tgt_null,               /* t_add_vwapt */
 930         (int (*)()) mdb_tgt_null,               /* t_add_iowapt */
 931         (int (*)()) mdb_tgt_null,               /* t_add_sysenter */
 932         (int (*)()) mdb_tgt_null,               /* t_add_sysexit */
 933         (int (*)()) mdb_tgt_null,               /* t_add_signal */
 934         (int (*)()) mdb_tgt_null,               /* t_add_fault */
 935         (int (*)()) mdb_tgt_notsup,             /* t_getareg XXX */
 936         (int (*)()) mdb_tgt_notsup,             /* t_putareg XXX */
 937         (int (*)()) mdb_tgt_notsup,             /* t_stack_iter XXX */
 938         kp_auxv                                 /* t_auxv */
 939 };
 940 
 941 int
 942 mdb_kproc_tgt_create(mdb_tgt_t *t, int argc, const char *argv[])




   4  * The contents of this file are subject to the terms of the
   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 2008 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  *
  25  * Copyright 2018 Joyent, Inc.
  26  */
  27 


  28 /*
  29  * Kernel Process View Target
  30  *
  31  * The kproc target is activated when the user is debugging a kernel using the
  32  * kvm target and executes a ::context dcmd to change the debugger view to one
  33  * of the running processes.  The kvm target's t_setcontext operation will
  34  * create and activate a kproc target in response to this call.  The kproc
  35  * target itself is built upon the kvm target's libkvm cookie and the ability
  36  * to read information from the kernel itself and the ability to read the
  37  * address space of a particular user process with kvm_aread().  It also relies
  38  * on a special set of functions provided by the kvm target's mdb_ks support
  39  * module in order to bootstrap: specifically, given the initial proc pointer,
  40  * mdb_ks provides functions to return the set of address space mappings, the
  41  * address space pointer itself, the aux vector vector saved in the u-area,
  42  * and the process data model.  The kproc target maintains a list of address
  43  * space mappings (kp_map_t) and load objects (kp_file_t), and for each load
  44  * object will attempt to read the corresponding dynamic symbol table.  In
  45  * order to bootstrap, the target uses the AT_BASE and AT_ENTRY aux vector
  46  * elements to locate the dynamic linker and executable mappings.  With these
  47  * mappings in place, we initialize a librtld_db agent on the target (see


 902         (ssize_t (*)()) mdb_tgt_notsup,         /* t_pread */
 903         (ssize_t (*)()) mdb_tgt_notsup,         /* t_pwrite */
 904         (ssize_t (*)()) mdb_tgt_notsup,         /* t_fread */
 905         (ssize_t (*)()) mdb_tgt_notsup,         /* t_fwrite */
 906         (ssize_t (*)()) mdb_tgt_notsup,         /* t_ioread */
 907         (ssize_t (*)()) mdb_tgt_notsup,         /* t_iowrite */
 908         kp_vtop,                                /* t_vtop */
 909         kp_lookup_by_name,                      /* t_lookup_by_name */
 910         kp_lookup_by_addr,                      /* t_lookup_by_addr */
 911         kp_symbol_iter,                         /* t_symbol_iter */
 912         kp_mapping_iter,                        /* t_mapping_iter */
 913         kp_object_iter,                         /* t_object_iter */
 914         kp_addr_to_map,                         /* t_addr_to_map */
 915         kp_name_to_map,                         /* t_name_to_map */
 916         (struct ctf_file *(*)()) mdb_tgt_null,  /* t_addr_to_ctf */
 917         (struct ctf_file *(*)()) mdb_tgt_null,  /* t_name_to_ctf */
 918         kp_status,                              /* t_status */
 919         (int (*)()) mdb_tgt_notsup,             /* t_run */
 920         (int (*)()) mdb_tgt_notsup,             /* t_step */
 921         (int (*)()) mdb_tgt_notsup,             /* t_step_out */

 922         (int (*)()) mdb_tgt_notsup,             /* t_next */
 923         (int (*)()) mdb_tgt_notsup,             /* t_cont */
 924         (int (*)()) mdb_tgt_notsup,             /* t_signal */
 925         (int (*)()) mdb_tgt_null,               /* t_add_sbrkpt */
 926         (int (*)()) mdb_tgt_null,               /* t_add_vbrkpt */
 927         (int (*)()) mdb_tgt_null,               /* t_add_pwapt */
 928         (int (*)()) mdb_tgt_null,               /* t_add_vwapt */
 929         (int (*)()) mdb_tgt_null,               /* t_add_iowapt */
 930         (int (*)()) mdb_tgt_null,               /* t_add_sysenter */
 931         (int (*)()) mdb_tgt_null,               /* t_add_sysexit */
 932         (int (*)()) mdb_tgt_null,               /* t_add_signal */
 933         (int (*)()) mdb_tgt_null,               /* t_add_fault */
 934         (int (*)()) mdb_tgt_notsup,             /* t_getareg XXX */
 935         (int (*)()) mdb_tgt_notsup,             /* t_putareg XXX */
 936         (int (*)()) mdb_tgt_notsup,             /* t_stack_iter XXX */
 937         kp_auxv                                 /* t_auxv */
 938 };
 939 
 940 int
 941 mdb_kproc_tgt_create(mdb_tgt_t *t, int argc, const char *argv[])