From 5a812e5972bd3353c6b95a75d68d38db2686fbd2 Mon Sep 17 00:00:00 2001 From: Dejan Mircevski Date: Wed, 15 Jun 2016 01:26:02 -0400 Subject: [PATCH 1/3] First version of DebuggingFramework.md. --- DebuggingFramework.md | 139 ++++++++++++++++++++++++++++++++++++++++++ wasm-debug-chart.png | Bin 0 -> 22492 bytes 2 files changed, 139 insertions(+) create mode 100644 DebuggingFramework.md create mode 100644 wasm-debug-chart.png diff --git a/DebuggingFramework.md b/DebuggingFramework.md new file mode 100644 index 00000000..6b246896 --- /dev/null +++ b/DebuggingFramework.md @@ -0,0 +1,139 @@ +#WebAssembly Debugging + +This is a design proposal for enabling source-level debugging of WebAssembly +modules. + +## Introduction + +There are several entities involved in debugging a source program compiled into +WebAssembly: + +- the compiled code being executed, called the _debuggee_ +- the browser engine executing the debuggee +- the browser devtools +- the source-program listing, usually split into multiple source files +- the description of how the debuggee code maps to the source program and vice + versa (e.g., WebAssembly code locations to source code locations, source + variables to WebAssembly memory, WebAssembly call stack to source functions, + etc.), called the _debug info_ + +These entities carry information and interact in particular ways to enable a +user to perform debugging actions at the source-code level. For example, the +browser devtools offer a UI allowing the user to step through the source code, +requiring partial execution of the debuggee chunk corresponding to each step, +and displaying the source file containing the stepped-through program. + +Specifying the debugging framework means describing how these entities interact, +what they need from each other, and how they access it; all in order to execute +the user's commands. + +## Debugger as a Procedural Interface + +A crucial element of this design proposal is to omit specifying a particular +format for the debug info. Instead, we introduce a separate entity we call the +debugger; its job is to act as a procedural intermediary between the devtools +and the debug info. Devtools execute user actions by leveraging debugger +methods we will specify here. + +Thus any debug-info format is acceptable, as long as the debugger can correctly +interpret it. The format is, in effect, a convention between the front-end +parsing the source and the debugger. + +What the design _does_ specify is two interaction protocols: + +1. between the devtools and the debugger, and +2. between the debugger and the wasm execution engine + +## Action Flow + +For reference, the entities are charted in the figure below: + +![Entities making up the debug framework](wasm-debug-chart.png) + +(The figure uses the conventional phrase "wasm module" to refer to a debuggee. +For now, we overlook the complexities of multiple wasm modules or mixing JS and +wasm on the same call stack.) + +Black arrows in the figure indicate the action flow and timeline: + +1. When the page is first rendered, the debuggee is loaded into the browser and + sent to the wasm execution engine. +2. The user interacts with the browser's devtools UI (eg, requesting a source + listing for a function to set a breakpoint). +3. Devtools call on the debugger to execute operation(s) necessary to fulfilling + the user's request. After going through steps 4 and/or 5, the debugger + returns a result for the devtools to display. +4. The debugger consults the debug info and/or source files to obtain the proper + mapping between the source code and the wasm. +5. Optionally, the debugger requests information from the browser, such as + examining the wasm memory or call stack in the execution engine. + +Note that 3 and 5 are bidirectional arrows: sometimes the flow of action goes +from the browser through the debugger to devtools. For instance, this will +happen when a breakpoint is hit and the wasm execution is paused. The browser +will then notify the debugger, who will in turn notify devtools after +translating the wasm program counter to the corresponding source line. + +## About the Debugger + +We propose that the debugger be a JavaScript library providing the interface +described in the next section. This allows for easy access to the browser, as +well as ease of implementation because JavaScript is widely known and supported. + +This also makes it possible for the debuggee to contain a URL for the debugger +to be used on it. This URL can point to any server, allowing debugger reuse +among many debuggees. + +## UI -> Debugger Protocol Operations + +First, we list the basic debugger operations that the UI can invoke: + +- get a source location given a mangled function name +- get a function signature given a mangled function name +- get the source given a location +- set a breakpoint at a given location +- interrupt the ongoing debuggee execution +- get the source location for the current debuggee execution point +- step into the next source line, descending into function calls +- step over the next source line +- get the current value of a given identifier (descending into struct members) +- set the current value of a given identifier (descending into struct members) +- get the type of a given identifier (descending into struct members) +- get the current call stack as a list of source locations +- return a given value from the current function + +(TODO: specify parameters and results for the above operations; also describe +custom types like "source location") + +## Debugger -> UI Notifications + +- a step into/over has completed +- a breakpoint was hit +- an uncaught exception was thrown +- `abort()` was called +- `exit()` was called + +(TODO: specify parameters and results) + +## About Debug Info and Source Files + +The debugger will need to access the debug info and source files for the current +debuggee. The debuggee can specify URLs for these items. Their format is not +specified -- it can be anything that the debugger knows how to interpret. + +## Debugger -> Debuggee Protocol Operations + +- interrupt execution +- set a breakpoint at a given byte offset +- get the current call stack +- execute the current wasm instruction and move on to the next one +- get the value of a wasm memory location +- set the value of a wasm memory location + +(TODO: specify parameters and results) + +## Debuggee -> Debugger Notifications + +- an uncaught exception was thrown + +(TODO: specify parameters and results) diff --git a/wasm-debug-chart.png b/wasm-debug-chart.png new file mode 100644 index 0000000000000000000000000000000000000000..3cfc60e3485c46b2389b53b3674caba8d0f36c6d GIT binary patch literal 22492 zcmbrmbyQVR+dX;+L68s$X(a>&q&r2rrMtVkQ&2i2q`SMjL%O6pq`N!sI`8+rW8887 zy7&HYaLyTfZ}wjCJoA}zu5}FhCM|-BjE@X~Kv2a*1?3$x4#Cl=7ruE~M?G}QNkQ8Bq+(af#omUOLNFt_vjBF|MwImAm z^~c3rv7 zzN&}e{wqlmsSa4)G#mgvV1EmI+x=G zO_qCDmVyxFUHGmpvDe9QmLx7WYFVV_C+!ku&}5w>cD|6-7YS8!W0eA!YR+b6#I@GF zB)Q&f5h2E95FL8le7PoAo)#|XJt6vclJM;<1q9K}#_@g%=#cNJn})O z-zZd=tk$X4Vec7<`18_d>Ai`zq|u|2`(fP;%{WGfhj~m9O2iO)#>b{x3)PmT=Fr+D zUeR)1(2$Kk8S+DOH&xvyZPUkkTj;NLo+skie^bZq)Z&H-<49`_sI{SPy;l0m@b0jA z{#%QeB2gbHDKbGpoIr)Ig;tHt5FU9N32vod!%nlU5) zMbe~JM2U47$yK;<9Gn|a-pqe?t0VeqAV{9dqyA4L1OBbFwq8f}hl}%zp5B=SLiV1E zgg!8?rfa+3C0YhFIK0DdF>x@wC}Hop=Z5z&L9an?B1$-1<-+>vzst`xn{hcNHvU`A zMi5^2rb%i^l+{|_xfU3ujP(lyLEbD!>quRtd&`Q3K+NJTz>DiL>CwqkdrWRv#GYjK zvG!edvjiUFyn)VsB9WlTlJV*fEu59JS8qQDD(`HM`b9*;hC@zx&pTRREeBkw82&Y5Fw36X?w5(*@{O1hW)IDwGQCMpqC^CYP@ z`Pb?<;h~!zy_P`*TCq_axcEyyx-28~H4snG=@GVE$+};?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w9nL(Kz!uQA&hW1uDG{Yq$; z@MoVJX6nWqKs18{JNvr}HkMd_4K7?&*$_2{NY*)ke+@Pqqrp9$62eM&81Wy%1jy)j za0?Z}5x=^hNVr=Nk`AcTw^e?}h$S@T6wF2zyca z|L!m-g@<7mwoDK1{Cl>}678bG!>9G|Ao9?L4hlDszO`7(nV|Q+u3(_C)@h`~!EKIj zDB$3zIFn;#txboSh-nY7o|S0&lX!x3pgnF1gTd-219p3r6xzbj^xGVld1q6RZP~S;v2G z>2t|kyKNJ|VkLT=iFz@wG3#2)V@J!4^%IyckW&DNgUK6a1^fN*^9-z3=R{>U!@JYs ztkoSDxF&|akWlm;eF8t5!vthf58RHZyTpKap>tVw_<}=#Vf$w}2HZ2q?L+SO7$Sz> zO$H6HRVW=THg-nGhcv@^yN^{#->!QxF}k}wtH-$*Dzs=x#Jq49_3yqCl0OBLuit(R z^g1_L#95}Z%Wc2v6gevpaLj!cQH3^nSQ z#ax11WeiR!=o~nu4zm*fc^58&oj>tV6Ra!nbN0D&0(LCL@7P691{w^9=L?Dn#_2f; z41+YBgdt^#HJgzVO}QMPX|A>*#kG~Pe`wmn+=;s;68Laexv|L?T^xW{)1k*a6Na#9 zaRI2U0TdLJv!n))!T-hs3_|$tMKXSK)HtQ58UkS&O=1EvF(UNi<>M0|Ni{hR2@mY~ zX|6c!Q$h8>hwKdINlZZ28T+}Ln$#4)n*G5w%4LDlDt}>j7X51= zklqDC#Dli$uoBg7GtJjgHVG#IF+(scL~~qP0IHOI7X-?v8HEXoI@sy|_>L`40n}y~ z?G)|2ZNHu@v0 zTiP}~m;t*~s!;{Lu2JAx0t+W7>Xb2>mC9b5g{aAXbjt`J?f>mc+z%|9+MIxM$k{Li NVX8WhN*+9W^)GicutER; literal 0 HcmV?d00001 From 19fd73471e0852ea222bcaa9320ed82dca8656e3 Mon Sep 17 00:00:00 2001 From: Dejan Mircevski Date: Wed, 15 Jun 2016 10:21:55 -0400 Subject: [PATCH 2/3] Reword so the debugger can itself be wasm. --- DebuggingFramework.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/DebuggingFramework.md b/DebuggingFramework.md index 6b246896..58e7d134 100644 --- a/DebuggingFramework.md +++ b/DebuggingFramework.md @@ -76,14 +76,20 @@ translating the wasm program counter to the corresponding source line. ## About the Debugger -We propose that the debugger be a JavaScript library providing the interface -described in the next section. This allows for easy access to the browser, as -well as ease of implementation because JavaScript is widely known and supported. +We propose that the debugger implement a JavaScript API (by, for example, being +a JavaScript library) that provides the actions described in the next section. +This allows for easy access to the browser, as well as ease of implementation +because JavaScript is widely known and supported. This also makes it possible for the debuggee to contain a URL for the debugger to be used on it. This URL can point to any server, allowing debugger reuse among many debuggees. +Because wasm [will](GC.md), in the future, be callable from JavaScript, this +opens up the possibility of a debugger itself being a wasm module. Similarly, +this API can, over time, expand to serve the debugging needs of not just wasm +but also all other scripts on the page (most significantly JavaScript modules). + ## UI -> Debugger Protocol Operations First, we list the basic debugger operations that the UI can invoke: From ed04e15d141521839d294424a853157cdb9d7ecc Mon Sep 17 00:00:00 2001 From: Dejan Mircevski Date: Tue, 28 Jun 2016 00:29:52 -0400 Subject: [PATCH 3/3] Add a few end-to-end flows. Add missing operations the flows require. Specify the debugger operations more precisely. --- DebuggingFramework.md | 111 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 91 insertions(+), 20 deletions(-) diff --git a/DebuggingFramework.md b/DebuggingFramework.md index 58e7d134..bae0e0ab 100644 --- a/DebuggingFramework.md +++ b/DebuggingFramework.md @@ -92,28 +92,57 @@ but also all other scripts on the page (most significantly JavaScript modules). ## UI -> Debugger Protocol Operations -First, we list the basic debugger operations that the UI can invoke: - -- get a source location given a mangled function name -- get a function signature given a mangled function name -- get the source given a location -- set a breakpoint at a given location -- interrupt the ongoing debuggee execution -- get the source location for the current debuggee execution point -- step into the next source line, descending into function calls -- step over the next source line -- get the current value of a given identifier (descending into struct members) -- set the current value of a given identifier (descending into struct members) -- get the type of a given identifier (descending into struct members) -- get the current call stack as a list of source locations -- return a given value from the current function - -(TODO: specify parameters and results for the above operations; also describe -custom types like "source location") +The following operations are available regardless of the debuggee's execution +status: + +`init(debug_info_url)` the debugger visits the url, obtaining the debug info +(including how to grab source files). + +`sources()` returns a list of handles to all source files. A handle contains +the file path and a unique identifier. + +`symbol_location(mangled_name)` returns the source location where the named +symbol is defined. Locations consist of a file handle, a line number, and a +column number. + +`typeof(mangled_name)` returns the type of the named symbol; for functions, +returns the entire function type, including the return type and the types of all +parameters. (TODO: define type) + +`source(file_handle)` returns the source-file text. + +`break(location)` sets a breakpoint, returning a handle to it. + +`status()` returns a value indicating whether the debuggee is currently running, +paused, or inactive. + +`pause()` if the debuggee is currently running, pauses its execution; otherwise, +does nothing. + +`resume()` if the debuggee is currently paused, resumes its execution; +otherwise, does nothing. + +The following operations are additionally available when the debuggee is paused: + +`callstack()` returns the call stack of the debuggee's current execution state. +The call stack is an array whose elements correspond to stack frames. Each +frame has the location, the mangled function name, and argument values. + +`step_into()` steps into debuggee's current source line (entering functions). + +`step_over()` steps over the current source line (not entering functions). + +`value(mangled_name)` returns the current value of the named symbol; the symbol +is looked up in debuggee's current execution context. + +`set(mangled_name, value)` sets the current value of the named symbol; the +symbol is looked up in the current debuggee execution context. + +`return(value)` makes the current function return the given value. (TODO: what +if the function's return type is void?) ## Debugger -> UI Notifications -- a step into/over has completed - a breakpoint was hit - an uncaught exception was thrown - `abort()` was called @@ -129,10 +158,12 @@ specified -- it can be anything that the debugger knows how to interpret. ## Debugger -> Debuggee Protocol Operations -- interrupt execution +- pause execution - set a breakpoint at a given byte offset - get the current call stack - execute the current wasm instruction and move on to the next one +- execute the current wasm instruction, but if it's a function call, execute the + whole function - get the value of a wasm memory location - set the value of a wasm memory location @@ -143,3 +174,43 @@ specified -- it can be anything that the debugger knows how to interpret. - an uncaught exception was thrown (TODO: specify parameters and results) + +## Example End-To-End Flows + +Here are a few examples of how the user's actions can be implemented using the +operations listed above: + +### Setting and Triggering a Breakpoint + +1. The UI initializes the debugger with the debug-info URL from the wasm module. +2. The UI invokes `sources()` and shows a list of file paths. +3. The user picks a file. The UI invokes `source()` on the file's handle to + obtain the file's text, then displays it to the user. +4. The user sets a breakpoint in the displayed source. + - The UI constructs a location from the file and the line, then invokes + `break()`. It stores the returned handle in the list of existing + breakpoints. + - The debugger translates the source location into a wasm byte offset using + the debug info, then asks the debuggee to set a breakpoint there. +5. When the breakpoint is triggered in the debuggee, the debuggee notifies the + debugger, which in turn notifies the UI. The UI looks up the received handle + in the list of all breakpoints and informs the user which breakpoint has just + triggered. The UI then invokes `callstack()` and displays it to the user for + examining. + +### Printing a Paused Program's Variable Value + +1. The user selects a symbol from the source listing. The UI mangles the name + and invokes `value()` on it. +2. The debugger looks up the symbol in the debug info and obtains its location + in the wasm memory. It asks the debuggee for the memory contents and returns + the result to the UI, which displays it. + +### Stepping over a Source Line + +1. The users clicks the UI element for stepping over. The UI invokes + `step_over()`. +2. The debugger looks up the current location in the debug info. +3. The debugger then tells the debuggee to execute the current wasm instruction, + executing whole functions. +4. The debugger repeats steps 2 and 3 until the current location changes.