< prev index next >

src/share/vm/utilities/xmlstream.cpp

Print this page




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/nmethod.hpp"
  27 #include "memory/allocation.hpp"
  28 #include "memory/allocation.inline.hpp"
  29 #include "memory/resourceArea.hpp"
  30 #include "oops/methodData.hpp"
  31 #include "oops/method.hpp"
  32 #include "oops/oop.inline.hpp"
  33 #include "runtime/deoptimization.hpp"
  34 #include "runtime/vmThread.hpp"

  35 #include "utilities/xmlstream.hpp"
  36 
  37 // Do not assert this condition if there's already another error reported.
  38 #define assert_if_no_error(cond, msg) \
  39   vmassert((cond) || is_error_reported(), msg)
  40 
  41 void xmlStream::initialize(outputStream* out) {
  42   _out = out;
  43   _last_flush = 0;
  44   _markup_state = BODY;
  45   _text_init._outer_xmlStream = this;
  46   _text = &_text_init;
  47 
  48 #ifdef ASSERT
  49   _element_depth = 0;
  50   int   init_len = 100;
  51   char* init_buf = NEW_C_HEAP_ARRAY(char, init_len, mtInternal);
  52   _element_close_stack_low  = init_buf;
  53   _element_close_stack_high = init_buf + init_len;
  54   _element_close_stack_ptr  = init_buf + init_len - 1;
  55   _element_close_stack_ptr[0] = '\0';
  56 #endif
  57 
  58   // Make sure each log uses the same base for time stamps.
  59   if (is_open()) {


 181 void xmlStream::pop_tag(const char* tag) {
 182   assert_if_no_error(!inside_attrs(), "cannot close element inside attrs");
 183   assert(_element_depth > 0, "must be in an element to close");
 184   assert(*tag != 0, "tag must not be empty");
 185   char* cur_tag = _element_close_stack_ptr;
 186   bool  bad_tag = false;
 187   while (*cur_tag != 0 && strcmp(cur_tag, tag) != 0) {
 188     this->print_cr("</%s> <!-- missing closing tag -->", cur_tag);
 189     _element_close_stack_ptr = (cur_tag += strlen(cur_tag) + 1);
 190     _element_depth -= 1;
 191     bad_tag = true;
 192   }
 193   if (*cur_tag == 0) {
 194     bad_tag = true;
 195   } else {
 196     // Pop the stack, by skipping over the tag and its null.
 197     _element_close_stack_ptr = cur_tag + strlen(cur_tag) + 1;
 198     _element_depth -= 1;
 199   }
 200   if (bad_tag && !VMThread::should_terminate() && !VM_Exit::vm_exited() &&
 201       !is_error_reported())
 202   {
 203     assert(false, "bad tag in log");
 204   }
 205 }
 206 #endif
 207 
 208 
 209 // ------------------------------------------------------------------
 210 // First word in formatted string is element kind, and any subsequent
 211 // words must be XML attributes.  Outputs "<kind .../>".
 212 void xmlStream::elem(const char* format, ...) {
 213   va_list ap;
 214   va_start(ap, format);
 215   va_elem(format, ap);
 216   va_end(ap);
 217 }
 218 
 219 // ------------------------------------------------------------------
 220 void xmlStream::va_elem(const char* format, va_list ap) {
 221   va_begin_elem(format, ap);




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/nmethod.hpp"
  27 #include "memory/allocation.hpp"
  28 #include "memory/allocation.inline.hpp"
  29 #include "memory/resourceArea.hpp"
  30 #include "oops/methodData.hpp"
  31 #include "oops/method.hpp"
  32 #include "oops/oop.inline.hpp"
  33 #include "runtime/deoptimization.hpp"
  34 #include "runtime/vmThread.hpp"
  35 #include "utilities/vmError.hpp"
  36 #include "utilities/xmlstream.hpp"
  37 
  38 // Do not assert this condition if there's already another error reported.
  39 #define assert_if_no_error(cond, msg) \
  40   vmassert((cond) || VMError::is_error_reported(), msg)
  41 
  42 void xmlStream::initialize(outputStream* out) {
  43   _out = out;
  44   _last_flush = 0;
  45   _markup_state = BODY;
  46   _text_init._outer_xmlStream = this;
  47   _text = &_text_init;
  48 
  49 #ifdef ASSERT
  50   _element_depth = 0;
  51   int   init_len = 100;
  52   char* init_buf = NEW_C_HEAP_ARRAY(char, init_len, mtInternal);
  53   _element_close_stack_low  = init_buf;
  54   _element_close_stack_high = init_buf + init_len;
  55   _element_close_stack_ptr  = init_buf + init_len - 1;
  56   _element_close_stack_ptr[0] = '\0';
  57 #endif
  58 
  59   // Make sure each log uses the same base for time stamps.
  60   if (is_open()) {


 182 void xmlStream::pop_tag(const char* tag) {
 183   assert_if_no_error(!inside_attrs(), "cannot close element inside attrs");
 184   assert(_element_depth > 0, "must be in an element to close");
 185   assert(*tag != 0, "tag must not be empty");
 186   char* cur_tag = _element_close_stack_ptr;
 187   bool  bad_tag = false;
 188   while (*cur_tag != 0 && strcmp(cur_tag, tag) != 0) {
 189     this->print_cr("</%s> <!-- missing closing tag -->", cur_tag);
 190     _element_close_stack_ptr = (cur_tag += strlen(cur_tag) + 1);
 191     _element_depth -= 1;
 192     bad_tag = true;
 193   }
 194   if (*cur_tag == 0) {
 195     bad_tag = true;
 196   } else {
 197     // Pop the stack, by skipping over the tag and its null.
 198     _element_close_stack_ptr = cur_tag + strlen(cur_tag) + 1;
 199     _element_depth -= 1;
 200   }
 201   if (bad_tag && !VMThread::should_terminate() && !VM_Exit::vm_exited() &&
 202       !VMError::is_error_reported())
 203   {
 204     assert(false, "bad tag in log");
 205   }
 206 }
 207 #endif
 208 
 209 
 210 // ------------------------------------------------------------------
 211 // First word in formatted string is element kind, and any subsequent
 212 // words must be XML attributes.  Outputs "<kind .../>".
 213 void xmlStream::elem(const char* format, ...) {
 214   va_list ap;
 215   va_start(ap, format);
 216   va_elem(format, ap);
 217   va_end(ap);
 218 }
 219 
 220 // ------------------------------------------------------------------
 221 void xmlStream::va_elem(const char* format, va_list ap) {
 222   va_begin_elem(format, ap);


< prev index next >