ps_proc.c revision 1897
0N/A * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A// This file has the libproc implementation specific to live process 0N/A// --------------------------------------------- 0N/A// --------------------------------------------- 0N/A// read "size" bytes of data from "addr" within the target process. 0N/A// unlike the standard ptrace() function, process_read_data() can handle 0N/A// unaligned address - alignment check, if required, should be done 0N/A// before calling process_read_data. 0N/A // assert((intptr_t)aligned_addr % sizeof(long) == 0); 1142N/A// null implementation for write 0N/A// "user" should be a pointer to a user_regs_struct 0N/A // we have already attached to all thread 'pid's, just use ptrace call 0N/A // to get regset now. Note that we don't cache regset upfront for processes. 0N/A// Linux on x86 and sparc are different. On x86 ptrace(PTRACE_GETREGS, ...) 0N/A// uses pointer from 4th argument and ignores 3rd argument. On sparc it uses 0N/A// pointer from 3rd argument and ignores 4th argument 0N/A // Wait for debuggee to stop. 0N/A // try cloned process. 0N/A // Debuggee stopped. 0N/A// ------------------------------------------------------- 0N/A// functions for obtaining library information 0N/A// ------------------------------------------------------- 0N/A * splits a string _str_ into substrings with delimiter _delim_ by replacing old * delimiters with _new_delim_ (ideally, '\0'). the address of each substring 0N/A * is stored in array _ptrs_ as the return value. the maximum capacity of _ptrs_ * array is specified by parameter _n_. 0N/A * RETURN VALUE: total number of substrings (always <= _n_) 0N/A * NOTE: string _str_ is modified if _delim_!=_new_delim_ 0N/A // skipping leading blanks * fgets without storing '\n' at the end of the string // callback for read_thread_info continue;
// ignore, add_lib_info prints error // we don't need to keep the library open, symtab is already // built. Only for core dump we need to keep the fd open. // detach all pids of a ps_prochandle // attach to the process. One and only one exposed stuff print_debug(
"can't allocate memory for ps_prochandle\n");
// initialize ps_prochandle // read library info and symbol tables, must do this before attaching threads, // as the symbols in the pthread library will be used to figure out // the list of threads within the same process. // don't attach to the main thread again // even if one attach fails, we get return NULL