1
|
1 |
/*
|
|
2 |
* Copyright 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*
|
|
23 |
*/
|
|
24 |
|
|
25 |
// Events and EventMark provide interfaces to log events taking place in the vm.
|
|
26 |
// This facility is extremly useful for post-mortem debugging. The eventlog
|
|
27 |
// often provides crucial information about events leading up to the crash.
|
|
28 |
//
|
|
29 |
// All arguments past the format string must be passed as an intptr_t.
|
|
30 |
//
|
|
31 |
// To log a single event use:
|
|
32 |
// Events::log("New nmethod has been created " INTPTR_FORMAT, nm);
|
|
33 |
//
|
|
34 |
// To log a block of events use:
|
|
35 |
// EventMark m("GarbageCollecting %d", (intptr_t)gc_number);
|
|
36 |
//
|
|
37 |
// The constructor to eventlog indents the eventlog until the
|
|
38 |
// destructor has been executed.
|
|
39 |
//
|
|
40 |
// IMPLEMENTATION RESTRICTION:
|
|
41 |
// Max 3 arguments are saved for each logged event.
|
|
42 |
//
|
|
43 |
|
|
44 |
class Events : AllStatic {
|
|
45 |
public:
|
|
46 |
// Logs an event, format as printf
|
|
47 |
static void log(const char* format, ...) PRODUCT_RETURN;
|
|
48 |
|
|
49 |
// Prints all events in the buffer
|
|
50 |
static void print_all(outputStream* st) PRODUCT_RETURN;
|
|
51 |
|
|
52 |
// Prints last number events from the event buffer
|
|
53 |
static void print_last(outputStream *st, int number) PRODUCT_RETURN;
|
|
54 |
};
|
|
55 |
|
|
56 |
class EventMark : public StackObj {
|
|
57 |
public:
|
|
58 |
// log a begin event, format as printf
|
|
59 |
EventMark(const char* format, ...) PRODUCT_RETURN;
|
|
60 |
// log an end event
|
|
61 |
~EventMark() PRODUCT_RETURN;
|
|
62 |
};
|
|
63 |
|
|
64 |
int print_all_events(outputStream *st);
|