tnfctl_int.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 (c) 1994, by Sun Microsytems, Inc.
*/
#ifndef _TNFCTL_INT_H
#define _TNFCTL_INT_H
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Interfaces private to libtnfctl
* layout of tnfctl handle structure
* layout of probe handle structure
* other misc. interfaces used across source files
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "tnfctl.h"
#include <gelf.h>
#include <libelf.h>
#include "prb_proc.h"
/* for warlock (lock_lint) static lock checking */
#include <note.h>
#include <thread.h>
#include <synch.h>
/*
* This bogus structure is our way of getting around the fact that
* warlock does not handle recursive locks (warlock does not complain
* when anonymous locks, such as warlock_kludge->lmap_lock, are
* multiply locked).
*/
#if defined(__lock_lint)
struct warlock {
} *warlock_kludge;
#endif
/*
* global variables used for INTERNAL_MODE synchronization with
* dlopen's and dlclose's on another thread.
*/
extern mutex_t _tnfctl_lmap_lock;
extern boolean_t _tnfctl_libs_changed;
/* Project private interface - function name in target */
#define TRACE_END_FUNC "tnf_trace_end"
/* All tnfctl handles are in one of the following 4 modes */
enum proc_mode {
KERNEL_MODE, /* kernel tracing */
DIRECT_MODE, /* tracing another process (exec or attach) */
INDIRECT_MODE, /* client provides /proc functions */
INTERNAL_MODE /* tracing probes in the same process */
};
typedef struct prbctlref prbctlref_t;
/* per probe state - transient - freed on dlclose() */
struct prbctlref {
char *attr_string;
};
/* per object state */
struct objlist {
char * objname;
int objfd;
};
/* per probe state that is freed only on tnfctl_close() */
struct tnfctl_probe_handle {
void *client_registered_data;
struct tnfctl_probe_handle *next;
};
/*
* state saved per tnfctl handle
*/
struct tnfctl_handle {
void *proc_p; /* proc handle */
int kfd; /* kernel handle */
/* tracing info */
const char *trace_file_name;
int trace_buf_size;
int trace_min_size;
/* addresses of functions in target */
/* object info */
/* combination info */
void *buildroot; /* root of built combinations */
void *decoderoot; /* root of decoded combinations */
void (*destroy_func)(void *);
/* functions to inspect target process */
void *client_data);
};
typedef enum comb_op {
PRB_COMB_CHAIN = 0, /* call the down, then the next */
} comb_op_t;
enum event_op_t {
};
/*
* interfaces to search for symbols or to search for relocations
* in an elf file
*/
typedef struct tnfctl_elf_search tnfctl_elf_search_t;
/* prototype for callback for traversing an elf section */
typedef tnfctl_errcode_t
/* prototype for callback for traversing records in an elf section */
typedef tnfctl_errcode_t
struct tnfctl_elf_search {
void *section_data;
void *record_data;
};
/* traverse all the sections in an object */
/* search a .rela section */
/* search a .dynsym section */
/* prototype of callback for internal probe traversal function */
typedef tnfctl_errcode_t
/* sync up list of objects with that of the linker */
enum event_op_t *evt);
/* sync up list of objects and probes */
enum event_op_t *);
/* probe interfaces */
/* combination interfaces */
/* allocate memory in target process */
/* inprocess "plug ins" for functions in tnfctl_handle_t structure */
void *client_data);
/* read a string from the target process */
char **outstr_pp);
/* symbol searching interfaces */
char **symname);
/* free objs and probes */
/* locking interfaces */
/*
* BugID 1253419
* Used to prevent simultaneous internal and external probe control.
* For external control keep pid of traced process to handle case
* where process forks. (child is not under external control)
*/
#define TNFCTL_INTERNAL_TRACEFLAG "_tnfctl_internal_tracing_flag"
#define TNFCTL_EXTERNAL_TRACEDPID "_tnfctl_externally_traced_pid"
extern pid_t _tnfctl_externally_traced_pid;
/* error mapping functions */
/*
* LOCK is the macro to lock down the library list so that a dlopen or
* dlclose by another thread will block waiting for the lock to be released.
*
* LOCK_SYNC does the same as LOCK + it syncs up libtnfctl's cache of
* libraries in target process with that of what the run time linker maintains.
*
* These macros do conditional locking because they are needed only by
* INTERNAL_MODE clients. There are 2 versions of these macros so that
* lock_lint won't have to see the conditional locking.
* CAUTION: Be aware that these macros have a return() embedded in them.
*/
#ifdef __lock_lint
(void) _tnfctl_sync_lib_list(hndl)
#else
if (stat) \
return (stat); \
} \
else
if (stat) \
return (stat); \
if (stat) { \
return (stat); \
} \
} \
else
else
#endif
#ifdef __cplusplus
}
#endif
#endif /* _TNFCTL_INT_H */