1 /* Test that execinfo.h defines stub functions.
2 Copyright (C) 2024 Free Software Foundation, Inc.
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published
6 by the Free Software Foundation, either version 3 of the License,
7 or (at your option) any later version.
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Collin Funk <collin.funk1@gmail.com>, 2024. */
30 test_backtrace (int pass
)
37 max_size
= (pass
== 0 ? SIZEOF (buffer
) : 1);
38 size
= backtrace (buffer
, max_size
);
39 ASSERT (size
>= 0 && size
<= max_size
);
41 /* Print the backtrace to a file descriptor. */
42 backtrace_symbols_fd (buffer
, size
, 1);
45 symbols
= backtrace_symbols (buffer
, size
);
47 /* We have enough memory available. */
48 ASSERT (symbols
!= NULL
);
50 /* Print the backtrace if possible. */
53 for (int i
= 0; i
< size
; ++i
)
54 printf ("%s\n", symbols
[i
]);
62 printf ("Full stack trace:\n"); fflush (stdout
);
64 printf ("\nTruncated stack trace:\n"); fflush (stdout
);
67 return test_exit_status
;