agent/src/os/linux/libproc_impl.h

Fri, 25 Jan 2013 16:50:33 -0800

author
morris
date
Fri, 25 Jan 2013 16:50:33 -0800
changeset 4535
9fae07c31641
parent 1907
c18cbe5936b8
child 4599
2394a89e89f4
permissions
-rw-r--r--

6518907: cleanup IA64 specific code in Hotspot
Summary: removed unused IA64 specific code
Reviewed-by: twisti, kvn, dholmes

duke@435 1 /*
trims@1907 2 * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 #ifndef _LIBPROC_IMPL_H_
duke@435 26 #define _LIBPROC_IMPL_H_
duke@435 27
duke@435 28 #include <unistd.h>
duke@435 29 #include <limits.h>
duke@435 30 #include "libproc.h"
duke@435 31 #include "symtab.h"
duke@435 32
duke@435 33 // data structures in this file mimic those of Solaris 8.0 - libproc's Pcontrol.h
duke@435 34
duke@435 35 #define BUF_SIZE (PATH_MAX + NAME_MAX + 1)
duke@435 36
duke@435 37 // list of shared objects
duke@435 38 typedef struct lib_info {
duke@435 39 char name[BUF_SIZE];
duke@435 40 uintptr_t base;
duke@435 41 struct symtab* symtab;
duke@435 42 int fd; // file descriptor for lib
duke@435 43 struct lib_info* next;
duke@435 44 } lib_info;
duke@435 45
duke@435 46 // list of threads
duke@435 47 typedef struct thread_info {
duke@435 48 lwpid_t lwp_id;
duke@435 49 pthread_t pthread_id; // not used cores, always -1
duke@435 50 struct user_regs_struct regs; // not for process, core uses for caching regset
duke@435 51 struct thread_info* next;
duke@435 52 } thread_info;
duke@435 53
duke@435 54 // list of virtual memory maps
duke@435 55 typedef struct map_info {
duke@435 56 int fd; // file descriptor
duke@435 57 off_t offset; // file offset of this mapping
duke@435 58 uintptr_t vaddr; // starting virtual address
duke@435 59 size_t memsz; // size of the mapping
duke@435 60 struct map_info* next;
duke@435 61 } map_info;
duke@435 62
duke@435 63 // vtable for ps_prochandle
duke@435 64 typedef struct ps_prochandle_ops {
duke@435 65 // "derived class" clean-up
duke@435 66 void (*release)(struct ps_prochandle* ph);
duke@435 67 // read from debuggee
duke@435 68 bool (*p_pread)(struct ps_prochandle *ph,
duke@435 69 uintptr_t addr, char *buf, size_t size);
duke@435 70 // write into debuggee
duke@435 71 bool (*p_pwrite)(struct ps_prochandle *ph,
duke@435 72 uintptr_t addr, const char *buf , size_t size);
duke@435 73 // get integer regset of a thread
duke@435 74 bool (*get_lwp_regs)(struct ps_prochandle* ph, lwpid_t lwp_id, struct user_regs_struct* regs);
duke@435 75 } ps_prochandle_ops;
duke@435 76
duke@435 77 // the ps_prochandle
duke@435 78
duke@435 79 struct core_data {
duke@435 80 int core_fd; // file descriptor of core file
duke@435 81 int exec_fd; // file descriptor of exec file
duke@435 82 int interp_fd; // file descriptor of interpreter (ld-linux.so.2)
duke@435 83 // part of the class sharing workaround
duke@435 84 int classes_jsa_fd; // file descriptor of class share archive
duke@435 85 uintptr_t dynamic_addr; // address of dynamic section of a.out
duke@435 86 uintptr_t ld_base_addr; // base address of ld.so
duke@435 87 size_t num_maps; // number of maps.
duke@435 88 map_info* maps; // maps in a linked list
duke@435 89 // part of the class sharing workaround
duke@435 90 map_info* class_share_maps;// class share maps in a linked list
duke@435 91 map_info** map_array; // sorted (by vaddr) array of map_info pointers
duke@435 92 };
duke@435 93
duke@435 94 struct ps_prochandle {
duke@435 95 ps_prochandle_ops* ops; // vtable ptr
duke@435 96 pid_t pid;
duke@435 97 int num_libs;
duke@435 98 lib_info* libs; // head of lib list
duke@435 99 lib_info* lib_tail; // tail of lib list - to append at the end
duke@435 100 int num_threads;
duke@435 101 thread_info* threads; // head of thread list
duke@435 102 struct core_data* core; // data only used for core dumps, NULL for process
duke@435 103 };
duke@435 104
duke@435 105 int pathmap_open(const char* name);
duke@435 106
duke@435 107 void print_debug(const char* format,...);
duke@435 108 bool is_debug();
duke@435 109
duke@435 110 typedef bool (*thread_info_callback)(struct ps_prochandle* ph, pthread_t pid, lwpid_t lwpid);
duke@435 111
duke@435 112 // reads thread info using libthread_db and calls above callback for each thread
duke@435 113 bool read_thread_info(struct ps_prochandle* ph, thread_info_callback cb);
duke@435 114
duke@435 115 // adds a new shared object to lib list, returns NULL on failure
duke@435 116 lib_info* add_lib_info(struct ps_prochandle* ph, const char* libname, uintptr_t base);
duke@435 117
duke@435 118 // adds a new shared object to lib list, supply open lib file descriptor as well
duke@435 119 lib_info* add_lib_info_fd(struct ps_prochandle* ph, const char* libname, int fd,
duke@435 120 uintptr_t base);
duke@435 121
duke@435 122 // adds a new thread to threads list, returns NULL on failure
duke@435 123 thread_info* add_thread_info(struct ps_prochandle* ph, pthread_t pthread_id, lwpid_t lwp_id);
duke@435 124
duke@435 125 // a test for ELF signature without using libelf
duke@435 126 bool is_elf_file(int fd);
duke@435 127
duke@435 128 #endif //_LIBPROC_IMPL_H_

mercurial