LLVM  3.7.0
Unix/Signals.inc
Go to the documentation of this file.
1 //===- Signals.cpp - Generic Unix Signals Implementation -----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines some helpful functions for dealing with the possibility of
11 // Unix signals occurring while your program is running.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "Unix.h"
16 #include "llvm/ADT/STLExtras.h"
17 #include "llvm/Support/Format.h"
22 #include "llvm/Support/Mutex.h"
23 #include "llvm/Support/Program.h"
26 #include <algorithm>
27 #include <string>
28 #include <vector>
29 #if HAVE_EXECINFO_H
30 # include <execinfo.h> // For backtrace().
31 #endif
32 #if HAVE_SIGNAL_H
33 #include <signal.h>
34 #endif
35 #if HAVE_SYS_STAT_H
36 #include <sys/stat.h>
37 #endif
38 #if HAVE_CXXABI_H
39 #include <cxxabi.h>
40 #endif
41 #if HAVE_DLFCN_H
42 #include <dlfcn.h>
43 #endif
44 #if HAVE_MACH_MACH_H
45 #include <mach/mach.h>
46 #endif
47 #if HAVE_LINK_H
48 #include <link.h>
49 #endif
50 
51 using namespace llvm;
52 
53 static RETSIGTYPE SignalHandler(int Sig); // defined below.
54 
55 static ManagedStatic<SmartMutex<true> > SignalsMutex;
56 
57 /// InterruptFunction - The function to call if ctrl-c is pressed.
58 static void (*InterruptFunction)() = nullptr;
59 
60 static ManagedStatic<std::vector<std::string>> FilesToRemove;
62  CallBacksToRun;
63 
64 // IntSigs - Signals that represent requested termination. There's no bug
65 // or failure, or if there is, it's not our direct responsibility. For whatever
66 // reason, our continued execution is no longer desirable.
67 static const int IntSigs[] = {
68  SIGHUP, SIGINT, SIGPIPE, SIGTERM, SIGUSR1, SIGUSR2
69 };
70 
71 // KillSigs - Signals that represent that we have a bug, and our prompt
72 // termination has been ordered.
73 static const int KillSigs[] = {
74  SIGILL, SIGTRAP, SIGABRT, SIGFPE, SIGBUS, SIGSEGV, SIGQUIT
75 #ifdef SIGSYS
76  , SIGSYS
77 #endif
78 #ifdef SIGXCPU
79  , SIGXCPU
80 #endif
81 #ifdef SIGXFSZ
82  , SIGXFSZ
83 #endif
84 #ifdef SIGEMT
85  , SIGEMT
86 #endif
87 };
88 
89 static unsigned NumRegisteredSignals = 0;
90 static struct {
91  struct sigaction SA;
92  int SigNo;
93 } RegisteredSignalInfo[(sizeof(IntSigs)+sizeof(KillSigs))/sizeof(KillSigs[0])];
94 
95 
96 static void RegisterHandler(int Signal) {
97  assert(NumRegisteredSignals <
98  sizeof(RegisteredSignalInfo)/sizeof(RegisteredSignalInfo[0]) &&
99  "Out of space for signal handlers!");
100 
101  struct sigaction NewHandler;
102 
103  NewHandler.sa_handler = SignalHandler;
104  NewHandler.sa_flags = SA_NODEFER|SA_RESETHAND;
105  sigemptyset(&NewHandler.sa_mask);
106 
107  // Install the new handler, save the old one in RegisteredSignalInfo.
108  sigaction(Signal, &NewHandler,
109  &RegisteredSignalInfo[NumRegisteredSignals].SA);
110  RegisteredSignalInfo[NumRegisteredSignals].SigNo = Signal;
111  ++NumRegisteredSignals;
112 }
113 
114 static void RegisterHandlers() {
115  // We need to dereference the signals mutex during handler registration so
116  // that we force its construction. This is to prevent the first use being
117  // during handling an actual signal because you can't safely call new in a
118  // signal handler.
119  *SignalsMutex;
120 
121  // If the handlers are already registered, we're done.
122  if (NumRegisteredSignals != 0) return;
123 
124  for (auto S : IntSigs) RegisterHandler(S);
125  for (auto S : KillSigs) RegisterHandler(S);
126 }
127 
128 static void UnregisterHandlers() {
129  // Restore all of the signal handlers to how they were before we showed up.
130  for (unsigned i = 0, e = NumRegisteredSignals; i != e; ++i)
131  sigaction(RegisteredSignalInfo[i].SigNo,
132  &RegisteredSignalInfo[i].SA, nullptr);
133  NumRegisteredSignals = 0;
134 }
135 
136 
137 /// RemoveFilesToRemove - Process the FilesToRemove list. This function
138 /// should be called with the SignalsMutex lock held.
139 /// NB: This must be an async signal safe function. It cannot allocate or free
140 /// memory, even in debug builds.
141 static void RemoveFilesToRemove() {
142  // Avoid constructing ManagedStatic in the signal handler.
143  // If FilesToRemove is not constructed, there are no files to remove.
144  if (!FilesToRemove.isConstructed())
145  return;
146 
147  // We avoid iterators in case of debug iterators that allocate or release
148  // memory.
149  std::vector<std::string>& FilesToRemoveRef = *FilesToRemove;
150  for (unsigned i = 0, e = FilesToRemoveRef.size(); i != e; ++i) {
151  // We rely on a std::string implementation for which repeated calls to
152  // 'c_str()' don't allocate memory. We pre-call 'c_str()' on all of these
153  // strings to try to ensure this is safe.
154  const char *path = FilesToRemoveRef[i].c_str();
155 
156  // Get the status so we can determine if it's a file or directory. If we
157  // can't stat the file, ignore it.
158  struct stat buf;
159  if (stat(path, &buf) != 0)
160  continue;
161 
162  // If this is not a regular file, ignore it. We want to prevent removal of
163  // special files like /dev/null, even if the compiler is being run with the
164  // super-user permissions.
165  if (!S_ISREG(buf.st_mode))
166  continue;
167 
168  // Otherwise, remove the file. We ignore any errors here as there is nothing
169  // else we can do.
170  unlink(path);
171  }
172 }
173 
174 // SignalHandler - The signal handler that runs.
175 static RETSIGTYPE SignalHandler(int Sig) {
176  // Restore the signal behavior to default, so that the program actually
177  // crashes when we return and the signal reissues. This also ensures that if
178  // we crash in our signal handler that the program will terminate immediately
179  // instead of recursing in the signal handler.
180  UnregisterHandlers();
181 
182  // Unmask all potentially blocked kill signals.
183  sigset_t SigMask;
184  sigfillset(&SigMask);
185  sigprocmask(SIG_UNBLOCK, &SigMask, nullptr);
186 
187  {
188  unique_lock<SmartMutex<true>> Guard(*SignalsMutex);
189  RemoveFilesToRemove();
190 
191  if (std::find(std::begin(IntSigs), std::end(IntSigs), Sig)
192  != std::end(IntSigs)) {
193  if (InterruptFunction) {
194  void (*IF)() = InterruptFunction;
195  Guard.unlock();
196  InterruptFunction = nullptr;
197  IF(); // run the interrupt function.
198  return;
199  }
200 
201  Guard.unlock();
202  raise(Sig); // Execute the default handler.
203  return;
204  }
205  }
206 
207  // Otherwise if it is a fault (like SEGV) run any handler.
208  if (CallBacksToRun.isConstructed()) {
209  auto &CallBacksToRunRef = *CallBacksToRun;
210  for (unsigned i = 0, e = CallBacksToRun->size(); i != e; ++i)
211  CallBacksToRunRef[i].first(CallBacksToRunRef[i].second);
212  }
213 
214 #ifdef __s390__
215  // On S/390, certain signals are delivered with PSW Address pointing to
216  // *after* the faulting instruction. Simply returning from the signal
217  // handler would continue execution after that point, instead of
218  // re-raising the signal. Raise the signal manually in those cases.
219  if (Sig == SIGILL || Sig == SIGFPE || Sig == SIGTRAP)
220  raise(Sig);
221 #endif
222 }
223 
225  sys::SmartScopedLock<true> Guard(*SignalsMutex);
226  RemoveFilesToRemove();
227 }
228 
229 void llvm::sys::SetInterruptFunction(void (*IF)()) {
230  {
231  sys::SmartScopedLock<true> Guard(*SignalsMutex);
232  InterruptFunction = IF;
233  }
234  RegisterHandlers();
235 }
236 
237 // RemoveFileOnSignal - The public API
239  std::string* ErrMsg) {
240  {
241  sys::SmartScopedLock<true> Guard(*SignalsMutex);
242  std::vector<std::string>& FilesToRemoveRef = *FilesToRemove;
243  std::string *OldPtr =
244  FilesToRemoveRef.empty() ? nullptr : &FilesToRemoveRef[0];
245  FilesToRemoveRef.push_back(Filename);
246 
247  // We want to call 'c_str()' on every std::string in this vector so that if
248  // the underlying implementation requires a re-allocation, it happens here
249  // rather than inside of the signal handler. If we see the vector grow, we
250  // have to call it on every entry. If it remains in place, we only need to
251  // call it on the latest one.
252  if (OldPtr == &FilesToRemoveRef[0])
253  FilesToRemoveRef.back().c_str();
254  else
255  for (unsigned i = 0, e = FilesToRemoveRef.size(); i != e; ++i)
256  FilesToRemoveRef[i].c_str();
257  }
258 
259  RegisterHandlers();
260  return false;
261 }
262 
263 // DontRemoveFileOnSignal - The public API
265  sys::SmartScopedLock<true> Guard(*SignalsMutex);
266  std::vector<std::string>::reverse_iterator RI =
267  std::find(FilesToRemove->rbegin(), FilesToRemove->rend(), Filename);
268  std::vector<std::string>::iterator I = FilesToRemove->end();
269  if (RI != FilesToRemove->rend())
270  I = FilesToRemove->erase(RI.base()-1);
271 
272  // We need to call c_str() on every element which would have been moved by
273  // the erase. These elements, in a C++98 implementation where c_str()
274  // requires a reallocation on the first call may have had the call to c_str()
275  // made on insertion become invalid by being copied down an element.
276  for (std::vector<std::string>::iterator E = FilesToRemove->end(); I != E; ++I)
277  I->c_str();
278 }
279 
280 /// AddSignalHandler - Add a function to be called when a signal is delivered
281 /// to the process. The handler can have a cookie passed to it to identify
282 /// what instance of the handler it is.
283 void llvm::sys::AddSignalHandler(void (*FnPtr)(void *), void *Cookie) {
284  CallBacksToRun->push_back(std::make_pair(FnPtr, Cookie));
285  RegisterHandlers();
286 }
287 
288 #if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES)
289 
290 #if HAVE_LINK_H && (defined(__linux__) || defined(__FreeBSD__) || \
291  defined(__FreeBSD_kernel__) || defined(__NetBSD__))
292 struct DlIteratePhdrData {
293  void **StackTrace;
294  int depth;
295  bool first;
296  const char **modules;
297  intptr_t *offsets;
298  const char *main_exec_name;
299 };
300 
301 static int dl_iterate_phdr_cb(dl_phdr_info *info, size_t size, void *arg) {
302  DlIteratePhdrData *data = (DlIteratePhdrData*)arg;
303  const char *name = data->first ? data->main_exec_name : info->dlpi_name;
304  data->first = false;
305  for (int i = 0; i < info->dlpi_phnum; i++) {
306  const auto *phdr = &info->dlpi_phdr[i];
307  if (phdr->p_type != PT_LOAD)
308  continue;
309  intptr_t beg = info->dlpi_addr + phdr->p_vaddr;
310  intptr_t end = beg + phdr->p_memsz;
311  for (int j = 0; j < data->depth; j++) {
312  if (data->modules[j])
313  continue;
314  intptr_t addr = (intptr_t)data->StackTrace[j];
315  if (beg <= addr && addr < end) {
316  data->modules[j] = name;
317  data->offsets[j] = addr - info->dlpi_addr;
318  }
319  }
320  }
321  return 0;
322 }
323 
324 static bool findModulesAndOffsets(void **StackTrace, int Depth,
325  const char **Modules, intptr_t *Offsets,
326  const char *MainExecutableName) {
327  DlIteratePhdrData data = {StackTrace, Depth, true,
328  Modules, Offsets, MainExecutableName};
329  dl_iterate_phdr(dl_iterate_phdr_cb, &data);
330  return true;
331 }
332 #else
333 static bool findModulesAndOffsets(void **StackTrace, int Depth,
334  const char **Modules, intptr_t *Offsets,
335  const char *MainExecutableName) {
336  return false;
337 }
338 #endif
339 
340 static bool printSymbolizedStackTrace(void **StackTrace, int Depth,
341  llvm::raw_ostream &OS) {
342  // FIXME: Subtract necessary number from StackTrace entries to turn return addresses
343  // into actual instruction addresses.
344  // Use llvm-symbolizer tool to symbolize the stack traces.
345  ErrorOr<std::string> LLVMSymbolizerPathOrErr =
346  sys::findProgramByName("llvm-symbolizer");
347  if (!LLVMSymbolizerPathOrErr)
348  return false;
349  const std::string &LLVMSymbolizerPath = *LLVMSymbolizerPathOrErr;
350  // We don't know argv0 or the address of main() at this point, but try
351  // to guess it anyway (it's possible on some platforms).
352  std::string MainExecutableName = sys::fs::getMainExecutable(nullptr, nullptr);
353  if (MainExecutableName.empty() ||
354  MainExecutableName.find("llvm-symbolizer") != std::string::npos)
355  return false;
356 
357  std::vector<const char *> Modules(Depth, nullptr);
358  std::vector<intptr_t> Offsets(Depth, 0);
359  if (!findModulesAndOffsets(StackTrace, Depth, Modules.data(), Offsets.data(),
360  MainExecutableName.c_str()))
361  return false;
362  int InputFD;
363  SmallString<32> InputFile, OutputFile;
364  sys::fs::createTemporaryFile("symbolizer-input", "", InputFD, InputFile);
365  sys::fs::createTemporaryFile("symbolizer-output", "", OutputFile);
366  FileRemover InputRemover(InputFile.c_str());
367  FileRemover OutputRemover(OutputFile.c_str());
368 
369  {
370  raw_fd_ostream Input(InputFD, true);
371  for (int i = 0; i < Depth; i++) {
372  if (Modules[i])
373  Input << Modules[i] << " " << (void*)Offsets[i] << "\n";
374  }
375  }
376 
377  StringRef InputFileStr(InputFile);
378  StringRef OutputFileStr(OutputFile);
379  StringRef StderrFileStr;
380  const StringRef *Redirects[] = {&InputFileStr, &OutputFileStr,
381  &StderrFileStr};
382  const char *Args[] = {"llvm-symbolizer", "--functions=linkage", "--inlining",
383  "--demangle", nullptr};
384  int RunResult =
385  sys::ExecuteAndWait(LLVMSymbolizerPath, Args, nullptr, Redirects);
386  if (RunResult != 0)
387  return false;
388 
389  auto OutputBuf = MemoryBuffer::getFile(OutputFile.c_str());
390  if (!OutputBuf)
391  return false;
392  StringRef Output = OutputBuf.get()->getBuffer();
394  Output.split(Lines, "\n");
395  auto CurLine = Lines.begin();
396  int frame_no = 0;
397  for (int i = 0; i < Depth; i++) {
398  if (!Modules[i]) {
399  OS << format("#%d %p\n", frame_no++, StackTrace[i]);
400  continue;
401  }
402  // Read pairs of lines (function name and file/line info) until we
403  // encounter empty line.
404  for (;;) {
405  if (CurLine == Lines.end())
406  return false;
407  StringRef FunctionName = *CurLine++;
408  if (FunctionName.empty())
409  break;
410  OS << format("#%d %p ", frame_no++, StackTrace[i]);
411  if (!FunctionName.startswith("??"))
412  OS << format("%s ", FunctionName.str().c_str());
413  if (CurLine == Lines.end())
414  return false;
415  StringRef FileLineInfo = *CurLine++;
416  if (!FileLineInfo.startswith("??"))
417  OS << format("%s", FileLineInfo.str().c_str());
418  else
419  OS << format("(%s+%p)", Modules[i], (void *)Offsets[i]);
420  OS << "\n";
421  }
422  }
423  return true;
424 }
425 #endif // defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES)
426 
427 // PrintStackTrace - In the case of a program crash or fault, print out a stack
428 // trace so that the user has an indication of why and where we died.
429 //
430 // On glibc systems we have the 'backtrace' function, which works nicely, but
431 // doesn't demangle symbols.
433 #if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES)
434  static void* StackTrace[256];
435  // Use backtrace() to output a backtrace on Linux systems with glibc.
436  int depth = backtrace(StackTrace,
437  static_cast<int>(array_lengthof(StackTrace)));
438  if (printSymbolizedStackTrace(StackTrace, depth, OS))
439  return;
440 #if HAVE_DLFCN_H && __GNUG__
441  int width = 0;
442  for (int i = 0; i < depth; ++i) {
443  Dl_info dlinfo;
444  dladdr(StackTrace[i], &dlinfo);
445  const char* name = strrchr(dlinfo.dli_fname, '/');
446 
447  int nwidth;
448  if (!name) nwidth = strlen(dlinfo.dli_fname);
449  else nwidth = strlen(name) - 1;
450 
451  if (nwidth > width) width = nwidth;
452  }
453 
454  for (int i = 0; i < depth; ++i) {
455  Dl_info dlinfo;
456  dladdr(StackTrace[i], &dlinfo);
457 
458  OS << format("%-2d", i);
459 
460  const char* name = strrchr(dlinfo.dli_fname, '/');
461  if (!name) OS << format(" %-*s", width, dlinfo.dli_fname);
462  else OS << format(" %-*s", width, name+1);
463 
464  OS << format(" %#0*lx", (int)(sizeof(void*) * 2) + 2,
465  (unsigned long)StackTrace[i]);
466 
467  if (dlinfo.dli_sname != nullptr) {
468  OS << ' ';
469 # if HAVE_CXXABI_H
470  int res;
471  char* d = abi::__cxa_demangle(dlinfo.dli_sname, nullptr, nullptr, &res);
472 # else
473  char* d = NULL;
474 # endif
475  if (!d) OS << dlinfo.dli_sname;
476  else OS << d;
477  free(d);
478 
479  // FIXME: When we move to C++11, use %t length modifier. It's not in
480  // C++03 and causes gcc to issue warnings. Losing the upper 32 bits of
481  // the stack offset for a stack dump isn't likely to cause any problems.
482  OS << format(" + %u",(unsigned)((char*)StackTrace[i]-
483  (char*)dlinfo.dli_saddr));
484  }
485  OS << '\n';
486  }
487 #else
488  backtrace_symbols_fd(StackTrace, depth, STDERR_FILENO);
489 #endif
490 #endif
491 }
492 
493 static void PrintStackTraceSignalHandler(void *) {
495 }
496 
498 
499 /// PrintStackTraceOnErrorSignal - When an error signal (such as SIGABRT or
500 /// SIGSEGV) is delivered to the process, print a stack trace and then exit.
501 void llvm::sys::PrintStackTraceOnErrorSignal(bool DisableCrashReporting) {
502  AddSignalHandler(PrintStackTraceSignalHandler, nullptr);
503 
504 #if defined(__APPLE__) && defined(ENABLE_CRASH_OVERRIDES)
505  // Environment variable to disable any kind of crash dialog.
506  if (DisableCrashReporting || getenv("LLVM_DISABLE_CRASH_REPORT")) {
507  mach_port_t self = mach_task_self();
508 
509  exception_mask_t mask = EXC_MASK_CRASH;
510 
511  kern_return_t ret = task_set_exception_ports(self,
512  mask,
513  MACH_PORT_NULL,
514  EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES,
515  THREAD_STATE_NONE);
516  (void)ret;
517  }
518 #endif
519 }
520 
521 
522 /***/
523 
524 // On Darwin, raise sends a signal to the main thread instead of the current
525 // thread. This has the unfortunate effect that assert() and abort() will end up
526 // bypassing our crash recovery attempts. We work around this for anything in
527 // the same linkage unit by just defining our own versions of the assert handler
528 // and abort.
529 
530 #if defined(__APPLE__) && defined(ENABLE_CRASH_OVERRIDES)
531 
532 #include <signal.h>
533 #include <pthread.h>
534 
535 int raise(int sig) {
536  return pthread_kill(pthread_self(), sig);
537 }
538 
539 void __assert_rtn(const char *func,
540  const char *file,
541  int line,
542  const char *expr) {
543  if (func)
544  fprintf(stderr, "Assertion failed: (%s), function %s, file %s, line %d.\n",
545  expr, func, file, line);
546  else
547  fprintf(stderr, "Assertion failed: (%s), file %s, line %d.\n",
548  expr, file, line);
549  abort();
550 }
551 
552 void abort() {
553  raise(SIGABRT);
554  usleep(1000);
555  __builtin_trap();
556 }
557 
558 #endif
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:240
void PrintStackTraceOnErrorSignal(bool DisableCrashReporting=false)
When an error signal (such as SIBABRT or SIGSEGV) is delivered to the process, print a stack trace an...
Represents either an error or a value T.
Definition: ErrorOr.h:82
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition: StringRef.h:450
Offsets
Offsets in bytes from the start of the input buffer.
Definition: SIInstrInfo.h:378
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:188
void DisableSystemDialogsOnCrash()
Disable all system dialog boxes that appear when the process crashes.
const_iterator begin(StringRef path)
Get begin iterator over path.
Definition: Path.cpp:232
FileRemover - This class is a simple object meant to be stack allocated.
Definition: FileUtilities.h:40
ErrorOr< std::string > findProgramByName(StringRef Name, ArrayRef< StringRef > Paths=ArrayRef< StringRef >())
Find the first executable file Name in Paths.
lazy value info
Number of individual test Apply this number of consecutive mutations to each input exit after the first new interesting input is found the minimized corpus is saved into the first input directory Number of jobs to run If Reload the main corpus periodically to get new units discovered by other processes Read the given input file
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:25
int ExecuteAndWait(StringRef Program, const char **args, const char **env=nullptr, const StringRef **redirects=nullptr, unsigned secondsToWait=0, unsigned memoryLimit=0, std::string *ErrMsg=nullptr, bool *ExecutionFailed=nullptr)
This function executes the program using the arguments provided.
Definition: Program.cpp:30
std::string getMainExecutable(const char *argv0, void *MainExecAddr)
Return the path to the main executable, given the value of argv[0] from program startup and the addre...
format_object< Ts...> format(const char *Fmt, const Ts &...Vals)
These are helper functions used to produce formatted output.
Definition: Format.h:111
LLVM_CONSTEXPR size_t array_lengthof(T(&)[N])
Find the length of an array.
Definition: STLExtras.h:247
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
void PrintStackTrace(raw_ostream &OS)
Print the stack trace using the given raw_ostream object.
void RunInterruptHandlers()
This function runs all the registered interrupt handlers, including the removal of files registered b...
A pared-down imitation of std::unique_lock from C++11.
Definition: UniqueLock.h:28
void DontRemoveFileOnSignal(StringRef Filename)
This function removes a file from the list of files to be removed on signal delivery.
SmallVectorImpl< T >::const_pointer c_str(SmallVectorImpl< T > &str)
bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:215
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:861
bool RemoveFileOnSignal(StringRef Filename, std::string *ErrMsg=nullptr)
This function registers signal handlers to ensure that if a signal gets delivered that the named file...
A raw_ostream that writes to a file descriptor.
Definition: raw_ostream.h:345
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatileSize=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix, int &ResultFD, SmallVectorImpl< char > &ResultPath)
Create a file in the system temporary directory.
Definition: Path.cpp:713
const char * c_str()
Definition: SmallString.h:270
#define I(x, y, z)
Definition: MD5.cpp:54
void size_t size
static const char * name
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
Definition: ManagedStatic.h:61
void SetInterruptFunction(void(*IF)())
This function registers a function to be called when the user "interrupts" the program (typically by ...
void AddSignalHandler(void(*FnPtr)(void *), void *Cookie)
AddSignalHandler - Add a function to be called when an abort/kill signal is delivered to the process...
void * addr
bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:110