面向死锁规避的路径敏感插装

来源 :智能计算机与应用 | 被引量 : 0次 | 上传用户:zouyuefu
下载到本地 , 更方便阅读
声明 : 本文档内容版权归属内容提供方 , 如果您对本文有版权争议 , 可与客服联系进行内容授权或下架
论文部分内容阅读
  摘 要:程序插桩技术是一种基本的测试手段,在软件测试中被广泛的应用。插装方式是指在程序源码中插入一些语句,通过这些语句可以获得所需要的信息,在死锁规避的静态分析中需要通过程序插装的方式记录下一些信息。程序插装按照源程序的结构分为顺序结构的插装,分支结构的插装和循环结构的插装。在对源程序进行词法语法分析的基础上建立抽象语法树和控制流图,根据控制流图获取程序可能执行的所有路径信息,接着根据路径信息决定插装的内容。
  关键词:词法分析;语法分析;抽象语法树;程序插装
  中图分类号:TP311 文献标识号:A
  Deadlock Avoidance Oriented Path Sensitive Instrumentation
  QI Peng, YU Zhen, SU Xiaohong, MA Peijun
  (School of Computer Science and Technology, Harbin Institute of Technology, Harbin 150001, China)
  Abstract:The instrumentation of the program is a basic test method, which is widely used in software testing. In instrumentation method is to insert some of the statements in the program source code, the required information is available through these statements, in static analysis of the deadlock avoidance through program instrumentation some information needs to be recorded. Procedures for the insertion into the structure of the source code structure is divided into the order of the structure of the insert, the branch structure of the insert and the structure of the loop. In this paper, on the basis of the lexical and syntax analysis of the source program to establish abstract syntax tree and control flow graph, according to the control flow graph to obtain the program may perform all path information, then according to the route information to decide the inserted content.
  Keywords:Lexical Analysis; Syntax Analysis; Abstract Syntax Tree; Program Instrumentation
  0 引 言
  程序插桩(Program Instrumentation)技术是一种基本的测试手段,由J.G.Huang教授首次提出,并已在软件测试中获得了广泛的应用。其目的是在保障源程序的逻辑和功能不被破坏的情况下,向源程序插入一些语句,这些语句可以记录或者输出一些需要关注的信息,进一步通过这些信息了解执行过程中程序的一些动态特性。
  Clang是一个支持 C,C ,Object-c及Object-c 等语言的编译器前端。在本文中即使用了Clang对源码经过词法语法分析,生成语法树,并在此基础上建立控制流图,方便之后的获取执行路径。使用Clang进行词法语法分析主要是由于Clang本身性能的优异,其生成语法树所消耗的内存仅仅是GCC的20%左右,同时编译时间快,错误输出明确,并且Clang支持在语法树的基础上建立控制流图,自动查找头文件,解析C语言在Linux下的头文件的功能。
  在基于未来锁集的死锁规避算法[1]中程序插装的是记录锁集信息的关键步骤[2],这也是基于未来锁集死锁规避算法与其它死锁规避算法[3-5]最大的不同,通常情况下程序插装的目的是获取程序的执行路径,或者关键的状态值等。虽然基于未来锁集的死锁规避算法也需要获取程序的执行路径,但却通过静态的分析方法获得程序可能的执行路径,而不是等到程序运行时获取真实的执行路径。所以本算法插装的目的是为了记录下相关的加锁操作的信息。只有获得了这些信息,才能根据这些信息添加规避逻辑[6]。
  1 路径敏感分析
  在基于未来锁集的死锁规避算法中程序的插装内容是根据程序的实际执行路径来确定的,然而在静态分析时却仍无法确定程序真实的执行路径,因此就需要找出程序所有的可能执行路径,并区分具体情况进行插装,这一过程就是路径敏感分析。
  下面使用块号代表节点,将控制流图这个有向图转化成矩阵的存储形式Arcs[N][N],N是所有节点的个数。在算法开始之前,需要首先引入一些变量定义:
  (1)节点栈mystack。
  (2)VertexStatus[]={0,0,0,1,1,…}当结点未进栈或者已经出栈,则其对应的状态为0,否则为1。
  (3)ArcStatus[][]={0,0,1,0,1…..} 当且仅当边的两个结点都在栈外时,边的状态才为0,否则为1。   对以上变量实现其定义后,算法1给出了路径敏感分析算法的具体描述。
  算法1:路径敏感分析算法
  输入:控制流图的矩阵存储形式Arcs[N][N]
  输出:控制流图中基本块N到基本块0的所有路径集合Paths
  1 Paths={}//路径集合
  2 VertexStatus[]={0};//全部置0
  3 ArcStatus[][]={0};//全部置0
  4 mystack.push(0);// 节点栈
  5 VertexStatus[N]=1;//将第N块入栈
  6 while !mystack.empty()
  7 elem= mystack.top();//获得栈顶元素
  8 if elem==0
  9 path=Traverse(mystack);//遍历栈将栈中信息组成路径
  10 Paths.add(path);//将栈中的路径添加到路径集合Paths中
  11 VertexStatus[elem]=0;
  12 UpdateArcStatus();//更新ArcStatus[][]
  13 mystack.pop();//移除栈顶元素
  14 else
  15 i=N
  16 T1= VertexStatus[i]==0;//第i块不在栈中
  17 T2= ArcStatus[elem][i]==0;//边(elem,i)不在栈中
  18 T3= Arcs.contain(elem,i);//控制流图中存在(elem,i)边
  19 if 如果存在一个最大的数i使i在0~N,并且使
  20 T1
其他文献
More and more of my classmates have mobile phones now. I also want one, but my mother doesn’t buy one for me. Mother said, “Teenagers shouldn’t use mobile phones, and it’s bad for your study.”  I don’
To find out whether bees can see colors, the following experiment1 is made. A round table is put in a garden and on the table is a piece of blue cardboard2 with a drop of syrup3 on it. After a short t
导演 (Director):拉加·高斯内尔 (Raja Gosnell)  配音演员 (Dubber): 尼尔·帕特里克·哈里斯 (Neil Patrick Harris)  克里斯托夫·梅兹-普莱瑟 (Christopher Mintz-Plasse)  克里斯蒂娜·里奇 (Christina Ricci) 凯蒂·派瑞 (Katy Perry)  杰玛·梅斯 (Jayma Mays) 安东·尤金
【栏目要求】  1. 将学生习作根据中考分值给出成绩; 2. 在应该修改的地方划线并标注序号;  3. 根据所标序号进行修改并说明修改的理由; 4. 给学生习作点评;  5. 请点评名师提供简历一份,包括:学校、职务、 职称、荣誉、教研教学成果、照片一张。  投稿邮箱: zxsyy2007@163.com或whzxsyy@163.com  来稿请寄: 430079 华中师范大学外国语学院《中学生英
展览时间:2014.02.20 至03.02  展览地点:中国美术馆  主办单位:民革中央、中華人民共和国文化部、中央文史研究馆、国家海洋局  在伟大祖国万里海疆和漫长界河中,无数珍珠般的岛屿是古今中外文化交流的桥梁,是民族独立尊严的历史见证,也承载了当代国人和平统一的伟大愿景。本次展览旨在用传统的书画形式表现祖国岛屿的自然风光和人文风情,借以弘扬爱国主义精神和民族文化情怀。展览展出的200余幅名
International Pillow Fight Day is held every April around the world—from Amsterdam, Budapest, to New York. It has been celebrated world widely since 2008.  国际枕头大战节每年四月份在世界各地举行——从阿姆斯特丹、布达佩斯到纽约。自2008年起,
Bikes are very popular in Holland. In fact, nearly half of all travel in Holland is by bike. Now, one Dutch bike designer, Thomas, is creating a different style of bike, which may not be popular every
对于画家而言,追求视觉形象的生动真实或许比图说主题情节更来得重要,但捕捉哪些与怎样的真实却因人而异。毋庸讳言,在当下一些历史与现实主题的绘画创作中,普遍存在用图像演绎主题内容的现象。这些作品往往注重事件情节的描述、主题内涵的表达和象征寓意的挖掘,而相对忽视了对于表现对象本身视觉真实性的生动展现。其实,绘画作品并非表现了主题、情节就失去了绘画存在的意义,优秀的主题性绘画总是通过真实生动的视觉形象超越
出生日期:2002年5月1日  爱好:足球  座右铭:态度决定高度,习惯成就人生。  就读学校:江苏省连云港市新海实验中学教育集团延安校区七(12)班  指导老师:陈传光  My School Life  Hello, everyone!I am in my new school now. My school is very good. And my favorite place in it is
The Twin Brothers  My aunt has two sons. They were born on the same day. They are twin brothers. One is Bingbing, and the other is Taotao. My parents and I like them very much. Bingbing doesn’t like t