ps_proc.c revision 2796
2796N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 2796N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2796N/A * This code is free software; you can redistribute it and/or modify it 2796N/A * under the terms of the GNU General Public License version 2 only, as 2796N/A * published by the Free Software Foundation. 2796N/A * This code is distributed in the hope that it will be useful, but WITHOUT 2796N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2796N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2796N/A * version 2 for more details (a copy is included in the LICENSE file that 2796N/A * You should have received a copy of the GNU General Public License version 2796N/A * 2 along with this work; if not, write to the Free Software Foundation, 2796N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2796N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2796N/A// This file has the libproc implementation specific to live process 2796N/A// --------------------------------------------- 2796N/A// --------------------------------------------- 2796N/A// read "size" bytes of data from "addr" within the target process. 2796N/A// unlike the standard ptrace() function, process_read_data() can handle 2796N/A// unaligned address - alignment check, if required, should be done 2796N/A// before calling process_read_data. 2796N/A // assert((intptr_t)aligned_addr % sizeof(int) == 0); 2796N/A// null implementation for write 2796N/A// "user" should be a pointer to a reg 2796N/A // we have already attached to all thread 'pid's, just use ptrace call 2796N/A // to get regset now. Note that we don't cache regset upfront for processes. 2796N/A// fill in ptrace_lwpinfo for lid 2796N/A // Wait for debuggee to stop. 2796N/A// ------------------------------------------------------- 2796N/A// functions for obtaining library information 2796N/A// ------------------------------------------------------- 2796N/A// callback for read_thread_info 2796N/A * Not the most robust but good enough. 2796N/A /* read ELF_EHDR at TEXT_START_ADDR and validate */ 2796N/A /* allocate space for all ELF_PHDR's and read */ 2796N/A /* find PT_DYNAMIC section */ 2796N/A /* allocate space and read in ELF_DYN headers */ 2796N/A /* read struct r_debug into dmap */ 2796N/A#
endif // __FreeBSD__ && __FreeBSD_version < 701000 2796N/A continue;
// ignore, add_lib_info prints error 2796N/A // we don't need to keep the library open, symtab is already 2796N/A // built. Only for core dump we need to keep the fd open. 2796N/A continue;
// ignore, add_lib_info prints error 2796N/A // we don't need to keep the library open, symtab is already 2796N/A // built. Only for core dump we need to keep the fd open. 2796N/A// attach to the process. One and only one exposed stuff 2796N/A // initialize ps_prochandle 2796N/A // read library info and symbol tables, must do this before attaching threads, 2796N/A // as the symbols in the pthread library will be used to figure out 2796N/A // the list of threads within the same process.