1 //===-- sanitizer_linux.h ---------------------------------------*- 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 // Linux-specific syscall wrappers and classes. 11 // 12 //===----------------------------------------------------------------------===// 13 #ifndef SANITIZER_LINUX_H 14 #define SANITIZER_LINUX_H 15 16 #include "sanitizer_internal_defs.h" 17 18 struct sigaltstack; 19 20 namespace __sanitizer { 21 // Dirent structure for getdents(). Note that this structure is different from 22 // the one in <dirent.h>, which is used by readdir(). 23 struct linux_dirent; 24 25 // Syscall wrappers. 26 int internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count); 27 int internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5); 28 int internal_sigaltstack(const struct sigaltstack *ss, struct sigaltstack *oss); 29 30 // This class reads thread IDs from /proc/<pid>/task using only syscalls. 31 class ThreadLister { 32 public: 33 explicit ThreadLister(int pid); 34 ~ThreadLister(); 35 // GetNextTID returns -1 if the list of threads is exhausted, or if there has 36 // been an error. 37 int GetNextTID(); 38 void Reset(); 39 bool error(); 40 41 private: 42 bool GetDirectoryEntries(); 43 44 int pid_; 45 int descriptor_; 46 char buffer_[4096]; 47 bool error_; 48 struct linux_dirent* entry_; 49 int bytes_read_; 50 }; 51 } // namespace __sanitizer 52 53 #endif // SANITIZER_LINUX_H 54