src/hotspot/share/runtime/arguments.hpp
changeset 48157 7c4d43c26352
parent 48115 d8ec0640616c
child 48474 6e69aea2aee7
child 55974 06122633fead
equal deleted inserted replaced
48156:a8f9aac3c2e5 48157:7c4d43c26352
    25 #ifndef SHARE_VM_RUNTIME_ARGUMENTS_HPP
    25 #ifndef SHARE_VM_RUNTIME_ARGUMENTS_HPP
    26 #define SHARE_VM_RUNTIME_ARGUMENTS_HPP
    26 #define SHARE_VM_RUNTIME_ARGUMENTS_HPP
    27 
    27 
    28 #include "logging/logLevel.hpp"
    28 #include "logging/logLevel.hpp"
    29 #include "logging/logTag.hpp"
    29 #include "logging/logTag.hpp"
    30 #include "memory/allocation.inline.hpp"
    30 #include "memory/allocation.hpp"
    31 #include "runtime/java.hpp"
    31 #include "runtime/java.hpp"
    32 #include "runtime/os.hpp"
    32 #include "runtime/os.hpp"
    33 #include "runtime/perfData.hpp"
    33 #include "runtime/perfData.hpp"
    34 #include "utilities/debug.hpp"
    34 #include "utilities/debug.hpp"
    35 
    35 
    58  protected:
    58  protected:
    59   char* _value;
    59   char* _value;
    60  public:
    60  public:
    61   char* value() const { return _value; }
    61   char* value() const { return _value; }
    62 
    62 
    63   bool set_value(const char *value) {
    63   bool set_value(const char *value);
    64     if (_value != NULL) {
    64   void append_value(const char *value);
    65       FreeHeap(_value);
    65 
    66     }
    66   PathString(const char* value);
    67     _value = AllocateHeap(strlen(value)+1, mtArguments);
    67   ~PathString();
    68     assert(_value != NULL, "Unable to allocate space for new path value");
       
    69     if (_value != NULL) {
       
    70       strcpy(_value, value);
       
    71     } else {
       
    72       // not able to allocate
       
    73       return false;
       
    74     }
       
    75     return true;
       
    76   }
       
    77 
       
    78   void append_value(const char *value) {
       
    79     char *sp;
       
    80     size_t len = 0;
       
    81     if (value != NULL) {
       
    82       len = strlen(value);
       
    83       if (_value != NULL) {
       
    84         len += strlen(_value);
       
    85       }
       
    86       sp = AllocateHeap(len+2, mtArguments);
       
    87       assert(sp != NULL, "Unable to allocate space for new append path value");
       
    88       if (sp != NULL) {
       
    89         if (_value != NULL) {
       
    90           strcpy(sp, _value);
       
    91           strcat(sp, os::path_separator());
       
    92           strcat(sp, value);
       
    93           FreeHeap(_value);
       
    94         } else {
       
    95           strcpy(sp, value);
       
    96         }
       
    97         _value = sp;
       
    98       }
       
    99     }
       
   100   }
       
   101 
       
   102   PathString(const char* value) {
       
   103     if (value == NULL) {
       
   104       _value = NULL;
       
   105     } else {
       
   106       _value = AllocateHeap(strlen(value)+1, mtArguments);
       
   107       strcpy(_value, value);
       
   108     }
       
   109   }
       
   110 
       
   111   ~PathString() {
       
   112     if (_value != NULL) {
       
   113       FreeHeap(_value);
       
   114       _value = NULL;
       
   115     }
       
   116   }
       
   117 };
    68 };
   118 
    69 
   119 // ModulePatchPath records the module/path pair as specified to --patch-module.
    70 // ModulePatchPath records the module/path pair as specified to --patch-module.
   120 class ModulePatchPath : public CHeapObj<mtInternal> {
    71 class ModulePatchPath : public CHeapObj<mtInternal> {
   121 private:
    72 private:
   122   char* _module_name;
    73   char* _module_name;
   123   PathString* _path;
    74   PathString* _path;
   124 public:
    75 public:
   125   ModulePatchPath(const char* module_name, const char* path) {
    76   ModulePatchPath(const char* module_name, const char* path);
   126     assert(module_name != NULL && path != NULL, "Invalid module name or path value");
    77   ~ModulePatchPath();
   127     size_t len = strlen(module_name) + 1;
       
   128     _module_name = AllocateHeap(len, mtInternal);
       
   129     strncpy(_module_name, module_name, len); // copy the trailing null
       
   130     _path =  new PathString(path);
       
   131   }
       
   132 
       
   133   ~ModulePatchPath() {
       
   134     if (_module_name != NULL) {
       
   135       FreeHeap(_module_name);
       
   136       _module_name = NULL;
       
   137     }
       
   138     if (_path != NULL) {
       
   139       delete _path;
       
   140       _path = NULL;
       
   141     }
       
   142   }
       
   143 
    78 
   144   inline void set_path(const char* path) { _path->set_value(path); }
    79   inline void set_path(const char* path) { _path->set_value(path); }
   145   inline const char* module_name() const { return _module_name; }
    80   inline const char* module_name() const { return _module_name; }
   146   inline char* path_string() const { return _path->value(); }
    81   inline char* path_string() const { return _path->value(); }
   147 };
    82 };
   184     }
   119     }
   185     return false;
   120     return false;
   186   }
   121   }
   187 
   122 
   188   // Constructor
   123   // Constructor
   189   SystemProperty(const char* key, const char* value, bool writeable, bool internal = false) : PathString(value) {
   124   SystemProperty(const char* key, const char* value, bool writeable, bool internal = false);
   190     if (key == NULL) {
       
   191       _key = NULL;
       
   192     } else {
       
   193       _key = AllocateHeap(strlen(key)+1, mtArguments);
       
   194       strcpy(_key, key);
       
   195     }
       
   196     _next = NULL;
       
   197     _internal = internal;
       
   198     _writeable = writeable;
       
   199   }
       
   200 };
   125 };
   201 
   126 
   202 
   127 
   203 // For use by -agentlib, -agentpath and -Xrun
   128 // For use by -agentlib, -agentpath and -Xrun
   204 class AgentLibrary : public CHeapObj<mtArguments> {
   129 class AgentLibrary : public CHeapObj<mtArguments> {
   233   bool valid()                              { return (_state == agent_valid); }
   158   bool valid()                              { return (_state == agent_valid); }
   234   void set_valid()                          { _state = agent_valid; }
   159   void set_valid()                          { _state = agent_valid; }
   235   void set_invalid()                        { _state = agent_invalid; }
   160   void set_invalid()                        { _state = agent_invalid; }
   236 
   161 
   237   // Constructor
   162   // Constructor
   238   AgentLibrary(const char* name, const char* options, bool is_absolute_path, void* os_lib) {
   163   AgentLibrary(const char* name, const char* options, bool is_absolute_path, void* os_lib);
   239     _name = AllocateHeap(strlen(name)+1, mtArguments);
       
   240     strcpy(_name, name);
       
   241     if (options == NULL) {
       
   242       _options = NULL;
       
   243     } else {
       
   244       _options = AllocateHeap(strlen(options)+1, mtArguments);
       
   245       strcpy(_options, options);
       
   246     }
       
   247     _is_absolute_path = is_absolute_path;
       
   248     _os_lib = os_lib;
       
   249     _next = NULL;
       
   250     _state = agent_invalid;
       
   251     _is_static_lib = false;
       
   252   }
       
   253 };
   164 };
   254 
   165 
   255 // maintain an order of entry list of AgentLibrary
   166 // maintain an order of entry list of AgentLibrary
   256 class AgentLibraryList VALUE_OBJ_CLASS_SPEC {
   167 class AgentLibraryList VALUE_OBJ_CLASS_SPEC {
   257  private:
   168  private:
   419 
   330 
   420   static uintx  _min_heap_size;
   331   static uintx  _min_heap_size;
   421 
   332 
   422   // -Xrun arguments
   333   // -Xrun arguments
   423   static AgentLibraryList _libraryList;
   334   static AgentLibraryList _libraryList;
   424   static void add_init_library(const char* name, char* options)
   335   static void add_init_library(const char* name, char* options);
   425     { _libraryList.add(new AgentLibrary(name, options, false, NULL)); }
       
   426 
   336 
   427   // -agentlib and -agentpath arguments
   337   // -agentlib and -agentpath arguments
   428   static AgentLibraryList _agentList;
   338   static AgentLibraryList _agentList;
   429   static void add_init_agent(const char* name, char* options, bool absolute_path)
   339   static void add_init_agent(const char* name, char* options, bool absolute_path);
   430     { _agentList.add(new AgentLibrary(name, options, absolute_path, NULL)); }
       
   431 
   340 
   432   // Late-binding agents not started via arguments
   341   // Late-binding agents not started via arguments
   433   static void add_loaded_agent(AgentLibrary *agentLib)
   342   static void add_loaded_agent(AgentLibrary *agentLib);
   434     { _agentList.add(agentLib); }
   343   static void add_loaded_agent(const char* name, char* options, bool absolute_path, void* os_lib);
   435   static void add_loaded_agent(const char* name, char* options, bool absolute_path, void* os_lib)
       
   436     { _agentList.add(new AgentLibrary(name, options, absolute_path, os_lib)); }
       
   437 
   344 
   438   // Operation modi
   345   // Operation modi
   439   static Mode _mode;
   346   static Mode _mode;
   440   static void set_mode_flags(Mode mode);
   347   static void set_mode_flags(Mode mode);
   441   static bool _java_compiler;
   348   static bool _java_compiler;