src/share/vm/utilities/decoder.cpp

Wed, 02 Feb 2011 11:35:26 -0500

author
bobv
date
Wed, 02 Feb 2011 11:35:26 -0500
changeset 2508
b92c45f2bc75
parent 2364
2d4762ec74af
child 3156
f08d439fab8c
permissions
-rw-r--r--

7016023: Enable building ARM and PPC from src/closed repository
Reviewed-by: dholmes, bdelsart

     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  */
    25 #include "precompiled.hpp"
    26 #include "prims/jvm.h"
    27 #include "utilities/decoder.hpp"
    29 Decoder::decoder_status  Decoder::_decoder_status = Decoder::no_error;
    30 bool                     Decoder::_initialized = false;
    32 #ifndef _WINDOWS
    34 // Implementation of common functionalities among Solaris and Linux
    35 #include "utilities/elfFile.hpp"
    37 ElfFile* Decoder::_opened_elf_files = NULL;
    39 bool Decoder::can_decode_C_frame_in_vm() {
    40   return true;
    41 }
    43 void Decoder::initialize() {
    44   _initialized = true;
    45 }
    47 void Decoder::uninitialize() {
    48   if (_opened_elf_files != NULL) {
    49     delete _opened_elf_files;
    50     _opened_elf_files = NULL;
    51   }
    52   _initialized = false;
    53 }
    55 Decoder::decoder_status Decoder::decode(address addr, const char* filepath, char *buf, int buflen, int *offset) {
    56   if (_decoder_status != no_error) {
    57     return _decoder_status;
    58   }
    60   ElfFile* file = get_elf_file(filepath);
    61   if (_decoder_status != no_error) {
    62     return _decoder_status;
    63   }
    65   const char* symbol = file->decode(addr, offset);
    66   if (file->get_status() == out_of_memory) {
    67     _decoder_status = out_of_memory;
    68     return _decoder_status;
    69   } else if (symbol != NULL) {
    70     if (!demangle(symbol, buf, buflen)) {
    71       jio_snprintf(buf, buflen, "%s", symbol);
    72     }
    73     return no_error;
    74   } else {
    75     return symbol_not_found;
    76   }
    77 }
    79 ElfFile* Decoder::get_elf_file(const char* filepath) {
    80   if (_decoder_status != no_error) {
    81     return NULL;
    82   }
    83   ElfFile* file = _opened_elf_files;
    84   while (file != NULL) {
    85     if (file->same_elf_file(filepath)) {
    86       return file;
    87     }
    88     file = file->m_next;
    89   }
    91   file = new ElfFile(filepath);
    92   if (file == NULL) {
    93     _decoder_status = out_of_memory;
    94   }
    95   if (_opened_elf_files != NULL) {
    96     file->m_next = _opened_elf_files;
    97   }
    99   _opened_elf_files = file;
   100   return file;
   101 }
   103 #endif

mercurial