Commit bc5f13bb authored by Guillaume Sadegh's avatar Guillaume Sadegh
Browse files

NIPS VM added to the SPOT distribution.

2008-05-29  Guillaume SADEGH  <sadegh@lrde.epita.fr>

	* iface/nips/nips.cc, iface/nips/nips.hh, iface/nips/common.cc,
	iface/nips/common.hh, iface/nips/Makefile.am: TGBA implementation
	with the NIPS library.
	* iface/nips/emptiness_check.cc: Emptiness check on a Promela
	interface.
	* iface/nips/dottynips.cc: Dot printer on the NIPS interface.
	* iface/nips/compile.sh: Add. Wrapper around nips compiler to
	compile Promela to NIPS bytecode.
	* iface/nips/nips_vm,iface/nips/nips_vm/bytecode.h,
	iface/nips/nips_vm/ChangeLog, iface/nips/nips_vm/COPYING,
	iface/nips/nips_vm/hashtab.c, iface/nips/nips_vm/hashtab.h,
	iface/nips/nips_vm/INSTALL, iface/nips/nips_vm/instr.c,
	iface/nips/nips_vm/instr.h, iface/nips/nips_vm/instr_step.c,
	iface/nips/nips_vm/instr_step.h,
	iface/nips/nips_vm/instr_tools.c,
	iface/nips/nips_vm/instr_tools.h,
	iface/nips/nips_vm/instr_wrap.c,
	iface/nips/nips_vm/instr_wrap.h,
	iface/nips/nips_vm/interactive.c,
	iface/nips/nips_vm/interactive.h, iface/nips/nips_vm/main.c,
	iface/nips/nips_vm/Makefile, iface/nips/nips_vm/Makefile.am,
	iface/nips/nips_vm/nips_asm_help.pl,
	iface/nips/nips_vm/nips_asm_instr.pl,
	iface/nips/nips_vm/nips_asm.pl,
	iface/nips/nips_vm/nips_disasm.pl, iface/nips/nips_vm/nipsvm.c,
	iface/nips/nips_vm/nipsvm.h, iface/nips/nips_vm/README,
	iface/nips/nips_vm/rt_err.c, iface/nips/nips_vm/rt_err.h,
	iface/nips/nips_vm/search.c, iface/nips/nips_vm/search.h,
	iface/nips/nips_vm/split.c, iface/nips/nips_vm/split.h,
	iface/nips/nips_vm/state.c, iface/nips/nips_vm/state.h,
	iface/nips/nips_vm/state_inline.h,
	iface/nips/nips_vm/state_parts.c,
	iface/nips/nips_vm/state_parts.h, iface/nips/nips_vm/timeval.h,
	iface/nips/nips_vm/tools.h: NIPS VM added to the SPOT
	distribution.
	* configure.ac, iface/Makefile.am: Build system updated for the
	NIPS front-end.
parent 543190f2
2008-05-29 Guillaume SADEGH <sadegh@lrde.epita.fr>
* iface/nips/nips.cc, iface/nips/nips.hh, iface/nips/common.cc,
iface/nips/common.hh, iface/nips/Makefile.am: TGBA implementation
with the NIPS library.
* iface/nips/emptiness_check.cc: Emptiness check on a Promela
interface.
* iface/nips/dottynips.cc: Dot printer on the NIPS interface.
* iface/nips/compile.sh: Add. Wrapper around nips compiler to
compile Promela to NIPS bytecode.
* iface/nips/nips_vm,iface/nips/nips_vm/bytecode.h,
iface/nips/nips_vm/ChangeLog, iface/nips/nips_vm/COPYING,
iface/nips/nips_vm/hashtab.c, iface/nips/nips_vm/hashtab.h,
iface/nips/nips_vm/INSTALL, iface/nips/nips_vm/instr.c,
iface/nips/nips_vm/instr.h, iface/nips/nips_vm/instr_step.c,
iface/nips/nips_vm/instr_step.h,
iface/nips/nips_vm/instr_tools.c,
iface/nips/nips_vm/instr_tools.h,
iface/nips/nips_vm/instr_wrap.c,
iface/nips/nips_vm/instr_wrap.h,
iface/nips/nips_vm/interactive.c,
iface/nips/nips_vm/interactive.h, iface/nips/nips_vm/main.c,
iface/nips/nips_vm/Makefile, iface/nips/nips_vm/Makefile.am,
iface/nips/nips_vm/nips_asm_help.pl,
iface/nips/nips_vm/nips_asm_instr.pl,
iface/nips/nips_vm/nips_asm.pl,
iface/nips/nips_vm/nips_disasm.pl, iface/nips/nips_vm/nipsvm.c,
iface/nips/nips_vm/nipsvm.h, iface/nips/nips_vm/README,
iface/nips/nips_vm/rt_err.c, iface/nips/nips_vm/rt_err.h,
iface/nips/nips_vm/search.c, iface/nips/nips_vm/search.h,
iface/nips/nips_vm/split.c, iface/nips/nips_vm/split.h,
iface/nips/nips_vm/state.c, iface/nips/nips_vm/state.h,
iface/nips/nips_vm/state_inline.h,
iface/nips/nips_vm/state_parts.c,
iface/nips/nips_vm/state_parts.h, iface/nips/nips_vm/timeval.h,
iface/nips/nips_vm/tools.h: NIPS VM added to the SPOT
distribution.
* configure.ac, iface/Makefile.am: Build system updated for the
NIPS front-end.
* src/Makefile.am (_.cc): Fix for `make tags`.
2008-04-16 Damien Lefortier <dam@lrde.epita.fr>
* configure.ac, Makefile.am: Add src/eltltest/ support.
......
......@@ -87,7 +87,7 @@ restart:
od;
if
:: win == myid ->
:: win == myid ->
leader = myid;
nr_leaders++;
assert(nr_leaders == 1);
......
......@@ -78,6 +78,8 @@ AC_CONFIG_FILES([
iface/Makefile
iface/gspn/Makefile
iface/gspn/defs
iface/nips/Makefile
iface/nips/nips_vm/Makefile
src/Makefile
src/eltlast/Makefile
src/eltlenv/Makefile
......
## Copyright (C) 2003 Laboratoire d'Informatique de Paris 6 (LIP6),
## Copyright (C) 2003, 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
## département Systèmes Répartis Coopératifs (SRC), Université Pierre
## et Marie Curie.
##
......@@ -19,6 +19,8 @@
## Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.
SUBDIRS = nips
if WITH_GSPN
SUBDIRS = gspn
SUBDIRS += gspn
endif
## Copyright (C) 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
## dpartement Systmes Rpartis Coopratifs (SRC), Universit Pierre
## et Marie Curie.
##
## This file is part of Spot, a model checking library.
##
## Spot is free software; you can redistribute it and/or modify it
## 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.
##
## Spot 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 Spot; see the file COPYING. If not, write to the Free
## Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.
AM_CPPFLAGS = -I$(top_srcdir)/src $(BUDDY_CPPFLAGS) -I$(srcdir)/nips_vm
AM_CXXFLAGS = $(WARNING_CXXFLAGS)
nipsdir = $(pkgincludedir)/nips
nips_HEADERS = \
common.hh \
nips.hh
lib_LTLIBRARIES = libspotnips.la
libspotnips_la_LIBADD = $(top_builddir)/src/libspot.la
libspotnips_la_SOURCES = \
common.cc \
nips.cc
noinst_PROGRAMS = \
dottynips
dottynips_SOURCES = dottynips.cc
dottynips_LDADD = libspotnips.la $(builddir)/nips_vm/libnipsvm.la
empt_check_SOURCES = emptiness_check.cc
empt_check_LDADD = libspotnips.la $(builddir)/nips_vm/libnipsvm.la
SUBDIRS = nips_vm
// Copyright (C) 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// 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.
//
// Spot 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 Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#include "common.hh"
#include <ostream>
namespace spot
{
std::ostream&
operator<<(std::ostream& os, const nips_exception& e)
{
if (e.get_err_defined())
os << e.get_where() << " exited with " << e.get_err();
else
os << e.get_where() << " with no exit value";
return os;
}
}
// Copyright (C) 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// 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.
//
// Spot 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 Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#ifndef SPOT_IFACE_NIPS_COMMON_HH
# define SPOT_IFACE_NIPS_COMMON_HH
# include <string>
# include <iosfwd>
namespace spot
{
/// An exception used to forward NIPS errors.
class nips_exception
{
public:
nips_exception(const std::string& where, int err)
: err_(err), where_(where), err_defined_(true)
{
}
nips_exception(const std::string& where)
: err_(-1), where_(where), err_defined_(false)
{
}
int
get_err() const
{
return err_;
}
std::string
get_where() const
{
return where_;
}
int
get_err_defined() const
{
return err_defined_;
}
private:
int err_;
std::string where_;
bool err_defined_;
};
std::ostream& operator<<(std::ostream& os, const nips_exception& e);
}
#endif // SPOT_IFACE_NIPS_COMMON_HH
#! /bin/bash
NIPS_COMPILER=~/lrde/vmssg/nips_c/CodeGen
NIPS_ASSEMBLER=~/lrde/vmssg/nips_vm/nips_asm.pl
THISDIR=`pwd`
if [ ! -f "$NIPS_COMPILER" ]; then
echo "You have to specify the path of your NIPS compiler (CodeGen)"
exit 3
fi
if [ ! -f "$NIPS_ASSEMBLER" ]; then
echo "You have to specify the path of your NIPS assembler (nips_asm.pl)"
exit 3
fi
if [ $# -ne 1 ]; then
echo "usage : $0 promela_model"
exit 1
fi
FILE="$(cd `dirname $1`; pwd)/`basename $1`"
TMP_FILE="/tmp/`basename $1`"
cpp "$FILE" | sed 's/^#.*$//' > "$TMP_FILE"
cd `dirname $NIPS_COMPILER`
./`basename $NIPS_COMPILER` "$TMP_FILE"
cd `dirname $NIPS_ASSEMBLER`
./`basename $NIPS_ASSEMBLER` "$TMP_FILE.s"
mv "$TMP_FILE.b" "$FILE.b"
echo "$FILE".b
// Copyright (C) 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
// dpartement Systmes Rpartis Coopratifs (SRC), Universit Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// 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.
//
// Spot 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 Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#include "nips.hh"
#include "tgbaalgos/dotty.hh"
int
main(int argc, char **argv)
try
{
if (argc < 2)
{
std::cerr << "usage: " << argv[0] << " promela_bytecode" << std::endl;
exit(1);
}
spot::bdd_dict* dict = new spot::bdd_dict();
spot::nips_interface nips(dict, argv[1]);
spot::tgba* a = nips.automaton();
spot::dotty_reachable(std::cout, a);
delete a;
delete dict;
}
catch (spot::nips_exception& e)
{
std::cerr << e << std::endl;
throw;
}
// Copyright (C) 2008 Laboratoire
// d'Informatique de Paris 6 (LIP6), département Systèmes Répartis
// Coopératifs (SRC), Université Pierre et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// 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.
//
// Spot 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 Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#include <iostream>
#include <cassert>
#include <cstring>
#include "common.hh"
#include "nips.hh"
#include "tgbaalgos/gtec/gtec.hh"
#include "tgbaalgos/gtec/ce.hh"
#include "tgbaalgos/projrun.hh"
void
display_stats(const spot::unsigned_statistics* s)
{
assert(s);
spot::unsigned_statistics::stats_map::const_iterator i;
for (i = s->stats.begin(); i != s->stats.end(); ++i)
std::cout << i->first << " = " << (s->*i->second)() << std::endl;
}
int
main(int argc, char **argv)
try
{
// enum {Couvreur, Couvreur2} check = Couvreur;
bool compute_counter_example = true;
if (argc < 2)
{
std::cerr << "usage: " << argv[0] << "[OPTIONS...] promela_bytecode"
<< std::endl
<< "with OPTIONS :" << std::endl
<< " -c compute an example" << std::endl
<< " (instead of just checking for emptiness)" << std::endl
<< " -eALGO use ALGO emptiness-check (default)" << std::endl
<< "Where ALGO should be one of:" << std::endl
<< " Cou99(OPTIONS) (the default)" << std::endl
<< " CVWY90(OPTIONS)" << std::endl
<< " GV04(OPTIONS)" << std::endl
<< " SE05(OPTIONS)" << std::endl
<< " Tau03(OPTIONS)" << std::endl
<< " Tau03_opt(OPTIONS)" << std::endl;
exit(2);
}
int arg_index = 1;
spot::emptiness_check_instantiator* echeck_inst = 0;
const char* echeck_algo = "Cou99";
for (; arg_index < argc - 1; ++arg_index)
{
if (!strcmp(argv[arg_index], "-c"))
compute_counter_example = false;
else if (!strncmp(argv[arg_index], "-e", 2))
{
echeck_algo = 2 + argv[arg_index];
if (!*echeck_algo)
echeck_algo = "Cou99";
}
}
const char* err;
echeck_inst =
spot::emptiness_check_instantiator::construct(echeck_algo, &err);
if (!echeck_inst)
{
std::cerr << "Failed to parse argument of -e near `"
<< err << "'" << std::endl;
exit(2);
}
spot::bdd_dict* dict = new spot::bdd_dict();
spot::nips_interface nips(dict, argv[arg_index]);
spot::tgba* a = nips.automaton();
spot::emptiness_check* ec = echeck_inst->instantiate(a);
spot::emptiness_check_result* res = ec->check();
if (res)
{
if (compute_counter_example)
{
spot::tgba_run* run = res->accepting_run();
spot::print_tgba_run(std::cout, a, run);
std::cout << "non empty" << std::endl;
ec->print_stats(std::cout);
delete run;
}
else
{
std::cout << "non empty" << std::endl;
ec->print_stats(std::cout);
}
delete res;
}
else
{
std::cout << "empty" << std::endl;
ec->print_stats(std::cout);
}
std::cout << std::endl;
delete ec;
}
catch (spot::nips_exception& e)
{
std::cerr << e << std::endl;
throw;
}
// Copyright (C) 2008 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// 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.
//
// Spot 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 Spot; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
#include <cassert>
#include "misc/hashfunc.hh"
#include "nips.hh"
namespace spot
{
namespace
{
// Callback for errors
//////////////////////////////////////////////////////////////////////
// Callback for error which continues on assertions
nipsvm_status_t
search_error_callback(nipsvm_errorcode_t err, nipsvm_pid_t pid,
nipsvm_pc_t pc, void *)
{
char str[256];
nipsvm_errorstring (str, sizeof str, err, pid, pc);
std::cerr << "RUNTIME ERROR (" << err << "): " << str << std::endl;
// Continue on assertions
if (err == 9)
return IC_CONTINUE;
throw nips_exception(std::string(str), static_cast<int>(err));
return IC_STOP;
}
// Callback for error which fails on assertions
nipsvm_status_t
search_error_callback_assert(nipsvm_errorcode_t err, nipsvm_pid_t pid,
nipsvm_pc_t pc, void *)
{
char str[256];
nipsvm_errorstring (str, sizeof str, err, pid, pc);
std::cerr << "RUNTIME ERROR (" << err << "): " << str << std::endl;
throw nips_exception(std::string(str), static_cast<int>(err));
return IC_STOP;
}
// state_nips
//////////////////////////////////////////////////////////////////////
class state_nips: public state
{
public:
state_nips(nipsvm_state_t* s)
{
state_nips_init(s);
nips_state_ = s;
}
state_nips(nipsvm_state_t* s, nipsvm_state_t* nips_state)
{
state_nips_init(s);
nips_state_ = nips_state;
}
void state_nips_init(nipsvm_state_t* s)
{
ref_ = new unsigned(1);
unsigned long size = nipsvm_state_size(s);
unsigned long size_buf = size;
char* state_as_char = new char[size];
state_ = reinterpret_cast<nipsvm_state_t*>(state_as_char);
nipsvm_state_copy(size, s, &state_as_char, &size_buf);
}
state_nips(const state* other)
: ref_(new unsigned(1))
{
const state_nips* o = dynamic_cast<const state_nips*>(other);
assert(o);
ref_ = o->ref_;
++(*ref_);
state_ = o->state_;
}
virtual
~state_nips()
{
--(*ref_);
if (*ref_ == 0)
{
delete[] state_;
delete ref_;
}
}
/// Lazy computation for the hash.
void
hash_comp()
{
size_t size = nipsvm_state_size(get_state());
hash_ = 0;
size_t* state = reinterpret_cast<size_t*>(get_state());
size_t full_size = (size - (size % sizeof (size_t))) / sizeof (size_t);
unsigned i;
for (i = 0; i < full_size; ++i)
hash_ ^= wang32_hash(state[i]);
// Hash on the remainder.
unsigned remainder = 0;
char* state_in_char = reinterpret_cast<char*>(state);
size_t init_pos = i * sizeof (size_t);
unsigned j;
for (j = 0; j < (size % sizeof (size_t)); ++j)
remainder = remainder * 0x100 + state_in_char[init_pos + j];
for (; j < sizeof (size_t); ++j)
remainder *= 0x100;
hash_ ^= remainder;
}
virtual int
compare(const state* other) const
{
const state_nips* o = dynamic_cast<const state_nips*>(other);
assert(o);
return reinterpret_cast<char*>(o->get_state())
- reinterpret_cast<char*>(get_state());
}
virtual size_t
hash() const
{
return reinterpret_cast<char*>(get_state()) - static_cast<char*>(0);
}
virtual state_nips* clone() const
{
return new state_nips(get_state());
}
nipsvm_state_t*
get_state() const
{
return state_;