File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <execinfo.h>
3
+ #include <stdio.h>
4
+ #include <unistd.h>
5
+
6
+ void func () {
7
+ void * callstack [128 ];
8
+ int frames = backtrace (callstack , 128 );
9
+ fprintf (stderr , "backtrace returns %d frames:\n" , frames );
10
+ // we expect at least 3 frames: _start, main and func
11
+ assert (frames >= 3 );
12
+
13
+ backtrace_symbols_fd (callstack , frames , STDERR_FILENO );
14
+ return ;
15
+ }
16
+
17
+ int main (int argc , char * * argv ) {
18
+ (void ) argc ;
19
+ (void ) argv ;
20
+
21
+ func ();
22
+
23
+ return 0 ;
24
+ }
Original file line number Diff line number Diff line change @@ -114,6 +114,7 @@ all_test_cases = [
114
114
' glibc/error_at_line' ,
115
115
' glibc/getgrouplist' ,
116
116
' glibc/rpmatch' ,
117
+ ' glibc/backtrace' ,
117
118
' linux/xattr' ,
118
119
' linux/pthread_setname_np' ,
119
120
' linux/pthread_attr' ,
You can’t perform that action at this time.
0 commit comments