LiveRec:通过框架化调试协议进行探针原型设计
LiveRec: Prototyping Probes by Framing Debug Protocols
AI总结:
本文提出LiveRec,通过复用JDI和DAP等现有调试协议实现跨语言实时探针,无需修改编译器或运行时,并评估了Java、Python、C和Javascript原型的性能。
摘要:
背景:在Bret Victor于2012年发表的演讲《Inventing on Principle》的第一部分中,他演示了一个面向Javascript的实时代码编辑器,该编辑器能够实时显示变量值的动态历史。这种形式的实时编程已被称为“探针(probes)”。探针为程序员提供对函数或方法变量动态演变的持久且连续的洞察,从而改善反馈和开发者体验。问题:尽管Victor展示了Javascript语境下可工作的实时探针原型,但他并未讨论实现这些探针的策略。后续工作提供了一种实现方法,但这要求编程语言构建在GraalVM运行时之上。在本文中,我们提出LiveRec,这是一种用于实现探针的通用方法,可应用于多种编程语言语境,而无需修改编译器或运行时系统。方法:LiveRec基于复用现有调试协议来实现探针。方法或函数在每次代码变更后都会被编译,并在调试器内部执行。在执行期间,系统会记录当前栈帧中所有局部变量的演变,并将其传回编辑器或IDE以向用户显示。认识:事实证明,主流调试协议足够丰富,可以实现实时探针。逐步执行、代码热替换和栈帧检查提供了合适的粒度和充分的信息,可在不修改编译器或语言运行时的情况下实现实时探针。此外,事实证明,最近提出的Debugger Adapter Protocol(DAP,调试器适配器协议)提供了一种更通用的实时探针实现方式,但在某些情况下会带来显著的性能损失。实证:我们已经应用LiveRec实现探针:对于Java,通过Java Debug Interface(JDI,Java调试接口)原生使用栈记录;并通过DAP支持Java、Python、C和Javascript,所有这些都只需要适量的配置代码。我们评估了全部四个探针原型的运行时性能,并将其分解为:变更后编译、热替换、单步开销和栈记录开销。我们的初步结果表明,构建在原生调试API之上的实时探针可以具备足以支持交互式使用的性能。然而,在DAP情况下,其性能高度依赖于编程语言实现及其相关调试基础设施的特征。重要性:实时编程通过提供关于程序执行的即时反馈并消除具有打断性的编辑—编译—重启序列来改善程序员体验。探针是在函数和方法层面缩短程序员反馈回路的一种方式。尽管探针并不是新事物,并且已经在(原型)系统中得到实现,但LiveRec将实时探针构建于现有通用调试协议之上的方法,有望以合理的工作量为众多主流编程语言提供一条实现探针的路径。
英文摘要:
Context: In the first part of his 2012 presentation "Inventing on Principle", Bret Victor gives a demo of a live code editor for Javascript which shows the dynamic history of values of variables in real time. This form of live programming has become known as "probes". Probes provide the programmer with permanent and continuous insight into the dynamic evolution of function or method variables, thus improving feedback and developer experience. Inquiry: Although Victor shows a working prototype of live probes in the context of Javascript, he does not discuss strategies for implementing them. Later work provides an implementation approach, but this requires a programming language to be implemented on top of the GraalVM runtime. In this paper we present **LiveRec**, a generic approach for implementing probes which can be applied in the context of many programming languages, without requiring the modification of compilers or run-time systems. Approach: **LiveRec** is based on reusing existing debug protocols to implement probes. Methods or functions are compiled after every code change and executed inside the debugger. During execution the evolution of all local variables in the current stack frame are recorded and communicated back to the editor or IDE for display to the user. Knowledge: It turns out that mainstream debug protocols are rich enough for implementing live probes. Step-wise execution, code hot swapping, and stack frame inspection provide the right granularity and sufficient information to realize live probes, without modifying compilers or language runtimes. Furthermore, it turns out that the recently proposed Debugger Adapter Protocol (DAP) provides an even more generic approach of implementing live probes, but, in some cases, at the cost of a significant performance penalty. Grounding: We have applied **LiveRec** to implement probes using stack recording natively for Java through the Java Debug Interface (JDI), and through the DAP for Java, Python, C, and Javascript, all requiring just modest amounts of configuration code. We evaluate the run-time performance of all four probes prototypes, decomposed into: compile-after-change, hot swap, single step overhead, and stack recording overhead. Our initial results show that live probes on top of native debug APIs can be performant enough for interactive use. In the case of DAP, however, it highly depends on characteristics of the programming language implementation and its associated debugging infrastructure. Importance: Live programming improves the programmer experience by providing immediate feedback about a program's execution and eliminating disruptive edit-compile-restart sequences. Probes are one way to shorten the programmer feedback loop at the level of functions and methods. Although probes are not new, and have been implemented in (prototype) systems, **LiveRec**'s approach of building live probes on top of existing and generic debug protocols promises a path towards probes for a host of mainstream programming languages, with reasonable effort.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。