Add the beginnings of an interactive debugger.
This commit is contained in:
parent
e09a14aa44
commit
de5930f7d8
|
|
@ -16,7 +16,7 @@
|
||||||
# 59 Temple Place - Suite 330
|
# 59 Temple Place - Suite 330
|
||||||
# Boston, MA 02111-1307, USA
|
# Boston, MA 02111-1307, USA
|
||||||
#
|
#
|
||||||
#ident "$Id: Makefile.in,v 1.15 2001/05/01 01:09:39 steve Exp $"
|
#ident "$Id: Makefile.in,v 1.16 2001/05/05 23:55:46 steve Exp $"
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
SHELL = /bin/sh
|
SHELL = /bin/sh
|
||||||
|
|
@ -42,6 +42,7 @@ STRIP = @STRIP@
|
||||||
CPPFLAGS = -I. -I$(srcdir)/.. @CPPFLAGS@ @DEFS@ -DMODULE_DIR=\"$(libdir)/ivl\"
|
CPPFLAGS = -I. -I$(srcdir)/.. @CPPFLAGS@ @DEFS@ -DMODULE_DIR=\"$(libdir)/ivl\"
|
||||||
CXXFLAGS = @CXXFLAGS@
|
CXXFLAGS = @CXXFLAGS@
|
||||||
LDFLAGS = @LDFLAGS@
|
LDFLAGS = @LDFLAGS@
|
||||||
|
LIBS = @LIBS@
|
||||||
|
|
||||||
dllib=@DLLIB@
|
dllib=@DLLIB@
|
||||||
rdynamic=@rdynamic@
|
rdynamic=@rdynamic@
|
||||||
|
|
@ -60,11 +61,11 @@ check: all
|
||||||
V = vpi_modules.o vpi_const.o vpi_iter.o vpi_mcd.o vpi_priv.o \
|
V = vpi_modules.o vpi_const.o vpi_iter.o vpi_mcd.o vpi_priv.o \
|
||||||
vpi_scope.o vpi_signal.o vpi_tasks.o vpi_time.o
|
vpi_scope.o vpi_signal.o vpi_tasks.o vpi_time.o
|
||||||
|
|
||||||
O = main.o parse.o parse_misc.o lexor.o compile.o functor.o symbols.o \
|
O = main.o parse.o parse_misc.o lexor.o compile.o debug.o functor.o \
|
||||||
codes.o vthread.o schedule.o tables.o udp.o memory.o $V
|
symbols.o codes.o vthread.o schedule.o tables.o udp.o memory.o $V
|
||||||
|
|
||||||
vvp: $O
|
vvp: $O
|
||||||
$(CXX) $(rdynamic) $(CXXFLAGS) $(LDFLAGS) -o vvp $O $(dllib)
|
$(CXX) $(rdynamic) $(CXXFLAGS) $(LDFLAGS) -o vvp $O $(LIBS) $(dllib)
|
||||||
|
|
||||||
|
|
||||||
%.o: %.cc
|
%.o: %.cc
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#if !defined(WINNT)
|
||||||
#ident "$Id: codes.h,v 1.23 2001/05/02 23:16:50 steve Exp $"
|
#ident "$Id: codes.h,v 1.24 2001/05/05 23:55:46 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -40,6 +40,7 @@ extern bool of_ADD(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_AND(vthread_t thr, vvp_code_t code);
|
extern bool of_AND(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_ASSIGN(vthread_t thr, vvp_code_t code);
|
extern bool of_ASSIGN(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_ASSIGN_MEM(vthread_t thr, vvp_code_t code);
|
extern bool of_ASSIGN_MEM(vthread_t thr, vvp_code_t code);
|
||||||
|
extern bool of_BREAKPOINT(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_CMPS(vthread_t thr, vvp_code_t code);
|
extern bool of_CMPS(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_CMPU(vthread_t thr, vvp_code_t code);
|
extern bool of_CMPU(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_CMPX(vthread_t thr, vvp_code_t code);
|
extern bool of_CMPX(vthread_t thr, vvp_code_t code);
|
||||||
|
|
@ -127,6 +128,9 @@ extern void codespace_dump(FILE*fd);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: codes.h,v $
|
* $Log: codes.h,v $
|
||||||
|
* Revision 1.24 2001/05/05 23:55:46 steve
|
||||||
|
* Add the beginnings of an interactive debugger.
|
||||||
|
*
|
||||||
* Revision 1.23 2001/05/02 23:16:50 steve
|
* Revision 1.23 2001/05/02 23:16:50 steve
|
||||||
* Document memory related opcodes,
|
* Document memory related opcodes,
|
||||||
* parser uses numbv_s structures instead of the
|
* parser uses numbv_s structures instead of the
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#if !defined(WINNT)
|
||||||
#ident "$Id: compile.cc,v 1.53 2001/05/02 23:16:50 steve Exp $"
|
#ident "$Id: compile.cc,v 1.54 2001/05/05 23:55:46 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "compile.h"
|
# include "compile.h"
|
||||||
|
|
@ -73,6 +73,7 @@ const static struct opcode_table_s opcode_table[] = {
|
||||||
{ "%and", of_AND, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
{ "%and", of_AND, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||||
{ "%assign", of_ASSIGN, 3, {OA_FUNC_PTR, OA_BIT1, OA_BIT2} },
|
{ "%assign", of_ASSIGN, 3, {OA_FUNC_PTR, OA_BIT1, OA_BIT2} },
|
||||||
{ "%assign/m",of_ASSIGN_MEM,3,{OA_MEM_PTR,OA_BIT1, OA_BIT2} },
|
{ "%assign/m",of_ASSIGN_MEM,3,{OA_MEM_PTR,OA_BIT1, OA_BIT2} },
|
||||||
|
{ "%breakpoint", of_BREAKPOINT, 0, {OA_NONE, OA_NONE, OA_NONE} },
|
||||||
{ "%cmp/s", of_CMPS, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
{ "%cmp/s", of_CMPS, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||||
{ "%cmp/u", of_CMPU, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
{ "%cmp/u", of_CMPU, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||||
{ "%cmp/x", of_CMPX, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
{ "%cmp/x", of_CMPX, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||||
|
|
@ -1044,6 +1045,9 @@ void compile_dump(FILE*fd)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: compile.cc,v $
|
* $Log: compile.cc,v $
|
||||||
|
* Revision 1.54 2001/05/05 23:55:46 steve
|
||||||
|
* Add the beginnings of an interactive debugger.
|
||||||
|
*
|
||||||
* Revision 1.53 2001/05/02 23:16:50 steve
|
* Revision 1.53 2001/05/02 23:16:50 steve
|
||||||
* Document memory related opcodes,
|
* Document memory related opcodes,
|
||||||
* parser uses numbv_s structures instead of the
|
* parser uses numbv_s structures instead of the
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#if !defined(WINNT)
|
||||||
#ident "$Id: config.h.in,v 1.3 2001/03/22 21:26:53 steve Exp $"
|
#ident "$Id: config.h.in,v 1.4 2001/05/05 23:55:46 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# define SIZEOF_UNSIGNED_LONG 0
|
# define SIZEOF_UNSIGNED_LONG 0
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
# undef HAVE_DLFCN_H
|
# undef HAVE_DLFCN_H
|
||||||
# undef HAVE_DL_H
|
# undef HAVE_DL_H
|
||||||
|
# undef HAVE_LIBREADLINE
|
||||||
|
|
||||||
# define LU ""
|
# define LU ""
|
||||||
# define TU ""
|
# define TU ""
|
||||||
|
|
@ -35,8 +36,15 @@
|
||||||
# define MODULE_DIR "."
|
# define MODULE_DIR "."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_LIBREADLINE)
|
||||||
|
# define WITH_DEBUG 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: config.h.in,v $
|
* $Log: config.h.in,v $
|
||||||
|
* Revision 1.4 2001/05/05 23:55:46 steve
|
||||||
|
* Add the beginnings of an interactive debugger.
|
||||||
|
*
|
||||||
* Revision 1.3 2001/03/22 21:26:53 steve
|
* Revision 1.3 2001/03/22 21:26:53 steve
|
||||||
* Compile in a default VPI module dir.
|
* Compile in a default VPI module dir.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ AC_PROG_INSTALL
|
||||||
AC_CHECK_SIZEOF(unsigned long)
|
AC_CHECK_SIZEOF(unsigned long)
|
||||||
AC_CHECK_SIZEOF(unsigned)
|
AC_CHECK_SIZEOF(unsigned)
|
||||||
|
|
||||||
|
AC_CHECK_LIB(termcap, tputs)
|
||||||
|
AC_CHECK_LIB(readline, readline)
|
||||||
|
|
||||||
# --
|
# --
|
||||||
# Look for a dl library to use. First look for the standard dlopen
|
# Look for a dl library to use. First look for the standard dlopen
|
||||||
# functions, and failing that look for the HP specific shl_load function.
|
# functions, and failing that look for the HP specific shl_load function.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||||
|
*
|
||||||
|
* This source code is free software; you can redistribute it
|
||||||
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
* General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 2 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
|
*/
|
||||||
|
#if !defined(WINNT)
|
||||||
|
#ident "$Id: debug.cc,v 1.1 2001/05/05 23:55:46 steve Exp $"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file provides a simple command line debugger for the vvp
|
||||||
|
* runtime. It is a means to interract with the user running the
|
||||||
|
* simulation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
# include "config.h"
|
||||||
|
|
||||||
|
#if defined(WITH_DEBUG)
|
||||||
|
|
||||||
|
# include "debug.h"
|
||||||
|
# include "schedule.h"
|
||||||
|
# include <stdio.h>
|
||||||
|
# include <readline/readline.h>
|
||||||
|
# include <readline/history.h>
|
||||||
|
# include <string.h>
|
||||||
|
# include <malloc.h>
|
||||||
|
|
||||||
|
|
||||||
|
static bool interact_flag = false;
|
||||||
|
|
||||||
|
static void cmd_go(unsigned, char*[])
|
||||||
|
{
|
||||||
|
interact_flag = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void cmd_time(unsigned, char*[])
|
||||||
|
{
|
||||||
|
unsigned long ticks = schedule_simtime();
|
||||||
|
printf("%lu ticks\n", ticks);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void cmd_unknown(unsigned argc, char*argv[])
|
||||||
|
{
|
||||||
|
printf("Unknown command: %s\n", argv[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct {
|
||||||
|
const char*name; void (*proc)(unsigned argc, char*argv[]);
|
||||||
|
} cmd_table[] = {
|
||||||
|
{ "go", &cmd_go},
|
||||||
|
{ "time", &cmd_time},
|
||||||
|
{ 0, &cmd_unknown}
|
||||||
|
};
|
||||||
|
|
||||||
|
void breakpoint(void)
|
||||||
|
{
|
||||||
|
printf("** VVP Interactive Debugger **\n");
|
||||||
|
printf("Current simulation time is %lu ticks.\n", schedule_simtime());
|
||||||
|
|
||||||
|
interact_flag = true;
|
||||||
|
while (interact_flag) {
|
||||||
|
char*input = readline("> ");
|
||||||
|
unsigned argc = 0;
|
||||||
|
char**argv = new char*[strlen(input)/2];
|
||||||
|
|
||||||
|
for (char*cp = input+strspn(input, " ")
|
||||||
|
; *cp; cp += strspn(cp, " ")) {
|
||||||
|
argv[argc] = cp;
|
||||||
|
|
||||||
|
cp += strcspn(cp, " ");
|
||||||
|
if (*cp)
|
||||||
|
*cp++ = 0;
|
||||||
|
|
||||||
|
argc += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc > 0) {
|
||||||
|
unsigned idx;
|
||||||
|
for (idx = 0 ; cmd_table[idx].name ; idx += 1)
|
||||||
|
if (strcmp(cmd_table[idx].name, argv[0]) == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
cmd_table[idx].proc (argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] argv;
|
||||||
|
free(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* $Log: debug.cc,v $
|
||||||
|
* Revision 1.1 2001/05/05 23:55:46 steve
|
||||||
|
* Add the beginnings of an interactive debugger.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
#ifndef __debug_H
|
||||||
|
#define __debug_H
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||||
|
*
|
||||||
|
* This source code is free software; you can redistribute it
|
||||||
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
* General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 2 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
|
*/
|
||||||
|
#if !defined(WINNT)
|
||||||
|
#ident "$Id: debug.h,v 1.1 2001/05/05 23:55:46 steve Exp $"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern void breakpoint(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* $Log: debug.h,v $
|
||||||
|
* Revision 1.1 2001/05/05 23:55:46 steve
|
||||||
|
* Add the beginnings of an interactive debugger.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#endif
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* $Id: opcodes.txt,v 1.17 2001/05/02 23:16:50 steve Exp $
|
* $Id: opcodes.txt,v 1.18 2001/05/05 23:55:46 steve Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -50,6 +50,17 @@ by index register 3. Bit address zero is the LSB of the first memory
|
||||||
word.
|
word.
|
||||||
|
|
||||||
|
|
||||||
|
* %breakpoint
|
||||||
|
|
||||||
|
This instruction unconditionally breaks the simulator into the
|
||||||
|
interactive debugger. The idea is to stop the simulator here and give
|
||||||
|
the user a chance to display the state of the simulation using
|
||||||
|
debugger commands.
|
||||||
|
|
||||||
|
This may not work on all platforms. If run-time debugging is compiled
|
||||||
|
out, then this function is a no-op.
|
||||||
|
|
||||||
|
|
||||||
* %cmp/u <bit-l>, <bit-r>, <wid>
|
* %cmp/u <bit-l>, <bit-r>, <wid>
|
||||||
* %cmp/s <bit-l>, <bit-r>, <wid>
|
* %cmp/s <bit-l>, <bit-r>, <wid>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,12 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#if !defined(WINNT)
|
||||||
#ident "$Id: vthread.cc,v 1.34 2001/05/02 23:16:50 steve Exp $"
|
#ident "$Id: vthread.cc,v 1.35 2001/05/05 23:55:46 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "vthread.h"
|
# include "vthread.h"
|
||||||
# include "codes.h"
|
# include "codes.h"
|
||||||
|
# include "debug.h"
|
||||||
# include "schedule.h"
|
# include "schedule.h"
|
||||||
# include "functor.h"
|
# include "functor.h"
|
||||||
# include "vpi_priv.h"
|
# include "vpi_priv.h"
|
||||||
|
|
@ -338,6 +339,14 @@ bool of_ASSIGN_MEM(vthread_t thr, vvp_code_t cp)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool of_BREAKPOINT(vthread_t thr, vvp_code_t cp)
|
||||||
|
{
|
||||||
|
#if defined(WITH_DEBUG)
|
||||||
|
breakpoint();
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool of_CMPS(vthread_t thr, vvp_code_t cp)
|
bool of_CMPS(vthread_t thr, vvp_code_t cp)
|
||||||
{
|
{
|
||||||
unsigned eq = 1;
|
unsigned eq = 1;
|
||||||
|
|
@ -969,6 +978,9 @@ bool of_ZOMBIE(vthread_t thr, vvp_code_t)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: vthread.cc,v $
|
* $Log: vthread.cc,v $
|
||||||
|
* Revision 1.35 2001/05/05 23:55:46 steve
|
||||||
|
* Add the beginnings of an interactive debugger.
|
||||||
|
*
|
||||||
* Revision 1.34 2001/05/02 23:16:50 steve
|
* Revision 1.34 2001/05/02 23:16:50 steve
|
||||||
* Document memory related opcodes,
|
* Document memory related opcodes,
|
||||||
* parser uses numbv_s structures instead of the
|
* parser uses numbv_s structures instead of the
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue