CACAO
assertion.cpp
Go to the documentation of this file.
1 /* src/vm/assertion.cpp - assertion options
2 
3  Copyright (C) 2007, 2008
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2, or (at
11  your option) any later version.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 
23 */
24 
25 
26 #include "config.h"
27 
28 #include <stdint.h>
29 
30 #include <cstddef>
31 
32 #include "mm/memory.hpp"
33 
34 #include "toolbox/list.hpp"
35 
36 #include "vm/assertion.hpp"
37 #include "vm/os.hpp"
38 
39 
40 /* -ea/-da options ************************************************************/
41 
47 
48 
49 /* assertion_ea_da *************************************************************
50 
51  Handle -ea:/-enableassertions: and -da:/-disableassertions: options.
52 
53 *******************************************************************************/
54 
55 void assertion_ea_da(const char *name, bool enabled)
56 {
57  bool package;
58  size_t len;
59  char *buf;
60  assertion_name_t *item;
61 
62  if (name == NULL) {
64  return;
65  }
66 
67  package = false;
68  len = os::strlen(name);
69 
70  if (name[len - 1] == '/') {
71  return;
72  }
73 
74  buf = os::strdup(name);
75 
76  if (buf == NULL) {
77  os::abort_errno("assertion_ea_da: strdup failed");
78  }
79 
80  if ((len > 2) && (strcmp(name + (len - 3), "...") == 0)) {
81  package = true;
82  buf[len - 3] = '\0';
84  }
85  else {
87  }
88 
89  len = os::strlen(buf);
90 
91  for (size_t i = 0; i < len; i++) {
92 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
93  if (buf[i] == '.') {
94  buf[i] = '/';
95  }
96 #else
97  if (buf[i] == '/') {
98  buf[i] = '.';
99  }
100 #endif
101  }
102 
103  item = NEW(assertion_name_t);
104  item->name = buf;
105  item->enabled = enabled;
106  item->package = package;
107 
108  if (list_assertion_names == NULL) {
109  list_assertion_names = new List<assertion_name_t*>();
110  }
111 
112  list_assertion_names->push_back(item);
113 }
114 
115 
116 /*
117  * These are local overrides for various environment variables in Emacs.
118  * Please do not remove this and leave it at the end of the file, where
119  * Emacs will automagically detect them.
120  * ---------------------------------------------------------------------
121  * Local variables:
122  * mode: c++
123  * indent-tabs-mode: t
124  * c-basic-offset: 4
125  * tab-width: 4
126  * End:
127  * vim:noexpandtab:sw=4:ts=4:
128  */
#define NEW(type)
Definition: memory.hpp:93
static void abort_errno(const char *text,...)
Equal to abort_errnum, but uses errno to get the error number.
Definition: os.cpp:165
List< assertion_name_t * > * list_assertion_names
Definition: assertion.cpp:42
void assertion_ea_da(const char *name, bool enabled)
Definition: assertion.cpp:55
JNIEnv jclass jobject const char * name
Definition: jvmti.h:312
static size_t strlen(const char *s)
Definition: os.hpp:672
bool assertion_user_enabled
Definition: assertion.cpp:45
List implementation.
Definition: lock.hpp:35
Option< bool > enabled("DebugCompiler2","compiler with compiler2", false, option::xx_root())
Definition: Compiler.hpp:112
int32_t assertion_class_count
Definition: assertion.cpp:43
MIIterator i
bool assertion_system_enabled
Definition: assertion.cpp:46
int32_t assertion_package_count
Definition: assertion.cpp:44
static char * strdup(const char *s)
Definition: os.hpp:654