src/share/vm/utilities/decoder.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 7089790_shared Sdiff src/share/vm/utilities

src/share/vm/utilities/decoder.hpp

Print this page
rev 2696 : elf fixes


  21  * questions.
  22  *
  23  */
  24 
  25 
  26 #ifndef __DECODER_HPP
  27 #define __DECODER_HPP
  28 
  29 #include "memory/allocation.hpp"
  30 
  31 #ifdef _WINDOWS
  32 #include <windows.h>
  33 #include <imagehlp.h>
  34 
  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);
  40 


  41 #else
  42 
  43 class ElfFile;
  44 
  45 #endif // _WINDOWS
  46 
  47 
  48 class Decoder: public StackObj {
  49 
  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


  62 
  63  public:
  64   Decoder() { initialize(); };
  65   ~Decoder() { uninitialize(); };
  66 
  67   static bool can_decode_C_frame_in_vm();
  68 
  69   static void initialize();
  70   static void uninitialize();
  71 
  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
  77 
  78   static bool              demangle(const char* symbol, char *buf, int buflen);
  79 
  80   static decoder_status    get_status() { return _decoder_status; };
  81 
  82 #ifndef _WINDOWS
  83  private:
  84   static ElfFile*         get_elf_file(const char* filepath);
  85 #endif // _WINDOWS
  86 
  87 
  88  private:
  89   static decoder_status     _decoder_status;
  90   static bool               _initialized;
  91 
  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 };
 101 
 102 #endif // __DECODER_HPP


  21  * questions.
  22  *
  23  */
  24 
  25 
  26 #ifndef __DECODER_HPP
  27 #define __DECODER_HPP
  28 
  29 #include "memory/allocation.hpp"
  30 
  31 #ifdef _WINDOWS
  32 #include <windows.h>
  33 #include <imagehlp.h>
  34 
  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);
  40 
  41 #elif defined(__APPLE__)
  42 
  43 #else
  44 
  45 class ElfFile;
  46 
  47 #endif // _WINDOWS
  48 
  49 
  50 class Decoder: public StackObj {
  51 
  52  public:
  53   // status code for decoding native C frame
  54   enum decoder_status {
  55          no_error,             // successfully decoded frames
  56          out_of_memory,        // out of memory
  57          file_invalid,         // invalid elf file
  58          file_not_found,       // could not found symbol file (on windows), such as jvm.pdb or jvm.map
  59          helper_not_found,     // could not load dbghelp.dll (Windows only)
  60          helper_func_error,    // decoding functions not found (Windows only)
  61          helper_init_error,    // SymInitialize failed (Windows only)
  62          symbol_not_found      // could not find the symbol


  64 
  65  public:
  66   Decoder() { initialize(); };
  67   ~Decoder() { uninitialize(); };
  68 
  69   static bool can_decode_C_frame_in_vm();
  70 
  71   static void initialize();
  72   static void uninitialize();
  73 
  74 #ifdef _WINDOWS
  75   static decoder_status    decode(address addr, char *buf, int buflen, int *offset);
  76 #else
  77   static decoder_status    decode(address addr, const char* filepath, char *buf, int buflen, int *offset);
  78 #endif
  79 
  80   static bool              demangle(const char* symbol, char *buf, int buflen);
  81 
  82   static decoder_status    get_status() { return _decoder_status; };
  83 
  84 #if !defined(_WINDOWS) && !defined(__APPLE__)
  85  private:
  86   static ElfFile*         get_elf_file(const char* filepath);
  87 #endif // _WINDOWS
  88 
  89 
  90  private:
  91   static decoder_status     _decoder_status;
  92   static bool               _initialized;
  93 
  94 #ifdef _WINDOWS
  95   static HMODULE                   _dbghelp_handle;
  96   static bool                      _can_decode_in_vm;
  97   static pfn_SymGetSymFromAddr64   _pfnSymGetSymFromAddr64;
  98   static pfn_UndecorateSymbolName  _pfnUndecorateSymbolName;
  99 #elif __APPLE__
 100 #else
 101   static ElfFile*                  _opened_elf_files;
 102 #endif // _WINDOWS
 103 };
 104 
 105 #endif // __DECODER_HPP
src/share/vm/utilities/decoder.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File