duke@435: /* trims@1907: * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: duke@435: class ciObject; duke@435: class ciSymbol; duke@435: duke@435: // CompileLog duke@435: // duke@435: // An open stream for logging information about activities in a duke@435: // compiler thread. There is exactly one per CompilerThread, duke@435: // if the +LogCompilation switch is enabled. duke@435: class CompileLog : public xmlStream { duke@435: private: duke@435: const char* _file; // name of file where XML goes duke@435: julong _file_end; // last good end of file duke@435: intx _thread_id; // which compile thread duke@435: duke@435: stringStream _context; // optional, killable context marker duke@435: char _context_buffer[100]; duke@435: duke@435: char* _identities; // array of boolean duke@435: int _identities_limit; duke@435: int _identities_capacity; duke@435: duke@435: CompileLog* _next; // static chain of all logs duke@435: duke@435: static CompileLog* _first; // head of static chain duke@435: duke@435: void va_tag(bool push, const char* format, va_list ap); duke@435: duke@435: public: duke@435: CompileLog(const char* file, FILE* fp, intx thread_id); duke@435: ~CompileLog(); duke@435: duke@435: intx thread_id() { return _thread_id; } duke@435: const char* file() { return _file; } duke@435: stringStream* context() { return &_context; } duke@435: duke@435: void name(ciSymbol* s); // name='s' duke@435: void name(symbolHandle s) { xmlStream::name(s); } duke@435: duke@435: // Output an object description, return obj->ident(). duke@435: int identify(ciObject* obj); duke@435: void clear_identities(); duke@435: duke@435: // virtuals duke@435: virtual void see_tag(const char* tag, bool push); duke@435: virtual void pop_tag(const char* tag); duke@435: duke@435: // make a provisional end of log mark duke@435: void mark_file_end() { _file_end = out()->count(); } duke@435: duke@435: // copy all logs to the given stream duke@435: static void finish_log(outputStream* out); duke@435: static void finish_log_on_error(outputStream* out, char *buf, int buflen); duke@435: };