[BACK]Return to pmdb.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / pmdb

Annotation of src/usr.bin/pmdb/pmdb.h, Revision 1.2

1.2     ! jason       1: /*     $OpenBSD: pmdb.h,v 1.26 2002/03/11 23:39:49 art Exp $   */
1.1       art         2: /*
                      3:  * Copyright (c) 2002 Artur Grabowski <art@openbsd.org>
                      4:  * All rights reserved.
                      5:  *
                      6:  * Redistribution and use in source and binary forms, with or without
                      7:  * modification, are permitted provided that the following conditions
                      8:  * are met:
                      9:  *
                     10:  * 1. Redistributions of source code must retain the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer.
                     12:  * 2. The name of the author may not be used to endorse or promote products
                     13:  *    derived from this software without specific prior written permission.
                     14:  *
                     15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
                     16:  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
                     17:  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
                     18:  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
                     19:  * EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLUDING, BUT NOT LIMITED TO,
                     20:  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
                     21:  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
                     22:  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
                     23:  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
                     24:  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     25:  */
                     26:
                     27: #include <sys/signal.h>                /* for NSIG */
                     28: #include <sys/queue.h>
                     29: #include <sys/ptrace.h>
                     30: #include <err.h>
                     31:
                     32: /* XXX - ugh, yuck, bleah. */
                     33: #ifndef PT_STEP
                     34: #define PT_STEP PT_CONTINUE
                     35: #endif
                     36:
                     37: /*
                     38:  * Process handling.
                     39:  */
                     40:
                     41: struct breakpoint;
                     42: struct callback;
                     43: struct sym_table;
                     44: struct sym_ops;
                     45:
                     46: /* XXX - should be machdep some day. */
                     47: typedef unsigned long reg;
                     48:
                     49: /* The state for a debugged process. */
                     50: struct pstate {
                     51:        pid_t ps_pid;
                     52:        enum { NONE, LOADED, RUNNING, STOPPED, TERMINATED } ps_state;
                     53:        int ps_argc;
                     54:        char **ps_argv;
                     55:        int ps_flags;
                     56:        int ps_signum;
                     57:        int ps_sigstate[NSIG];
                     58:        reg ps_npc;
                     59:        TAILQ_HEAD(,sym_table) ps_syms; /* all symbols tables in a list */
                     60:        struct sym_table *ps_sym_exe;   /* symbol table for the executable */
                     61:        struct sym_ops *ps_sops;        /* operations on symbol tables */
                     62:        TAILQ_HEAD(,breakpoint) ps_bkpts; /* breakpoints */
                     63:        TAILQ_HEAD(,callback) ps_sstep_cbs; /* single step actions */
                     64: };
                     65:
                     66: /* flags in ps_flags */
                     67: #define PSF_SYMBOLS    0x02            /* basic symbols loaded */
                     68: #define PSF_KILL       0x04            /* kill this process asap */
                     69: #define PSF_STEP       0x08            /* next continue should sstep */
                     70:
                     71: /* ps_sigstate */
                     72: #define SS_STOP                0x00
                     73: #define SS_IGNORE      0x01
                     74:
                     75: /* misc helper functions */
                     76: int process_kill(struct pstate *);
                     77: int read_from_pid(pid_t pid, off_t from, void *to, size_t size);
                     78: int write_to_pid(pid_t pid, off_t to, void *from, size_t size);
                     79:
                     80: /* process.c */
                     81: int process_load(struct pstate *);
                     82: int cmd_process_run(int, char **, void *);
                     83: int cmd_process_cont(int, char **, void *);
                     84: int cmd_process_kill(int, char **, void *);
                     85:
                     86: /* signal.c */
                     87: void init_sigstate(struct pstate *);
                     88: void process_signal(struct pstate *, int, int, int);
                     89: int cmd_signal_ignore(int, char **, void *);
                     90: int cmd_signal_show(int, char **, void *);
                     91:
                     92: /*
                     93:  * Machine dependent stuff.
                     94:  */
                     95: /* register names */
                     96: struct md_def {
                     97:        const char **md_reg_names;      /* array of register names */
                     98:        const int nregs;                /* number of registers */
                     99:        const int pcoff;                /* offset of the pc */
                    100: };
                    101: extern struct md_def md_def;
                    102: void md_def_init(void);
                    103:
                    104: #define MDF_MAX_ARGS   16
                    105:
                    106: struct md_frame {
                    107:        reg pc, fp;
                    108:        int nargs;
                    109:        reg args[MDF_MAX_ARGS];
                    110: };
                    111:
                    112: /*
                    113:  * Return the registers for the process "ps" in the frame "frame".
                    114:  */
                    115: int md_getframe(struct pstate *, int, struct md_frame *);
                    116: int md_getregs(struct pstate *, reg *);
                    117:
                    118: /* misc */
                    119: void *emalloc(size_t);