src/share/vm/runtime/os.hpp

Print this page




  29 #include "runtime/atomic.hpp"
  30 #include "runtime/extendedPC.hpp"
  31 #include "runtime/handles.hpp"
  32 #include "utilities/top.hpp"
  33 #ifdef TARGET_OS_FAMILY_linux
  34 # include "jvm_linux.h"
  35 # include <setjmp.h>
  36 #endif
  37 #ifdef TARGET_OS_FAMILY_solaris
  38 # include "jvm_solaris.h"
  39 # include <setjmp.h>
  40 #endif
  41 #ifdef TARGET_OS_FAMILY_windows
  42 # include "jvm_windows.h"
  43 #endif
  44 #ifdef TARGET_OS_FAMILY_bsd
  45 # include "jvm_bsd.h"
  46 # include <setjmp.h>
  47 #endif
  48 


  49 // os defines the interface to operating system; this includes traditional
  50 // OS services (time, I/O) as well as other functionality with system-
  51 // dependent code.
  52 
  53 typedef void (*dll_func)(...);
  54 
  55 class Thread;
  56 class JavaThread;
  57 class Event;
  58 class DLL;
  59 class FileHandle;
  60 template<class E> class GrowableArray;
  61 
  62 // %%%%% Moved ThreadState, START_FN, OSThread to new osThread.hpp. -- Rose
  63 
  64 // Platform-independent error return values from OS functions
  65 enum OSReturn {
  66   OS_OK         =  0,        // Operation was successful
  67   OS_ERR        = -1,        // Operation failed
  68   OS_INTRPT     = -2,        // Operation was interrupted


 520   // buf, and offset is optionally set to be the distance between addr
 521   // and the library's base address. On failure, buf[0] is set to '\0'
 522   // and offset is set to -1 (if offset is non-NULL).
 523   static bool dll_address_to_library_name(address addr, char* buf,
 524                                           int buflen, int* offset);
 525 
 526   // Find out whether the pc is in the static code for jvm.dll/libjvm.so.
 527   static bool address_is_in_vm(address addr);
 528 
 529   // Loads .dll/.so and
 530   // in case of error it checks if .dll/.so was built for the
 531   // same architecture as Hotspot is running on
 532   static void* dll_load(const char *name, char *ebuf, int ebuflen);
 533 
 534   // lookup symbol in a shared library
 535   static void* dll_lookup(void* handle, const char* name);
 536 
 537   // Unload library
 538   static void  dll_unload(void *lib);
 539 











 540   // Print out system information; they are called by fatal error handler.
 541   // Output format may be different on different platforms.
 542   static void print_os_info(outputStream* st);
 543   static void print_os_info_brief(outputStream* st);
 544   static void print_cpu_info(outputStream* st);
 545   static void pd_print_cpu_info(outputStream* st);
 546   static void print_memory_info(outputStream* st);
 547   static void print_dll_info(outputStream* st);
 548   static void print_environment_variables(outputStream* st, const char** env_list, char* buffer, int len);
 549   static void print_context(outputStream* st, void* context);
 550   static void print_register_info(outputStream* st, void* context);
 551   static void print_siginfo(outputStream* st, void* siginfo);
 552   static void print_signal_handlers(outputStream* st, char* buf, size_t buflen);
 553   static void print_date_and_time(outputStream* st);
 554 
 555   static void print_location(outputStream* st, intptr_t x, bool verbose = false);
 556   static size_t lasterror(char *buf, size_t len);
 557   static int get_last_error();
 558 
 559   // Determines whether the calling process is being debugged by a user-mode debugger.


 789   // debugging support (mostly used by debug.cpp but also fatal error handler)
 790   static bool find(address pc, outputStream* st = tty); // OS specific function to make sense out of an address
 791 
 792   static bool dont_yield();                     // when true, JVM_Yield() is nop
 793   static void print_statistics();
 794 
 795   // Thread priority helpers (implemented in OS-specific part)
 796   static OSReturn set_native_priority(Thread* thread, int native_prio);
 797   static OSReturn get_native_priority(const Thread* const thread, int* priority_ptr);
 798   static int java_to_os_priority[CriticalPriority + 1];
 799   // Hint to the underlying OS that a task switch would not be good.
 800   // Void return because it's a hint and can fail.
 801   static void hint_no_preempt();
 802 
 803   // Used at creation if requested by the diagnostic flag PauseAtStartup.
 804   // Causes the VM to wait until an external stimulus has been applied
 805   // (for Unix, that stimulus is a signal, for Windows, an external
 806   // ResumeThread call)
 807   static void pause();
 808 





 809   class SuspendedThreadTaskContext {
 810   public:
 811     SuspendedThreadTaskContext(Thread* thread, void *ucontext) : _thread(thread), _ucontext(ucontext) {}
 812     Thread* thread() const { return _thread; }
 813     void* ucontext() const { return _ucontext; }
 814   private:
 815     Thread* _thread;
 816     void* _ucontext;
 817   };
 818 
 819   class SuspendedThreadTask {
 820   public:
 821     SuspendedThreadTask(Thread* thread) : _thread(thread), _done(false) {}
 822     virtual ~SuspendedThreadTask() {}
 823     void run();
 824     bool is_done() { return _done; }
 825     virtual void do_task(const SuspendedThreadTaskContext& context) = 0;
 826   protected:
 827   private:
 828     void internal_do_task();




  29 #include "runtime/atomic.hpp"
  30 #include "runtime/extendedPC.hpp"
  31 #include "runtime/handles.hpp"
  32 #include "utilities/top.hpp"
  33 #ifdef TARGET_OS_FAMILY_linux
  34 # include "jvm_linux.h"
  35 # include <setjmp.h>
  36 #endif
  37 #ifdef TARGET_OS_FAMILY_solaris
  38 # include "jvm_solaris.h"
  39 # include <setjmp.h>
  40 #endif
  41 #ifdef TARGET_OS_FAMILY_windows
  42 # include "jvm_windows.h"
  43 #endif
  44 #ifdef TARGET_OS_FAMILY_bsd
  45 # include "jvm_bsd.h"
  46 # include <setjmp.h>
  47 #endif
  48 
  49 class AgentLibrary;
  50 
  51 // os defines the interface to operating system; this includes traditional
  52 // OS services (time, I/O) as well as other functionality with system-
  53 // dependent code.
  54 
  55 typedef void (*dll_func)(...);
  56 
  57 class Thread;
  58 class JavaThread;
  59 class Event;
  60 class DLL;
  61 class FileHandle;
  62 template<class E> class GrowableArray;
  63 
  64 // %%%%% Moved ThreadState, START_FN, OSThread to new osThread.hpp. -- Rose
  65 
  66 // Platform-independent error return values from OS functions
  67 enum OSReturn {
  68   OS_OK         =  0,        // Operation was successful
  69   OS_ERR        = -1,        // Operation failed
  70   OS_INTRPT     = -2,        // Operation was interrupted


 522   // buf, and offset is optionally set to be the distance between addr
 523   // and the library's base address. On failure, buf[0] is set to '\0'
 524   // and offset is set to -1 (if offset is non-NULL).
 525   static bool dll_address_to_library_name(address addr, char* buf,
 526                                           int buflen, int* offset);
 527 
 528   // Find out whether the pc is in the static code for jvm.dll/libjvm.so.
 529   static bool address_is_in_vm(address addr);
 530 
 531   // Loads .dll/.so and
 532   // in case of error it checks if .dll/.so was built for the
 533   // same architecture as Hotspot is running on
 534   static void* dll_load(const char *name, char *ebuf, int ebuflen);
 535 
 536   // lookup symbol in a shared library
 537   static void* dll_lookup(void* handle, const char* name);
 538 
 539   // Unload library
 540   static void  dll_unload(void *lib);
 541 
 542   // return the handle of this process
 543   static void* get_default_process_handle();
 544 
 545   // Check for static linked agent library
 546   static bool find_builtin_agent(AgentLibrary *agent_lib, const char *syms[],
 547                                size_t syms_len);
 548 
 549   // Find agent entry point
 550   static void *find_agent_function(AgentLibrary *agent_lib, bool check_lib,
 551                                  const char *syms[], size_t syms_len);
 552 
 553   // Print out system information; they are called by fatal error handler.
 554   // Output format may be different on different platforms.
 555   static void print_os_info(outputStream* st);
 556   static void print_os_info_brief(outputStream* st);
 557   static void print_cpu_info(outputStream* st);
 558   static void pd_print_cpu_info(outputStream* st);
 559   static void print_memory_info(outputStream* st);
 560   static void print_dll_info(outputStream* st);
 561   static void print_environment_variables(outputStream* st, const char** env_list, char* buffer, int len);
 562   static void print_context(outputStream* st, void* context);
 563   static void print_register_info(outputStream* st, void* context);
 564   static void print_siginfo(outputStream* st, void* siginfo);
 565   static void print_signal_handlers(outputStream* st, char* buf, size_t buflen);
 566   static void print_date_and_time(outputStream* st);
 567 
 568   static void print_location(outputStream* st, intptr_t x, bool verbose = false);
 569   static size_t lasterror(char *buf, size_t len);
 570   static int get_last_error();
 571 
 572   // Determines whether the calling process is being debugged by a user-mode debugger.


 802   // debugging support (mostly used by debug.cpp but also fatal error handler)
 803   static bool find(address pc, outputStream* st = tty); // OS specific function to make sense out of an address
 804 
 805   static bool dont_yield();                     // when true, JVM_Yield() is nop
 806   static void print_statistics();
 807 
 808   // Thread priority helpers (implemented in OS-specific part)
 809   static OSReturn set_native_priority(Thread* thread, int native_prio);
 810   static OSReturn get_native_priority(const Thread* const thread, int* priority_ptr);
 811   static int java_to_os_priority[CriticalPriority + 1];
 812   // Hint to the underlying OS that a task switch would not be good.
 813   // Void return because it's a hint and can fail.
 814   static void hint_no_preempt();
 815 
 816   // Used at creation if requested by the diagnostic flag PauseAtStartup.
 817   // Causes the VM to wait until an external stimulus has been applied
 818   // (for Unix, that stimulus is a signal, for Windows, an external
 819   // ResumeThread call)
 820   static void pause();
 821 
 822   // Builds a platform dependent Agent_OnLoad_<libname> function name
 823   // which is used to find statically linked in agents. 
 824   static char*  build_agent_function_name(const char *sym, const char *cname,
 825                                           bool is_absolute_path);
 826  
 827   class SuspendedThreadTaskContext {
 828   public:
 829     SuspendedThreadTaskContext(Thread* thread, void *ucontext) : _thread(thread), _ucontext(ucontext) {}
 830     Thread* thread() const { return _thread; }
 831     void* ucontext() const { return _ucontext; }
 832   private:
 833     Thread* _thread;
 834     void* _ucontext;
 835   };
 836 
 837   class SuspendedThreadTask {
 838   public:
 839     SuspendedThreadTask(Thread* thread) : _thread(thread), _done(false) {}
 840     virtual ~SuspendedThreadTask() {}
 841     void run();
 842     bool is_done() { return _done; }
 843     virtual void do_task(const SuspendedThreadTaskContext& context) = 0;
 844   protected:
 845   private:
 846     void internal_do_task();