mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-24 06:55:15 +00:00
Improve Wasm debug instructions
This commit is contained in:
parent
6b191fcfc2
commit
6e2d7e4a8d
2 changed files with 24 additions and 16 deletions
|
@ -69,10 +69,12 @@
|
|||
<h3>Steps</h3>
|
||||
<ul>
|
||||
<li>
|
||||
In <code>gen_wasm/src/lib.rs</code>, set
|
||||
<code>DEBUG_LOG_SETTINGS.keep_test_binary = true</code>
|
||||
Run
|
||||
<code
|
||||
>ROC_WRITE_FINAL_WASM=1 cargo test-gen-wasm
|
||||
my_test_function_name</code
|
||||
>
|
||||
</li>
|
||||
<li>Run <code>cargo test-gen-wasm my_test_function_name</code></li>
|
||||
<li>
|
||||
Look for the path written to the console for
|
||||
<code>final.wasm</code> and select it in the file picker below
|
||||
|
@ -81,9 +83,6 @@
|
|||
Open the browser DevTools <br />
|
||||
<small> Control+Shift+I or Command+Option+I or F12 </small>
|
||||
</li>
|
||||
<li>
|
||||
If your test is from <code>gen_refcount.rs</code>
|
||||
</li>
|
||||
<li>
|
||||
The debugger should pause just before entering the first Wasm call.
|
||||
Step into a couple of Wasm calls until you reach your test code in
|
||||
|
@ -99,8 +98,8 @@
|
|||
<div class="controls">
|
||||
<div class="row">
|
||||
<label>
|
||||
<input type="checkbox" id="refcount-test">
|
||||
Check box if test is from <code>gen_refcount.rs</code>
|
||||
<input type="checkbox" id="refcount-test" />
|
||||
Check this box if your test is in <code>gen_refcount.rs</code>
|
||||
</label>
|
||||
</div>
|
||||
<div class="row row-file">
|
||||
|
@ -128,7 +127,7 @@
|
|||
} else {
|
||||
localStorage.removeItem("refcount-test");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
button.onclick = function () {
|
||||
if (refcount_checkbox.checked) {
|
||||
|
@ -136,7 +135,7 @@
|
|||
} else {
|
||||
runExpressionTest();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
file_input.onchange = function () {
|
||||
error_box.innerHTML = "";
|
||||
|
|
|
@ -26,15 +26,24 @@ pub(crate) fn save_wasm_file(app_module_bytes: &[u8], build_dir_hash: u64) {
|
|||
|
||||
let debug_dir_str = format!("/tmp/roc/gen_wasm/{build_dir_hash:016x}");
|
||||
let debug_dir_path = Path::new(&debug_dir_str);
|
||||
let final_wasm_file = debug_dir_path.join("final.wasm");
|
||||
let final_wasm_path = debug_dir_path.join("final.wasm");
|
||||
|
||||
std::fs::create_dir_all(debug_dir_path).unwrap();
|
||||
std::fs::write(&final_wasm_file, app_module_bytes).unwrap();
|
||||
std::fs::write(&final_wasm_path, app_module_bytes).unwrap();
|
||||
|
||||
println!(
|
||||
"Debug command:\n\twasm-objdump -dx {}",
|
||||
final_wasm_file.to_str().unwrap()
|
||||
);
|
||||
let final_wasm_str = final_wasm_path.to_str().unwrap();
|
||||
|
||||
// Get the absolute path to our HTML debug tool.
|
||||
// Use the fact that Cargo runs tests from the root of the crate
|
||||
let test_gen_dir = std::env::current_dir().unwrap();
|
||||
let debug_wasm_test_path = test_gen_dir.join("src").join("helpers").join("debug-wasm-test.html");
|
||||
let debug_wasm_test_str = debug_wasm_test_path.to_str().unwrap();
|
||||
|
||||
println!("");
|
||||
println!("Wrote wasm file to\n\t{final_wasm_str}");
|
||||
println!("Go to the Roc Wasm Debug tool in your browser\n\tfile://{debug_wasm_test_str}");
|
||||
println!("Or analyse the generated code\n\twasm-objdump -dx {final_wasm_str}");
|
||||
println!("");
|
||||
}
|
||||
|
||||
/// Used in the with_larger_debug_stack() function, for tests that otherwise
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue