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 */
24
25
26 // Loadlib_aix.cpp contains support code for analysing the memory
27 // layout of loaded binaries in ones own process space.
28 //
29 // It is needed, among other things, to provide a dladdr() emulation, because
30 // that one is not provided by AIX
31
32 #ifndef OS_AIX_VM_LOADLIB_AIX_HPP
33 #define OS_AIX_VM_LOADLIB_AIX_HPP
34
35 class outputStream;
36
37 // This class holds information about a single loaded library module.
38 // Note that on AIX, a single library can be spread over multiple
39 // uintptr_t range on a module base, eg.
40 // libC.a(shr3_64.o) or libC.a(shrcore_64.o).
41 class LoadedLibraryModule {
42
43 friend class LoadedLibraries;
44
45 char fullpath[512]; // eg /usr/lib/libC.a
46 char shortname[30]; // eg libC.a
47 char membername[30]; // eg shrcore_64.o
48 const unsigned char* text_from;
49 const unsigned char* text_to;
50 const unsigned char* data_from;
51 const unsigned char* data_to;
52
53 public:
54
55 const char* get_fullpath() const {
56 return fullpath;
57 }
58 const char* get_shortname() const {
59 return shortname;
60 }
61 const char* get_membername() const {
62 return membername;
63 }
64
65 // text_from, text_to: returns the range of the text (code)
66 // segment for that module
67 const unsigned char* get_text_from() const {
68 return text_from;
69 }
70 const unsigned char* get_text_to() const {
71 return text_to;
72 }
73
74 // data_from/data_to: returns the range of the data
75 // segment for that module
76 const unsigned char* get_data_from() const {
77 return data_from;
78 }
79 const unsigned char* get_data_to() const {
80 return data_to;
81 }
82
83 // returns true if the
84 bool is_in_text(const unsigned char* p) const {
85 return p >= text_from && p < text_to ? true : false;
86 }
87
88 bool is_in_data(const unsigned char* p) const {
89 return p >= data_from && p < data_to ? true : false;
90 }
91
92 // output debug info
93 void print(outputStream* os) const;
94
95 }; // end LoadedLibraryModule
96
97 // This class is a singleton holding a map of all loaded binaries
98 // in the AIX process space.
99 class LoadedLibraries
100 // : AllStatic (including allocation.hpp just for AllStatic is overkill.)
101 {
102
103 private:
104
105 enum {MAX_MODULES = 100};
106 static LoadedLibraryModule tab[MAX_MODULES];
107 static int num_loaded;
108
109 public:
110
111 // rebuild the internal table of LoadedLibraryModule objects
112 static void reload();
113
114 // checks whether the address p points to any of the loaded code segments.
115 // If it does, returns the LoadedLibraryModule entry. If not, returns NULL.
116 static const LoadedLibraryModule* find_for_text_address(const unsigned char* p);
117
118 // checks whether the address p points to any of the loaded data segments.
119 // If it does, returns the LoadedLibraryModule entry. If not, returns NULL.
120 static const LoadedLibraryModule* find_for_data_address(const unsigned char* p);
121
122 // output debug info
123 static void print(outputStream* os);
124
125 }; // end LoadedLibraries
126
127
128 #endif // OS_AIX_VM_LOADLIB_AIX_HPP
|
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 */
24
25
26 // Loadlib_aix.cpp contains support code for analysing the memory
27 // layout of loaded binaries in ones own process space.
28 //
29 // It is needed, among other things, to provide a dladdr() emulation, because
30 // that one is not provided by AIX
31
32 #ifndef OS_AIX_VM_LOADLIB_AIX_HPP
33 #define OS_AIX_VM_LOADLIB_AIX_HPP
34
35 class outputStream;
36
37 // Struct holds information about a single loaded library module.
38 // Note that on AIX, a single library can be spread over multiple
39 // uintptr_t range on a module base, eg.
40 // libC.a(shr3_64.o) or libC.a(shrcore_64.o).
41
42 // Note: all pointers to strings (path, member) point to strings which are immortal.
43 struct loaded_module_t {
44
45 // points to the full path of the lodaed module, e.g.
46 // "/usr/lib/libC.a"
47 const char* path;
48
49 // host library name without path
50 const char* shortname;
51
52 // points to the object file (AIX specific stuff)
53 // e.g "shrcore_64.o"
54 const char* member;
55
56 // text area from, to
57 const void* text;
58 size_t text_len;
59
60 // data area from, to
61 const void* data;
62 size_t data_len;
63
64 // true if this module is part of the vm
65 bool is_in_vm;
66
67 }; // end LoadedLibraryModule
68
69 // This class is a singleton holding a map of all loaded binaries
70 // in the AIX process space.
71 class LoadedLibraries
72 // : AllStatic (including allocation.hpp just for AllStatic is overkill.)
73 {
74
75 public:
76
77 // rebuild the internal module table. If an error occurs, internal module
78 // table remains untouched.
79 static bool reload();
80
81 // check whether the given address points into the text segment of a
82 // loaded module. Return true if this is the case.
83 // Optionally, information about the module is returned (info)
84 static bool find_for_text_address (
85 const void* p,
86 loaded_module_t* info // optional, leave NULL if not needed.
87 );
88
89 // check whether the given address points into the data segment of a
90 // loaded module. Return true if this is the case.
91 // Optionally, information about the module is returned (info)
92 static bool find_for_data_address (
93 const void* p,
94 loaded_module_t* info // optional, leave NULL if not needed.
95 );
96
97 // output debug info
98 static void print(outputStream* os);
99
100 }; // end LoadedLibraries
101
102 #endif // OS_AIX_VM_LOADLIB_AIX_HPP
|