mdb_target_impl.h revision 9acbbeaf2a1ffe5c14b244867d427714fab43c5c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _MDB_TARGET_IMPL_H
#define _MDB_TARGET_IMPL_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <mdb/mdb_target.h>
#include <mdb/mdb_module.h>
#include <mdb/mdb_list.h>
#include <mdb/mdb_gelf.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _MDB
/*
* Target Operations
*
* This ops vector implements the set of primitives which can be used by the
* debugger to interact with the target, and encompasses most of the calls
* found in <mdb/mdb_target.h>. The remainder of the target interface is
* implemented by common code that invokes these primitives or manipulates
* the common target structures directly.
*/
typedef struct mdb_tgt_ops {
int (*t_setflags)(mdb_tgt_t *, int);
int (*t_setcontext)(mdb_tgt_t *, void *);
void (*t_activate)(mdb_tgt_t *);
void (*t_deactivate)(mdb_tgt_t *);
void (*t_periodic)(mdb_tgt_t *);
const char *(*t_platform)(mdb_tgt_t *);
int (*t_lookup_by_name)(mdb_tgt_t *,
const char *, const char *, GElf_Sym *, mdb_syminfo_t *);
int (*t_lookup_by_addr)(mdb_tgt_t *,
int (*t_symbol_iter)(mdb_tgt_t *,
int (*t_step_branch)(mdb_tgt_t *);
int, mdb_tgt_se_f *, void *);
int (*t_add_sbrkpt)(mdb_tgt_t *, const char *,
int, mdb_tgt_se_f *, void *);
int, mdb_tgt_se_f *, void *);
int, mdb_tgt_se_f *, void *);
int, mdb_tgt_se_f *, void *);
mdb_tgt_reg_t *);
mdb_tgt_stack_f *, void *);
/*
* Software Event Specifiers
*
* The common target layer provides support for the management of software
* event specifiers, used to describe conditions under which a live executing
* target program instance will stop and transfer control back to the debugger.
* Software event management design is discussed in more detail in mdb_target.c.
*/
struct mdb_sespec; /* Software event specifier */
struct mdb_vespec; /* Virtual event specifier */
typedef struct mdb_se_ops {
} mdb_se_ops_t;
typedef struct mdb_sespec {
void *se_data; /* Private storage for ops vector */
int se_state; /* Event specifier state */
int se_errno; /* Last error code (if error state) */
} mdb_sespec_t;
typedef struct mdb_vespec {
int ve_id; /* Virtual event specifier ID (VID) */
int ve_flags; /* Flags (see mdb_target.h) */
void *ve_data; /* Private storage for callback */
void *ve_args; /* Arguments for sespec constructor */
} mdb_vespec_t;
/*
* Xdata Descriptors
*
* Each external data item (xdata) exported by the target has a corresponding
* descriptor associated with the target. The descriptor provides the name
* and description of the data, as well as the routine which is used to
* retrieve the actual data or its size.
*/
typedef struct mdb_xdata {
const char *xd_name; /* Buffer name */
const char *xd_desc; /* Buffer description */
} mdb_xdata_t;
/*
* Target Structure
*
* The target itself contains a few common data members, and then a pointer to
* the underlying ops vector and its private storage pointer. MDB can manage
* multiple targets simultaneously, and the list of all constructed targets is
* pointed to by the mdb_t structure.
*/
struct mdb_tgt {
void *t_pshandle; /* Proc service handle (if not tgt) */
void *t_data; /* Private storage for implementation */
int t_vepos; /* Sequence # for next vespec id > 0 */
int t_veneg; /* Sequence # for next vespec id < 0 */
};
/*
* Special functions which targets can use to fill ops vector slots:
*/
extern long mdb_tgt_notsup(); /* Return -1, errno EMDB_TGTNOTSUP */
extern long mdb_tgt_hwnotsup(); /* return -1, errno EMDB_TGTHWNOTSUP */
extern void *mdb_tgt_null(); /* Return NULL, errno EMDB_TGTNOTSUP */
extern long mdb_tgt_nop(); /* Return 0 for success */
/*
* Utility structures for target implementations:
*/
#define MDB_TGT_R_FLAGS(v) ((v) & 0xffff)
typedef struct mdb_tgt_regdesc {
const char *rd_name; /* Register string name */
/*
* Utility functions for target implementations to use in order to simplify
* the implementation of various routines and to insert and delete xdata
* specifiers and software event specifiers. Refer to the associated comments
* in mdb_target.c for more information about each function.
*/
extern int mdb_tgt_xdata_insert(mdb_tgt_t *, const char *, const char *,
extern int mdb_tgt_xdata_delete(mdb_tgt_t *, const char *);
extern void mdb_tgt_elf_export(mdb_gelf_file_t *);
extern int mdb_tgt_sespec_activate_all(mdb_tgt_t *t);
extern void mdb_tgt_sespec_idle_all(mdb_tgt_t *t, int, int);
extern void mdb_tgt_sespec_arm_all(mdb_tgt_t *t);
extern void mdb_tgt_sespec_idle_all(mdb_tgt_t *t, int, int);
extern void mdb_tgt_sespec_prune_all(mdb_tgt_t *t);
const mdb_se_ops_t *, mdb_list_t *);
const mdb_se_ops_t *, void *);
const mdb_se_ops_t *, void *);
extern void mdb_tgt_sespec_prune_all(mdb_tgt_t *t);
const mdb_se_ops_t *, mdb_list_t *);
const mdb_se_ops_t *, void *);
const mdb_se_ops_t *, void *);
int, mdb_tgt_se_f *, void *, void *, void (*)(mdb_vespec_t *));
/*
* Utility function that target implementations can use to register dcmds,
* walkers, and to create named variables for registers
*/
const mdb_nv_disc_t *, int);
/*
* Utility functions that target implementations can use to fill in the
* mdb_se_ops_t structure and vespec destructor. Each software event specifier
* must minimally supply its own constructor, info function, and match function.
*/
extern void no_ve_dtor(mdb_vespec_t *);
/*
* In the initial version of MDB, the data model property is not part of the
* public API. However, I am providing this as a hidden part of the ABI as
* one way we can handle the situation. If this turns out to be the right
* decision, we can document it later without having to rev the API version.
*/
#define MDB_TGT_MODEL_UNKNOWN 0 /* Unknown data model */
#ifdef _LP64
#else
#endif
extern int mdb_prop_datamodel;
#endif /* _MDB */
#ifdef __cplusplus
}
#endif
#endif /* _MDB_TARGET_IMPL_H */