ยปCore Development>Code coverage>Modules/_ctypes/libffi/src/debug.c

Python code coverage for Modules/_ctypes/libffi/src/debug.c

#countcontent
1n/a/* -----------------------------------------------------------------------
2n/a debug.c - Copyright (c) 1996 Red Hat, Inc.
3n/a
4n/a Permission is hereby granted, free of charge, to any person obtaining
5n/a a copy of this software and associated documentation files (the
6n/a ``Software''), to deal in the Software without restriction, including
7n/a without limitation the rights to use, copy, modify, merge, publish,
8n/a distribute, sublicense, and/or sell copies of the Software, and to
9n/a permit persons to whom the Software is furnished to do so, subject to
10n/a the following conditions:
11n/a
12n/a The above copyright notice and this permission notice shall be included
13n/a in all copies or substantial portions of the Software.
14n/a
15n/a THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
16n/a EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17n/a MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18n/a NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19n/a HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20n/a WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21n/a OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22n/a DEALINGS IN THE SOFTWARE.
23n/a ----------------------------------------------------------------------- */
24n/a
25n/a#include <ffi.h>
26n/a#include <ffi_common.h>
27n/a#include <stdlib.h>
28n/a#include <stdio.h>
29n/a
30n/a/* General debugging routines */
31n/a
32n/avoid ffi_stop_here(void)
33n/a{
34n/a /* This function is only useful for debugging purposes.
35n/a Place a breakpoint on ffi_stop_here to be notified of
36n/a significant events. */
37n/a}
38n/a
39n/a/* This function should only be called via the FFI_ASSERT() macro */
40n/a
41n/avoid ffi_assert(char *expr, char *file, int line)
42n/a{
43n/a fprintf(stderr, "ASSERTION FAILURE: %s at %s:%d\n", expr, file, line);
44n/a ffi_stop_here();
45n/a abort();
46n/a}
47n/a
48n/a/* Perform a sanity check on an ffi_type structure */
49n/a
50n/avoid ffi_type_test(ffi_type *a, char *file, int line)
51n/a{
52n/a FFI_ASSERT_AT(a != NULL, file, line);
53n/a
54n/a FFI_ASSERT_AT(a->type <= FFI_TYPE_LAST, file, line);
55n/a FFI_ASSERT_AT(a->type == FFI_TYPE_VOID || a->size > 0, file, line);
56n/a FFI_ASSERT_AT(a->type == FFI_TYPE_VOID || a->alignment > 0, file, line);
57n/a FFI_ASSERT_AT(a->type != FFI_TYPE_STRUCT || a->elements != NULL, file, line);
58n/a
59n/a}