LCOV - code coverage report
Current view: top level - vm - assertion.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 22 27 81.5 %
Date: 2017-07-14 10:03:36 Functions: 1 1 100.0 %

          Line data    Source code
       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             : 
      42             : List<assertion_name_t*>* list_assertion_names = NULL;
      43             : int32_t  assertion_class_count    = 0;
      44             : int32_t  assertion_package_count  = 0;
      45             : bool     assertion_user_enabled   = false;
      46             : bool     assertion_system_enabled = false;
      47             : 
      48             : 
      49             : /* assertion_ea_da *************************************************************
      50             : 
      51             :    Handle -ea:/-enableassertions: and -da:/-disableassertions: options.
      52             : 
      53             : *******************************************************************************/
      54             : 
      55          20 : 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          20 :         if (name == NULL) {
      63           0 :                 assertion_user_enabled = enabled;
      64           0 :                 return;
      65             :         }
      66             : 
      67          20 :         package = false;
      68          20 :         len     = os::strlen(name);
      69             : 
      70          20 :         if (name[len - 1] == '/') {
      71           0 :                 return;
      72             :         }
      73             : 
      74          20 :         buf = os::strdup(name);
      75             : 
      76          20 :         if (buf == NULL) {
      77           0 :                 os::abort_errno("assertion_ea_da: strdup failed");
      78             :         }
      79             : 
      80          30 :         if ((len > 2) && (strcmp(name + (len - 3), "...") == 0)) {
      81          10 :                 package = true;
      82          10 :                 buf[len - 3] = '\0';
      83          10 :                 assertion_package_count += 1;
      84             :         }
      85             :         else {
      86          10 :                 assertion_class_count += 1;
      87             :         }
      88             : 
      89          20 :         len = os::strlen(buf);
      90             : 
      91         270 :         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         250 :                 if (buf[i] == '/') {
      98           0 :                         buf[i] = '.';
      99             :                 }
     100             : #endif
     101             :         }
     102             : 
     103          20 :         item          = NEW(assertion_name_t);
     104          20 :         item->name    = buf;
     105          20 :         item->enabled = enabled;
     106          20 :         item->package = package;
     107             : 
     108          20 :         if (list_assertion_names == NULL) {
     109          20 :                 list_assertion_names = new List<assertion_name_t*>();
     110             :         }
     111             : 
     112          20 :         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             :  */

Generated by: LCOV version 1.11