src/share/vm/utilities/decoder.hpp

Thu, 27 Jan 2011 16:11:27 -0800

author
coleenp
date
Thu, 27 Jan 2011 16:11:27 -0800
changeset 2497
3582bf76420e
parent 2364
2d4762ec74af
child 3156
f08d439fab8c
permissions
-rw-r--r--

6990754: Use native memory and reference counting to implement SymbolTable
Summary: move symbols from permgen into C heap and reference count them
Reviewed-by: never, acorn, jmasa, stefank

     1 /*
     2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. 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 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  */
    26 #ifndef __DECODER_HPP
    27 #define __DECODER_HPP
    29 #include "memory/allocation.hpp"
    31 #ifdef _WINDOWS
    32 #include <windows.h>
    33 #include <imagehlp.h>
    35 // functions needed for decoding symbols
    36 typedef DWORD (WINAPI *pfn_SymSetOptions)(DWORD);
    37 typedef BOOL  (WINAPI *pfn_SymInitialize)(HANDLE, PCTSTR, BOOL);
    38 typedef BOOL  (WINAPI *pfn_SymGetSymFromAddr64)(HANDLE, DWORD64, PDWORD64, PIMAGEHLP_SYMBOL64);
    39 typedef DWORD (WINAPI *pfn_UndecorateSymbolName)(const char*, char*, DWORD, DWORD);
    41 #else
    43 class ElfFile;
    45 #endif // _WINDOWS
    48 class Decoder: public StackObj {
    50  public:
    51   // status code for decoding native C frame
    52   enum decoder_status {
    53          no_error,             // successfully decoded frames
    54          out_of_memory,        // out of memory
    55          file_invalid,         // invalid elf file
    56          file_not_found,       // could not found symbol file (on windows), such as jvm.pdb or jvm.map
    57          helper_not_found,     // could not load dbghelp.dll (Windows only)
    58          helper_func_error,    // decoding functions not found (Windows only)
    59          helper_init_error,    // SymInitialize failed (Windows only)
    60          symbol_not_found      // could not find the symbol
    61   };
    63  public:
    64   Decoder() { initialize(); };
    65   ~Decoder() { uninitialize(); };
    67   static bool can_decode_C_frame_in_vm();
    69   static void initialize();
    70   static void uninitialize();
    72 #ifdef _WINDOWS
    73   static decoder_status    decode(address addr, char *buf, int buflen, int *offset);
    74 #else
    75   static decoder_status    decode(address addr, const char* filepath, char *buf, int buflen, int *offset);
    76 #endif
    78   static bool              demangle(const char* symbol, char *buf, int buflen);
    80   static decoder_status    get_status() { return _decoder_status; };
    82 #ifndef _WINDOWS
    83  private:
    84   static ElfFile*         get_elf_file(const char* filepath);
    85 #endif // _WINDOWS
    88  private:
    89   static decoder_status     _decoder_status;
    90   static bool               _initialized;
    92 #ifdef _WINDOWS
    93   static HMODULE                   _dbghelp_handle;
    94   static bool                      _can_decode_in_vm;
    95   static pfn_SymGetSymFromAddr64   _pfnSymGetSymFromAddr64;
    96   static pfn_UndecorateSymbolName  _pfnUndecorateSymbolName;
    97 #else
    98   static ElfFile*                  _opened_elf_files;
    99 #endif // _WINDOWS
   100 };
   102 #endif // __DECODER_HPP

mercurial