libproc_impl.c revision 3208
0N/A * Copyright (c) 2003, 2012, 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 // initialize the thread_db library // do the "derived class" clean-up first // check whether we have got an ELF file. /proc/<pid>/map // gives out all file mappings and not just shared objects // even if symbol table building fails, we add the lib_info. // This is because we may need to read from the ELF file for core file // address read functionality. lookup_symbol checks for NULL symtab. // lookup for a specific symbol // ignore object_name. search in all libraries // FIXME: what should we do with object_name?? The library names are obtained // by parsing /proc/<pid>/maps, which may not be the same as object_name. // What we need is a utility to map object_name to real file name, something // dlopen() does by looking at LD_LIBRARY_PATH and /etc/ld.so.cache. For // now, we just ignore object_name and do a global search for the symbol. print_debug(
"lookup failed for symbol '%s' in obj '%s'\n",
// add a thread to ps_prochandle print_debug(
"can't allocate memory for thread_info\n");
// initialize thread info // add new thread to the list // struct used for client data from thread_db callback // callback function for libthread_db print_debug(
"libthread_db : td_thr_get_info failed, can't get thread info\n");
// read thread_info using libthread_db // we use libthread_db iterator to iterate thru list of threads. // get lwp_id of n'th thread // get regs for a given lwp // get number of shared objects // get name of n'th solib // get base address of a lib //-------------------------------------------------------------------------- // proc service functions // ps_pglobal_lookup() looks up the symbol sym_name in the symbol table // of the load object object_name in the target process identified by ph. // It returns the symbol's value as an address in the target process in // read "size" bytes info "buf" from address "addr" // write "size" bytes of data to debuggee at address "addr" // ------------------------------------------------------------------------ // Functions below this point are not yet implemented. They are here only // to make the linker happy. // new libthread_db of NPTL seem to require this symbol