539 // that support such things. This calls shutdown() and then aborts. 540 static void abort(bool dump_core = true); 541 542 // Die immediately, no exit hook, no abort hook, no cleanup. 543 static void die(); 544 545 // File i/o operations 546 static const int default_file_open_flags(); 547 static int open(const char *path, int oflag, int mode); 548 static FILE* open(int fd, const char* mode); 549 static int close(int fd); 550 static jlong lseek(int fd, jlong offset, int whence); 551 static char* native_path(char *path); 552 static int ftruncate(int fd, jlong length); 553 static int fsync(int fd); 554 static int available(int fd, jlong *bytes); 555 556 //File i/o operations 557 558 static size_t read(int fd, void *buf, unsigned int nBytes); 559 static size_t restartable_read(int fd, void *buf, unsigned int nBytes); 560 static size_t write(int fd, const void *buf, unsigned int nBytes); 561 562 // Reading directories. 563 static DIR* opendir(const char* dirname); 564 static int readdir_buf_size(const char *path); 565 static struct dirent* readdir(DIR* dirp, dirent* dbuf); 566 static int closedir(DIR* dirp); 567 568 // Dynamic library extension 569 static const char* dll_file_extension(); 570 571 static const char* get_temp_directory(); 572 static const char* get_current_directory(char *buf, size_t buflen); 573 574 // Builds a platform-specific full library path given a ld path and lib name 575 // Returns true if buffer contains full path to existing file, false otherwise 576 static bool dll_build_name(char* buffer, size_t size, 577 const char* pathname, const char* fname); 578 579 // Symbol lookup, find nearest function name; basically it implements 580 // dladdr() for all platforms. Name of the nearest function is copied 581 // to buf. Distance from its base address is optionally returned as offset. 582 // If function name is not found, buf[0] is set to '\0' and offset is 583 // set to -1 (if offset is non-NULL). 584 static bool dll_address_to_function_name(address addr, char* buf, 585 int buflen, int* offset); 587 // Locate DLL/DSO. On success, full path of the library is copied to 588 // buf, and offset is optionally set to be the distance between addr 589 // and the library's base address. On failure, buf[0] is set to '\0' 590 // and offset is set to -1 (if offset is non-NULL). 591 static bool dll_address_to_library_name(address addr, char* buf, 592 int buflen, int* offset); 593 594 // Find out whether the pc is in the static code for jvm.dll/libjvm.so. 595 static bool address_is_in_vm(address addr); 596 597 // Loads .dll/.so and 598 // in case of error it checks if .dll/.so was built for the 599 // same architecture as Hotspot is running on 600 static void* dll_load(const char *name, char *ebuf, int ebuflen); 601 602 // lookup symbol in a shared library 603 static void* dll_lookup(void* handle, const char* name); 604 605 // Unload library 606 static void dll_unload(void *lib); 607 608 // Return the handle of this process 609 static void* get_default_process_handle(); 610 611 // Check for static linked agent library 612 static bool find_builtin_agent(AgentLibrary *agent_lib, const char *syms[], 613 size_t syms_len); 614 615 // Find agent entry point 616 static void *find_agent_function(AgentLibrary *agent_lib, bool check_lib, 617 const char *syms[], size_t syms_len); 618 619 static int vsnprintf(char* buf, size_t len, const char* fmt, va_list args) ATTRIBUTE_PRINTF(3, 0); 620 static int snprintf(char* buf, size_t len, const char* fmt, ...) ATTRIBUTE_PRINTF(3, 4); 621 622 // Print out system information; they are called by fatal error handler. 623 // Output format may be different on different platforms. 624 static void print_os_info(outputStream* st); 625 static void print_os_info_brief(outputStream* st); 626 static void print_cpu_info(outputStream* st); | 539 // that support such things. This calls shutdown() and then aborts. 540 static void abort(bool dump_core = true); 541 542 // Die immediately, no exit hook, no abort hook, no cleanup. 543 static void die(); 544 545 // File i/o operations 546 static const int default_file_open_flags(); 547 static int open(const char *path, int oflag, int mode); 548 static FILE* open(int fd, const char* mode); 549 static int close(int fd); 550 static jlong lseek(int fd, jlong offset, int whence); 551 static char* native_path(char *path); 552 static int ftruncate(int fd, jlong length); 553 static int fsync(int fd); 554 static int available(int fd, jlong *bytes); 555 556 //File i/o operations 557 558 static size_t read(int fd, void *buf, unsigned int nBytes); 559 static size_t read_at(int fd, void *buf, unsigned int nBytes, jlong offset); 560 static size_t restartable_read(int fd, void *buf, unsigned int nBytes); 561 static size_t write(int fd, const void *buf, unsigned int nBytes); 562 563 // Reading directories. 564 static DIR* opendir(const char* dirname); 565 static struct dirent* readdir(DIR* dirp); 566 static int closedir(DIR* dirp); 567 568 // Dynamic library extension 569 static const char* dll_file_extension(); 570 571 static const char* get_temp_directory(); 572 static const char* get_current_directory(char *buf, size_t buflen); 573 574 // Builds a platform-specific full library path given a ld path and lib name 575 // Returns true if buffer contains full path to existing file, false otherwise 576 static bool dll_build_name(char* buffer, size_t size, 577 const char* pathname, const char* fname); 578 579 // Symbol lookup, find nearest function name; basically it implements 580 // dladdr() for all platforms. Name of the nearest function is copied 581 // to buf. Distance from its base address is optionally returned as offset. 582 // If function name is not found, buf[0] is set to '\0' and offset is 583 // set to -1 (if offset is non-NULL). 584 static bool dll_address_to_function_name(address addr, char* buf, 585 int buflen, int* offset); 587 // Locate DLL/DSO. On success, full path of the library is copied to 588 // buf, and offset is optionally set to be the distance between addr 589 // and the library's base address. On failure, buf[0] is set to '\0' 590 // and offset is set to -1 (if offset is non-NULL). 591 static bool dll_address_to_library_name(address addr, char* buf, 592 int buflen, int* offset); 593 594 // Find out whether the pc is in the static code for jvm.dll/libjvm.so. 595 static bool address_is_in_vm(address addr); 596 597 // Loads .dll/.so and 598 // in case of error it checks if .dll/.so was built for the 599 // same architecture as Hotspot is running on 600 static void* dll_load(const char *name, char *ebuf, int ebuflen); 601 602 // lookup symbol in a shared library 603 static void* dll_lookup(void* handle, const char* name); 604 605 // Unload library 606 static void dll_unload(void *lib); 607 608 // Callback for loaded module information 609 // Input parameters: 610 // char* module_file_name, 611 // address module_base_addr, 612 // address module_top_addr, 613 // void* param 614 typedef int (*LoadedModulesCallbackFunc)(const char *, address, address, void *); 615 616 static int get_loaded_modules_info(LoadedModulesCallbackFunc callback, void *param); 617 618 // Return the handle of this process 619 static void* get_default_process_handle(); 620 621 // Check for static linked agent library 622 static bool find_builtin_agent(AgentLibrary *agent_lib, const char *syms[], 623 size_t syms_len); 624 625 // Find agent entry point 626 static void *find_agent_function(AgentLibrary *agent_lib, bool check_lib, 627 const char *syms[], size_t syms_len); 628 629 static int vsnprintf(char* buf, size_t len, const char* fmt, va_list args) ATTRIBUTE_PRINTF(3, 0); 630 static int snprintf(char* buf, size_t len, const char* fmt, ...) ATTRIBUTE_PRINTF(3, 4); 631 632 // Print out system information; they are called by fatal error handler. 633 // Output format may be different on different platforms. 634 static void print_os_info(outputStream* st); 635 static void print_os_info_brief(outputStream* st); 636 static void print_cpu_info(outputStream* st); |