LLVM API Documentation
00001 //===- llvm/System/Process.h ------------------------------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by Reid Spencer and is distributed under the 00006 // University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file declares the llvm::sys::Process class. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_SYSTEM_PROCESS_H 00015 #define LLVM_SYSTEM_PROCESS_H 00016 00017 #include "llvm/System/TimeValue.h" 00018 #include "llvm/System/IncludeFile.h" 00019 00020 namespace llvm { 00021 namespace sys { 00022 00023 /// This class provides an abstraction for getting information about the 00024 /// currently executing process. 00025 /// @since 1.4 00026 /// @brief An abstraction for operating system processes. 00027 class Process { 00028 /// @name Accessors 00029 /// @{ 00030 public: 00031 /// This static function will return the operating system's virtual memory 00032 /// page size. 00033 /// @returns The number of bytes in a virtual memory page. 00034 /// @throws nothing 00035 /// @brief Get the virtual memory page size 00036 static unsigned GetPageSize(); 00037 00038 /// This static function will return the total amount of memory allocated 00039 /// by the process. This only counts the memory allocated via the malloc, 00040 /// calloc and realloc functions and includes any "free" holes in the 00041 /// allocated space. 00042 /// @throws nothing 00043 /// @brief Return process memory usage. 00044 static size_t GetMallocUsage(); 00045 00046 /// This static function will return the total memory usage of the 00047 /// process. This includes code, data, stack and mapped pages usage. Notei 00048 /// that the value returned here is not necessarily the Running Set Size, 00049 /// it is the total virtual memory usage, regardless of mapped state of 00050 /// that memory. 00051 static size_t GetTotalMemoryUsage(); 00052 00053 /// This static function will set \p user_time to the amount of CPU time 00054 /// spent in user (non-kernel) mode and \p sys_time to the amount of CPU 00055 /// time spent in system (kernel) mode. If the operating system does not 00056 /// support collection of these metrics, a zero TimeValue will be for both 00057 /// values. 00058 static void GetTimeUsage( 00059 TimeValue& elapsed, 00060 ///< Returns the TimeValue::now() giving current time 00061 TimeValue& user_time, 00062 ///< Returns the current amount of user time for the process 00063 TimeValue& sys_time 00064 ///< Returns the current amount of system time for the process 00065 ); 00066 00067 /// This static function will return the process' current user id number. 00068 /// Not all operating systems support this feature. Where it is not 00069 /// supported, the function should return 65536 as the value. 00070 static int GetCurrentUserId(); 00071 00072 /// This static function will return the process' current group id number. 00073 /// Not all operating systems support this feature. Where it is not 00074 /// supported, the function should return 65536 as the value. 00075 static int GetCurrentGroupId(); 00076 00077 /// This function makes the necessary calls to the operating system to 00078 /// prevent core files or any other kind of large memory dumps that can 00079 /// occur when a program fails. 00080 /// @brief Prevent core file generation. 00081 static void PreventCoreFiles(); 00082 00083 /// This function determines if the standard input is connected directly 00084 /// to a user's input (keyboard probably), rather than coming from a file 00085 /// or pipe. 00086 static bool StandardInIsUserInput(); 00087 00088 /// This function determines if the standard output is connected to a 00089 /// "tty" or "console" window. That is, the output would be displayed to 00090 /// the user rather than being put on a pipe or stored in a file. 00091 static bool StandardOutIsDisplayed(); 00092 00093 /// This function determines if the standard error is connected to a 00094 /// "tty" or "console" window. That is, the output would be displayed to 00095 /// the user rather than being put on a pipe or stored in a file. 00096 static bool StandardErrIsDisplayed(); 00097 00098 /// @} 00099 }; 00100 } 00101 } 00102 00103 FORCE_DEFINING_FILE_TO_BE_LINKED(SystemProcess) 00104 00105 #endif