• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/core/techModels/libsim-panalyzer/dlite.h

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 2003/09/18 00:57:54 panalyzer Exp $
00053  *
00054  * $Log: dlite.h,v $
00055  * Revision 1.1.1.1  2003/09/18 00:57:54  panalyzer
00056  *
00057  *
00058  * Revision 1.1.1.1  2003/09/18 00:18:43  panalyzer
00059  *
00060  *
00061  * Revision 1.1.1.1  2003/09/16 18:48:14  gdm
00062  *
00063  *
00064  * Revision 1.1.1.1  2000/11/29 14:53:54  cu-cs
00065  * Grand unification of arm sources.
00066  *
00067  *
00068  * Revision 1.1.1.1  2000/05/26 15:21:53  taustin
00069  * SimpleScalar Tool Set
00070  *
00071  *
00072  * Revision 1.3  1999/12/31 18:34:06  taustin
00073  * cross-endian execution support added
00074  *
00075  * Revision 1.2  1998/08/27 08:19:44  taustin
00076  * implemented host interface description in host.h
00077  * added target interface support
00078  * added support for qword's
00079  * added support for register and memory contexts
00080  *
00081  * Revision 1.1  1997/03/11  01:30:26  taustin
00082  * Initial revision
00083  *
00084  *
00085  */
00086 
00087 /*
00088  * This module implements DLite, the lite debugger.  DLite is a very light
00089  * weight semi-symbolic debbugger that can interface to any simulator with
00090  * only a few function calls.  See sim-safe.c for an example of how to
00091  * interface DLite to a simulator.
00092  *
00093  * The following commands are supported by DLite: 
00094  *
00095 
00096  *
00097  * help                  - print command reference
00098  * version               - print DLite version information
00099  * terminate             - terminate the simulation with statistics
00100  * quit                  - exit the simulator
00101  * cont {<addr>}         - continue program execution (optionally at <addr>)
00102  * step                  - step program one instruction
00103  * next                  - step program one instruction in current procedure
00104  * print <expr>          - print the value of <expr>
00105  * regs                  - print register contents
00106  * mstate                - print machine specific state (simulator dependent)
00107  * display/<mods> <addr> - display the value at <addr> using format <modifiers>
00108  * dump {<addr>} {<cnt>} - dump memory at <addr> (optionally for <cnt> words)
00109  * dis <addr> {<cnt>}    - disassemble instructions at <addr> (for <cnt> insts)
00110  * break <addr>          - set breakpoint at <addr>, returns <id> of breakpoint
00111  * dbreak <addr> {r|w|x} - set data breakpoint at <addr> (for (r)ead, (w)rite,
00112  *                         and/or e(x)ecute, returns <id> of breakpoint
00113  * breaks                - list active code and data breakpoints
00114  * delete <id>           - delete breakpoint <id>
00115  * clear                 - clear all breakpoints (code and data)
00116  *
00117  * ** command args <addr>, <cnt>, <expr>, and <id> are any legal expression:
00118  *
00119  * <expr>               <- <factor> +|- <expr>
00120  * <factor>             <- <term> *|/ <factor>
00121  * <term>               <- ( <expr> )
00122  *                         | - <term>
00123  *                         | <const>
00124  *                         | <symbol>
00125  *                         | <file:loc>
00126  *
00127  * ** command modifiers <mods> are any of the following:
00128  *
00129  * b - print a byte
00130  * h - print a half (short)
00131  * w - print a word
00132  * q - print a qword
00133  * t - print in decimal format
00134  * u - print in unsigned decimal format
00135  * o - print in octal format
00136  * x - print in hex format
00137  * 1 - print in binary format
00138  * f - print a float
00139  * d - print a double
00140  * c - print a character
00141  * s - print a string
00142  */
00143 
00144 #ifndef DLITE_H
00145 #define DLITE_H
00146 
00147 #include <stdio.h>
00148 
00149 #include "host.h"
00150 #include "misc.h"
00151 #include "machine.h"
00152 #include "regs.h"
00153 #include "memory.h"
00154 #include "eval.h"
00155 
00156 /* DLite register access function, the debugger uses this function to access
00157    simulator register state */
00158 typedef char *                                  /* error str, NULL if none */
00159 (*dlite_reg_obj_t)(struct regs_t *regs,         /* registers to access */
00160                    int is_write,                /* access type */
00161                    enum md_reg_type rt,         /* reg bank to access */
00162                    int reg,                     /* register number */
00163                    struct eval_value_t *val);   /* input, output */
00164 
00165 /* DLite memory access function, the debugger uses this function to access
00166    simulator memory state */
00167 typedef char *                                  /* error str, NULL if none */
00168 (*dlite_mem_obj_t)(struct mem_t *mem,           /* memory space to access */
00169                    int is_write,                /* access type */
00170                    md_addr_t addr,              /* address to access */
00171                    char *p,                     /* input/output buffer */
00172                    int nbytes);                 /* size of access */
00173 
00174 /* DLite memory access function, the debugger uses this function to display
00175    the state of machine-specific state */
00176 typedef char *                                  /* error str, NULL if none */
00177 (*dlite_mstate_obj_t)(FILE *stream,             /* output stream */
00178                       char *cmd,                /* optional command string */
00179                       struct regs_t *regs,      /* registers to access */
00180                       struct mem_t *mem);       /* memory space to access */
00181 
00182 /* initialize the DLite debugger */
00183 void
00184 dlite_init(dlite_reg_obj_t reg_obj,             /* register state object */
00185            dlite_mem_obj_t mem_obj,             /* memory state object */
00186            dlite_mstate_obj_t mstate_obj);      /* machine state object */
00187 
00188 /*
00189  * default architected/machine state accessors
00190  */
00191 
00192 /* default architected memory state accessor */
00193 char *                                          /* err str, NULL for no err */
00194 dlite_mem_obj(struct mem_t *mem,                /* memory space to access */
00195               int is_write,                     /* access type */
00196               md_addr_t addr,                   /* address to access */
00197               char *p,                          /* input, output */
00198               int nbytes);                      /* size of access */
00199 
00200 /* default architected machine-specific state accessor */
00201 char *                                          /* err str, NULL for no err */
00202 dlite_mstate_obj(FILE *stream,                  /* output stream */
00203                  char *cmd,                     /* optional command string */
00204                  struct regs_t *regs,           /* registers to access */
00205                  struct mem_t *mem);            /* memory space to access */
00206 
00207 /* state access masks */
00208 #define ACCESS_READ     0x01                    /* read access allowed */
00209 #define ACCESS_WRITE    0x02                    /* write access allowed */
00210 #define ACCESS_EXEC     0x04                    /* execute access allowed */
00211 
00212 /* non-zero iff one breakpoint is set, for fast break check */
00213 extern md_addr_t dlite_fastbreak /* = 0 */;
00214 
00215 /* set non-zero to enter DLite after next instruction */
00216 extern int dlite_active /* = FALSE */;
00217 
00218 /* non-zero to force a check for a break */
00219 extern int dlite_check /* = FALSE */;
00220 
00221 /* internal break check interface */
00222 int                                             /* non-zero if brkpt hit */
00223 __check_break(md_addr_t next_PC,                /* address of next inst */
00224               int access,                       /* mem access of last inst */
00225               md_addr_t addr,                   /* mem addr of last inst */
00226               counter_t icount,                 /* instruction count */
00227               counter_t cycle);                 /* cycle count */
00228 
00229 /* check for a break condition */
00230 #define dlite_check_break(NPC, ACCESS, ADDR, ICNT, CYCLE)               \
00231   ((dlite_check || dlite_active)                                        \
00232    ? __check_break((NPC), (ACCESS), (ADDR), (ICNT), (CYCLE))            \
00233    : FALSE)
00234 
00235 /* DLite debugger main loop */
00236 void
00237 dlite_main(md_addr_t regs_PC,                   /* addr of last inst to exec */
00238            md_addr_t next_PC,                   /* addr of next inst to exec */
00239            counter_t cycle,                     /* current processor cycle */
00240            struct regs_t *regs,                 /* registers to access */
00241            struct mem_t *mem);                  /* memory to access */
00242 
00243 #endif /* DLITE_H */

Generated on Fri Oct 22 2010 11:02:18 for SST by  doxygen 1.7.1