Wed, 27 Apr 2016 01:25:04 +0800
Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright 2012, 2013 SAP AG. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@0 | 25 | |
aoqi@0 | 26 | // Loadlib_aix.cpp contains support code for analysing the memory |
aoqi@0 | 27 | // layout of loaded binaries in ones own process space. |
aoqi@0 | 28 | // |
aoqi@0 | 29 | // It is needed, among other things, to provide a dladdr() emulation, because |
aoqi@0 | 30 | // that one is not provided by AIX |
aoqi@0 | 31 | |
aoqi@0 | 32 | #ifndef OS_AIX_VM_LOADLIB_AIX_HPP |
aoqi@0 | 33 | #define OS_AIX_VM_LOADLIB_AIX_HPP |
aoqi@0 | 34 | |
aoqi@0 | 35 | class outputStream; |
aoqi@0 | 36 | |
aoqi@0 | 37 | // This class holds information about a single loaded library module. |
aoqi@0 | 38 | // Note that on AIX, a single library can be spread over multiple |
aoqi@0 | 39 | // uintptr_t range on a module base, eg. |
aoqi@0 | 40 | // libC.a(shr3_64.o) or libC.a(shrcore_64.o). |
aoqi@0 | 41 | class LoadedLibraryModule { |
aoqi@0 | 42 | |
aoqi@0 | 43 | friend class LoadedLibraries; |
aoqi@0 | 44 | |
aoqi@0 | 45 | char fullpath[512]; // eg /usr/lib/libC.a |
aoqi@0 | 46 | char shortname[30]; // eg libC.a |
aoqi@0 | 47 | char membername[30]; // eg shrcore_64.o |
aoqi@0 | 48 | const unsigned char* text_from; |
aoqi@0 | 49 | const unsigned char* text_to; |
aoqi@0 | 50 | const unsigned char* data_from; |
aoqi@0 | 51 | const unsigned char* data_to; |
aoqi@0 | 52 | |
aoqi@0 | 53 | public: |
aoqi@0 | 54 | |
aoqi@0 | 55 | const char* get_fullpath() const { |
aoqi@0 | 56 | return fullpath; |
aoqi@0 | 57 | } |
aoqi@0 | 58 | const char* get_shortname() const { |
aoqi@0 | 59 | return shortname; |
aoqi@0 | 60 | } |
aoqi@0 | 61 | const char* get_membername() const { |
aoqi@0 | 62 | return membername; |
aoqi@0 | 63 | } |
aoqi@0 | 64 | |
aoqi@0 | 65 | // text_from, text_to: returns the range of the text (code) |
aoqi@0 | 66 | // segment for that module |
aoqi@0 | 67 | const unsigned char* get_text_from() const { |
aoqi@0 | 68 | return text_from; |
aoqi@0 | 69 | } |
aoqi@0 | 70 | const unsigned char* get_text_to() const { |
aoqi@0 | 71 | return text_to; |
aoqi@0 | 72 | } |
aoqi@0 | 73 | |
aoqi@0 | 74 | // data_from/data_to: returns the range of the data |
aoqi@0 | 75 | // segment for that module |
aoqi@0 | 76 | const unsigned char* get_data_from() const { |
aoqi@0 | 77 | return data_from; |
aoqi@0 | 78 | } |
aoqi@0 | 79 | const unsigned char* get_data_to() const { |
aoqi@0 | 80 | return data_to; |
aoqi@0 | 81 | } |
aoqi@0 | 82 | |
aoqi@0 | 83 | // returns true if the |
aoqi@0 | 84 | bool is_in_text(const unsigned char* p) const { |
aoqi@0 | 85 | return p >= text_from && p < text_to ? true : false; |
aoqi@0 | 86 | } |
aoqi@0 | 87 | |
aoqi@0 | 88 | bool is_in_data(const unsigned char* p) const { |
aoqi@0 | 89 | return p >= data_from && p < data_to ? true : false; |
aoqi@0 | 90 | } |
aoqi@0 | 91 | |
aoqi@0 | 92 | // output debug info |
aoqi@0 | 93 | void print(outputStream* os) const; |
aoqi@0 | 94 | |
aoqi@0 | 95 | }; // end LoadedLibraryModule |
aoqi@0 | 96 | |
aoqi@0 | 97 | // This class is a singleton holding a map of all loaded binaries |
aoqi@0 | 98 | // in the AIX process space. |
aoqi@0 | 99 | class LoadedLibraries |
aoqi@0 | 100 | // : AllStatic (including allocation.hpp just for AllStatic is overkill.) |
aoqi@0 | 101 | { |
aoqi@0 | 102 | |
aoqi@0 | 103 | private: |
aoqi@0 | 104 | |
aoqi@0 | 105 | enum {MAX_MODULES = 100}; |
aoqi@0 | 106 | static LoadedLibraryModule tab[MAX_MODULES]; |
aoqi@0 | 107 | static int num_loaded; |
aoqi@0 | 108 | |
aoqi@0 | 109 | public: |
aoqi@0 | 110 | |
aoqi@0 | 111 | // rebuild the internal table of LoadedLibraryModule objects |
aoqi@0 | 112 | static void reload(); |
aoqi@0 | 113 | |
aoqi@0 | 114 | // checks whether the address p points to any of the loaded code segments. |
aoqi@0 | 115 | // If it does, returns the LoadedLibraryModule entry. If not, returns NULL. |
aoqi@0 | 116 | static const LoadedLibraryModule* find_for_text_address(const unsigned char* p); |
aoqi@0 | 117 | |
aoqi@0 | 118 | // checks whether the address p points to any of the loaded data segments. |
aoqi@0 | 119 | // If it does, returns the LoadedLibraryModule entry. If not, returns NULL. |
aoqi@0 | 120 | static const LoadedLibraryModule* find_for_data_address(const unsigned char* p); |
aoqi@0 | 121 | |
aoqi@0 | 122 | // output debug info |
aoqi@0 | 123 | static void print(outputStream* os); |
aoqi@0 | 124 | |
aoqi@0 | 125 | }; // end LoadedLibraries |
aoqi@0 | 126 | |
aoqi@0 | 127 | |
aoqi@0 | 128 | #endif // OS_AIX_VM_LOADLIB_AIX_HPP |