Support reference types in the DWARF transform (#1986)
This commit is contained in:
@@ -166,3 +166,37 @@ check: resuming
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
#[cfg(all(
|
||||
any(target_os = "linux", target_os = "macos"),
|
||||
target_pointer_width = "64"
|
||||
))]
|
||||
pub fn test_debug_dwarf_ref() -> Result<()> {
|
||||
let output = lldb_with_script(
|
||||
&[
|
||||
"-g",
|
||||
"--opt-level",
|
||||
"0",
|
||||
"tests/all/debug/testsuite/fraction-norm.wasm",
|
||||
],
|
||||
r#"b fraction-norm.cc:26
|
||||
r
|
||||
p __vmctx->set(),n->denominator
|
||||
c"#,
|
||||
)?;
|
||||
|
||||
check_lldb_output(
|
||||
&output,
|
||||
r#"
|
||||
check: Breakpoint 1: no locations (pending)
|
||||
check: stop reason = breakpoint 1.1
|
||||
check: frame #0
|
||||
sameln: norm(n=(__ptr =
|
||||
check: = 27
|
||||
check: resuming
|
||||
"#,
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
40
tests/all/debug/testsuite/fraction-norm.cc
Normal file
40
tests/all/debug/testsuite/fraction-norm.cc
Normal file
@@ -0,0 +1,40 @@
|
||||
// Compile with:
|
||||
// clang++ --target=wasm32 fraction-norm.cc -o fraction-norm.wasm -g \
|
||||
// -O0 -nostdlib -fdebug-prefix-map=$PWD=.
|
||||
|
||||
struct Fraction {
|
||||
long numerator;
|
||||
long denominator;
|
||||
};
|
||||
|
||||
inline long abs(long x)
|
||||
{
|
||||
return x >= 0 ? x : -x;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void norm(Fraction &n)
|
||||
{
|
||||
long a = abs(n.numerator), b = abs(n.denominator);
|
||||
if (a == 0 || b == 0) return;
|
||||
do {
|
||||
a %= b;
|
||||
if (a == 0) break;
|
||||
b %= a;
|
||||
} while (b > 0);
|
||||
long gcd = a + b;
|
||||
if (n.denominator > 0) {
|
||||
n.numerator /= gcd;
|
||||
n.denominator /= gcd;
|
||||
} else {
|
||||
n.numerator /= -gcd;
|
||||
n.denominator /= -gcd;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void _start()
|
||||
{
|
||||
Fraction c = {6, 27};
|
||||
norm(c);
|
||||
}
|
||||
BIN
tests/all/debug/testsuite/fraction-norm.wasm
Executable file
BIN
tests/all/debug/testsuite/fraction-norm.wasm
Executable file
Binary file not shown.
Reference in New Issue
Block a user