ChangeLog | 13 ++++++++++++
NEWS | 6 +++++
src/task/Makefile.am | 1
src/task/libtask.hh | 11 +++++++++-
src/task/string_task.cc | 47 +++++++++++++++++++++++++++++++++++++++++++++
src/task/string_task.hh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++
src/vm-tasks.cc | 36 ++++++++++++++++++++++++++++++++--
src/vm-tasks.hh | 11 +++++++++-
8 files changed, 171 insertions(+), 4 deletions(-)
Index: ChangeLog
from Benoît Perrot <benoit(a)lrde.epita.fr>
Provide --system-library option.
* src/task/string_task.hh, src/task/string_task.cc:
New.
* src/task/libtask.hh, src/task/Makefile.am:
Distribute them.
* src/vm-tasks.hh, src/vm-tasks.hh:
(select_system_library): Implement builtin system library
selection.
* NEWS: Update.
Index: src/vm-tasks.cc
--- src/vm-tasks.cc (révision 198)
+++ src/vm-tasks.cc (révision 199)
@@ -21,6 +21,7 @@
#include "inst/program.hh"
#include "vm/spim_system_library.hh"
+#include "vm/nolimips_system_library.hh"
#include "vm/virtual_machine.hh"
#include "parse-tasks.hh"
@@ -33,14 +34,45 @@
namespace tasks
{
+ // Default system library
+ static vm::SystemLibrary *system_library =
+ new vm::SpimSystemLibrary(std::cin, std::cout);
+
+ void
+ select_system_library(const std::string &library_name)
+ {
+ if (library_name == "nolimips")
+ {
+ delete system_library;
+ system_library = new vm::NolimipsSystemLibrary(std::cin,
+ std::cout, std::cerr);
+ }
+ else if (library_name == "spim")
+ {
+// delete system_library;
+// system_library = new vm::SpimSystemLibrary(std::cin, std::cout);
+ }
+ else if (library_name == "none")
+ {
+ delete system_library;
+ system_library = 0;
+ }
+ else
+ {
+ std::cerr << program_name
+ << ": `" << library_name << "': no such system library"
+ << std::endl;
+ exit_set (exit_failure);
+ }
+ }
+
void
execute ()
{
- vm::SpimSystemLibrary l(std::cin, std::cout);
vm::VirtualMachine vm;
vm.get_cpu().set_check_callee_save(check_callee_save_p);
vm.get_cpu().set_trace(trace_exec_p);
- vm.set_system_library(&l);
+ vm.set_system_library(system_library);
vm.load_program(* parse::tasks::program);
if (exit_status != exit_success)
exit(exit_status);
Index: src/task/string_task.hh
--- src/task/string_task.hh (révision 0)
+++ src/task/string_task.hh (révision 199)
@@ -0,0 +1,50 @@
+//
+// This file is part of Nolimips, a MIPS simulator with unlimited registers
+// Copyright (C) 2005 Akim Demaille <akim(a)epita.fr> and
+// Benoit Perrot <benoit(a)lrde.epita.fr>
+//
+// Nolimips 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.
+//
+// Nolimips 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
+//
+#ifndef TASK_STRING_TASK_HH
+# define TASK_STRING_TASK_HH
+
+# include <string>
+
+# include "task/task.hh"
+
+namespace task
+{
+
+ class StringTask: public Task
+ {
+ public:
+ StringTask(void (*execute) (const std::string &),
+ const std::string &option, const std::string &module_name,
+ const std::string &desc, const std::string &deps = "");
+
+ public:
+ virtual bool set_value(const std::string &value) const;
+
+ virtual void execute() const;
+
+ private:
+ void (*execute_) (const std::string &);
+
+ mutable std::string s_;
+ };
+
+} // namespace task
+
+#endif // !TASK_STRING_TASK_HH
Index: src/task/libtask.hh
--- src/task/libtask.hh (révision 198)
+++ src/task/libtask.hh (révision 199)
@@ -1,6 +1,6 @@
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
-// Copyright (C) 2004 Akim Demaille <akim(a)epita.fr> and
+// Copyright (C) 2004, 2005 Akim Demaille <akim(a)epita.fr> and
// Benoit Perrot <benoit(a)lrde.epita.fr>
//
// Nolimips is free software; you can redistribute it and/or modify
@@ -24,6 +24,7 @@
# include "task/function_task.hh"
# include "task/boolean_task.hh"
# include "task/int_task.hh"
+# include "task/string_task.hh"
# ifdef NOLIMIPS_CC_
@@ -48,6 +49,12 @@
Option, module_name, \
Desc, Deps)
+# define STRING_TASK_DECLARE(Option, Desc, Routine, Default, Deps) \
+ extern void (Routine) (const std::string &); \
+ static task::StringTask task_##Routine(Routine, \
+ Option, module_name, \
+ Desc, Deps)
+
# else // !NOLIMIPS_CC_
@@ -58,6 +65,8 @@
extern bool Flag
# define INT_TASK_DECLARE(Option, Desc, Var, Default, Min, Max, Deps) \
extern int Var
+# define STRING_TASK_DECLARE(Option, Desc, Routine, Default, Deps) \
+ extern void (Routine) (const std::string &)
# endif // NOLIMIPS_CC_
Index: src/task/Makefile.am
--- src/task/Makefile.am (révision 198)
+++ src/task/Makefile.am (révision 199)
@@ -6,5 +6,6 @@
function_task.hh function_task.cc \
boolean_task.hh boolean_task.cc \
int_task.hh int_task.cc \
+ string_task.hh string_task.cc \
task_register.hh task_register.cc \
libtask.hh
Index: src/task/string_task.cc
--- src/task/string_task.cc (révision 0)
+++ src/task/string_task.cc (révision 199)
@@ -0,0 +1,47 @@
+//
+// This file is part of Nolimips, a MIPS simulator with unlimited registers
+// Copyright (C) 2004 Akim Demaille <akim(a)epita.fr> and
+// Benoit Perrot <benoit(a)lrde.epita.fr>
+//
+// Nolimips 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.
+//
+// Nolimips 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
+//
+#include "task/string_task.hh"
+
+namespace task
+{
+
+ StringTask::StringTask(void (*execute) (const std::string &),
+ const std::string &option,
+ const std::string &module_name,
+ const std::string &desc,
+ const std::string &deps):
+ Task(option, module_name, desc, deps, true),
+ execute_(execute)
+ {}
+
+ bool
+ StringTask::set_value(const std::string &value) const
+ {
+ s_ = value;
+ return true;
+ }
+
+ void
+ StringTask::execute() const
+ {
+ execute_(s_);
+ }
+
+} //namespace task
Index: src/vm-tasks.hh
--- src/vm-tasks.hh (révision 198)
+++ src/vm-tasks.hh (révision 199)
@@ -1,6 +1,6 @@
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
-// Copyright (C) 2003, 2004 Benoit Perrot <benoit(a)lrde.epita.fr>
+// Copyright (C) 2003, 2004, 2005 Benoit Perrot <benoit(a)lrde.epita.fr>
//
// Nolimips is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -37,6 +37,15 @@
BOOLEAN_TASK_DECLARE ("profile", "Enable program profiling",
profile_p, "");
+ STRING_TASK_DECLARE ("l|system-library",
+ "\n"
+ "\t\t\tSpecify the builtin system library to use;\n"
+ "\t\t\tvalid library names are: `spim' (default), "
+ "`nolimips', \n"
+ "\t\t\tand `none'\n",
+ select_system_library, "spim",
+ "");
+
BOOLEAN_TASK_DECLARE ("E|trace-exec", "Trace the execution",
trace_exec_p, "");
TASK_DECLARE ("e|execute", "Execute the program on virtual machine",
Index: NEWS
--- NEWS (révision 198)
+++ NEWS (révision 199)
@@ -1,3 +1,9 @@
+New in 0.8a:
+* `--system-library' option provides builtin system library selection,
+ so the user can use a spim-like or the nolimips-original syscall set.
+
+* `--argument-registers' is the new name of `--args'.
+
New in 0.8, 2005-07-11:
* The shell now has (some) completion.
https://svn.lrde.epita.fr/svn/lrdetools/trunk
Index: ChangeLog
from Nicolas Pouillard <ertai(a)lrde.epita.fr>
Add --force to common_commit.
* vcs/lib/vcs/common_commit.rb:
The --force option bypass the rule with unrecognized files.
Inform the user that an update is done.
Make the message for +commited files shorter.
common_commit.rb | 26 +++++++++++++++++++-------
1 files changed, 19 insertions(+), 7 deletions(-)
Index: vcs/lib/vcs/common_commit.rb
--- vcs/lib/vcs/common_commit.rb (revision 272)
+++ vcs/lib/vcs/common_commit.rb (working copy)
@@ -11,8 +11,12 @@
raise Failure, "No `#{CL}', you are probably not in a valid directory."
end
+ force = opts[:force]
+ opts.delete :force
+
@@subject_format = subject_format
+ logger.info { 'Updating your working copy...' }
update!
have_unrecognized_files = false
@@ -24,7 +28,7 @@
end
end
if have_unrecognized_files
- raise Failure, "
+ message = "
|You have unrecognized files in your working copy!
|This meant that these files won't be commited!
|You have some solutions to comply with the rule:
@@ -43,9 +47,15 @@
| ------------ .vcs ------------
|- You can also perform a partial commit and specify which files
| and directories commit. For example this command:
- | #{@command} commit foo.c bar/
+ | #{(a)cmd.command} commit foo.c bar/
|
- |Commit failed".head_cut!
+ |".head_cut!
+ if force
+ logger.warn { message }
+ else
+ logger.error { message }
+ commit_failed
+ end
end
Vcs.commited = edit_form!(files)
@@ -82,23 +92,25 @@
block[iform['subject']] if block_given?
- logger.info 'Deleting junk files...'
+ logger.info { 'Deleting junk files...' }
TMP_CL.delete if TMP_CL.exist?
destdir = '+commited'.to_path/iform['revision'].to_s
destdir.mkpath unless destdir.directory?
+ moved = PathList.new
[LogEntry, Form, IForm, Message, MAIL, NEWS].each do |path|
next unless path.exist?
dest = destdir/path
- logger.info "Moving `#{path}' to `#{dest}'..."
+ moved << path
path.rename(dest)
end
+ logger.info { "Moving `#{moved.join('\', `')}' to `#{destdir}'..." }
end
protected :common_commit!
def commit_failed ( ex=nil )
- logger.error "Aborting #{ex}"
- logger.info 'You can rerun the same command to resume the commit'
+ logger.error { "Aborting #{ex}" }
+ logger.info { 'You can rerun the same command to resume the commit' }
raise 'Commit failed'
end
https://svn.lrde.epita.fr/svn/nolimips/trunk
ChangeLog | 11 +++
src/vm-tasks.cc | 4 -
src/vm/Makefile.am | 2
src/vm/nolimips_system_library.cc | 115 +++++++++++++++++++++++++++++++++++++
src/vm/nolimips_system_library.hh | 57 ++++++++++++++++++
src/vm/nolimips_system_library.hxx | 36 +++++++++++
6 files changed, 224 insertions(+), 1 deletion(-)
Index: ChangeLog
from Benoît Perrot <benoit(a)lrde.epita.fr>
Introduce nolimips system library.
* src/vm/nolimips_system_library.hh,
* src/vm/nolimips_system_library.hxx,
* src/vm/nolimips_system_library.cc:
Provide a set of some libc functions as syscalls.
* src/vm/Makefile.am: Distribute these new files.
* src/vm-tasks.cc: Fix missing include.
Index: src/vm/nolimips_system_library.hh
--- src/vm/nolimips_system_library.hh (revision 0)
+++ src/vm/nolimips_system_library.hh (revision 197)
@@ -0,0 +1,57 @@
+//
+// This file is part of Nolimips, a MIPS simulator with unlimited registers
+// Copyright (C) 2005 Benoit Perrot <benoit(a)lrde.epita.fr>
+//
+// Nolimips 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.
+//
+// Nolimips 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
+//
+#ifndef VM_NOLIMIPS_SYSTEM_LIBRARY_HH
+# define VM_NOLIMIPS_SYSTEM_LIBRARY_HH
+
+# include <iostream>
+# include <map>
+
+# include "vm/system_library.hh"
+
+namespace vm
+{
+
+ class Mmu;
+
+ class NolimipsSystemLibrary: public SystemLibrary
+ {
+ public:
+ NolimipsSystemLibrary(std::istream &istr,
+ std::ostream &ostr,
+ std::ostream &estr);
+ virtual ~NolimipsSystemLibrary();
+
+ public:
+ virtual void invoke(Cpu &cpu);
+
+ protected:
+ int read(int fd, Mmu &mmu, int offset, int count);
+ int write(int fd, const Mmu &mmu, int offset, int count);
+
+ protected:
+ std::istream &istr_;
+ std::ostream &ostr_;
+ std::ostream &estr_;
+ };
+
+} // namespace vm
+
+# include "vm/nolimips_system_library.hxx"
+
+#endif // !VM_NOLIMIPS_SYSTEM_LIBRARY_HH
Index: src/vm/nolimips_system_library.hxx
--- src/vm/nolimips_system_library.hxx (revision 0)
+++ src/vm/nolimips_system_library.hxx (revision 197)
@@ -0,0 +1,36 @@
+//
+// This file is part of Nolimips, a MIPS simulator with unlimited registers
+// Copyright (C) 2005 Benoit Perrot <benoit(a)lrde.epita.fr>
+//
+// Nolimips 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.
+//
+// Nolimips 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
+//
+#ifndef VM_NOLIMIPS_SYSTEM_LIBRARY_HXX
+# define VM_NOLIMIPS_SYSTEM_LIBRARY_HXX
+
+# include "vm/nolimips_system_library.hh"
+
+namespace vm
+{
+
+ inline
+ NolimipsSystemLibrary::NolimipsSystemLibrary(std::istream &istr,
+ std::ostream &ostr,
+ std::ostream &estr):
+ istr_(istr), ostr_(ostr), estr_(estr)
+ {}
+
+} // namespace vm
+
+#endif // !VM_NOLIMIPS_SYSTEM_LIBRARY_HXX
Index: src/vm/nolimips_system_library.cc
--- src/vm/nolimips_system_library.cc (revision 0)
+++ src/vm/nolimips_system_library.cc (revision 197)
@@ -0,0 +1,115 @@
+//
+// This file is part of Nolimips, a MIPS simulator with unlimited registers
+// Copyright (C) 2005 Benoit Perrot <benoit(a)lrde.epita.fr>
+//
+// Nolimips 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.
+//
+// Nolimips 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
+//
+#include "common.hh"
+
+#include "vm/nolimips_system_library.hh"
+#include "vm/cpu.hh"
+#include "vm/mmu.hh"
+
+namespace vm
+{
+
+ NolimipsSystemLibrary::~NolimipsSystemLibrary()
+ {}
+
+ int
+ NolimipsSystemLibrary::read(int fd, Mmu &mmu, int offset, int count)
+ {
+ std::istream *istr = 0;
+
+ if (fd == 0)
+ istr = &istr_;
+
+ int i = -1;
+ if (istr)
+ {
+ for (i = 0; i < count; ++i, ++offset)
+ {
+ int c = istr->get();
+ if (istr->eof())
+ break;
+
+ mmu.data_store_byte(offset, c);
+ }
+ }
+
+ return i;
+ }
+
+ int
+ NolimipsSystemLibrary::write(int fd, const Mmu &mmu, int offset, int count)
+ {
+ std::ostream *ostr = 0;
+
+ if (fd == 1)
+ ostr = &ostr_;
+ else if (fd == 2)
+ ostr = &estr_;
+
+ int i = -1;
+ if (ostr)
+ {
+ for (i = 0; i < count; ++i, ++offset)
+ ostr->put(static_cast<char>(mmu.data_load_byte(offset)));
+ }
+
+ return i;
+ }
+
+ void
+ NolimipsSystemLibrary::invoke(Cpu &cpu)
+ {
+ switch (cpu.get_register(Cpu::v0))
+ {
+ case 0x02: // read(fd: $a0, buf: $a1, count: $a2): $v0
+ {
+ cpu.set_register(Cpu::v0,
+ read(cpu.get_register(Cpu::a0),
+ cpu.get_mmu(), cpu.get_register(Cpu::a1),
+ cpu.get_register(Cpu::a2)));
+ }
+ break;
+
+ case 0x03: // write(fd: $a0, buf: $a1, count: $a2): $v0
+ {
+ cpu.set_register(Cpu::v0,
+ write(cpu.get_register(Cpu::a0),
+ cpu.get_mmu(), cpu.get_register(Cpu::a1),
+ cpu.get_register(Cpu::a2)));
+ }
+ break;
+
+ case 0x06: // exit(status: $a0)
+ cpu.get_cp0().set_fatal_exception();
+ if (!exit_status)
+ exit_status = (exit_type) cpu.get_register(Cpu::a0);
+ break;
+
+ case 0x33: // malloc(size: $a0)
+ cpu.set_register(Cpu::v0,
+ cpu.get_mmu().data_sbrk(cpu.get_register(Cpu::a0)));
+ break;
+
+ default:
+ assertion(!"syscall: Not implemented yet");
+ break;
+ }
+ }
+
+} // namespace vm
Index: src/vm/Makefile.am
--- src/vm/Makefile.am (revision 196)
+++ src/vm/Makefile.am (revision 197)
@@ -10,4 +10,6 @@
system_library.hh system_library.cc \
spim_system_library.hh spim_system_library.hxx \
spim_system_library.cc \
+ nolimips_system_library.hh nolimips_system_library.hxx \
+ nolimips_system_library.cc \
virtual_machine.hh virtual_machine.cc
Index: src/vm-tasks.cc
--- src/vm-tasks.cc (revision 196)
+++ src/vm-tasks.cc (revision 197)
@@ -1,6 +1,6 @@
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
-// Copyright (C) 2003, 2004 Benoit Perrot <benoit(a)lrde.epita.fr>
+// Copyright (C) 2003, 2004, 2005 Benoit Perrot <benoit(a)lrde.epita.fr>
//
// Nolimips is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -18,6 +18,8 @@
//
#include "common.hh"
+#include "inst/program.hh"
+
#include "vm/spim_system_library.hh"
#include "vm/virtual_machine.hh"
>>> "Nicolas" == Nicolas Pouillard <nicolas.pouillard(a)gmail.com> writes:
> On 10/5/05, Akim Demaille <akim(a)lrde.epita.fr> wrote:
>> >>> "Olivier" == Olivier Gournet <olivier.gournet(a)lrde.epita.fr> writes:
>>
>> > Nicolas Pouillard <nicolas.pouillard(a)gmail.com> disait le 10/03/05 :
>> >> - svn junk: This command use `list' to remove all junk files.
>>
>> > And directories ?
>>
>> This action name is wrong. It looks like "list the junk", not "trash
>> the junk". "vcs clean" seems more appropriate.
>>
> Ok.
> But it's just a shortcut for svn list --junk --do 'rm -rf'.
So what? I still don't care about implementation details.