Lifestate:事件驱动协议和回调控制流(扩展版)
Lifestate: Event-Driven Protocols and Callback Control Flow (Extended Version)
摘要:
在事件驱动的软件框架(如Android)上开发交互式应用程序(app)是非常困难的。要创建符合预期的应用程序,开发人员必须遵循复杂且通常是隐式的异步编程协议。这些协议阻止了回调的正确注册,以便从具有适当应用程序编程接口(API)调用的框架接收控制,这些API调用反过来影响可能的未来回调的集合。例如,当应用在框架的某个状态下调用特定API方法时(在该状态下,此类调用无效),应用就会违反协议。在这个领域中,自动推理很难实现的原因很大程度上是因为在这样的框架下编写应用程序很难实现:协议的规范不清楚,控制流复杂、异步且高阶。在本文中,我们解决的问题,指定和建模事件驱动的应用程序编程协议。特别是,我们正式的核心元模型,捕捉事件驱动的框架和应用程序回调之间的对话。基于这个元模型,我们定义了一种语言,称为生命状态,允许精确和正式的描述应用程序编程协议和回调控制流所施加的事件驱动的框架。Lifestate统一了应用程序回调对框架的期望建模,并指定了应用程序在调用框架时必须遵守的规则。通过这种方式,我们有效地结合了生命周期约束和类型状态规则。为了评估生命状态建模的有效性,我们提供了一个动态验证算法,该算法将应用程序的执行轨迹和生命状态协议规范作为输入,以生成一个见证协议违反的轨迹,或者证明没有这样的轨迹是可实现的。
英文摘要:
Developing interactive applications (apps) against event-driven software frameworks such as Android is notoriously difficult. To create apps that behave as expected, developers must follow complex and often implicit asynchronous programming protocols. Such protocols intertwine the proper registering of callbacks to receive control from the framework with appropriate application-programming interface (API) calls that in turn affect the set of possible future callbacks. An app violates the protocol when, for example, it calls a particular API method in a state of the framework where such a call is invalid. What makes automated reasoning hard in this domain is largely what makes programming apps against such frameworks hard: the specification of the protocol is unclear, and the control flow is complex, asynchronous, and higher-order. In this paper, we tackle the problem of specifying and modeling event-driven application-programming protocols. In particular, we formalize a core meta-model that captures the dialogue between event-driven frameworks and application callbacks. Based on this meta-model, we define a language called lifestate that permits precise and formal descriptions of application-programming protocols and the callback control flow imposed by the event-driven framework. Lifestate unifies modeling what app callbacks can expect of the framework with specifying rules the app must respect when calling into the framework. In this way, we effectively combine lifecycle constraints and typestate rules. To evaluate the effectiveness of lifestate modeling, we provide a dynamic verification algorithm that takes as input a trace of execution of an app and a lifestate protocol specification to either produce a trace witnessing a protocol violation or a proof that no such trace is realizable.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。