< prev index next >

src/os/aix/vm/os_aix.cpp

Print this page
rev 9211 : 8140645: Recent Developments for AIX
Summary: Port recent developments from SAP for AIX to the OpenJDK

@@ -38,10 +38,11 @@
 #include "jvm_aix.h"
 #include "libperfstat_aix.hpp"
 #include "loadlib_aix.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/filemap.hpp"
+#include "misc_aix.hpp"
 #include "mutex_aix.inline.hpp"
 #include "oops/oop.inline.hpp"
 #include "os_aix.inline.hpp"
 #include "os_share_aix.hpp"
 #include "porting_aix.hpp"

@@ -173,11 +174,11 @@
 }
 
 // Query dimensions of the stack of the calling thread.
 static bool query_stack_dimensions(address* p_stack_base, size_t* p_stack_size);
 
-// function to check a given stack pointer against given stack limits
+// Function to check a given stack pointer against given stack limits
 inline bool is_valid_stackpointer(stackptr_t sp, stackptr_t stack_base, size_t stack_size) {
   if (((uintptr_t)sp) & 0x7) {
     return false;
   }
   if (sp > stack_base) {

@@ -187,19 +188,19 @@
     return false;
   }
   return true;
 }
 
-// returns true if function is a valid codepointer
+// Returns true if function is a valid codepointer
 inline bool is_valid_codepointer(codeptr_t p) {
   if (!p) {
     return false;
   }
   if (((uintptr_t)p) & 0x3) {
     return false;
   }
-  if (LoadedLibraries::find_for_text_address((address)p) == NULL) {
+  if (!LoadedLibraries::find_for_text_address(p, NULL)) {
     return false;
   }
   return true;
 }
 

@@ -1385,30 +1386,19 @@
 // Check if addr is inside libjvm.so.
 bool os::address_is_in_vm(address addr) {
 
   // Input could be a real pc or a function pointer literal. The latter
   // would be a function descriptor residing in the data segment of a module.
-
-  const LoadedLibraryModule* lib = LoadedLibraries::find_for_text_address(addr);
-  if (lib) {
-    if (strcmp(lib->get_shortname(), "libjvm.so") == 0) {
-      return true;
-    } else {
-      return false;
-    }
-  } else {
-    lib = LoadedLibraries::find_for_data_address(addr);
-    if (lib) {
-      if (strcmp(lib->get_shortname(), "libjvm.so") == 0) {
-        return true;
-      } else {
-        return false;
-      }
+  loaded_module_t lm;
+  if (LoadedLibraries::find_for_text_address(addr, &lm) != NULL) {
+    return lm.is_in_vm;
+  } else if (LoadedLibraries::find_for_data_address(addr, &lm) != NULL) {
+    return lm.is_in_vm;
     } else {
       return false;
     }
-  }
+
 }
 
 // Resolve an AIX function descriptor literal to a code pointer.
 // If the input is a valid code pointer to a text segment of a loaded module,
 //   it is returned unchanged.

@@ -1416,25 +1406,22 @@
 //   code entry point.
 // If the input is neither a valid function descriptor nor a valid code pointer,
 //   NULL is returned.
 static address resolve_function_descriptor_to_code_pointer(address p) {
 
-  const LoadedLibraryModule* lib = LoadedLibraries::find_for_text_address(p);
-  if (lib) {
+  if (LoadedLibraries::find_for_text_address(p, NULL) != NULL) {
     // its a real code pointer
     return p;
-  } else {
-    lib = LoadedLibraries::find_for_data_address(p);
-    if (lib) {
+  } else if (LoadedLibraries::find_for_data_address(p, NULL) != NULL) {
       // pointer to data segment, potential function descriptor
       address code_entry = (address)(((FunctionDescriptor*)p)->entry());
-      if (LoadedLibraries::find_for_text_address(code_entry)) {
+    if (LoadedLibraries::find_for_text_address(code_entry, NULL) != NULL) {
         // Its a function descriptor
         return code_entry;
       }
     }
-  }
+
   return NULL;
 }
 
 bool os::dll_address_to_function_name(address addr, char *buf,
                                       int buflen, int *offset,

@@ -1459,28 +1446,26 @@
 static int getModuleName(codeptr_t pc,                    // [in] program counter
                          char* p_name, size_t namelen,    // [out] optional: function name
                          char* p_errmsg, size_t errmsglen // [out] optional: user provided buffer for error messages
                          ) {
 
-  // initialize output parameters
   if (p_name && namelen > 0) {
     *p_name = '\0';
   }
   if (p_errmsg && errmsglen > 0) {
     *p_errmsg = '\0';
   }
 
-  const LoadedLibraryModule* const lib = LoadedLibraries::find_for_text_address((address)pc);
-  if (lib) {
     if (p_name && namelen > 0) {
-      sprintf(p_name, "%.*s", namelen, lib->get_shortname());
+    loaded_module_t lm;
+    if (LoadedLibraries::find_for_text_address(pc, &lm) != NULL) {
+      strncpy(p_name, lm.shortname, namelen);
+      p_name[namelen - 1] = '\0';
     }
     return 0;
   }
 
-  trcVerbose("pc outside any module");
-
   return -1;
 }
 
 bool os::dll_address_to_library_name(address addr, char* buf,
                                      int buflen, int* offset) {

@@ -3785,22 +3770,15 @@
 
 bool os::find(address addr, outputStream* st) {
 
   st->print(PTR_FORMAT ": ", addr);
 
-  const LoadedLibraryModule* lib = LoadedLibraries::find_for_text_address(addr);
-  if (lib) {
-    lib->print(st);
-    return true;
-  } else {
-    lib = LoadedLibraries::find_for_data_address(addr);
-    if (lib) {
-      lib->print(st);
+  loaded_module_t lm;
+  if ( LoadedLibraries::find_for_text_address(addr, &lm) != NULL ||
+       LoadedLibraries::find_for_data_address(addr, &lm) != NULL) {
+    st->print("%s", lm.path);
       return true;
-    } else {
-      st->print_cr("(outside any module)");
-    }
   }
 
   return false;
 }
 
< prev index next >