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>


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


  25  */
  26 
  27 #ifndef _MDB_TARGET_H
  28 #define _MDB_TARGET_H
  29 
  30 #include <sys/utsname.h>
  31 #include <sys/types.h>
  32 #include <gelf.h>
  33 
  34 #ifdef  __cplusplus
  35 extern "C" {
  36 #endif
  37 
  38 /*
  39  * Forward declaration of the target structure: the target itself is defined in
  40  * mdb_tgt_impl.h and is opaque with respect to callers of this interface.
  41  */
  42 
  43 struct mdb_tgt;
  44 struct mdb_arg;


  62 extern int mdb_proc_tgt_create(mdb_tgt_t *, int, const char *[]);
  63 extern int mdb_kproc_tgt_create(mdb_tgt_t *, int, const char *[]);
  64 extern int mdb_rawfile_tgt_create(mdb_tgt_t *, int, const char *[]);
  65 #else
  66 extern int kmdb_kvm_create(mdb_tgt_t *, int, const char *[]);
  67 #endif
  68 
  69 /*
  70  * Targets are created by calling mdb_tgt_create() with an optional set of
  71  * target flags, an argument list, and a target constructor (see above):
  72  */
  73 
  74 #define MDB_TGT_F_RDWR          0x0001  /* Open for writing (else read-only) */
  75 #define MDB_TGT_F_ALLOWIO       0x0002  /* Allow I/O mem access (live only) */
  76 #define MDB_TGT_F_FORCE         0x0004  /* Force open (even if non-exclusive) */
  77 #define MDB_TGT_F_PRELOAD       0x0008  /* Preload all symbol tables */
  78 #define MDB_TGT_F_NOLOAD        0x0010  /* Do not do load-object processing */
  79 #define MDB_TGT_F_NOSTOP        0x0020  /* Do not stop target on attach */
  80 #define MDB_TGT_F_STEP          0x0040  /* Single-step is pending */
  81 #define MDB_TGT_F_STEP_OUT      0x0080  /* Step-out is pending */
  82 #define MDB_TGT_F_STEP_BRANCH   0x0100  /* Step-branch is pending */
  83 #define MDB_TGT_F_NEXT          0x0200  /* Step-over is pending */
  84 #define MDB_TGT_F_CONT          0x0400  /* Continue is pending */
  85 #define MDB_TGT_F_BUSY          0x0800  /* Target is busy executing */
  86 #define MDB_TGT_F_ASIO          0x1000  /* Use t_aread and t_awrite for i/o */
  87 #define MDB_TGT_F_UNLOAD        0x2000  /* Unload has been requested */
  88 #define MDB_TGT_F_ALL           0x3fff  /* Mask of all valid flags */
  89 
  90 typedef int mdb_tgt_ctor_f(mdb_tgt_t *, int, const char *[]);
  91 
  92 extern mdb_tgt_t *mdb_tgt_create(mdb_tgt_ctor_f *, int, int, const char *[]);
  93 extern void mdb_tgt_destroy(mdb_tgt_t *);
  94 
  95 extern int mdb_tgt_getflags(mdb_tgt_t *);
  96 extern int mdb_tgt_setflags(mdb_tgt_t *, int);
  97 extern int mdb_tgt_setcontext(mdb_tgt_t *, void *);
  98 
  99 /*
 100  * Targets are activated and de-activated by the debugger framework.  An
 101  * activation occurs after construction when the target becomes the current
 102  * target in the debugger.  A target is de-activated prior to its destructor
 103  * being called by mdb_tgt_destroy, or when another target is activated.
 104  * These callbacks are suitable for loading support modules and other tasks.
 105  */
 106 extern void mdb_tgt_activate(mdb_tgt_t *);
 107 
 108 /*


 335  * (MDB_STATE_* definitions in the module API need to be in sync with these)
 336  */
 337 #define MDB_TGT_IDLE            0       /* Target is idle (not running yet) */
 338 #define MDB_TGT_RUNNING         1       /* Target is currently executing */
 339 #define MDB_TGT_STOPPED         2       /* Target is stopped */
 340 #define MDB_TGT_UNDEAD          3       /* Target is undead (zombie) */
 341 #define MDB_TGT_DEAD            4       /* Target is dead (core dump) */
 342 #define MDB_TGT_LOST            5       /* Target lost by debugger */
 343 
 344 /*
 345  * Status flags (st_flags):
 346  */
 347 #define MDB_TGT_ISTOP           0x1     /* Stop on event of interest */
 348 #define MDB_TGT_DSTOP           0x2     /* Stop directive is pending */
 349 #define MDB_TGT_BUSY            0x4     /* Busy in debugger */
 350 
 351 extern int mdb_tgt_status(mdb_tgt_t *, mdb_tgt_status_t *);
 352 extern int mdb_tgt_run(mdb_tgt_t *, int, const struct mdb_arg *);
 353 extern int mdb_tgt_step(mdb_tgt_t *, mdb_tgt_status_t *);
 354 extern int mdb_tgt_step_out(mdb_tgt_t *, mdb_tgt_status_t *);
 355 extern int mdb_tgt_step_branch(mdb_tgt_t *, mdb_tgt_status_t *);
 356 extern int mdb_tgt_next(mdb_tgt_t *, mdb_tgt_status_t *);
 357 extern int mdb_tgt_continue(mdb_tgt_t *, mdb_tgt_status_t *);
 358 extern int mdb_tgt_signal(mdb_tgt_t *, int);
 359 
 360 /*
 361  * Iterating through the specifier list yields the integer id (VID) and private
 362  * data pointer for each specifier.
 363  */
 364 typedef int mdb_tgt_vespec_f(mdb_tgt_t *, void *, int, void *);
 365 
 366 /*
 367  * Each event specifier is defined to be in one of the following states.  The
 368  * state transitions are discussed in detail in the comments in mdb_target.c.
 369  */
 370 #define MDB_TGT_SPEC_IDLE       1       /* Inactive (e.g. object not loaded) */
 371 #define MDB_TGT_SPEC_ACTIVE     2       /* Active but not armed in target */
 372 #define MDB_TGT_SPEC_ARMED      3       /* Active and armed (e.g. bkpt set) */
 373 #define MDB_TGT_SPEC_ERROR      4       /* Failed to arm event */
 374 
 375 /*




   5  * Common Development and Distribution License, Version 1.0 only
   6  * (the "License").  You may not use this file except in compliance
   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  *
  26  * Copyright 2018 Joyent, Inc.
  27  */
  28 
  29 #ifndef _MDB_TARGET_H
  30 #define _MDB_TARGET_H
  31 
  32 #include <sys/utsname.h>
  33 #include <sys/types.h>
  34 #include <gelf.h>
  35 
  36 #ifdef  __cplusplus
  37 extern "C" {
  38 #endif
  39 
  40 /*
  41  * Forward declaration of the target structure: the target itself is defined in
  42  * mdb_tgt_impl.h and is opaque with respect to callers of this interface.
  43  */
  44 
  45 struct mdb_tgt;
  46 struct mdb_arg;


  64 extern int mdb_proc_tgt_create(mdb_tgt_t *, int, const char *[]);
  65 extern int mdb_kproc_tgt_create(mdb_tgt_t *, int, const char *[]);
  66 extern int mdb_rawfile_tgt_create(mdb_tgt_t *, int, const char *[]);
  67 #else
  68 extern int kmdb_kvm_create(mdb_tgt_t *, int, const char *[]);
  69 #endif
  70 
  71 /*
  72  * Targets are created by calling mdb_tgt_create() with an optional set of
  73  * target flags, an argument list, and a target constructor (see above):
  74  */
  75 
  76 #define MDB_TGT_F_RDWR          0x0001  /* Open for writing (else read-only) */
  77 #define MDB_TGT_F_ALLOWIO       0x0002  /* Allow I/O mem access (live only) */
  78 #define MDB_TGT_F_FORCE         0x0004  /* Force open (even if non-exclusive) */
  79 #define MDB_TGT_F_PRELOAD       0x0008  /* Preload all symbol tables */
  80 #define MDB_TGT_F_NOLOAD        0x0010  /* Do not do load-object processing */
  81 #define MDB_TGT_F_NOSTOP        0x0020  /* Do not stop target on attach */
  82 #define MDB_TGT_F_STEP          0x0040  /* Single-step is pending */
  83 #define MDB_TGT_F_STEP_OUT      0x0080  /* Step-out is pending */
  84 #define MDB_TGT_F_NEXT          0x0100  /* Step-over is pending */
  85 #define MDB_TGT_F_CONT          0x0200  /* Continue is pending */
  86 #define MDB_TGT_F_BUSY          0x0400  /* Target is busy executing */
  87 #define MDB_TGT_F_ASIO          0x0800  /* Use t_aread and t_awrite for i/o */
  88 #define MDB_TGT_F_UNLOAD        0x1000  /* Unload has been requested */
  89 #define MDB_TGT_F_ALL           0x1fff  /* Mask of all valid flags */

  90 
  91 typedef int mdb_tgt_ctor_f(mdb_tgt_t *, int, const char *[]);
  92 
  93 extern mdb_tgt_t *mdb_tgt_create(mdb_tgt_ctor_f *, int, int, const char *[]);
  94 extern void mdb_tgt_destroy(mdb_tgt_t *);
  95 
  96 extern int mdb_tgt_getflags(mdb_tgt_t *);
  97 extern int mdb_tgt_setflags(mdb_tgt_t *, int);
  98 extern int mdb_tgt_setcontext(mdb_tgt_t *, void *);
  99 
 100 /*
 101  * Targets are activated and de-activated by the debugger framework.  An
 102  * activation occurs after construction when the target becomes the current
 103  * target in the debugger.  A target is de-activated prior to its destructor
 104  * being called by mdb_tgt_destroy, or when another target is activated.
 105  * These callbacks are suitable for loading support modules and other tasks.
 106  */
 107 extern void mdb_tgt_activate(mdb_tgt_t *);
 108 
 109 /*


 336  * (MDB_STATE_* definitions in the module API need to be in sync with these)
 337  */
 338 #define MDB_TGT_IDLE            0       /* Target is idle (not running yet) */
 339 #define MDB_TGT_RUNNING         1       /* Target is currently executing */
 340 #define MDB_TGT_STOPPED         2       /* Target is stopped */
 341 #define MDB_TGT_UNDEAD          3       /* Target is undead (zombie) */
 342 #define MDB_TGT_DEAD            4       /* Target is dead (core dump) */
 343 #define MDB_TGT_LOST            5       /* Target lost by debugger */
 344 
 345 /*
 346  * Status flags (st_flags):
 347  */
 348 #define MDB_TGT_ISTOP           0x1     /* Stop on event of interest */
 349 #define MDB_TGT_DSTOP           0x2     /* Stop directive is pending */
 350 #define MDB_TGT_BUSY            0x4     /* Busy in debugger */
 351 
 352 extern int mdb_tgt_status(mdb_tgt_t *, mdb_tgt_status_t *);
 353 extern int mdb_tgt_run(mdb_tgt_t *, int, const struct mdb_arg *);
 354 extern int mdb_tgt_step(mdb_tgt_t *, mdb_tgt_status_t *);
 355 extern int mdb_tgt_step_out(mdb_tgt_t *, mdb_tgt_status_t *);

 356 extern int mdb_tgt_next(mdb_tgt_t *, mdb_tgt_status_t *);
 357 extern int mdb_tgt_continue(mdb_tgt_t *, mdb_tgt_status_t *);
 358 extern int mdb_tgt_signal(mdb_tgt_t *, int);
 359 
 360 /*
 361  * Iterating through the specifier list yields the integer id (VID) and private
 362  * data pointer for each specifier.
 363  */
 364 typedef int mdb_tgt_vespec_f(mdb_tgt_t *, void *, int, void *);
 365 
 366 /*
 367  * Each event specifier is defined to be in one of the following states.  The
 368  * state transitions are discussed in detail in the comments in mdb_target.c.
 369  */
 370 #define MDB_TGT_SPEC_IDLE       1       /* Inactive (e.g. object not loaded) */
 371 #define MDB_TGT_SPEC_ACTIVE     2       /* Active but not armed in target */
 372 #define MDB_TGT_SPEC_ARMED      3       /* Active and armed (e.g. bkpt set) */
 373 #define MDB_TGT_SPEC_ERROR      4       /* Failed to arm event */
 374 
 375 /*