1 /*
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
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 *
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
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 // Print out system information; they are called by fatal error handler.
620 // Output format may be different on different platforms.
621 static void print_os_info(outputStream* st);
622 static void print_os_info_brief(outputStream* st);
623 static void print_cpu_info(outputStream* st);
624 static void pd_print_cpu_info(outputStream* st);
625 static void print_memory_info(outputStream* st);
626 static void print_dll_info(outputStream* st);
627 static void print_environment_variables(outputStream* st, const char** env_list, char* buffer, int len);
|
1 /*
2 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
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 *
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 int readdir_buf_size(const char *path);
566 static struct dirent* readdir(DIR* dirp, dirent* dbuf);
567 static int closedir(DIR* dirp);
568
569 // Dynamic library extension
570 static const char* dll_file_extension();
571
572 static const char* get_temp_directory();
573 static const char* get_current_directory(char *buf, size_t buflen);
574
575 // Builds a platform-specific full library path given a ld path and lib name
576 // Returns true if buffer contains full path to existing file, false otherwise
577 static bool dll_build_name(char* buffer, size_t size,
578 const char* pathname, const char* fname);
579
589 // buf, and offset is optionally set to be the distance between addr
590 // and the library's base address. On failure, buf[0] is set to '\0'
591 // and offset is set to -1 (if offset is non-NULL).
592 static bool dll_address_to_library_name(address addr, char* buf,
593 int buflen, int* offset);
594
595 // Find out whether the pc is in the static code for jvm.dll/libjvm.so.
596 static bool address_is_in_vm(address addr);
597
598 // Loads .dll/.so and
599 // in case of error it checks if .dll/.so was built for the
600 // same architecture as Hotspot is running on
601 static void* dll_load(const char *name, char *ebuf, int ebuflen);
602
603 // lookup symbol in a shared library
604 static void* dll_lookup(void* handle, const char* name);
605
606 // Unload library
607 static void dll_unload(void *lib);
608
609 // Callback for loaded module information
610 // Input parameters:
611 // char* module_file_name,
612 // address module_base_addr,
613 // address module_top_addr,
614 // void* param
615 typedef int (*LoadedModulesCallbackFunc)(const char *, address, address, void *);
616
617 static int get_loaded_modules_info(LoadedModulesCallbackFunc callback, void *param);
618
619 // Return the handle of this process
620 static void* get_default_process_handle();
621
622 // Check for static linked agent library
623 static bool find_builtin_agent(AgentLibrary *agent_lib, const char *syms[],
624 size_t syms_len);
625
626 // Find agent entry point
627 static void *find_agent_function(AgentLibrary *agent_lib, bool check_lib,
628 const char *syms[], size_t syms_len);
629
630 // Print out system information; they are called by fatal error handler.
631 // Output format may be different on different platforms.
632 static void print_os_info(outputStream* st);
633 static void print_os_info_brief(outputStream* st);
634 static void print_cpu_info(outputStream* st);
635 static void pd_print_cpu_info(outputStream* st);
636 static void print_memory_info(outputStream* st);
637 static void print_dll_info(outputStream* st);
638 static void print_environment_variables(outputStream* st, const char** env_list, char* buffer, int len);
|