调试服务器端WebAssembly的四种方法
Shopify Functions enables customizing the business logic of Shopify’s back end with server-side WebAssembly. There are many benefits to using a WebAssembly environment to host these customizations such as low cold-start latency and robust security compared to other alternatives. However, WebAssembly poses new challenges when debugging. These challenges aren’t unique to Shopify Functions and are common to other uses of WebAssembly including other server-side use cases. One of these challenges is a less refined developer experience when using step debuggers.
Shopify Functions可以通过服务器端的WebAssembly来定制Shopify的后端业务逻辑。使用WebAssembly环境来承载这些定制的功能有很多好处,比如与其他替代方案相比,冷启动延迟低,安全性强。然而,WebAssembly在调试时带来了新的挑战。这些挑战并不是Shopify功能所独有的,在WebAssembly的其他使用中也很常见,包括其他服务器端的使用案例。其中一个挑战是,在使用步骤调试器时,开发者的体验不太完善。
Step debuggers allow developers to pause execution on certain lines of code given certain conditions, execute lines of code one at a time, descend and ascend the current callstack, and see the values of in-scope variables at a particular point in execution. This flexibility can reduce the amount of time it takes to find a problem compared to debugging with print or log statements or studying the code. Some examples of step debuggers are GDB, LLDB, and the Visual Studio Debugger.
步进式调试器允许开发者在特定条件下暂停某些行代码的执行,一次执行几行代码,下降和上升当前的调用栈,并查看执行中某一特定点的范围内变量的值。与使用打印、日志语句或研究代码的调试相比,这种灵活性可以减少发现问题的时间。步骤调试器的一些例子是GDB、LDDB和Visual Studio调试器。
There are a few approaches that can be taken to step debug code that will be running in a WebAssembly environment:
有几种方法可以用来逐步调试将在WebAssembly环境中运行的代码。
- compile the code to a native architecture and use an appropriate step debugger for the particular language that code was written in
- 将代码编译为本地架构,并使用适当的步骤调试器来调试代码所使用的特定语言。
- use a debugger like LLDB or GDB to run the WebAssembly code in a WebAssembly environment like Wasmtime
- 使用LLDB或GDB等调试器,在Wasmtime等WebAssembly环境中运行WebAssembly代码。
- use a dedicated WebAssembly step debugger
- 使用专门的WebAssembly步骤调试器
- leverage browser developer tools’ step debuggers.
- 利用浏览器开发工具的步骤调试器。
There are tradeoffs to e...