"I am a person who works hard and plays hard."

Yuan Wei
Second Year Graduate Student Department of Computer Science
University of Virginia Charlottesville, VA 22903
Email: yw3f@cs.virginia.edu


Source Code Analysis

Main Page   Compound List   File List   Compound Members   File Members  

dlite.h

Go to the documentation of this file.
00001 /*
00002  * dlite.h - DLite, the lite debugger, interfaces
00003  *
00004  * This file is a part of the SimpleScalar tool suite written by
00005  * Todd M. Austin as a part of the Multiscalar Research Project.
00006  *  
00007  * The tool suite is currently maintained by Doug Burger and Todd M. Austin.
00008  * 
00009  * Copyright (C) 1994, 1995, 1996, 1997, 1998 by Todd M. Austin
00010  *
00011  * This source file is distributed "as is" in the hope that it will be
00012  * useful.  The tool set comes with no warranty, and no author or
00013  * distributor accepts any responsibility for the consequences of its
00014  * use. 
00015  * 
00016  * Everyone is granted permission to copy, modify and redistribute
00017  * this tool set under the following conditions:
00018  * 
00019  *    This source code is distributed for non-commercial use only. 
00020  *    Please contact the maintainer for restrictions applying to 
00021  *    commercial use.
00022  *
00023  *    Permission is granted to anyone to make or distribute copies
00024  *    of this source code, either as received or modified, in any
00025  *    medium, provided that all copyright notices, permission and
00026  *    nonwarranty notices are preserved, and that the distributor
00027  *    grants the recipient permission for further redistribution as
00028  *    permitted by this document.
00029  *
00030  *    Permission is granted to distribute this file in compiled
00031  *    or executable form under the same conditions that apply for
00032  *    source code, provided that either:
00033  *
00034  *    A. it is accompanied by the corresponding machine-readable
00035  *       source code,
00036  *    B. it is accompanied by a written offer, with no time limit,
00037  *       to give anyone a machine-readable copy of the corresponding
00038  *       source code in return for reimbursement of the cost of
00039  *       distribution.  This written offer must permit verbatim
00040  *       duplication by anyone, or
00041  *    C. it is distributed by someone who received only the
00042  *       executable form, and is accompanied by a copy of the
00043  *       written offer of source code that they received concurrently.
00044  *
00045  * In other words, you are welcome to use, share and improve this
00046  * source file.  You are forbidden to forbid anyone else to use, share
00047  * and improve what you give them.
00048  *
00049  * INTERNET: dburger@cs.wisc.edu
00050  * US Mail:  1210 W. Dayton Street, Madison, WI 53706
00051  *
00052  * $Id: dlite.h,v 1.1.1.1 2000/05/26 15:21:53 taustin Exp $
00053  *
00054  * $Log: dlite.h,v $
00055  * Revision 1.1.1.1  2000/05/26 15:21:53  taustin
00056  * SimpleScalar Tool Set
00057  *
00058  *
00059  * Revision 1.3  1999/12/31 18:34:06  taustin
00060  * cross-endian execution support added
00061  *
00062  * Revision 1.2  1998/08/27 08:19:44  taustin
00063  * implemented host interface description in host.h
00064  * added target interface support
00065  * added support for qword's
00066  * added support for register and memory contexts
00067  *
00068  * Revision 1.1  1997/03/11  01:30:26  taustin
00069  * Initial revision
00070  *
00071  *
00072  */
00073 
00074 /*
00075  * This module implements DLite, the lite debugger.  DLite is a very light
00076  * weight semi-symbolic debbugger that can interface to any simulator with
00077  * only a few function calls.  See sim-safe.c for an example of how to
00078  * interface DLite to a simulator.
00079  *
00080  * The following commands are supported by DLite: 
00081  *
00082 
00083  *
00084  * help                  - print command reference
00085  * version               - print DLite version information
00086  * terminate             - terminate the simulation with statistics
00087  * quit                  - exit the simulator
00088  * cont {<addr>}         - continue program execution (optionally at <addr>)
00089  * step                  - step program one instruction
00090  * next                  - step program one instruction in current procedure
00091  * print <expr>          - print the value of <expr>
00092  * regs                  - print register contents
00093  * mstate                - print machine specific state (simulator dependent)
00094  * display/<mods> <addr> - display the value at <addr> using format <modifiers>
00095  * dump {<addr>} {<cnt>} - dump memory at <addr> (optionally for <cnt> words)
00096  * dis <addr> {<cnt>}    - disassemble instructions at <addr> (for <cnt> insts)
00097  * break <addr>          - set breakpoint at <addr>, returns <id> of breakpoint
00098  * dbreak <addr> {r|w|x} - set data breakpoint at <addr> (for (r)ead, (w)rite,
00099  *                         and/or e(x)ecute, returns <id> of breakpoint
00100  * breaks                - list active code and data breakpoints
00101  * delete <id>           - delete breakpoint <id>
00102  * clear                 - clear all breakpoints (code and data)
00103  *
00104  * ** command args <addr>, <cnt>, <expr>, and <id> are any legal expression:
00105  *
00106  * <expr>               <- <factor> +|- <expr>
00107  * <factor>             <- <term> *|/ <factor>
00108  * <term>               <- ( <expr> )
00109  *                         | - <term>
00110  *                         | <const>
00111  *                         | <symbol>
00112  *                         | <file:loc>
00113  *
00114  * ** command modifiers <mods> are any of the following:
00115  *
00116  * b - print a byte
00117  * h - print a half (short)
00118  * w - print a word
00119  * q - print a qword
00120  * t - print in decimal format
00121  * u - print in unsigned decimal format
00122  * o - print in octal format
00123  * x - print in hex format
00124  * 1 - print in binary format
00125  * f - print a float
00126  * d - print a double
00127  * c - print a character
00128  * s - print a string
00129  */
00130 
00131 #ifndef DLITE_H
00132 #define DLITE_H
00133 
00134 #include <stdio.h>
00135 
00136 #include "host.h"
00137 #include "misc.h"
00138 #include "machine.h"
00139 #include "regs.h"
00140 #include "memory.h"
00141 #include "eval.h"
00142 
00143 /* DLite register access function, the debugger uses this function to access
00144    simulator register state */
00145 typedef char *                                  /* error str, NULL if none */
00146 (*dlite_reg_obj_t)(struct regs_t *regs,         /* registers to access */
00147                    int is_write,                /* access type */
00148                    enum md_reg_type rt,         /* reg bank to access */
00149                    int reg,                     /* register number */
00150                    struct eval_value_t *val);   /* input, output */
00151 
00152 /* DLite memory access function, the debugger uses this function to access
00153    simulator memory state */
00154 typedef char *                                  /* error str, NULL if none */
00155 (*dlite_mem_obj_t)(struct mem_t *mem,           /* memory space to access */
00156                    int is_write,                /* access type */
00157                    md_addr_t addr,              /* address to access */
00158                    char *p,                     /* input/output buffer */
00159                    int nbytes);                 /* size of access */
00160 
00161 /* DLite memory access function, the debugger uses this function to display
00162    the state of machine-specific state */
00163 typedef char *                                  /* error str, NULL if none */
00164 (*dlite_mstate_obj_t)(FILE *stream,             /* output stream */
00165                       char *cmd,                /* optional command string */
00166                       struct regs_t *regs,      /* registers to access */
00167                       struct mem_t *mem);       /* memory space to access */
00168 
00169 /* initialize the DLite debugger */
00170 void
00171 dlite_init(dlite_reg_obj_t reg_obj,             /* register state object */
00172            dlite_mem_obj_t mem_obj,             /* memory state object */
00173            dlite_mstate_obj_t mstate_obj);      /* machine state object */
00174 
00175 /*
00176  * default architected/machine state accessors
00177  */
00178 
00179 /* default architected memory state accessor */
00180 char *                                          /* err str, NULL for no err */
00181 dlite_mem_obj(struct mem_t *mem,                /* memory space to access */
00182               int is_write,                     /* access type */
00183               md_addr_t addr,                   /* address to access */
00184               char *p,                          /* input, output */
00185               int nbytes);                      /* size of access */
00186 
00187 /* default architected machine-specific state accessor */
00188 char *                                          /* err str, NULL for no err */
00189 dlite_mstate_obj(FILE *stream,                  /* output stream */
00190                  char *cmd,                     /* optional command string */
00191                  struct regs_t *regs,           /* registers to access */
00192                  struct mem_t *mem);            /* memory space to access */
00193 
00194 /* state access masks */
00195 #define ACCESS_READ     0x01                    /* read access allowed */
00196 #define ACCESS_WRITE    0x02                    /* write access allowed */
00197 #define ACCESS_EXEC     0x04                    /* execute access allowed */
00198 
00199 /* non-zero iff one breakpoint is set, for fast break check */
00200 extern md_addr_t dlite_fastbreak /* = 0 */;
00201 
00202 /* set non-zero to enter DLite after next instruction */
00203 extern int dlite_active /* = FALSE */;
00204 
00205 /* non-zero to force a check for a break */
00206 extern int dlite_check /* = FALSE */;
00207 
00208 /* internal break check interface */
00209 int                                             /* non-zero if brkpt hit */
00210 __check_break(md_addr_t next_PC,                /* address of next inst */
00211               int access,                       /* mem access of last inst */
00212               md_addr_t addr,                   /* mem addr of last inst */
00213               counter_t icount,                 /* instruction count */
00214               counter_t cycle);                 /* cycle count */
00215 
00216 /* check for a break condition */
00217 #define dlite_check_break(NPC, ACCESS, ADDR, ICNT, CYCLE)               \
00218   ((dlite_check || dlite_active)                                        \
00219    ? __check_break((NPC), (ACCESS), (ADDR), (ICNT), (CYCLE))            \
00220    : FALSE)
00221 
00222 /* DLite debugger main loop */
00223 void
00224 dlite_main(md_addr_t regs_PC,                   /* addr of last inst to exec */
00225            md_addr_t next_PC,                   /* addr of next inst to exec */
00226            counter_t cycle,                     /* current processor cycle */
00227            struct regs_t *regs,                 /* registers to access */
00228            struct mem_t *mem);                  /* memory to access */
00229 
00230 #endif /* DLITE_H */


UVa CS Department of Computer Science
School of Engineering, University of Virginia
151 Engineer's Way, P.O. Box 400740
Charlottesville, Virginia 22904-4740

(434) 982-2200  Fax: (434) 982-2214