⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linux_syscall_support.h

📁 能把所有线程的数据和环境记录到文件,方便调试.
💻 H
📖 第 1 页 / 共 4 页
字号:
/* Copyright (c) 2005-2007, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * *     * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. *     * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. *     * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * --- * Author: Markus Gutschke *//* This file includes Linux-specific support functions common to the * coredumper and the thread lister; primarily, this is a collection * of direct system calls, and a couple of symbols missing from * standard header files. * There are a few options that the including file can set to control * the behavior of this file: * * SYS_CPLUSPLUS: *   The entire header file will normally be wrapped in 'extern "C" { }", *   making it suitable for compilation as both C and C++ source. If you *   do not want to do this, you can set the SYS_CPLUSPLUS macro to inhibit *   the wrapping. N.B. doing so will suppress inclusion of all prerequisite *   system header files, too. It is the caller's responsibility to provide *   the necessary definitions. * * SYS_ERRNO: *   All system calls will update "errno" unless overriden by setting the *   SYS_ERRNO macro prior to including this file. SYS_ERRNO should be *   an l-value. * * SYS_INLINE: *   New symbols will be defined "static inline", unless overridden by *   the SYS_INLINE macro. * * SYS_LINUX_SYSCALL_SUPPORT_H *   This macro is used to avoid multiple inclusions of this header file. *   If you need to include this file more than once, make sure to *   unset SYS_LINUX_SYSCALL_SUPPORT_H before each inclusion. * * SYS_PREFIX: *   New system calls will have a prefix of "sys_" unless overridden by *   the SYS_PREFIX macro. Valid values for this macro are [0..9] which *   results in prefixes "sys[0..9]_". It is also possible to set this *   macro to -1, which avoids all prefixes. * * This file defines a few internal symbols that all start with "LSS_". * Do not access these symbols from outside this file. They are not part * of the supported API. */#ifndef SYS_LINUX_SYSCALL_SUPPORT_H#define SYS_LINUX_SYSCALL_SUPPORT_H/* We currently only support x86-32, x86-64, and ARM on Linux. Porting to * other related platforms should not be difficult. */#if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__)) && \    defined(__linux)#ifndef SYS_CPLUSPLUS#ifdef __cplusplus/* Some system header files in older versions of gcc neglect to properly * handle being included from C++. As it appears to be harmless to have * multiple nested 'extern "C"' blocks, just add another one here. */extern "C" {#endif#include <errno.h>#include <signal.h>#include <stdarg.h>#include <sys/ptrace.h>#include <sys/resource.h>#include <sys/time.h>#include <sys/types.h>#include <syscall.h>#include <unistd.h>#include <linux/unistd.h>/* libc defines versions of stat, dirent, and dirent64 that are incompatible * with the structures that the kernel API expects. If you wish to use * sys_fstat(), sys_stat(), sys_getdents(), or sys_getdents64(), you will * need to include the kernel headers in your code. * *   asm/posix_types.h *   asm/stat.h *   asm/types.h *   linux/dirent.h */struct dirent64;struct dirent;struct iovec;struct msghdr;struct pollfd;struct rlimit;struct sockaddr;struct stat;struct stat64;#endif/* Definitions missing from the standard header files                        */#ifndef O_DIRECTORY#if defined(__ARM_ARCH_3__)#define O_DIRECTORY             0040000#else#define O_DIRECTORY             0200000#endif#endif#ifndef NT_PRXFPREG#define NT_PRXFPREG             0x46e62b7f#endif#ifndef PTRACE_GETFPXREGS#define PTRACE_GETFPXREGS       ((enum __ptrace_request)18)#endif#ifndef PR_GET_DUMPABLE#define PR_GET_DUMPABLE         3#endif#ifndef PR_SET_DUMPABLE#define PR_SET_DUMPABLE         4#endif#ifndef AT_FDCWD#define AT_FDCWD                (-100)#endif#ifndef AT_SYMLINK_NOFOLLOW#define AT_SYMLINK_NOFOLLOW     0x100#endif#ifndef AT_REMOVEDIR#define AT_REMOVEDIR            0x200#endif#if defined(__i386__)#ifndef __NR_ugetrlimit#define __NR_ugetrlimit         191#endif#ifndef __NR_getdents64#define __NR_getdents64         220#endif#ifndef __NR_gettid#define __NR_gettid             224#endif#ifndef __NR_futex#define __NR_futex              240#endif#ifndef __NR_sched_setaffinity#define __NR_sched_setaffinity  241#define __NR_sched_getaffinity  242#endif#ifndef __NR_setresuid#define __NR_setresuid          164#define __NR_setresgid          170#endif#ifndef __NR_setresuid32#define __NR_setresuid32        208#define __NR_setresgid32        210#endif#ifndef __NR_setfsuid32#define __NR_setfsuid32         215#define __NR_setfsgid32         216#endif#ifndef __NR_set_tid_address#define __NR_set_tid_address    258#endif#ifndef __NR_openat#define __NR_openat             295#endif#ifndef __NR_fstatat64#define __NR_fstatat64          300#endif#ifndef __NR_unlinkat#define __NR_unlinkat           301#endif/* End of i386 definitions                                                   */#elif defined(__ARM_ARCH_3__)#ifndef __NR_ugetrlimit#define __NR_ugetrlimit         (__NR_SYSCALL_BASE + 191)#endif#ifndef __NR_getdents64#define __NR_getdents64         (__NR_SYSCALL_BASE + 217)#endif#ifndef __NR_gettid#define __NR_gettid             (__NR_SYSCALL_BASE + 224)#endif#ifndef __NR_futex#define __NR_futex              (__NR_SYSCALL_BASE + 240)#endif#ifndef __NR_sched_setaffinity#define __NR_sched_setaffinity  (__NR_SYSCALL_BASE + 241)#define __NR_sched_getaffinity  (__NR_SYSCALL_BASE + 242)#endif#ifndef __NR_setresuid#define __NR_setresuid          (__NR_SYSCALL_BASE + 164)#define __NR_setresgid          (__NR_SYSCALL_BASE + 170)#endif#ifndef __NR_setresuid32#define __NR_setresuid32        (__NR_SYSCALL_BASE + 208)#define __NR_setresgid32        (__NR_SYSCALL_BASE + 210)#endif#ifndef __NR_setfsuid32#define __NR_setfsuid32         (__NR_SYSCALL_BASE + 215)#define __NR_setfsgid32         (__NR_SYSCALL_BASE + 216)#endif#ifndef __NR_set_tid_address#define __NR_set_tid_address    (__NR_SYSCALL_BASE + 256)#endif/* End of ARM 3 definitions                                                  */#elif defined(__x86_64__)#ifndef __NR_getdents64#define __NR_getdents64         217#endif#ifndef __NR_gettid#define __NR_gettid             186#endif#ifndef __NR_futex#define __NR_futex              202#endif#ifndef __NR_sched_setaffinity#define __NR_sched_setaffinity  203#define __NR_sched_getaffinity  204#endif#ifndef __NR_setresuid#define __NR_setresuid          117#define __NR_setresgid          119#endif#ifndef __NR_set_tid_address#define __NR_set_tid_address    218#endif#ifndef __NR_openat#define __NR_openat             257#endif#ifndef __NR_newfstatat#define __NR_newfstatat         262#endif#ifndef __NR_unlinkat#define __NR_unlinkat           263#endif/* End of x86-64 definitions                                                 */#endif/* After forking, we must make sure to only call system calls.               */#if __BOUNDED_POINTERS__  #error "Need to port invocations of syscalls for bounded ptrs"#else  /* The core dumper and the thread lister get executed after threads   * have been suspended. As a consequence, we cannot call any functions   * that acquire locks. Unfortunately, libc wraps most system calls   * (e.g. in order to implement pthread_atfork, and to make calls   * cancellable), which means we cannot call these functions. Instead,   * we have to call syscall() directly.   */  #undef LSS_ERRNO  #ifdef SYS_ERRNO    /* Allow the including file to override the location of errno. This can     * be useful when using clone() with the CLONE_VM option.     */    #define LSS_ERRNO SYS_ERRNO  #else

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -