Line data Source code
1 : /* do not edit automatically generated by mc from M2Debug. */
2 : /* M2Debug.mod simple debugging facilities in the Modula-2 compiler.
3 :
4 : Copyright (C) 2001-2026 Free Software Foundation, Inc.
5 : Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 :
7 : This file is part of GNU Modula-2.
8 :
9 : GNU Modula-2 is free software; you can redistribute it and/or modify
10 : it under the terms of the GNU General Public License as published by
11 : the Free Software Foundation; either version 3, or (at your option)
12 : any later version.
13 :
14 : GNU Modula-2 is distributed in the hope that it will be useful, but
15 : WITHOUT ANY WARRANTY; without even the implied warranty of
16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 : General Public License for more details.
18 :
19 : You should have received a copy of the GNU General Public License
20 : along with GNU Modula-2; see the file COPYING3. If not see
21 : <http://www.gnu.org/licenses/>. */
22 :
23 : #include "config.h"
24 : #include "system.h"
25 : #include "gcc-consolidation.h"
26 :
27 : #include <stdbool.h>
28 : # if !defined (PROC_D)
29 : # define PROC_D
30 : typedef void (*PROC_t) (void);
31 : typedef struct { PROC_t proc; } PROC;
32 : # endif
33 :
34 : #define _M2Debug_C
35 :
36 : #include "GM2Debug.h"
37 : # include "GStrIO.h"
38 : # include "GM2Error.h"
39 : # include "GM2Options.h"
40 :
41 :
42 : /*
43 : Assert - tests the boolean, q. If false then an error is reported
44 : and the execution is HALTed.
45 : */
46 :
47 : extern "C" void M2Debug_Assert (bool q);
48 :
49 : /*
50 : WriteDebug - only writes a string if the debugging mode is on.
51 : */
52 :
53 : extern "C" void M2Debug_WriteDebug (const char *a_, unsigned int _a_high);
54 :
55 :
56 : /*
57 : Assert - tests the boolean, q. If false then an error is reported
58 : and the execution is HALTed.
59 : */
60 :
61 5010698200 : extern "C" void M2Debug_Assert (bool q)
62 : {
63 5010698200 : if (! q)
64 : {
65 24 : M2Error_InternalError ((const char *) "assert failed", 13);
66 : }
67 5010698176 : }
68 :
69 :
70 : /*
71 : WriteDebug - only writes a string if the debugging mode is on.
72 : */
73 :
74 0 : extern "C" void M2Debug_WriteDebug (const char *a_, unsigned int _a_high)
75 : {
76 0 : char a[_a_high+1];
77 :
78 : /* make a local copy of each unbounded array. */
79 0 : memcpy (a, a_, _a_high+1);
80 :
81 0 : if (M2Options_CompilerDebugging)
82 : {
83 0 : StrIO_WriteString ((const char *) a, _a_high);
84 0 : StrIO_WriteLn ();
85 : }
86 0 : }
87 :
88 14952 : extern "C" void _M2_M2Debug_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
89 : {
90 14952 : }
91 :
92 0 : extern "C" void _M2_M2Debug_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
93 : {
94 0 : }
|