diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2002-03-15 16:30:34 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2002-03-15 16:30:34 +0000 |
commit | 762c7e2653616ce6ca212000d059575f5a3667da (patch) | |
tree | 6e68b250f0e7b3a3f5eb8b708861130a0aed9524 /usr.bin/pmdb/pmdb.h | |
parent | 8ac4d27abf792757bbc8e71d8497b8631145bd6a (diff) |
Import pmdb 4.1.
(see http://www.blahonga.org/~art/openbsd/pmdb.html for more info).
The development repository now moves here out from my local repository.
Diffstat (limited to 'usr.bin/pmdb/pmdb.h')
-rw-r--r-- | usr.bin/pmdb/pmdb.h | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/usr.bin/pmdb/pmdb.h b/usr.bin/pmdb/pmdb.h new file mode 100644 index 00000000000..18d5cf023c7 --- /dev/null +++ b/usr.bin/pmdb/pmdb.h @@ -0,0 +1,119 @@ +/* $PMDB: pmdb.h,v 1.26 2002/03/11 23:39:49 art Exp $ */ +/* + * Copyright (c) 2002 Artur Grabowski <art@openbsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/signal.h> /* for NSIG */ +#include <sys/queue.h> +#include <sys/ptrace.h> +#include <err.h> + +/* XXX - ugh, yuck, bleah. */ +#ifndef PT_STEP +#define PT_STEP PT_CONTINUE +#endif + +/* + * Process handling. + */ + +struct breakpoint; +struct callback; +struct sym_table; +struct sym_ops; + +/* XXX - should be machdep some day. */ +typedef unsigned long reg; + +/* The state for a debugged process. */ +struct pstate { + pid_t ps_pid; + enum { NONE, LOADED, RUNNING, STOPPED, TERMINATED } ps_state; + int ps_argc; + char **ps_argv; + int ps_flags; + int ps_signum; + int ps_sigstate[NSIG]; + reg ps_npc; + TAILQ_HEAD(,sym_table) ps_syms; /* all symbols tables in a list */ + struct sym_table *ps_sym_exe; /* symbol table for the executable */ + struct sym_ops *ps_sops; /* operations on symbol tables */ + TAILQ_HEAD(,breakpoint) ps_bkpts; /* breakpoints */ + TAILQ_HEAD(,callback) ps_sstep_cbs; /* single step actions */ +}; + +/* flags in ps_flags */ +#define PSF_SYMBOLS 0x02 /* basic symbols loaded */ +#define PSF_KILL 0x04 /* kill this process asap */ +#define PSF_STEP 0x08 /* next continue should sstep */ + +/* ps_sigstate */ +#define SS_STOP 0x00 +#define SS_IGNORE 0x01 + +/* misc helper functions */ +int process_kill(struct pstate *); +int read_from_pid(pid_t pid, off_t from, void *to, size_t size); +int write_to_pid(pid_t pid, off_t to, void *from, size_t size); + +/* process.c */ +int process_load(struct pstate *); +int cmd_process_run(int, char **, void *); +int cmd_process_cont(int, char **, void *); +int cmd_process_kill(int, char **, void *); + +/* signal.c */ +void init_sigstate(struct pstate *); +void process_signal(struct pstate *, int, int, int); +int cmd_signal_ignore(int, char **, void *); +int cmd_signal_show(int, char **, void *); + +/* + * Machine dependent stuff. + */ +/* register names */ +struct md_def { + const char **md_reg_names; /* array of register names */ + const int nregs; /* number of registers */ + const int pcoff; /* offset of the pc */ +}; +extern struct md_def md_def; +void md_def_init(void); + +#define MDF_MAX_ARGS 16 + +struct md_frame { + reg pc, fp; + int nargs; + reg args[MDF_MAX_ARGS]; +}; + +/* + * Return the registers for the process "ps" in the frame "frame". + */ +int md_getframe(struct pstate *, int, struct md_frame *); +int md_getregs(struct pstate *, reg *); + +/* misc */ +void *emalloc(size_t); |