mostang.com!davidm | 907e498 | 2004-05-04 20:13:07 +0000 | [diff] [blame] | 1 | /* libunwind - a platform-independent unwind library |
| 2 | Copyright (C) 2004 Hewlett-Packard Co |
| 3 | Contributed by David Mosberger-Tang <davidm@hpl.hp.com> |
| 4 | |
| 5 | This file is part of libunwind. |
| 6 | |
| 7 | Copyright (c) 2003 Hewlett-Packard Co. |
| 8 | |
| 9 | Permission is hereby granted, free of charge, to any person obtaining |
| 10 | a copy of this software and associated documentation files (the |
| 11 | "Software"), to deal in the Software without restriction, including |
| 12 | without limitation the rights to use, copy, modify, merge, publish, |
| 13 | distribute, sublicense, and/or sell copies of the Software, and to |
| 14 | permit persons to whom the Software is furnished to do so, subject to |
| 15 | the following conditions: |
| 16 | |
| 17 | The above copyright notice and this permission notice shall be |
| 18 | included in all copies or substantial portions of the Software. |
| 19 | |
| 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 21 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 22 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 23 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 24 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 25 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 26 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 27 | |
| 28 | /* The purpose of this program is simply to link in all libunwind-API |
| 29 | functions both in their local-only and generic variants and to make |
| 30 | sure that the final result can be linked statically. */ |
| 31 | |
| 32 | #include <stdio.h> |
| 33 | |
| 34 | #define UNW_LOCAL_ONLY |
| 35 | #include <libunwind.h> |
| 36 | |
| 37 | extern int test_generic (void); |
| 38 | |
| 39 | int verbose; |
| 40 | |
| 41 | #ifdef UNW_REMOTE_ONLY |
| 42 | |
| 43 | int |
| 44 | test_local (void) |
| 45 | { |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | #else /* !UNW_REMOTE_ONLY */ |
| 50 | |
| 51 | static void *funcs[] = |
| 52 | { |
| 53 | (void *) &unw_get_reg, |
| 54 | (void *) &unw_get_fpreg, |
| 55 | (void *) &unw_set_reg, |
| 56 | (void *) &unw_set_fpreg, |
| 57 | (void *) &unw_resume, |
| 58 | (void *) &unw_create_addr_space, |
| 59 | (void *) &unw_destroy_addr_space, |
| 60 | (void *) &unw_get_accessors, |
| 61 | (void *) &unw_flush_cache, |
| 62 | (void *) &unw_set_caching_policy, |
| 63 | (void *) &unw_regname, |
| 64 | (void *) &unw_get_proc_info, |
| 65 | (void *) &unw_get_save_loc, |
| 66 | (void *) &unw_is_signal_frame, |
| 67 | (void *) &unw_get_proc_name, |
| 68 | (void *) &_U_dyn_register, |
| 69 | (void *) &_U_dyn_cancel |
| 70 | }; |
| 71 | |
| 72 | int |
| 73 | test_local (void) |
| 74 | { |
| 75 | unw_context_t uc; |
| 76 | unw_cursor_t c; |
| 77 | |
| 78 | if (verbose) |
| 79 | printf (__FILE__": funcs[0]=%p\n", funcs[0]); |
| 80 | |
| 81 | unw_getcontext (&uc); |
| 82 | unw_init_local (&c, &uc); |
| 83 | unw_init_remote (&c, unw_local_addr_space, &uc); |
| 84 | return unw_step (&c); |
| 85 | } |
| 86 | |
| 87 | #endif /* !UNW_REMOTE_ONLY */ |
| 88 | |
| 89 | int |
| 90 | main (int argc, char **argv) |
| 91 | { |
| 92 | if (argc > 1) |
| 93 | verbose = 1; |
| 94 | |
| 95 | if (test_local () < 0) |
| 96 | return -1; |
| 97 | if (test_generic () < 0) |
| 98 | return -1; |
| 99 | return 0; |
| 100 | } |