1/* 2 * Copyright (c) 2004-2009 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Ali Saidi 29 */ 30 31#ifndef __LINUX_HH__ 32#define __LINUX_HH__
| 1/* 2 * Copyright (c) 2004-2009 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Ali Saidi 29 */ 30 31#ifndef __LINUX_HH__ 32#define __LINUX_HH__
|
42#include <string> 43 44#include "kern/operatingsystem.hh" 45 46class ThreadContext; 47class LiveProcess; 48 49/// 50/// This class encapsulates the types, structures, constants, 51/// functions, and syscall-number mappings specific to the Alpha Linux 52/// syscall interface. 53/// 54class Linux : public OperatingSystem 55{ 56 57 public: 58 59 //@{ 60 /// Basic Linux types. 61 typedef uint64_t size_t; 62 typedef uint64_t off_t; 63 typedef int64_t time_t; 64 typedef uint32_t uid_t; 65 typedef uint32_t gid_t; 66 //@} 67 68 /// Stat buffer. Note that we can't call it 'stat' since that 69 /// gets #defined to something else on some systems. This type 70 /// can be specialized by architecture specific "Linux" classes 71 typedef struct { 72 uint32_t st_dev; //!< device 73 uint32_t st_ino; //!< inode 74 uint32_t st_mode; //!< mode 75 uint32_t st_nlink; //!< link count 76 uint32_t st_uid; //!< owner's user ID 77 uint32_t st_gid; //!< owner's group ID 78 uint32_t st_rdev; //!< device number 79 int32_t _pad1; //!< for alignment 80 int64_t st_size; //!< file size in bytes 81 uint64_t st_atimeX; //!< time of last access 82 uint64_t st_mtimeX; //!< time of last modification 83 uint64_t st_ctimeX; //!< time of last status change 84 uint32_t st_blksize; //!< optimal I/O block size 85 int32_t st_blocks; //!< number of blocks allocated 86 uint32_t st_flags; //!< flags 87 uint32_t st_gen; //!< unknown 88 } tgt_stat; 89 90 // same for stat64 91 typedef struct { 92 uint64_t st_dev; 93 uint64_t st_ino; 94 uint64_t st_rdev; 95 int64_t st_size; 96 uint64_t st_blocks; 97 98 uint32_t st_mode; 99 uint32_t st_uid; 100 uint32_t st_gid; 101 uint32_t st_blksize; 102 uint32_t st_nlink; 103 uint32_t __pad0; 104 105 uint64_t st_atimeX; 106 uint64_t st_atime_nsec; 107 uint64_t st_mtimeX; 108 uint64_t st_mtime_nsec; 109 uint64_t st_ctimeX; 110 uint64_t st_ctime_nsec; 111 int64_t ___unused[3]; 112 } tgt_stat64; 113 114 /// Length of strings in struct utsname (plus 1 for null char). 115 static const int _SYS_NMLN = 65; 116 117 /// Interface struct for uname(). 118 struct utsname { 119 char sysname[_SYS_NMLN]; //!< System name. 120 char nodename[_SYS_NMLN]; //!< Node name. 121 char release[_SYS_NMLN]; //!< OS release. 122 char version[_SYS_NMLN]; //!< OS version. 123 char machine[_SYS_NMLN]; //!< Machine type. 124 }; 125 126 /// Limit struct for getrlimit/setrlimit. 127 struct rlimit { 128 uint64_t rlim_cur; //!< soft limit 129 uint64_t rlim_max; //!< hard limit 130 }; 131 132 /// For gettimeofday(). 133 struct timeval { 134 int64_t tv_sec; //!< seconds 135 int64_t tv_usec; //!< microseconds 136 }; 137 138 // For writev/readv 139 struct tgt_iovec { 140 uint64_t iov_base; // void * 141 uint64_t iov_len; 142 }; 143 144 145 /// For getrusage(). 146 struct rusage { 147 struct timeval ru_utime; //!< user time used 148 struct timeval ru_stime; //!< system time used 149 int64_t ru_maxrss; //!< max rss 150 int64_t ru_ixrss; //!< integral shared memory size 151 int64_t ru_idrss; //!< integral unshared data " 152 int64_t ru_isrss; //!< integral unshared stack " 153 int64_t ru_minflt; //!< page reclaims - total vmfaults 154 int64_t ru_majflt; //!< page faults 155 int64_t ru_nswap; //!< swaps 156 int64_t ru_inblock; //!< block input operations 157 int64_t ru_oublock; //!< block output operations 158 int64_t ru_msgsnd; //!< messages sent 159 int64_t ru_msgrcv; //!< messages received 160 int64_t ru_nsignals; //!< signals received 161 int64_t ru_nvcsw; //!< voluntary context switches 162 int64_t ru_nivcsw; //!< involuntary " 163 }; 164 165 static int openSpecialFile(std::string path, LiveProcess *process, ThreadContext *tc); 166 static std::string procMeminfo(LiveProcess *process, ThreadContext *tc); 167 168}; // class Linux 169 170 171#endif // FULL_SYSTEM 172 173#endif // __LINUX_HH__
| 43#include <string> 44 45#include "kern/operatingsystem.hh" 46 47class ThreadContext; 48class LiveProcess; 49 50/// 51/// This class encapsulates the types, structures, constants, 52/// functions, and syscall-number mappings specific to the Alpha Linux 53/// syscall interface. 54/// 55class Linux : public OperatingSystem 56{ 57 58 public: 59 60 //@{ 61 /// Basic Linux types. 62 typedef uint64_t size_t; 63 typedef uint64_t off_t; 64 typedef int64_t time_t; 65 typedef uint32_t uid_t; 66 typedef uint32_t gid_t; 67 //@} 68 69 /// Stat buffer. Note that we can't call it 'stat' since that 70 /// gets #defined to something else on some systems. This type 71 /// can be specialized by architecture specific "Linux" classes 72 typedef struct { 73 uint32_t st_dev; //!< device 74 uint32_t st_ino; //!< inode 75 uint32_t st_mode; //!< mode 76 uint32_t st_nlink; //!< link count 77 uint32_t st_uid; //!< owner's user ID 78 uint32_t st_gid; //!< owner's group ID 79 uint32_t st_rdev; //!< device number 80 int32_t _pad1; //!< for alignment 81 int64_t st_size; //!< file size in bytes 82 uint64_t st_atimeX; //!< time of last access 83 uint64_t st_mtimeX; //!< time of last modification 84 uint64_t st_ctimeX; //!< time of last status change 85 uint32_t st_blksize; //!< optimal I/O block size 86 int32_t st_blocks; //!< number of blocks allocated 87 uint32_t st_flags; //!< flags 88 uint32_t st_gen; //!< unknown 89 } tgt_stat; 90 91 // same for stat64 92 typedef struct { 93 uint64_t st_dev; 94 uint64_t st_ino; 95 uint64_t st_rdev; 96 int64_t st_size; 97 uint64_t st_blocks; 98 99 uint32_t st_mode; 100 uint32_t st_uid; 101 uint32_t st_gid; 102 uint32_t st_blksize; 103 uint32_t st_nlink; 104 uint32_t __pad0; 105 106 uint64_t st_atimeX; 107 uint64_t st_atime_nsec; 108 uint64_t st_mtimeX; 109 uint64_t st_mtime_nsec; 110 uint64_t st_ctimeX; 111 uint64_t st_ctime_nsec; 112 int64_t ___unused[3]; 113 } tgt_stat64; 114 115 /// Length of strings in struct utsname (plus 1 for null char). 116 static const int _SYS_NMLN = 65; 117 118 /// Interface struct for uname(). 119 struct utsname { 120 char sysname[_SYS_NMLN]; //!< System name. 121 char nodename[_SYS_NMLN]; //!< Node name. 122 char release[_SYS_NMLN]; //!< OS release. 123 char version[_SYS_NMLN]; //!< OS version. 124 char machine[_SYS_NMLN]; //!< Machine type. 125 }; 126 127 /// Limit struct for getrlimit/setrlimit. 128 struct rlimit { 129 uint64_t rlim_cur; //!< soft limit 130 uint64_t rlim_max; //!< hard limit 131 }; 132 133 /// For gettimeofday(). 134 struct timeval { 135 int64_t tv_sec; //!< seconds 136 int64_t tv_usec; //!< microseconds 137 }; 138 139 // For writev/readv 140 struct tgt_iovec { 141 uint64_t iov_base; // void * 142 uint64_t iov_len; 143 }; 144 145 146 /// For getrusage(). 147 struct rusage { 148 struct timeval ru_utime; //!< user time used 149 struct timeval ru_stime; //!< system time used 150 int64_t ru_maxrss; //!< max rss 151 int64_t ru_ixrss; //!< integral shared memory size 152 int64_t ru_idrss; //!< integral unshared data " 153 int64_t ru_isrss; //!< integral unshared stack " 154 int64_t ru_minflt; //!< page reclaims - total vmfaults 155 int64_t ru_majflt; //!< page faults 156 int64_t ru_nswap; //!< swaps 157 int64_t ru_inblock; //!< block input operations 158 int64_t ru_oublock; //!< block output operations 159 int64_t ru_msgsnd; //!< messages sent 160 int64_t ru_msgrcv; //!< messages received 161 int64_t ru_nsignals; //!< signals received 162 int64_t ru_nvcsw; //!< voluntary context switches 163 int64_t ru_nivcsw; //!< involuntary " 164 }; 165 166 static int openSpecialFile(std::string path, LiveProcess *process, ThreadContext *tc); 167 static std::string procMeminfo(LiveProcess *process, ThreadContext *tc); 168 169}; // class Linux 170 171 172#endif // FULL_SYSTEM 173 174#endif // __LINUX_HH__
|