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