经典的自动修复工具GenProg配置过程

前言

对于软件工程自动修复方向的人来说,GenProg是一个跳不过的软件。GenProg的作者在2009年,2012年,2013年发了三篇A会,都是有关GenProg的(我没记错的话)。

这里给出软件自动修复经典工具GenProg的简介和配置过程。

一、简介

现在的GenProg网站:https://squareslab.github.io/genprog-code/

源码地址:https://github.com/squaresLab/genprog-code

二、具体信息

在这个github网站中提供了一些信息:
1)当前版本是GenProg 3.2,还有其他老的版本,但是放在别处。
**2)**These instructions are very similar to those associated with previous versions of repair. Command line options should work as they did previously; older READMEs from previous releases contain detailed explanations of the relavent options.

新版本的指令和以前的差不多。
**3)**Read the entirety of this README before diving into a particular benchmark because I do not repeat instructions applying to all experiments in the benchmark-specific READMEs.

作者也没有运行完所有程序,所以自己一定要看清楚了ReadMe
**4)**GenProg operates on pre-processed code, meaning that the generated patches are sometimes non-obvious. Compare pre-processed code to original code to get a handle on what is going on.

Genprog是基于预处理代码操作的,要注意一下。
**5)**If you’d like to use the tarballs associated with the repair scenarios we ran for ICSE 2012 (we used similar scenarios but with different parameters for GECCO 2012) and ASE 2013 “out of the box”, you will need to use them with the VM images we provide, as they assume a certain directory structure. Check out the instructions associated with the disk image we provide on genprog.cs.virginia.edu on how to set up the VirtualBox image.

然而!!!作者给的genprog.cs.virginia.edu网站已经失效了。
**6)**Basics
The genprog prototype assumes bash scripting and standard utilities; Windows most likely requires cygwin. Some number of experiments can be performed in OS X, with some extra legwork (Jeremy’s note: the original version of this README mentions that compiling CIL for OS X is challenging, but I have not have much trouble with version 1.7.3)

Ensure that sh is symlinked to bash, not dash (as is the default on Ubuntu), on your machine. (Jeremy’s note: As of 2017 I’m not sure this matters any more)

Our prototype is written in OCaml. It should work for releases starting from at least 3.09.3; the most recent version of OCaml is 4.04.x. Our code has been shown to work with version 4.02.3, but it should work with the latest versions as well.

要注意#1 在Ubuntu里面,sh要对应bash而不是默认的dash。 #2 OCaml的版本注意下。 #3 要编译CIL

三、具体运行

很多,具体参考https://github.com/squaresLab/genprog-code

最重要的是,我发现作者在这里有很多不确定的地方(她说她自己也拿不准,我们看着办,或者有待后来的补充)

四、配置过程

1)用VMware安装Ubuntu 14.04虚拟机
2)拷贝之前下载的genprog-source-v1.tar.gz到Ubuntu
3)将Ubuntu换源 https://www.cnblogs.com/littlemonsters/p/5783690.html

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #备份
sudo vim /etc/apt/sources.list #修改
sudo apt-get update #更新列表

4)安装nautilus
https://www.linuxidc.com/Linux/2014-04/100498.htm

sudo apt-get install nautilus-open-terminal

记得注销log out一下,然后再登录即可。

5)从dash切换到bash
https://blog.csdn.net/gatieme/article/details/52136411

ls -l /bin/sh
sudo dpkg-reconfigure dash

选择否即可切换到bash。

6)安装OCaml
http://caml.inria.fr/ocaml/release.en.html 主页
http://caml.inria.fr/pub/distrib/ocaml-4.07/ocaml-4.07-refman.pdf 用户手册
http://caml.inria.fr/ocaml/release.en.htmlhttp://caml.inria.fr/pub/distrib/ocaml-3.09/ 下载地址

先参考readme,然后参考install,根据install里面的提示运行 ./configure,
输出信息应该是“成功安装”了。

Configuring for a x86_64-unknown-linux-gnu ...
gcc found
The C compiler is ANSI-compliant.
Checking the sizes of integers and pointers...
Wow! A 64 bit architecture!
This is a little-endian architecture.
Doubles can be word-aligned.
64-bit integers can be word-aligned.
Native division and modulus have round-towards-zero semantics, will use them.
Will use mmap() instead of malloc() for allocation of major heap chunks.
ranlib found
#! appears to work in shell scripts
POSIX signal handling found.
getrusage() found.
times() found.
You have BSD sockets.
socklen_t is defined in <sys/socket.h>
inet_aton() found.
IPv6 is supported.
unistd.h found.
off_t is defined in <sys/types.h>
dirent.h found.
rewinddir() found.
lockf() found.
mkfifo() found.
getcwd() found.
getwd() found.
getpriority() found.
utime() found.
utimes() found.
dup2() found.
fchmod() found.
truncate() found.
sys/select.h found.
select() found.
symlink() found.
waitpid() found.
wait4() found.
getgroups() found.
POSIX termios found.
Asynchronous I/O are supported.
setitimer() found.
gethostname() found.
uname() found.
gettimeofday() found.
mktime() found.
setsid() found.
putenv() found.
setlocale() and <locale.h> found.
dlopen() found in -ldl.
Dynamic loading of shared libraries is supported.
mmap() found.
gethostbyname_r() found (with 6 arguments).
gethostbyaddr_r() found (with 8 arguments).
Replay debugger supported.
System stack overflow can be detected.
POSIX threads library supported.
Options for linking with POSIX threads: -lpthread
sigwait() found
Bytecode threads library supported.
X11 not found, the "graph" library will not be supported.
NDBM not found, the "dbm" library will not be supported.
Configuring LablTk...
X11 not found.
Configuration failed, LablTk will not be built.
Camlp4 correctly configured.

** Configuration summary **

Directories where Objective Caml will be installed:
        binaries.................. /usr/local/bin
        standard library.......... /usr/local/lib/ocaml
        manual pages.............. /usr/local/man (with extension .1)
Configuration for the bytecode compiler:
        C compiler used........... gcc
        options for compiling..... -fno-defer-pop -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT
        options for linking.......  -Wl,-E  -lm  -ldl  -lpthread
        shared libraries are supported
        options for compiling..... -fPIC -fno-defer-pop -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT
        command for building...... gcc -shared -o lib.so -Wl,-rpath,/a/path objs
Configuration for the native-code compiler:
        hardware architecture..... amd64
        OS variant................ linux
        C compiler used........... gcc
        options for compiling..... -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT
        options for linking.......   -lm
        assembler ................ $(AS) 
        preprocessed assembler ... gcc -c -DSYS_$(SYSTEM)
        profiling with gprof ..... supported
Source-level replay debugger: supported
Additional libraries supported:
        unix str num dynlink bigarray systhreads threads
Configuration for the "num" library:
        target architecture ...... amd64 (asm level 1)
Configuration for the "graph" library:
        options for compiling .... 
        options for linking ...... not found
The "labltk" library: not supported

** Objective Caml configuration completed successfully **

然后运行:

make world
make bootstrap
make opt
make opt.opt
umask 022   // 然而在个umask似乎是Linux的指令,所以我在Ubuntu下用了sudo
make install

输出:

make[2]: Leaving directory `/home/dale123456/environment/ocaml-3.09.3/camlp4/compile'
make[1]: Leaving directory `/home/dale123456/environment/ocaml-3.09.3/camlp4'
if test -f debugger/ocamldebug; then (cd debugger; make install); \
       else :; fi
make[1]: Entering directory `/home/dale123456/environment/ocaml-3.09.3/debugger'
cp ocamldebug /usr/local/bin/ocamldebug
make[1]: Leaving directory `/home/dale123456/environment/ocaml-3.09.3/debugger'
cp config/Makefile /usr/local/lib/ocaml/Makefile.config

我没有运行make clean,我觉得应该没有关系。

7)安装ocamlfind
根据https://github.com/squaresLab/genprog-code 提示,CIL需要安装ocamlfind。
虽然原先的readme没说要这个,但是readme给的链接http://hal.cs.berkeley.edu/cil/ 已经失效了。

而且readme说的是Anything newer than CIL 1.3.7 should work.

反正现在我从下载地址http://projects.camlcity.org/projects/findlib.html 下了一个1.73版本的。先复制进Ubuntu,然后安装。

根据ocamlfind的install,运行./configure,结果发现 “m4 not found in the path” 的问题,最后从https://stackoverflow.com/questions/17912116/error-while-installing-ocamlfind-1-3-3-configure-m4-not-in-path-this-is-requir
找到了答案,运行sudo apt-get install m4,然后再./configure即可。

然而make all的时候报错:”make[1]: ocamlbuild: Command not found“

原因是:
Using ocamlfind with ocamlbuild (integrated since OCaml 3.12, plugin for earlier versions).
这个来源于:https://ocaml.org/ 主页,右上角搜索,然后搜索到 https://ocaml.org/learn/tutorials/ocamlbuild/

所以我打算先装ocamlbuild 谷歌搜索install ocamlbuild,参考 https://github.com/ocaml/ocamlbuild ,实在不行卸载原来的ocaml,改装 OCaml 3.12,

但是要先安装opam,我懒得再编译源码,直接sudo apt-get install opam
https://opam.ocaml.org/ opam官网

然而,sudo apt-get 版本太低,1.1的,最少要1.2的,所以我卸载了,参考
https://blog.csdn.net/luckydog612/article/details/80877179

8)安装CIL
http://hal.cs.berkeley.edu/cil/ 地址已经失效。

五、总结

这个配置过程还未完成,因为我现在还要忙其他事情,不过也算做了一大半了吧,接下来只要换一下OPAM的版本,然后装CIL就行了,应该问题不大。

以后有机会我会补充,欢迎交流。

生词:

verbose
英 [vɜ:ˈbəʊs] 美 [vɜ:rˈboʊs]
adj. 冗长的,啰唆的,累赘的
adv. 冗长地,啰唆地,累赘地
ADJ-GRADED 冗长的;啰唆的;唠叨的
If you describe a person or a piece of writing as verbose, you are critical of them because they use more words than are necessary, and so make you feel bored or annoyed.

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值