LLVM  6.0.0svn
Static Public Member Functions | List of all members
llvm::sys::Process Class Reference

A collection of legacy interfaces for querying information about the current executing process. More...

#include "llvm/Support/Process.h"

Static Public Member Functions

static unsigned getPageSize ()
 
static size_t GetMallocUsage ()
 Return process memory usage. More...
 
static void GetTimeUsage (TimePoint<> &elapsed, std::chrono::nanoseconds &user_time, std::chrono::nanoseconds &sys_time)
 This static function will set user_time to the amount of CPU time spent in user (non-kernel) mode and sys_time to the amount of CPU time spent in system (kernel) mode. More...
 
static void PreventCoreFiles ()
 This function makes the necessary calls to the operating system to prevent core files or any other kind of large memory dumps that can occur when a program fails. More...
 
static bool AreCoreFilesPrevented ()
 true if PreventCoreFiles has been called, false otherwise. More...
 
static Optional< std::string > GetEnv (StringRef name)
 
static Optional< std::string > FindInEnvPath (StringRef EnvName, StringRef FileName, ArrayRef< std::string > IgnoreList)
 This function searches for an existing file in the list of directories in a PATH like environment variable, and returns the first file found, according to the order of the entries in the PATH like environment variable. More...
 
static Optional< std::string > FindInEnvPath (StringRef EnvName, StringRef FileName)
 
static std::error_code GetArgumentVector (SmallVectorImpl< const char *> &Args, ArrayRef< const char *> ArgsFromMain, SpecificBumpPtrAllocator< char > &ArgAllocator)
 This function returns a SmallVector containing the arguments passed from the operating system to the program. More...
 
static std::error_code FixupStandardFileDescriptors ()
 
static std::error_code SafelyCloseFileDescriptor (int FD)
 
static bool StandardInIsUserInput ()
 This function determines if the standard input is connected directly to a user's input (keyboard probably), rather than coming from a file or pipe. More...
 
static bool StandardOutIsDisplayed ()
 This function determines if the standard output is connected to a "tty" or "console" window. More...
 
static bool StandardErrIsDisplayed ()
 This function determines if the standard error is connected to a "tty" or "console" window. More...
 
static bool FileDescriptorIsDisplayed (int fd)
 This function determines if the given file descriptor is connected to a "tty" or "console" window. More...
 
static bool FileDescriptorHasColors (int fd)
 This function determines if the given file descriptor is displayd and supports colors. More...
 
static unsigned StandardOutColumns ()
 This function determines the number of columns in the window if standard output is connected to a "tty" or "console" window. More...
 
static unsigned StandardErrColumns ()
 This function determines the number of columns in the window if standard error is connected to a "tty" or "console" window. More...
 
static bool StandardOutHasColors ()
 This function determines whether the terminal connected to standard output supports colors. More...
 
static bool StandardErrHasColors ()
 This function determines whether the terminal connected to standard error supports colors. More...
 
static void UseANSIEscapeCodes (bool enable)
 Enables or disables whether ANSI escape sequences are used to output colors. More...
 
static bool ColorNeedsFlush ()
 Whether changing colors requires the output to be flushed. More...
 
static const charOutputColor (char c, bool bold, bool bg)
 This function returns the colorcode escape sequences. More...
 
static const charOutputBold (bool bg)
 Same as OutputColor, but only enables the bold attribute. More...
 
static const charOutputReverse ()
 This function returns the escape sequence to reverse forground and background colors. More...
 
static const charResetColor ()
 Resets the terminals colors, or returns an escape sequence to do so. More...
 
static unsigned GetRandomNumber ()
 Get the result of a process wide random number generator. More...
 

Detailed Description

A collection of legacy interfaces for querying information about the current executing process.

Definition at line 44 of file Process.h.

Member Function Documentation

◆ AreCoreFilesPrevented()

bool Process::AreCoreFilesPrevented ( )
static

true if PreventCoreFiles has been called, false otherwise.

Definition at line 88 of file Process.cpp.

References coreFilesPrevented.

◆ ColorNeedsFlush()

static bool llvm::sys::Process::ColorNeedsFlush ( )
static

Whether changing colors requires the output to be flushed.

This is needed on systems that don't support escape sequences for changing colors.

Referenced by llvm::raw_fd_ostream::changeColor(), llvm::raw_fd_ostream::resetColor(), and llvm::raw_fd_ostream::reverseColor().

◆ FileDescriptorHasColors()

static bool llvm::sys::Process::FileDescriptorHasColors ( int  fd)
static

This function determines if the given file descriptor is displayd and supports colors.

Referenced by llvm::raw_fd_ostream::has_colors().

◆ FileDescriptorIsDisplayed()

static bool llvm::sys::Process::FileDescriptorIsDisplayed ( int  fd)
static

This function determines if the given file descriptor is connected to a "tty" or "console" window.

That is, the output would be displayed to the user rather than being put on a pipe or stored in a file.

Referenced by llvm::raw_fd_ostream::is_displayed().

◆ FindInEnvPath() [1/2]

Optional< std::string > Process::FindInEnvPath ( StringRef  EnvName,
StringRef  FileName,
ArrayRef< std::string >  IgnoreList 
)
static

This function searches for an existing file in the list of directories in a PATH like environment variable, and returns the first file found, according to the order of the entries in the PATH like environment variable.

If an ignore list is specified, then any folder which is in the PATH like environment variable but is also in IgnoreList is not considered.

Definition at line 35 of file Process.cpp.

References llvm::any_of(), llvm::sys::path::append(), assert(), llvm::sys::fs::equivalent(), llvm::sys::fs::exists(), GetEnv(), llvm::Optional< T >::getValue(), llvm::Optional< T >::hasValue(), llvm::sys::path::is_absolute(), llvm::SplitString(), and llvm::SmallString< InternalLen >::str().

Referenced by FindInEnvPath().

◆ FindInEnvPath() [2/2]

Optional< std::string > Process::FindInEnvPath ( StringRef  EnvName,
StringRef  FileName 
)
static

Definition at line 30 of file Process.cpp.

References FindInEnvPath().

◆ FixupStandardFileDescriptors()

static std::error_code llvm::sys::Process::FixupStandardFileDescriptors ( )
static

◆ GetArgumentVector()

static std::error_code llvm::sys::Process::GetArgumentVector ( SmallVectorImpl< const char *> &  Args,
ArrayRef< const char *>  ArgsFromMain,
SpecificBumpPtrAllocator< char > &  ArgAllocator 
)
static

This function returns a SmallVector containing the arguments passed from the operating system to the program.

This function expects to be handed the vector passed in from main.

◆ GetEnv()

static Optional<std::string> llvm::sys::Process::GetEnv ( StringRef  name)
static

◆ GetMallocUsage()

static size_t llvm::sys::Process::GetMallocUsage ( )
static

Return process memory usage.

This static function will return the total amount of memory allocated by the process. This only counts the memory allocated via the malloc, calloc and realloc functions and includes any "free" holes in the allocated space.

Referenced by getMemUsage().

◆ getPageSize()

static unsigned llvm::sys::Process::getPageSize ( )
static

◆ GetRandomNumber()

static unsigned llvm::sys::Process::GetRandomNumber ( )
static

Get the result of a process wide random number generator.

The generator will be automatically seeded in non-deterministic fashion.

Referenced by createUniqueEntity().

◆ GetTimeUsage()

static void llvm::sys::Process::GetTimeUsage ( TimePoint<> &  elapsed,
std::chrono::nanoseconds &  user_time,
std::chrono::nanoseconds &  sys_time 
)
static

This static function will set user_time to the amount of CPU time spent in user (non-kernel) mode and sys_time to the amount of CPU time spent in system (kernel) mode.

If the operating system does not support collection of these metrics, a zero duration will be for both values.

Parameters
elapsedReturns the system_clock::now() giving current time
user_timeReturns the current amount of user time for the process
sys_timeReturns the current amount of system time for the process

Referenced by llvm::TimeRecord::getCurrentTime().

◆ OutputBold()

static const char* llvm::sys::Process::OutputBold ( bool  bg)
static

Same as OutputColor, but only enables the bold attribute.

Referenced by llvm::raw_fd_ostream::changeColor().

◆ OutputColor()

static const char* llvm::sys::Process::OutputColor ( char  c,
bool  bold,
bool  bg 
)
static

This function returns the colorcode escape sequences.

If ColorNeedsFlush() is true then this function will change the colors and return an empty escape sequence. In that case it is the responsibility of the client to flush the output stream prior to calling this function.

Referenced by llvm::raw_fd_ostream::changeColor().

◆ OutputReverse()

static const char* llvm::sys::Process::OutputReverse ( )
static

This function returns the escape sequence to reverse forground and background colors.

Referenced by llvm::raw_fd_ostream::reverseColor().

◆ PreventCoreFiles()

static void llvm::sys::Process::PreventCoreFiles ( )
static

This function makes the necessary calls to the operating system to prevent core files or any other kind of large memory dumps that can occur when a program fails.

Prevent core file generation.

◆ ResetColor()

static const char* llvm::sys::Process::ResetColor ( )
static

Resets the terminals colors, or returns an escape sequence to do so.

Referenced by llvm::raw_fd_ostream::resetColor().

◆ SafelyCloseFileDescriptor()

static std::error_code llvm::sys::Process::SafelyCloseFileDescriptor ( int  FD)
static

◆ StandardErrColumns()

static unsigned llvm::sys::Process::StandardErrColumns ( )
static

This function determines the number of columns in the window if standard error is connected to a "tty" or "console" window.

If standard error is not connected to a tty or console, or if the number of columns cannot be determined, this routine returns zero.

◆ StandardErrHasColors()

static bool llvm::sys::Process::StandardErrHasColors ( )
static

This function determines whether the terminal connected to standard error supports colors.

If standard error is not connected to a terminal, this function returns false.

◆ StandardErrIsDisplayed()

static bool llvm::sys::Process::StandardErrIsDisplayed ( )
static

This function determines if the standard error is connected to a "tty" or "console" window.

That is, the output would be displayed to the user rather than being put on a pipe or stored in a file.

◆ StandardInIsUserInput()

static bool llvm::sys::Process::StandardInIsUserInput ( )
static

This function determines if the standard input is connected directly to a user's input (keyboard probably), rather than coming from a file or pipe.

◆ StandardOutColumns()

static unsigned llvm::sys::Process::StandardOutColumns ( )
static

This function determines the number of columns in the window if standard output is connected to a "tty" or "console" window.

If standard output is not connected to a tty or console, or if the number of columns cannot be determined, this routine returns zero.

◆ StandardOutHasColors()

static bool llvm::sys::Process::StandardOutHasColors ( )
static

This function determines whether the terminal connected to standard output supports colors.

If standard output is not connected to a terminal, this function returns false.

◆ StandardOutIsDisplayed()

static bool llvm::sys::Process::StandardOutIsDisplayed ( )
static

This function determines if the standard output is connected to a "tty" or "console" window.

That is, the output would be displayed to the user rather than being put on a pipe or stored in a file.

◆ UseANSIEscapeCodes()

static void llvm::sys::Process::UseANSIEscapeCodes ( bool  enable)
static

Enables or disables whether ANSI escape sequences are used to output colors.

This only has an effect on Windows. Note: Setting this option is not thread-safe and should only be done during initialization.


The documentation for this class was generated from the following files: