Wed, 02 Jul 2008 12:55:16 -0700
6719955: Update copyright year
Summary: Update copyright year for files that have been modified in 2008
Reviewed-by: ohair, tbell
duke@435 | 1 | /* |
duke@435 | 2 | * Copyright 2003-2005 Sun Microsystems, Inc. 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 | * |
duke@435 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@435 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@435 | 21 | * have any 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_ |