src/hotspot/share/utilities/events.hpp
author stuefe
Wed, 22 May 2019 07:10:54 +0200
changeset 54973 0927d8c7296f
parent 54623 1126f0607c70
child 55044 d3afe760b392
permissions -rw-r--r--
8224487: outputStream should not be copyable Reviewed-by: kbarrett, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51334
diff changeset
     2
 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51334
diff changeset
    25
#ifndef SHARE_UTILITIES_EVENTS_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51334
diff changeset
    26
#define SHARE_UTILITIES_EVENTS_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "memory/allocation.hpp"
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    29
#include "runtime/mutexLocker.hpp"
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    30
#include "runtime/thread.hpp"
46560
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 37466
diff changeset
    31
#include "utilities/formatBuffer.hpp"
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    32
#include "utilities/vmError.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// Events and EventMark provide interfaces to log events taking place in the vm.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// This facility is extremly useful for post-mortem debugging. The eventlog
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// often provides crucial information about events leading up to the crash.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
//
11788
bef6166c683c 7145537: minor tweaks to LogEvents
never
parents: 11636
diff changeset
    38
// Abstractly the logs can record whatever they way but normally they
bef6166c683c 7145537: minor tweaks to LogEvents
never
parents: 11636
diff changeset
    39
// would record at least a timestamp and the current Thread, along
bef6166c683c 7145537: minor tweaks to LogEvents
never
parents: 11636
diff changeset
    40
// with whatever data they need in a ring buffer.  Commonly fixed
bef6166c683c 7145537: minor tweaks to LogEvents
never
parents: 11636
diff changeset
    41
// length text messages are recorded for simplicity but other
bef6166c683c 7145537: minor tweaks to LogEvents
never
parents: 11636
diff changeset
    42
// strategies could be used.  Several logs are provided by default but
bef6166c683c 7145537: minor tweaks to LogEvents
never
parents: 11636
diff changeset
    43
// new instances can be created as needed.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    45
// The base event log dumping class that is registered for dumping at
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    46
// crash time.  This is a very generic interface that is mainly here
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    47
// for completeness.  Normally the templated EventLogBase would be
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    48
// subclassed to provide different log types.
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11795
diff changeset
    49
class EventLog : public CHeapObj<mtInternal> {
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    50
  friend class Events;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    51
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    52
 private:
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    53
  EventLog* _next;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    54
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    55
  EventLog* next() const { return _next; }
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    56
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
 public:
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    58
  // Automatically registers the log so that it will be printed during
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    59
  // crashes.
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    60
  EventLog();
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    61
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    62
  virtual void print_log_on(outputStream* out) = 0;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    63
};
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    64
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    65
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    66
// A templated subclass of EventLog that provides basic ring buffer
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    67
// functionality.  Most event loggers should subclass this, possibly
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    68
// providing a more featureful log function if the existing copy
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    69
// semantics aren't appropriate.  The name is used as the label of the
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    70
// log when it is dumped during a crash.
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    71
template <class T> class EventLogBase : public EventLog {
17376
4ee999c3c007 8012902: remove use of global operator new - take 2
minqi
parents: 17031
diff changeset
    72
  template <class X> class EventRecord : public CHeapObj<mtInternal> {
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    73
   public:
11788
bef6166c683c 7145537: minor tweaks to LogEvents
never
parents: 11636
diff changeset
    74
    double  timestamp;
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    75
    Thread* thread;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    76
    X       data;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    77
  };
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    78
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    79
 protected:
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    80
  Mutex           _mutex;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    81
  const char*     _name;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    82
  int             _length;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    83
  int             _index;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    84
  int             _count;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    85
  EventRecord<T>* _records;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    86
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    87
 public:
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    88
  EventLogBase<T>(const char* name, int length = LogEventsBufferEntries):
51334
cc2c79d22508 8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents: 47216
diff changeset
    89
    _mutex(Mutex::event, name, false, Monitor::_safepoint_check_never),
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    90
    _name(name),
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    91
    _length(length),
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    92
    _index(0),
51334
cc2c79d22508 8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents: 47216
diff changeset
    93
    _count(0) {
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    94
    _records = new EventRecord<T>[length];
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
    95
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
11788
bef6166c683c 7145537: minor tweaks to LogEvents
never
parents: 11636
diff changeset
    97
  double fetch_timestamp() {
11795
0c892974d26c 7146729: nightly failure after 7141200: tty is sometimes null during shutdown of main thread
never
parents: 11788
diff changeset
    98
    return os::elapsedTime();
11788
bef6166c683c 7145537: minor tweaks to LogEvents
never
parents: 11636
diff changeset
    99
  }
bef6166c683c 7145537: minor tweaks to LogEvents
never
parents: 11636
diff changeset
   100
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   101
  // move the ring buffer to next open slot and return the index of
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   102
  // the slot to use for the current message.  Should only be called
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   103
  // while mutex is held.
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   104
  int compute_log_index() {
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   105
    int index = _index;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   106
    if (_count < _length) _count++;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   107
    _index++;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   108
    if (_index >= _length) _index = 0;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   109
    return index;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   110
  }
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   111
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   112
  bool should_log() {
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   113
    // Don't bother adding new entries when we're crashing.  This also
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   114
    // avoids mutating the ring buffer when printing the log.
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   115
    return !VMError::fatal_error_in_progress();
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   116
  }
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   117
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   118
  // Print the contents of the log
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   119
  void print_log_on(outputStream* out);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   120
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   121
 private:
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   122
  void print_log_impl(outputStream* out);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   123
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   124
  // Print a single element.  A templated implementation might need to
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   125
  // be declared by subclasses.
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   126
  void print(outputStream* out, T& e);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   128
  void print(outputStream* out, EventRecord<T>& e) {
11788
bef6166c683c 7145537: minor tweaks to LogEvents
never
parents: 11636
diff changeset
   129
    out->print("Event: %.3f ", e.timestamp);
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   130
    if (e.thread != NULL) {
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17376
diff changeset
   131
      out->print("Thread " INTPTR_FORMAT " ", p2i(e.thread));
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   132
    }
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   133
    print(out, e.data);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   134
  }
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   135
};
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   136
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   137
// A simple wrapper class for fixed size text messages.
53784
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   138
template <size_t bufsz>
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   139
class FormatStringLogMessage : public FormatBuffer<bufsz> {
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   140
};
53784
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   141
typedef FormatStringLogMessage<256> StringLogMessage;
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   142
typedef FormatStringLogMessage<512> ExtendedStringLogMessage;
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   143
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   144
// A simple ring buffer of fixed size text messages.
53784
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   145
template <size_t bufsz>
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   146
class FormatStringEventLog : public EventLogBase< FormatStringLogMessage<bufsz> > {
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   147
 public:
53784
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   148
  FormatStringEventLog(const char* name, int count = LogEventsBufferEntries) : EventLogBase< FormatStringLogMessage<bufsz> >(name, count) {}
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   149
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17376
diff changeset
   150
  void logv(Thread* thread, const char* format, va_list ap) ATTRIBUTE_PRINTF(3, 0) {
53784
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   151
    if (!this->should_log()) return;
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   152
53784
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   153
    double timestamp = this->fetch_timestamp();
54623
1126f0607c70 8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents: 53874
diff changeset
   154
    MutexLocker ml(&this->_mutex, Mutex::_no_safepoint_check_flag);
53784
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   155
    int index = this->compute_log_index();
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   156
    this->_records[index].thread = thread;
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   157
    this->_records[index].timestamp = timestamp;
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   158
    this->_records[index].data.printv(format, ap);
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   159
  }
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   160
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17376
diff changeset
   161
  void log(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(3, 4) {
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   162
    va_list ap;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   163
    va_start(ap, format);
53784
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   164
    this->logv(thread, format, ap);
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   165
    va_end(ap);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   166
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
};
53784
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   168
typedef FormatStringEventLog<256> StringEventLog;
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   169
typedef FormatStringEventLog<512> ExtendedStringEventLog;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
53738
7f3b27d9c22d 8212988: add recent class unloading events to the hs_err log
coleenp
parents: 53244
diff changeset
   171
class InstanceKlass;
7f3b27d9c22d 8212988: add recent class unloading events to the hs_err log
coleenp
parents: 53244
diff changeset
   172
7f3b27d9c22d 8212988: add recent class unloading events to the hs_err log
coleenp
parents: 53244
diff changeset
   173
// Event log for class unloading events to materialize the class name in place in the log stream.
7f3b27d9c22d 8212988: add recent class unloading events to the hs_err log
coleenp
parents: 53244
diff changeset
   174
class UnloadingEventLog : public EventLogBase<StringLogMessage> {
7f3b27d9c22d 8212988: add recent class unloading events to the hs_err log
coleenp
parents: 53244
diff changeset
   175
 public:
7f3b27d9c22d 8212988: add recent class unloading events to the hs_err log
coleenp
parents: 53244
diff changeset
   176
  UnloadingEventLog(const char* name, int count = LogEventsBufferEntries) : EventLogBase<StringLogMessage>(name, count) {}
7f3b27d9c22d 8212988: add recent class unloading events to the hs_err log
coleenp
parents: 53244
diff changeset
   177
7f3b27d9c22d 8212988: add recent class unloading events to the hs_err log
coleenp
parents: 53244
diff changeset
   178
  void log(Thread* thread, InstanceKlass* ik);
7f3b27d9c22d 8212988: add recent class unloading events to the hs_err log
coleenp
parents: 53244
diff changeset
   179
};
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   180
53874
b2fb6f782d84 8153413: Exceptions::_throw always logs exceptions, penalizing performance
coleenp
parents: 53784
diff changeset
   181
// Event log for exceptions
b2fb6f782d84 8153413: Exceptions::_throw always logs exceptions, penalizing performance
coleenp
parents: 53784
diff changeset
   182
class ExceptionsEventLog : public ExtendedStringEventLog {
b2fb6f782d84 8153413: Exceptions::_throw always logs exceptions, penalizing performance
coleenp
parents: 53784
diff changeset
   183
 public:
b2fb6f782d84 8153413: Exceptions::_throw always logs exceptions, penalizing performance
coleenp
parents: 53784
diff changeset
   184
  ExceptionsEventLog(const char* name, int count = LogEventsBufferEntries) : ExtendedStringEventLog(name, count) {}
b2fb6f782d84 8153413: Exceptions::_throw always logs exceptions, penalizing performance
coleenp
parents: 53784
diff changeset
   185
b2fb6f782d84 8153413: Exceptions::_throw always logs exceptions, penalizing performance
coleenp
parents: 53784
diff changeset
   186
  void log(Thread* thread, Handle h_exception, const char* message, const char* file, int line);
b2fb6f782d84 8153413: Exceptions::_throw always logs exceptions, penalizing performance
coleenp
parents: 53784
diff changeset
   187
};
b2fb6f782d84 8153413: Exceptions::_throw always logs exceptions, penalizing performance
coleenp
parents: 53784
diff changeset
   188
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   189
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   190
class Events : AllStatic {
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   191
  friend class EventLog;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   192
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   193
 private:
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   194
  static EventLog* _logs;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   195
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   196
  // A log for generic messages that aren't well categorized.
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   197
  static StringEventLog* _messages;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   198
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   199
  // A log for internal exception related messages, like internal
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   200
  // throws and implicit exceptions.
53874
b2fb6f782d84 8153413: Exceptions::_throw always logs exceptions, penalizing performance
coleenp
parents: 53784
diff changeset
   201
  static ExceptionsEventLog* _exceptions;
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   202
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   203
  // Deoptization related messages
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   204
  static StringEventLog* _deopt_messages;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   205
31234
48000028382c 8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file
coleenp
parents: 28163
diff changeset
   206
  // Redefinition related messages
48000028382c 8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file
coleenp
parents: 28163
diff changeset
   207
  static StringEventLog* _redefinitions;
48000028382c 8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file
coleenp
parents: 28163
diff changeset
   208
53738
7f3b27d9c22d 8212988: add recent class unloading events to the hs_err log
coleenp
parents: 53244
diff changeset
   209
  // Class unloading events
7f3b27d9c22d 8212988: add recent class unloading events to the hs_err log
coleenp
parents: 53244
diff changeset
   210
  static UnloadingEventLog* _class_unloading;
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   211
 public:
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   212
  static void print_all(outputStream* out);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   213
11788
bef6166c683c 7145537: minor tweaks to LogEvents
never
parents: 11636
diff changeset
   214
  // Dump all events to the tty
bef6166c683c 7145537: minor tweaks to LogEvents
never
parents: 11636
diff changeset
   215
  static void print();
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   216
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   217
  // Logs a generic message with timestamp and format as printf.
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17376
diff changeset
   218
  static void log(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   219
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   220
  // Log exception related message
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17376
diff changeset
   221
  static void log_exception(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
53874
b2fb6f782d84 8153413: Exceptions::_throw always logs exceptions, penalizing performance
coleenp
parents: 53784
diff changeset
   222
  static void log_exception(Thread* thread, Handle h_exception, const char* message, const char* file, int line);
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   223
31234
48000028382c 8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file
coleenp
parents: 28163
diff changeset
   224
  static void log_redefinition(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
48000028382c 8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file
coleenp
parents: 28163
diff changeset
   225
53738
7f3b27d9c22d 8212988: add recent class unloading events to the hs_err log
coleenp
parents: 53244
diff changeset
   226
  static void log_class_unloading(Thread* thread, InstanceKlass* ik);
7f3b27d9c22d 8212988: add recent class unloading events to the hs_err log
coleenp
parents: 53244
diff changeset
   227
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17376
diff changeset
   228
  static void log_deopt_message(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   229
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   230
  // Register default loggers
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   231
  static void init();
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   232
};
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   233
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   234
inline void Events::log(Thread* thread, const char* format, ...) {
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   235
  if (LogEvents) {
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   236
    va_list ap;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   237
    va_start(ap, format);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   238
    _messages->logv(thread, format, ap);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   239
    va_end(ap);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   240
  }
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   241
}
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   242
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   243
inline void Events::log_exception(Thread* thread, const char* format, ...) {
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   244
  if (LogEvents) {
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   245
    va_list ap;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   246
    va_start(ap, format);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   247
    _exceptions->logv(thread, format, ap);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   248
    va_end(ap);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   249
  }
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   250
}
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   251
53874
b2fb6f782d84 8153413: Exceptions::_throw always logs exceptions, penalizing performance
coleenp
parents: 53784
diff changeset
   252
inline void Events::log_exception(Thread* thread, Handle h_exception, const char* message, const char* file, int line) {
b2fb6f782d84 8153413: Exceptions::_throw always logs exceptions, penalizing performance
coleenp
parents: 53784
diff changeset
   253
  if (LogEvents) {
b2fb6f782d84 8153413: Exceptions::_throw always logs exceptions, penalizing performance
coleenp
parents: 53784
diff changeset
   254
    _exceptions->log(thread, h_exception, message, file, line);
b2fb6f782d84 8153413: Exceptions::_throw always logs exceptions, penalizing performance
coleenp
parents: 53784
diff changeset
   255
  }
b2fb6f782d84 8153413: Exceptions::_throw always logs exceptions, penalizing performance
coleenp
parents: 53784
diff changeset
   256
}
b2fb6f782d84 8153413: Exceptions::_throw always logs exceptions, penalizing performance
coleenp
parents: 53784
diff changeset
   257
31234
48000028382c 8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file
coleenp
parents: 28163
diff changeset
   258
inline void Events::log_redefinition(Thread* thread, const char* format, ...) {
48000028382c 8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file
coleenp
parents: 28163
diff changeset
   259
  if (LogEvents) {
48000028382c 8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file
coleenp
parents: 28163
diff changeset
   260
    va_list ap;
48000028382c 8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file
coleenp
parents: 28163
diff changeset
   261
    va_start(ap, format);
48000028382c 8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file
coleenp
parents: 28163
diff changeset
   262
    _redefinitions->logv(thread, format, ap);
48000028382c 8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file
coleenp
parents: 28163
diff changeset
   263
    va_end(ap);
48000028382c 8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file
coleenp
parents: 28163
diff changeset
   264
  }
48000028382c 8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file
coleenp
parents: 28163
diff changeset
   265
}
48000028382c 8081219: hs_err improvement: Add event logging for class redefinition to the hs_err file
coleenp
parents: 28163
diff changeset
   266
53738
7f3b27d9c22d 8212988: add recent class unloading events to the hs_err log
coleenp
parents: 53244
diff changeset
   267
inline void Events::log_class_unloading(Thread* thread, InstanceKlass* ik) {
7f3b27d9c22d 8212988: add recent class unloading events to the hs_err log
coleenp
parents: 53244
diff changeset
   268
  if (LogEvents) {
7f3b27d9c22d 8212988: add recent class unloading events to the hs_err log
coleenp
parents: 53244
diff changeset
   269
    _class_unloading->log(thread, ik);
7f3b27d9c22d 8212988: add recent class unloading events to the hs_err log
coleenp
parents: 53244
diff changeset
   270
  }
7f3b27d9c22d 8212988: add recent class unloading events to the hs_err log
coleenp
parents: 53244
diff changeset
   271
}
7f3b27d9c22d 8212988: add recent class unloading events to the hs_err log
coleenp
parents: 53244
diff changeset
   272
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   273
inline void Events::log_deopt_message(Thread* thread, const char* format, ...) {
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   274
  if (LogEvents) {
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   275
    va_list ap;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   276
    va_start(ap, format);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   277
    _deopt_messages->logv(thread, format, ap);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   278
    va_end(ap);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   279
  }
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   280
}
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   281
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   282
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   283
template <class T>
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   284
inline void EventLogBase<T>::print_log_on(outputStream* out) {
34633
2a6c7c7b30a7 8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents: 31234
diff changeset
   285
  if (Thread::current_or_null() == NULL) {
2a6c7c7b30a7 8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents: 31234
diff changeset
   286
    // Not yet attached? Don't try to use locking
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   287
    print_log_impl(out);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   288
  } else {
54623
1126f0607c70 8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents: 53874
diff changeset
   289
    MutexLocker ml(&_mutex, Mutex::_no_safepoint_check_flag);
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   290
    print_log_impl(out);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   291
  }
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   292
}
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   293
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   294
// Dump the ring buffer entries that current have entries.
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   295
template <class T>
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   296
inline void EventLogBase<T>::print_log_impl(outputStream* out) {
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   297
  out->print_cr("%s (%d events):", _name, _count);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   298
  if (_count == 0) {
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   299
    out->print_cr("No events");
11788
bef6166c683c 7145537: minor tweaks to LogEvents
never
parents: 11636
diff changeset
   300
    out->cr();
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   301
    return;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   302
  }
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   303
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   304
  if (_count < _length) {
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   305
    for (int i = 0; i < _count; i++) {
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   306
      print(out, _records[i]);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   307
    }
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   308
  } else {
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   309
    for (int i = _index; i < _length; i++) {
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   310
      print(out, _records[i]);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   311
    }
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   312
    for (int i = 0; i < _index; i++) {
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   313
      print(out, _records[i]);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   314
    }
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   315
  }
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   316
  out->cr();
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   317
}
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   318
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   319
// Implement a printing routine for the StringLogMessage
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   320
template <>
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   321
inline void EventLogBase<StringLogMessage>::print(outputStream* out, StringLogMessage& lm) {
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   322
  out->print_raw(lm);
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   323
  out->cr();
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   324
}
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   325
53784
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   326
// Implement a printing routine for the ExtendedStringLogMessage
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   327
template <>
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   328
inline void EventLogBase<ExtendedStringLogMessage>::print(outputStream* out, ExtendedStringLogMessage& lm) {
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   329
  out->print_raw(lm);
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   330
  out->cr();
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   331
}
31e3aa9c0c71 8204551: Event descriptions are truncated in logs
ysuenaga
parents: 53738
diff changeset
   332
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   333
// Place markers for the beginning and end up of a set of events.
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   334
// These end up in the default log.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
class EventMark : public StackObj {
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   336
  StringLogMessage _buffer;
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   337
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  // log a begin event, format as printf
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17376
diff changeset
   340
  EventMark(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  // log an end event
11636
3c07b54482a5 7141200: log some interesting information in ring buffers for crashes
never
parents: 7397
diff changeset
   342
  ~EventMark();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51334
diff changeset
   345
#endif // SHARE_UTILITIES_EVENTS_HPP