00001 /* 00002 * See the dyninst/COPYRIGHT file for copyright information. 00003 * 00004 * We provide the Paradyn Tools (below described as "Paradyn") 00005 * on an AS IS basis, and do not warrant its validity or performance. 00006 * We reserve the right to update, modify, or discontinue this 00007 * software at any time. We shall have no obligation to supply such 00008 * updates or modifications or any other form of support to you. 00009 * 00010 * By your use of Paradyn, you understand and agree that we (or any 00011 * other person or entity with proprietary rights in Paradyn) are 00012 * under no obligation to provide either maintenance services, 00013 * update services, notices of latent defects, or correction of 00014 * defects for Paradyn. 00015 * 00016 * This library is free software; you can redistribute it and/or 00017 * modify it under the terms of the GNU Lesser General Public 00018 * License as published by the Free Software Foundation; either 00019 * version 2.1 of the License, or (at your option) any later version. 00020 * 00021 * This library is distributed in the hope that it will be useful, 00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00024 * Lesser General Public License for more details. 00025 * 00026 * You should have received a copy of the GNU Lesser General Public 00027 * License along with this library; if not, write to the Free Software 00028 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00029 */ 00030 #ifndef BG_AUXV_READER_H 00031 #define BG_AUXV_READER_H 00032 00033 #include <string> 00034 #include "auxvtypes.h" 00035 00036 #if defined(os_bg_ion) && defined(os_bgp) 00037 #include "external/bluegene/bgp-debugger-interface.h" 00038 #else 00039 #error "BUILD ERROR: BG_AuxvReader.h compiled in non-bgp ion build." 00040 #endif // defined(os_bg_ion) && defined(os_bgp) 00041 00042 // Type for elements in the auxiliary vector. 00043 struct auxv_element { 00044 uint32_t type; 00045 uint32_t value; 00046 const char *name() { return auxv_type_to_string(type); } 00047 }; 00048 00049 /// 00050 /// Class for using CIO debugger interface to read auxv vectors. This will read 00051 /// all the vectors in order until there's nothing left. Sample usage: 00052 /// 00053 /// BG_AuxvReader reader(mypid); 00054 /// while (reader.hasNext()) { 00055 /// if (!reader.good()) { 00056 /// // handle error 00057 /// } 00058 /// auxv_element elt = reader.next(); 00059 /// // do stuff with elt 00060 /// } 00061 /// 00062 /// Note that the process on the compute node *must be stopped* for this to work 00063 /// properly. User of this class is responsible for stopping/restarting the process. 00064 /// 00065 class BG_AuxvReader { 00066 private: 00067 const size_t buffer_size; /// buffer size for chunks read from CN 00068 const int pid; /// process to read from 00069 size_t fetch_offset; /// offset within aux vectors to fetch 00070 size_t read_offset; /// local offset in buffer to read from 00071 DebuggerInterface::BG_Debugger_Msg ack_msg; /// BG msg containing fetched auxv buffer. 00072 00073 const char *error; /// set if we encounter an error while reading. 00074 auxv_element elt; /// Last element read 00075 00076 void check_buffer(); // checks whether buffer needs refilling. 00077 00078 public: 00079 /// Construct a new reader for the specified process. PID is according to MPIR proctable. 00080 BG_AuxvReader(int _pid); 00081 ~BG_AuxvReader(); 00082 00083 bool good(); /// Whether we encountered an error communicating wtih CIOD 00084 const char *error_msg(); /// Message associated with the last error. 00085 bool has_next(); /// Whether there are more auxv_elements to read. 00086 auxv_element next(); /// Gets the next auxv element 00087 }; 00088 00089 #endif //BG_AUXV_READER_H
1.6.1