Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

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