mirror of
https://github.com/siemens-mobile-hacks/llvm-c166.git
synced 2026-11-28 03:42:55 +00:00
A second pass over the full API suite for tests that depend on features
unavailable on wasm32-wasip1 or in LLDB's Wasm support:
- Expression evaluation (skipIfWasm) for the C++ tests that the
"expression" category doesn't cover, since that category only applies to
commands/expression/*.
- Attaching to a running process (skipIfWasm). These tests have the
harness spawn the inferior as a host process and then attach, but a
.wasm module isn't a native executable, so exec'ing it fails with
ENOEXEC ("Exec format error"). The wasm module only runs inside the
runtime (e.g. iwasm) that LLDB launches, so there is no host process to
attach to.
Where a test also has supported, passing cases, the decorator is applied
per method.
97 lines
3.6 KiB
Python
97 lines
3.6 KiB
Python
"""
|
|
Tests that C++ member and static variables have correct layout and scope.
|
|
"""
|
|
|
|
|
|
import lldb
|
|
from lldbsuite.test.decorators import *
|
|
from lldbsuite.test.lldbtest import *
|
|
from lldbsuite.test import lldbutil
|
|
|
|
|
|
class TestCase(TestBase):
|
|
# We fail to lookup static members on Windows.
|
|
@expectedFailureAll(oslist=["windows"])
|
|
@skipIfWasm # no expression evaluation
|
|
def test_access_from_main(self):
|
|
self.build()
|
|
lldbutil.run_to_source_breakpoint(
|
|
self, "// stop in main", lldb.SBFileSpec("main.cpp")
|
|
)
|
|
|
|
self.expect_expr("my_a.m_a", result_type="short", result_value="1")
|
|
self.expect_expr("my_a.s_b", result_type="long", result_value="2")
|
|
self.expect_expr("my_a.s_c", result_type="int", result_value="3")
|
|
|
|
# We fail to lookup static members on Windows.
|
|
@expectedFailureAll(oslist=["windows"])
|
|
@skipIfWasm # no expression evaluation
|
|
def test_access_from_member_function(self):
|
|
self.build()
|
|
lldbutil.run_to_source_breakpoint(
|
|
self, "// stop in member function", lldb.SBFileSpec("main.cpp")
|
|
)
|
|
self.expect_expr("m_a", result_type="short", result_value="1")
|
|
self.expect_expr("s_b", result_type="long", result_value="2")
|
|
self.expect_expr("s_c", result_type="int", result_value="3")
|
|
|
|
# Currently lookups find variables that are in any scope.
|
|
@expectedFailureAll()
|
|
def test_access_without_scope(self):
|
|
self.build()
|
|
self.createTestTarget()
|
|
self.expect(
|
|
"expression s_c",
|
|
error=True,
|
|
startstr="error: use of undeclared identifier 's_d'",
|
|
)
|
|
|
|
# We fail to lookup static members on Windows.
|
|
@expectedFailureAll(oslist=["windows"])
|
|
def test_no_crash_in_IR_arithmetic(self):
|
|
"""
|
|
Test that LLDB doesn't crash on evaluating specific expression involving
|
|
pointer arithmetic and taking the address of a static class member.
|
|
See https://bugs.llvm.org/show_bug.cgi?id=52449
|
|
"""
|
|
self.build()
|
|
lldbutil.run_to_source_breakpoint(
|
|
self, "// stop in main", lldb.SBFileSpec("main.cpp")
|
|
)
|
|
|
|
# This expression contains the following IR code:
|
|
# ... i64 ptrtoint (i32* @_ZN1A3s_cE to i64)) ...
|
|
expr = "(int*)100 + (long long)(&A::s_c)"
|
|
|
|
# The IR interpreter doesn't support non-const operands to the
|
|
# `GetElementPtr` IR instruction, so verify that it correctly fails to
|
|
# evaluate expression.
|
|
opts = lldb.SBExpressionOptions()
|
|
opts.SetAllowJIT(False)
|
|
value = self.target().EvaluateExpression(expr, opts)
|
|
self.assertTrue(value.GetError().Fail())
|
|
self.assertIn(
|
|
"Can't evaluate the expression without a running target",
|
|
value.GetError().GetCString(),
|
|
)
|
|
|
|
# Evaluating the expression via JIT should work fine.
|
|
value = self.target().EvaluateExpression(expr)
|
|
self.assertSuccess(value.GetError())
|
|
|
|
def test_IR_interpreter_can_handle_getelementptr_constants_args(self):
|
|
self.build()
|
|
lldbutil.run_to_source_breakpoint(
|
|
self, "// stop in main", lldb.SBFileSpec("main.cpp")
|
|
)
|
|
|
|
# This expression contains the following IR code:
|
|
# ... getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
|
|
expr = "arr[0]"
|
|
|
|
# The IR interpreter supports const operands to the `GetElementPtr` IR
|
|
# instruction, so it should be able to evaluate expression without JIT.
|
|
opts = lldb.SBExpressionOptions()
|
|
opts.SetAllowJIT(False)
|
|
value = self.target().EvaluateExpression(expr, opts)
|
|
self.assertSuccess(value.GetError())
|