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 2007 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.


  24  */
  25 
  26 #ifndef _KVM_H
  27 #define _KVM_H
  28 
  29 #pragma ident   "%Z%%M% %I%     %E% SMI"
  30 
  31 /*
  32  * The kmdb target
  33  */
  34 
  35 #include <mdb/mdb_modapi.h>
  36 #include <mdb/mdb_target.h>
  37 #include <kmdb/kmdb_dpi.h>
  38 #include <kmdb/kvm_isadep.h>
  39 #include <kmdb/kvm_cpu.h>
  40 
  41 #include <sys/kobj.h>
  42 
  43 #ifdef __cplusplus
  44 extern "C" {
  45 #endif
  46 
  47 #define KM_F_PRIMARY            1
  48 
  49 #define KMT_TRAP_NOTENUM        -1      /* Glob for unnamed traps */
  50 #define KMT_TRAP_ALL            -2      /* Glob for all traps */
  51 
  52 typedef struct kmt_module {
  53         mdb_list_t      km_list;        /* List forward/back pointers */
  54         char            *km_name;       /* Module name */
  55         char            km_seen;
  56         GElf_Ehdr       km_ehdr;
  57 
  58         mdb_gelf_symtab_t *km_symtab;
  59         Shdr            km_symtab_hdr;


  69         size_t          km_bss_size;
  70         const void      *km_ctf_va;
  71         size_t          km_ctf_size;
  72 
  73         ctf_file_t      *km_ctfp;
  74         struct modctl   km_modctl;
  75         struct module   km_module;
  76         int             km_flags;
  77 } kmt_module_t;
  78 
  79 typedef struct kmt_data {
  80         const mdb_tgt_regdesc_t *kmt_rds;       /* Register description table */
  81         mdb_nv_t        kmt_modules;            /* Hash table of modules */
  82         mdb_list_t      kmt_modlist;            /* List of mods in load order */
  83         const char      *kmt_rtld_name;         /* Module containing krtld */
  84         caddr_t         kmt_writemap;           /* Used to map PAs for writes */
  85         size_t          kmt_writemapsz;         /* Size of same */
  86         mdb_map_t       kmt_map;                /* Persistant map for callers */
  87         ulong_t         *kmt_trapmap;
  88         size_t          kmt_trapmax;
  89         kmt_cpu_t       *kmt_cpu;               /* CPU-specific plugin */
  90         int             kmt_cpu_retry;          /* Try CPU detect again? */
  91         int             kmt_symavail;           /* Symbol resolution allowed */
  92         uint_t          kmt_narmedbpts;         /* Number of armed brkpts */
  93 #if defined(__i386) || defined(__amd64)
  94         struct {
  95                 GElf_Sym        _kmt_cmnint;
  96                 GElf_Sym        _kmt_cmntrap;
  97                 GElf_Sym        _kmt_sysenter;
  98                 GElf_Sym        _kmt_brand_sysenter;
  99 #if defined(__amd64)
 100                 GElf_Sym        _kmt_syscall;
 101                 GElf_Sym        _kmt_brand_syscall;
 102 #endif
 103         } kmt_intrsyms;
 104 #endif
 105 } kmt_data_t;
 106 
 107 #if defined(__i386) || defined(__amd64)
 108 #define kmt_cmnint      kmt_intrsyms._kmt_cmnint
 109 #define kmt_cmntrap     kmt_intrsyms._kmt_cmntrap
 110 #endif


 126         char *ka_symbol;                        /* Symbolic name */
 127         kmt_defbp_t *ka_defbp;
 128 } kmt_bparg_t;
 129 
 130 extern void kmt_printregs(const mdb_tgt_gregset_t *gregs);
 131 
 132 extern const char *kmt_def_dismode(void);
 133 
 134 extern void kmt_init_isadep(mdb_tgt_t *);
 135 extern void kmt_startup_isadep(mdb_tgt_t *);
 136 
 137 extern ssize_t kmt_write(mdb_tgt_t *, const void *, size_t, uintptr_t);
 138 extern ssize_t kmt_pwrite(mdb_tgt_t *, const void *, size_t, physaddr_t);
 139 extern ssize_t kmt_rw(mdb_tgt_t *, void *, size_t, uint64_t,
 140     ssize_t (*)(void *, size_t, uint64_t));
 141 extern ssize_t kmt_writer(void *, size_t, uint64_t);
 142 extern ssize_t kmt_ioread(mdb_tgt_t *, void *, size_t, uintptr_t);
 143 extern ssize_t kmt_iowrite(mdb_tgt_t *, const void *, size_t, uintptr_t);
 144 
 145 extern int kmt_step_out(mdb_tgt_t *, uintptr_t *);
 146 extern int kmt_step_branch(mdb_tgt_t *);
 147 extern int kmt_next(mdb_tgt_t *, uintptr_t *);
 148 
 149 extern int kmt_stack(uintptr_t, uint_t, int, const mdb_arg_t *);
 150 extern int kmt_stackv(uintptr_t, uint_t, int, const mdb_arg_t *);
 151 extern int kmt_stackr(uintptr_t, uint_t, int, const mdb_arg_t *);
 152 extern int kmt_cpustack(uintptr_t, uint_t, int, const mdb_arg_t *, int, int);
 153 
 154 extern const char *kmt_trapname(int);
 155 
 156 #ifdef __cplusplus
 157 }
 158 #endif
 159 
 160 #endif /* _KVM_H */


   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 2007 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  *
  25  * Copyright 2018 Joyent, Inc.
  26  */
  27 
  28 #ifndef _KVM_H
  29 #define _KVM_H
  30 


  31 /*
  32  * The kmdb target
  33  */
  34 
  35 #include <mdb/mdb_modapi.h>
  36 #include <mdb/mdb_target.h>
  37 #include <kmdb/kmdb_dpi.h>
  38 #include <kmdb/kvm_isadep.h>

  39 
  40 #include <sys/kobj.h>
  41 
  42 #ifdef __cplusplus
  43 extern "C" {
  44 #endif
  45 
  46 #define KM_F_PRIMARY            1
  47 
  48 #define KMT_TRAP_NOTENUM        -1      /* Glob for unnamed traps */
  49 #define KMT_TRAP_ALL            -2      /* Glob for all traps */
  50 
  51 typedef struct kmt_module {
  52         mdb_list_t      km_list;        /* List forward/back pointers */
  53         char            *km_name;       /* Module name */
  54         char            km_seen;
  55         GElf_Ehdr       km_ehdr;
  56 
  57         mdb_gelf_symtab_t *km_symtab;
  58         Shdr            km_symtab_hdr;


  68         size_t          km_bss_size;
  69         const void      *km_ctf_va;
  70         size_t          km_ctf_size;
  71 
  72         ctf_file_t      *km_ctfp;
  73         struct modctl   km_modctl;
  74         struct module   km_module;
  75         int             km_flags;
  76 } kmt_module_t;
  77 
  78 typedef struct kmt_data {
  79         const mdb_tgt_regdesc_t *kmt_rds;       /* Register description table */
  80         mdb_nv_t        kmt_modules;            /* Hash table of modules */
  81         mdb_list_t      kmt_modlist;            /* List of mods in load order */
  82         const char      *kmt_rtld_name;         /* Module containing krtld */
  83         caddr_t         kmt_writemap;           /* Used to map PAs for writes */
  84         size_t          kmt_writemapsz;         /* Size of same */
  85         mdb_map_t       kmt_map;                /* Persistant map for callers */
  86         ulong_t         *kmt_trapmap;
  87         size_t          kmt_trapmax;


  88         int             kmt_symavail;           /* Symbol resolution allowed */
  89         uint_t          kmt_narmedbpts;         /* Number of armed brkpts */
  90 #if defined(__i386) || defined(__amd64)
  91         struct {
  92                 GElf_Sym        _kmt_cmnint;
  93                 GElf_Sym        _kmt_cmntrap;
  94                 GElf_Sym        _kmt_sysenter;
  95                 GElf_Sym        _kmt_brand_sysenter;
  96 #if defined(__amd64)
  97                 GElf_Sym        _kmt_syscall;
  98                 GElf_Sym        _kmt_brand_syscall;
  99 #endif
 100         } kmt_intrsyms;
 101 #endif
 102 } kmt_data_t;
 103 
 104 #if defined(__i386) || defined(__amd64)
 105 #define kmt_cmnint      kmt_intrsyms._kmt_cmnint
 106 #define kmt_cmntrap     kmt_intrsyms._kmt_cmntrap
 107 #endif


 123         char *ka_symbol;                        /* Symbolic name */
 124         kmt_defbp_t *ka_defbp;
 125 } kmt_bparg_t;
 126 
 127 extern void kmt_printregs(const mdb_tgt_gregset_t *gregs);
 128 
 129 extern const char *kmt_def_dismode(void);
 130 
 131 extern void kmt_init_isadep(mdb_tgt_t *);
 132 extern void kmt_startup_isadep(mdb_tgt_t *);
 133 
 134 extern ssize_t kmt_write(mdb_tgt_t *, const void *, size_t, uintptr_t);
 135 extern ssize_t kmt_pwrite(mdb_tgt_t *, const void *, size_t, physaddr_t);
 136 extern ssize_t kmt_rw(mdb_tgt_t *, void *, size_t, uint64_t,
 137     ssize_t (*)(void *, size_t, uint64_t));
 138 extern ssize_t kmt_writer(void *, size_t, uint64_t);
 139 extern ssize_t kmt_ioread(mdb_tgt_t *, void *, size_t, uintptr_t);
 140 extern ssize_t kmt_iowrite(mdb_tgt_t *, const void *, size_t, uintptr_t);
 141 
 142 extern int kmt_step_out(mdb_tgt_t *, uintptr_t *);

 143 extern int kmt_next(mdb_tgt_t *, uintptr_t *);
 144 
 145 extern int kmt_stack(uintptr_t, uint_t, int, const mdb_arg_t *);
 146 extern int kmt_stackv(uintptr_t, uint_t, int, const mdb_arg_t *);
 147 extern int kmt_stackr(uintptr_t, uint_t, int, const mdb_arg_t *);
 148 extern int kmt_cpustack(uintptr_t, uint_t, int, const mdb_arg_t *, int, int);
 149 
 150 extern const char *kmt_trapname(int);
 151 
 152 #ifdef __cplusplus
 153 }
 154 #endif
 155 
 156 #endif /* _KVM_H */