[Scummvm-cvs-logs] SF.net SVN: scummvm:[49205] tools/branches/gsoc2010-decompiler
pidgeot at users.sourceforge.net
pidgeot at users.sourceforge.net
Tue May 25 01:15:59 CEST 2010
Revision: 49205
http://scummvm.svn.sourceforge.net/scummvm/?rev=49205&view=rev
Author: pidgeot
Date: 2010-05-24 23:15:59 +0000 (Mon, 24 May 2010)
Log Message:
-----------
First steps towards a disassembly framework.
Added a decompiler driver which doesn't do anything yet, except receive and
parse options. Also added data types for instructions and a very basic
parent class for disassemblers, which is not at all complete yet.
Although this commit technically handles tickets #1 and #5 on my task list,
I won't mark them as complete just yet - I'll hold off on that until I've
finished defining the base Disassembler class.
Modified Paths:
--------------
tools/branches/gsoc2010-decompiler/Makefile.common
Added Paths:
-----------
tools/branches/gsoc2010-decompiler/decompiler/
tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp
tools/branches/gsoc2010-decompiler/decompiler/disassembler.h
tools/branches/gsoc2010-decompiler/decompiler/instruction.h
Modified: tools/branches/gsoc2010-decompiler/Makefile.common
===================================================================
--- tools/branches/gsoc2010-decompiler/Makefile.common 2010-05-24 22:36:50 UTC (rev 49204)
+++ tools/branches/gsoc2010-decompiler/Makefile.common 2010-05-24 23:15:59 UTC (rev 49205)
@@ -58,7 +58,8 @@
extract_mohawk$(EXEEXT) \
construct_mohawk$(EXEEXT) \
degob$(EXEEXT) \
- scummvm-tools-cli$(EXEEXT)
+ scummvm-tools-cli$(EXEEXT) \
+ decompiler$(EXEEXT)
ifdef USE_FREETYPE
ifdef USE_ICONV
@@ -116,7 +117,8 @@
create_sjisfnt \
scummvm-tools \
scummvm-tools-cli \
- sword2_clue
+ sword2_clue \
+ decompiler
decine_OBJS := engines/cine/decine.o
@@ -255,7 +257,13 @@
$(tools_OBJS)
scummvm-tools-cli_LIBS := $(LIBS)
+decompiler_OBJS := \
+ decompiler/decompiler.o \
+ common/file.o
+decompiler_LIBS := \
+ -lboost_program_options
+
# Make base/version.o depend on all other object files. This way if anything is
# changed, it causes version.cpp to be recompiled. This in turn ensures that
# the build date in gScummVMBuildDate is correct.
Property changes on: tools/branches/gsoc2010-decompiler/decompiler
___________________________________________________________________
Added: svn:ignore
+ .deps
Added: tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp (rev 0)
+++ tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp 2010-05-24 23:15:59 UTC (rev 49205)
@@ -0,0 +1,52 @@
+#include <iostream>
+
+#include <boost/program_options.hpp>
+
+using namespace std;
+using namespace boost::program_options;
+
+int main(int argc, char** argv) {
+
+ options_description visible("Options");
+ visible.add_options()
+ ("help", "Produce this help message.")
+ ("engine", value<string>(), "Engine the script originates from.")
+ ("list", "List the supported engines.");
+
+ options_description args("");
+ args.add(visible).add_options()
+ ("inputfile", value<string>(), "Input file");
+
+ positional_options_description filename;
+ filename.add("inputfile", -1);
+
+ variables_map vm;
+ try {
+ store(command_line_parser(argc, argv).options(args).positional(filename).run(), vm);
+ notify(vm);
+ } catch (std::exception& e) {
+ std::cout << e.what();
+ }
+
+ if (vm.count("help") || !vm.count("inputfile")) {
+ cout << "Usage: " << argv[0] << " [option...] file" << endl << endl;
+ cout << args << "\n";
+ return 1;
+ }
+
+ if (vm.count("list")) {
+ cout << "TODO" << "\n";
+ return 0;
+ }
+
+ if (!vm.count("engine")) {
+ cout << "Engine must be specified." << "\n";
+ return 2;
+ } else {
+ cout << "Engine selected: " << vm["engine"].as<string>() << "\n";
+ }
+
+ cout << "Input file is " << vm["inputfile"].as<string>() << "\n";
+
+ return 0;
+}
Property changes on: tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: tools/branches/gsoc2010-decompiler/decompiler/disassembler.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/disassembler.h (rev 0)
+++ tools/branches/gsoc2010-decompiler/decompiler/disassembler.h 2010-05-24 23:15:59 UTC (rev 49205)
@@ -0,0 +1,25 @@
+#ifndef DEC_DISASSEMBLER_H
+#define DEC_DISASSEMBLER_H
+
+#include "instruction.h"
+#include "common/file.h"
+
+struct Opcode {
+ uint32_t _opcode;
+ InstType _type;
+ char* name;
+ char* paramlist;
+};
+
+class Disassembler {
+ protected:
+ Common::File f;
+
+ void readParams(Instruction* inst, char* paramInfo);
+ virtual void setupOpcodes() = 0;
+ public:
+ void open(char* filename);
+ void disassemble();
+};
+
+#endif
Property changes on: tools/branches/gsoc2010-decompiler/decompiler/disassembler.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: tools/branches/gsoc2010-decompiler/decompiler/instruction.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/instruction.h (rev 0)
+++ tools/branches/gsoc2010-decompiler/decompiler/instruction.h 2010-05-24 23:15:59 UTC (rev 49205)
@@ -0,0 +1,30 @@
+#ifndef DEC_INSTRUCTION_H
+#define DEC_INSTRUCTION_H
+
+#include <stdint.h>
+
+/**
+ * Enumeration for categorizing the different kinds of instructions.
+ */
+enum InstType {
+ ARITHMETIC,
+ BOOLEAN,
+ COMPARISON,
+ COND_JUMP,
+ JUMP,
+ LOAD,
+ SPECIAL,
+ STORE
+};
+
+/**
+ * Structure for representing an instruction.
+ */
+struct Instruction {
+ uint32_t _address; ///<The instruction address.
+ uint32_t _opcode; ///<The instruction opcode.
+ InstType _type; ///<The instruction type.
+ void* _params[16]; ///<Array of pointers to point to the parameters used for the instruction.
+};
+
+#endif
Property changes on: tools/branches/gsoc2010-decompiler/decompiler/instruction.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list