Skip to content

Commit ecbc5ca

Browse files
Ami-zhangtru
authored andcommitted
[libunwind][test] Add test to check for unw_resume()
This is here for local unwinding, which unw_resume() restores the machine state and then directly resumes execution in the target stack frame. Reviewed By: wangleiat Differential Revision: https://reviews.llvm.org/D147371 (cherry picked from commit 366c547)
1 parent 1c76740 commit ecbc5ca

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

libunwind/test/unw_resume.pass.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// -*- C++ -*-
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
// Ensure that unw_resume() resumes execution at the stack frame identified by
11+
// cursor.
12+
13+
// TODO: Investigate this failure on AIX system.
14+
// XFAIL: target={{.*}}-aix{{.*}}
15+
16+
// TODO: Figure out why this fails with Memory Sanitizer.
17+
// XFAIL: msan
18+
19+
// FIXME: The return address register($ra/$r1) is restored with a destroyed base
20+
// address register($a0/$r4) in the assembly file `UnwindRegistersRestore.S` on
21+
// LoongArch. And we will fix this issue in the next commit.
22+
// XFAIL: target={{loongarch64-.+}}
23+
24+
#include <libunwind.h>
25+
26+
void test_unw_resume() {
27+
unw_context_t context;
28+
unw_cursor_t cursor;
29+
30+
unw_getcontext(&context);
31+
unw_init_local(&cursor, &context);
32+
unw_step(&cursor);
33+
unw_resume(&cursor);
34+
}
35+
36+
int main() {
37+
test_unw_resume();
38+
return 0;
39+
}

0 commit comments

Comments
 (0)