Crashpad
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
crashpad Namespace Reference

The main namespace. More...

Namespaces

 internal
 The internal namespace, not for public use.
 
 test
 The testing namespace, for use in test code only.
 

Classes

class  AgePruneCondition
 A PruneCondition that deletes reports older than the specified number days. More...
 
struct  AlignedAllocator
 A standard allocator that aligns its allocations as requested, suitable for use as an allocator in standard containers. More...
 
class  Annotation
 Base class for an annotation, which records a name-value pair of arbitrary data when set. More...
 
class  AnnotationList
 A list that contains all the currently set annotations. More...
 
struct  AnnotationSnapshot
 
class  AuxiliaryVector
 Read the auxiliary vector for a target process. More...
 
class  Base94OutputStream
 This class implements Base94 encoding/decoding, it uses all printable characters except space for encoding, and no padding is required. More...
 
class  BinaryPruneCondition
 A PruneCondition that conjoins two other PruneConditions. More...
 
class  CheckedRange
 Ensures that a range, composed of a base and size, does not overflow its data type. More...
 
class  ChildPortHandshake
 Implements a handshake protocol that allows processes to exchange port rights. More...
 
class  ChildPortServer
 A server interface for the child_port Mach subsystem. More...
 
struct  ClientToServerMessage
 The message passed from client to server by SendToCrashHandlerServer(). More...
 
struct  CodeViewRecordBuildID
 A CodeView record containing an ELF build-id. More...
 
struct  CodeViewRecordPDB20
 A CodeView record linking to a .pdb 2.0 file. More...
 
struct  CodeViewRecordPDB70
 A CodeView record linking to a .pdb 7.0 file. More...
 
class  CompositeHTTPBodyStream
 An implementation of HTTPBodyStream that combines an array of several other HTTPBodyStream objects into a single, unified stream. More...
 
class  CompositeMachMessageServer
 Adapts multiple MachMessageServer::Interface implementations for simultaneous use in a single MachMessageServer::Run() call. More...
 
struct  CPUContext
 A context structure capable of carrying the context of any supported CPU architecture. More...
 
struct  CPUContextARM
 A context structure carrying ARM CPU state. More...
 
struct  CPUContextARM64
 A context structure carrying ARM64 CPU state. More...
 
struct  CPUContextMIPS
 A context structure carrying MIPS CPU state. More...
 
struct  CPUContextMIPS64
 A context structure carrying MIPS64 CPU state. More...
 
struct  CPUContextX86
 A context structure carrying 32-bit x86 CPU state. More...
 
struct  CPUContextX86_64
 A context structure carrying x86_64 CPU state. More...
 
class  CrashpadClient
 The primary interface for an application to have Crashpad monitor it for crashes. More...
 
struct  CrashpadInfo
 A structure that can be used by a Crashpad-enabled program to provide information to the Crashpad crash handler. More...
 
struct  CrashpadInfoClientOptions
 Options represented in a client’s CrashpadInfo structure. More...
 
class  CrashpadInfoReader
 Reads CrashpadInfo structs from another process via a ProcessMemoryRange. More...
 
class  CrashReportDatabase
 An interface for managing a collection of crash report files and metadata associated with the crash reports. More...
 
class  CrashReportDatabaseGeneric
 
class  CrashReportDatabaseMac
 A CrashReportDatabase that uses HFS+ extended attributes to store report metadata. More...
 
class  CrashReportDatabaseWin
 
class  CrashReportExceptionHandler
 An exception handler that writes crash reports for exceptions to a CrashReportDatabase. More...
 
class  CrashReportUploadThread
 A thread that processes pending crash reports in a CrashReportDatabase by uploading them or marking them as completed without upload, as desired. More...
 
class  CrosCrashReportExceptionHandler
 An exception handler that writes crash reports to the ChromeOS crash_reporter. More...
 
class  DatabaseSizePruneCondition
 A PruneCondition that deletes older reports to keep the total Crashpad database size under the specified limit. More...
 
class  DebugRendezvous
 Reads an r_debug struct defined in <link.h> via ProcessMemoryRange. More...
 
class  DelimitedFileReader
 Reads a file one field or line at a time. More...
 
class  DirectoryReader
 Iterates over the file and directory names in a directory. More...
 
class  DirectPtraceConnection
 Manages a direct ptrace connection to a process. More...
 
class  ElfDynamicArrayReader
 A reader for ELF dynamic arrays mapped into another process. More...
 
class  ElfImageReader
 A reader for ELF images mapped into another process. More...
 
class  ElfSymbolTableReader
 A reader for symbol tables in ELF images mapped into another process. More...
 
class  ExceptionHandlerClient
 A client for an ExceptionHandlerServer. More...
 
class  ExceptionHandlerProtocol
 
class  ExceptionHandlerServer
 Runs the main exception-handling server in Crashpad’s handler process. More...
 
struct  ExceptionInformation
 Structure read out of the client process by the crash handler when an exception occurs. More...
 
class  ExceptionPorts
 A better interface to *_get_exception_ports() and *_set_exception_ports(). More...
 
class  ExceptionSnapshot
 An abstract interface to a snapshot representing an exception that a snapshot process sustained and triggered the snapshot being taken. More...
 
class  FileEncoder
 The class is used to compress and base94-encode, or base94-decode and decompress the given input file to the output file. More...
 
class  FileOutputStream
 The class is used to write data to a file. More...
 
class  FileReader
 A file reader implementation that wraps traditional system file operations on files accessed through the filesystem. More...
 
class  FileReaderHTTPBodyStream
 An implementation of HTTPBodyStream that reads from a FileReaderInterface and provides its contents for an HTTP body. More...
 
class  FileReaderInterface
 An interface to read to files and other file-like objects with semantics matching the underlying platform (POSIX or Windows). More...
 
class  FileSeekerInterface
 An interface to seek in files and other file-like objects with semantics matching the underlying platform (POSIX or Windows). More...
 
class  FileWriter
 A file writer implementation that wraps traditional system file operations on files accessed through the filesystem. More...
 
class  FileWriterInterface
 An interface to write to files and other file-like objects with semantics matching the underlying platform (POSIX or Windows). More...
 
union  FloatContext
 The floating point registers used for an architecture family. More...
 
class  GzipHTTPBodyStream
 An implementation of HTTPBodyStream that gzip-compresses another HTTPBodyStream. More...
 
struct  HandleSnapshot
 
class  HTTPBodyStream
 An interface to a stream that can be used for an HTTP request body. More...
 
class  HTTPMultipartBuilder
 This class is used to build a MIME multipart message, conforming to RFC 2046, for use as a HTTP request body. More...
 
class  HTTPTransport
 HTTPTransport executes a HTTP request using the specified URL, HTTP method, headers, and body. This class can only issue a synchronous HTTP request. More...
 
class  ImageAnnotationReader
 Reads Annotations from another process via a ProcessMemoryRange. More...
 
class  InitialClientData
 A container for the data associated with the --initial-client-data method for initializing the handler process on Windows. More...
 
class  InitializationState
 Tracks whether data are initialized. More...
 
class  InitializationStateDcheck
 Tracks whether data are initialized, triggering a DCHECK assertion on an invalid data access. More...
 
class  IOSSystemDataCollector
 Used to collect system level data before a crash occurs. More...
 
class  LogOutputStream
 This class output the received data to Android log, NOP in other platform. More...
 
class  MachMessageServer
 Runs a Mach message server to handle a Mach RPC request for MIG servers. More...
 
class  MachOImageAnnotationsReader
 A reader for annotations stored in a Mach-O image mapped into another process. More...
 
class  MachOImageReader
 A reader for Mach-O images mapped into another process. More...
 
class  MachOImageSegmentReader
 A reader for LC_SEGMENT or LC_SEGMENT_64 load commands in Mach-O images mapped into another process. More...
 
class  MachOImageSymbolTableReader
 A reader for symbol tables in Mach-O images mapped into another process. More...
 
class  MemoryMap
 Accesses information about mapped memory in another process. More...
 
class  MemoryMapFuchsia
 A list of mappings in the address space of a Fuchsia process. More...
 
class  MemoryMapRegionSnapshot
 An abstract interface to a snapshot representing a region of the memory map present in the snapshot process. More...
 
class  MemorySnapshot
 An abstract interface to a snapshot representing a region of memory present in a snapshot process. More...
 
class  Metrics
 Container class to hold shared UMA metrics integration points. More...
 
struct  MinidumpAnnotation
 A typed annotation object. More...
 
struct  MinidumpAnnotationList
 A list of annotation objects. More...
 
class  MinidumpAnnotationListWriter
 The writer for a MinidumpAnnotationList object in a minidump file, containing a list of MinidumpAnnotation objects. More...
 
class  MinidumpAnnotationWriter
 The writer for a MinidumpAnnotation object in a minidump file. More...
 
struct  MinidumpByteArray
 A variable-length array of bytes carried within a minidump file. The data have no intrinsic type and should be interpreted according to their referencing context. More...
 
class  MinidumpByteArrayWriter
 Writes a variable-length byte array for a minidump into a. More...
 
struct  MinidumpContextAMD64
 An x86_64 (AMD64) CPU context (register state) carried in a minidump file. More...
 
class  MinidumpContextAMD64Writer
 The writer for a MinidumpContextAMD64 structure in a minidump file. More...
 
struct  MinidumpContextARM
 A 32-bit ARM CPU context (register state) carried in a minidump file. More...
 
struct  MinidumpContextARM64
 A 64-bit ARM CPU context (register state) carried in a minidump file. More...
 
class  MinidumpContextARM64Writer
 The writer for a MinidumpContextARM64 structure in a minidump file. More...
 
class  MinidumpContextARMWriter
 The writer for a MinidumpContextARM structure in a minidump file. More...
 
struct  MinidumpContextMIPS
 A 32bit MIPS CPU context (register state) carried in a minidump file. More...
 
struct  MinidumpContextMIPS64
 A 32bit MIPS CPU context (register state) carried in a minidump file. More...
 
class  MinidumpContextMIPS64Writer
 The writer for a MinidumpContextMIPS64 structure in a minidump file. More...
 
class  MinidumpContextMIPSWriter
 The writer for a MinidumpContextMIPS structure in a minidump file. More...
 
class  MinidumpContextWriter
 The base class for writers of CPU context structures in minidump files. More...
 
struct  MinidumpContextX86
 A 32-bit x86 CPU context (register state) carried in a minidump file. More...
 
class  MinidumpContextX86Writer
 The writer for a MinidumpContextX86 structure in a minidump file. More...
 
struct  MinidumpCrashpadInfo
 Additional Crashpad-specific information carried within a minidump file. More...
 
class  MinidumpCrashpadInfoWriter
 The writer for a MinidumpCrashpadInfo stream in a minidump file. More...
 
class  MinidumpExceptionWriter
 The writer for a MINIDUMP_EXCEPTION_STREAM stream in a minidump file. More...
 
class  MinidumpFileWriter
 The root-level object in a minidump file. More...
 
class  MinidumpHandleDataWriter
 The writer for a MINIDUMP_HANDLE_DATA_STREAM stream in a minidump and its contained MINIDUMP_HANDLE_DESCRIPTOR s. More...
 
class  MinidumpMemoryInfoListWriter
 The writer for a MINIDUMP_MEMORY_INFO_LIST stream in a minidump file, containing a list of MINIDUMP_MEMORY_INFO objects. More...
 
class  MinidumpMemoryListWriter
 The writer for a MINIDUMP_MEMORY_LIST stream in a minidump file, containing a list of MINIDUMP_MEMORY_DESCRIPTOR objects. More...
 
class  MinidumpMiscInfoWriter
 The writer for a stream in the MINIDUMP_MISC_INFO family in a minidump file. More...
 
class  MinidumpModuleCodeViewRecordBuildIDWriter
 The writer for a CodeViewRecordBuildID object in a minidump file. More...
 
class  MinidumpModuleCodeViewRecordPDB20Writer
 The writer for a CodeViewRecordPDB20 object in a minidump file. More...
 
class  MinidumpModuleCodeViewRecordPDB70Writer
 The writer for a CodeViewRecordPDB70 object in a minidump file. More...
 
class  MinidumpModuleCodeViewRecordWriter
 The base class for writers of CodeView records referenced by MINIDUMP_MODULE::CvRecord in minidump files. More...
 
struct  MinidumpModuleCrashpadInfo
 Additional Crashpad-specific information about a module carried within a minidump file. More...
 
struct  MinidumpModuleCrashpadInfoLink
 A link between a MINIDUMP_MODULE structure and additional Crashpad-specific information about a module carried within a minidump file. More...
 
struct  MinidumpModuleCrashpadInfoList
 Additional Crashpad-specific information about modules carried within a minidump file. More...
 
class  MinidumpModuleCrashpadInfoListWriter
 The writer for a MinidumpModuleCrashpadInfoList object in a minidump file, containing a list of MinidumpModuleCrashpadInfo objects. More...
 
class  MinidumpModuleCrashpadInfoWriter
 The writer for a MinidumpModuleCrashpadInfo object in a minidump file. More...
 
class  MinidumpModuleListWriter
 The writer for a MINIDUMP_MODULE_LIST stream in a minidump file, containing a list of MINIDUMP_MODULE objects. More...
 
class  MinidumpModuleMiscDebugRecordWriter
 The writer for an IMAGE_DEBUG_MISC object in a minidump file. More...
 
class  MinidumpModuleWriter
 The writer for a MINIDUMP_MODULE object in a minidump file. More...
 
struct  MinidumpRVAList
 A list of RVA pointers. More...
 
struct  MinidumpSimpleStringDictionary
 A list of key-value pairs. More...
 
struct  MinidumpSimpleStringDictionaryEntry
 A key-value pair. More...
 
class  MinidumpSimpleStringDictionaryEntryWriter
 The writer for a MinidumpSimpleStringDictionaryEntry object in a minidump file. More...
 
class  MinidumpSimpleStringDictionaryWriter
 The writer for a MinidumpSimpleStringDictionary object in a minidump file, containing a list of MinidumpSimpleStringDictionaryEntry objects. More...
 
class  MinidumpStream
 Stores a minidump stream along with its stream ID. More...
 
class  MinidumpSystemInfoWriter
 The writer for a MINIDUMP_SYSTEM_INFO stream in a minidump file. More...
 
class  MinidumpThreadListWriter
 The writer for a MINIDUMP_THREAD_LIST stream in a minidump file, containing a list of MINIDUMP_THREAD objects. More...
 
class  MinidumpThreadWriter
 The writer for a MINIDUMP_THREAD object in a minidump file. More...
 
class  MinidumpUnloadedModuleListWriter
 The writer for a MINIDUMP_UNLOADED_MODULE_LIST stream in a minidump file, containing a list of MINIDUMP_UNLOADED_MODULE objects. More...
 
class  MinidumpUnloadedModuleWriter
 The writer for a MINIDUMP_UNLOADED_MODULE object in a minidump file. More...
 
class  MinidumpUserExtensionStreamDataSource
 Describes a user extension data stream in a minidump. More...
 
class  MinidumpUserStreamWriter
 The writer for a MINIDUMP_USER_STREAM in a minidump file. More...
 
struct  MinidumpUTF8String
 A variable-length UTF-8-encoded string carried within a minidump file. More...
 
class  ModuleSnapshot
 An abstract interface to a snapshot representing a code module (binary image) loaded into a snapshot process. More...
 
class  NotifyServer
 A server interface for the notify Mach subsystem. More...
 
class  Paths
 Functions to obtain paths. More...
 
class  PEImageAnnotationsReader
 A reader of annotations stored in a PE image mapped into another process. More...
 
class  PEImageReader
 A reader for PE images mapped into another process. More...
 
class  PEImageResourceReader
 A reader for resources stored in PE images mapped into another process. More...
 
class  ProcessInfo
 Gathers information about a process given its HANDLE. This consists primarily of information stored in the Process Environment Block. More...
 
class  ProcessMemory
 Abstract base class for accessing the memory of another process. More...
 
class  ProcessMemoryFuchsia
 Accesses the memory of another Fuchsia process. More...
 
class  ProcessMemoryLinux
 Accesses the memory of another Linux process. More...
 
class  ProcessMemoryMac
 Accesses the memory of another Mach task. More...
 
class  ProcessMemoryRange
 Provides range protected access to the memory of another process. More...
 
class  ProcessMemorySanitized
 Sanitized access to the memory of another process. More...
 
class  ProcessMemoryWin
 Accesses the memory of another Windows process. More...
 
class  ProcessReaderFuchsia
 Accesses information about another process, identified by a Fuchsia process. More...
 
class  ProcessReaderLinux
 Accesses information about another process, identified by a process ID. More...
 
class  ProcessReaderMac
 Accesses information about another process, identified by a Mach task. More...
 
class  ProcessReaderWin
 Accesses information about another process, identified by a HANDLE. More...
 
class  ProcessSnapshot
 An abstract interface to a snapshot representing the state of a process. More...
 
class  ProcessSnapshotFuchsia
 A ProcessSnapshot of a running (or crashed) process running on a Fuchsia system. This class is not yet implemented. More...
 
class  ProcessSnapshotIOS
 A ProcessSnapshot of a running (or crashed) process running on a iphoneOS system. More...
 
class  ProcessSnapshotLinux
 A ProcessSnapshot of a running (or crashed) process running on a Linux system. More...
 
class  ProcessSnapshotMac
 A ProcessSnapshot of a running (or crashed) process running on a macOS system. More...
 
class  ProcessSnapshotMinidump
 A ProcessSnapshot based on a minidump file. More...
 
class  ProcessSnapshotSanitized
 A ProcessSnapshot which wraps and filters sensitive information from another ProcessSnapshot. More...
 
class  ProcessSnapshotWin
 A ProcessSnapshot of a running (or crashed) process running on a Windows system. More...
 
class  ProcessSubrangeReader
 A wrapper for ProcessReaderWin that only allows a specific subrange to be read from. More...
 
class  ProcStatReader
 Reads the /proc/[pid]/stat file for a thread. More...
 
class  PruneCondition
 An abstract base class for evaluating crash reports for deletion. More...
 
class  PruneCrashReportThread
 A thread that periodically prunes crash reports from the database using the specified condition. More...
 
class  PtraceBroker
 Implements a PtraceConnection over a socket. More...
 
class  PtraceClient
 Implements a PtraceConnection over a socket. More...
 
class  PtraceConnection
 Provides an interface for making ptrace requests against a process and its threads. More...
 
class  Ptracer
 Provides an architecturally agnostic interface for collecting information with ptrace. More...
 
class  PtraceStrategyDecider
 Abstract base class for deciding how the handler should ptrace a client. More...
 
class  RangeSet
 A set of VMAddress ranges. More...
 
struct  RegistrationRequest
 A client registration request. More...
 
struct  RegistrationResponse
 A client registration response. More...
 
struct  RTL_UNLOAD_EVENT_TRACE
 
struct  SanitizationInformation
 Struture containing information about how snapshots should be sanitized. More...
 
struct  SanitizationMemoryRangeWhitelist
 Describes a list of white listed memory ranges. More...
 
class  ScopedForbidReturn
 Asserts that a scope must not be exited while unsafe. More...
 
class  ScopedMmap
 Maintains a memory-mapped region created by mmap(). More...
 
class  ScopedProcessSuspend
 Manages the suspension of another process. More...
 
class  ScopedPrSetDumpable
 
class  ScopedPrSetPtracer
 
class  ScopedPtraceAttach
 Maintains a ptrace() attachment to a process. More...
 
struct  ScopedRegistryKeyCloseTraits
 
struct  ScopedRemoveFileTraits
 
class  ScopedSetEvent
 Calls SetEvent() on destruction at latest. More...
 
class  ScopedTaskSuspend
 Manages the suspension of another task. More...
 
class  Semaphore
 An anonymous in-process counting sempahore. More...
 
union  ServerToClientMessage
 The response sent back to the client via SendToCrashHandlerServer(). More...
 
class  SessionEndWatcher
 Creates a hidden window and waits for a WM_ENDSESSION message, indicating that the session is ending and the application should terminate. More...
 
class  Settings
 An interface for accessing and modifying the settings of a CrashReportDatabase. More...
 
struct  ShutdownRequest
 A message only sent to the server by itself to trigger shutdown. More...
 
class  Signals
 Utilities for handling POSIX signals. More...
 
class  SnapshotMinidumpMemoryWriter
 The base class for writers of memory ranges pointed to by MINIDUMP_MEMORY_DESCRIPTOR objects in a minidump file. More...
 
class  Stoppable
 An interface for operations that may be Started and Stopped. More...
 
class  StringAnnotation
 An. More...
 
class  StringFile
 A file reader and writer backed by a virtual file, as opposed to a file on disk or other operating system file descriptor-based file. More...
 
class  StringHTTPBodyStream
 An implementation of HTTPBodyStream that turns a fixed string into a stream. More...
 
class  SystemSnapshot
 An abstract interface to a snapshot representing the state of a system, comprising an operating system, CPU architecture, and various other characteristics. More...
 
struct  TestCrashpadInfo
 
class  Thread
 Basic thread abstraction. Users should derive from this class and implement ThreadMain(). More...
 
union  ThreadContext
 The set of general purpose registers for an architecture family. More...
 
struct  ThreadInfo
 A collection of ptrace-able information about a thread. More...
 
class  ThreadLogMessages
 Captures log messages produced on the current thread during an object’s lifetime. More...
 
class  ThreadSafeVector
 A wrapper for a std::vector<> that can be accessed safely from multiple threads. More...
 
class  ThreadSnapshot
 An abstract interface to a snapshot representing a thread (lightweight process) present in a snapshot process. More...
 
class  ToolSupport
 Common functions used by command line tools. More...
 
struct  Traits32
 
struct  Traits64
 
class  TSimpleAddressRangeBag
 A bag implementation using a fixed amount of storage, so that it does not perform any dynamic allocations for its operations. More...
 
class  TSimpleStringDictionary
 A map/dictionary collection implementation using a fixed amount of storage, so that it does not perform any dynamic allocations for its operations. More...
 
struct  uint128_struct
 Stores a 128-bit quantity. More...
 
class  UniversalMachExcServer
 A server interface for the exc and mach_exc Mach subsystems, unified to handle exceptions delivered to either subsystem, and simplified to have only a single interface method needing implementation. More...
 
class  UnixCredentialSocket
 Utilities for communicating over SO_PASSCRED enabled AF_UNIX sockets. More...
 
class  UnloadedModuleSnapshot
 Information about an unloaded module that was previously loaded into a snapshot process. More...
 
class  UserMinidumpStream
 Information describing a custom user data stream in a minidump. More...
 
class  UserStreamDataSource
 Extensibility interface for embedders who wish to add custom streams to minidumps. More...
 
struct  UUID
 A universally unique identifier (UUID). More...
 
class  WeakFileHandleFileReader
 A file reader backed by a FileHandle. More...
 
class  WeakFileHandleFileWriter
 A file writer backed by a FileHandle. More...
 
class  WorkerThread
 A WorkerThread executes its Delegate's DoWork method repeatedly on a dedicated thread at a set time interval. More...
 
struct  WritableIoVec
 A version of iovec with a const iov_base field. More...
 
class  ZlibOutputStream
 The class wraps zlib into OutputStreamInterface. More...
 

Typedefs

using SimpleAddressRangeBag = TSimpleAddressRangeBag< 64 >
 A TSimpleAddressRangeBag with default template parameters.
 
using SimpleStringDictionary = TSimpleStringDictionary< 256, 256, 64 >
 A TSimpleStringDictionary with default template parameters. More...
 
using UserStreamDataSources = std::vector< std::unique_ptr< UserStreamDataSource > >
 
using MinidumpUTF16StringListWriter = internal::MinidumpStringListWriter< internal::MinidumpUTF16StringWriter >
 
using MinidumpUTF8StringListWriter = internal::MinidumpStringListWriter< internal::MinidumpUTF8StringWriter >
 
using MinidumpThreadIDMap = std::map< uint64_t, uint32_t >
 A map that connects 64-bit snapshot thread IDs to 32-bit minidump thread IDs. More...
 
using FileHandle = int
 Platform-specific alias for a low-level file handle.
 
using FileOffset = off_t
 Platform-specific alias for a position in an open file.
 
using ScopedFileHandle = base::ScopedFD
 Scoped wrapper of a FileHandle.
 
using FileOperationResult = ssize_t
 The return value of read and write calls.
 
using ScopedRemoveFile = base::ScopedGeneric< base::FilePath, ScopedRemoveFileTraits >
 
using LinuxVMAddress = uint64_t
 Type used to represent an address in a process, potentially across bitness.
 
using LinuxVMSize = uint64_t
 Type used to represent the size of a memory range (with a LinuxVMAddress), potentially across bitness.
 
using LinuxVMOffset = int64_t
 Type used to represent an offset from a LinuxVMAddress, potentially across bitness.
 
using CheckedLinuxAddressRange = internal::CheckedAddressRangeGeneric< LinuxVMAddress, LinuxVMSize >
 Ensures that a range, composed of a base and a size, does not overflow the pointer type of the process it describes a range in. More...
 
using CheckedMachAddressRange = internal::CheckedAddressRangeGeneric< mach_vm_address_t, mach_vm_size_t >
 Ensures that a range, composed of a base and a size, does not overflow the pointer type of the process it describes a range in. More...
 
using ConstThreadState = const natural_t *
 A const version of thread_state_t. More...
 
using MachMessageDeadline = uint64_t
 The time before which a MachMessageWithDeadline() call should complete. More...
 
using VMAddress = uint64_t
 Type used to represent an address in a process, potentially across bitness.
 
using VMSize = uint64_t
 Type used to represent the size of a memory range (with a VMAddress), potentially across bitness.
 
using VMOffset = std::make_signed< VMSize >::type
 Type used to represent an offset from a VMAddress, potentially across bitness.
 
using SymbolicConstantToStringOptions = unsigned int
 A bitfield containing values of SymbolicConstantToStringOptionBits.
 
using StringToSymbolicConstantOptions = unsigned int
 A bitfield containing values of StringToSymbolicConstantOptionBits.
 
using HTTPHeaders = std::map< std::string, std::string >
 A map of HTTP header fields to their values.
 
using CheckedVMAddressRange = internal::CheckedAddressRangeGeneric< VMAddress, VMSize >
 Ensures that a range, composed of a base and a size, does not overflow the pointer type of the process it describes a range in. More...
 
using ScopedDIR = base::ScopedGeneric< DIR *, internal::ScopedDIRCloseTraits >
 Maintains a directory opened by opendir. More...
 
using ProcessID = pid_t
 Alias for platform-specific type to represent a process.
 
using ProcessMemoryNative = ProcessMemoryFuchsia
 Alias for platform-specific native implementation of ProcessMemory.
 
template<typename T , size_t Alignment = alignof(T)>
using AlignedVector = std::vector< T, AlignedAllocator< T, Alignment > >
 A std::vector using AlignedAllocator. More...
 
using WinVMAddress = uint64_t
 Type used to represent an address in a process, potentially across bitness.
 
using WinVMSize = uint64_t
 Type used to represent the size of a memory range (with a WinVMAddress), potentially across bitness.
 
using CheckedWinAddressRange = internal::CheckedAddressRangeGeneric< WinVMAddress, WinVMSize >
 Ensures that a range, composed of a base and a size, does not overflow the pointer type of the process it describes a range in. More...
 
using ScopedFileHANDLE = base::ScopedGeneric< HANDLE, internal::ScopedFileHANDLECloseTraits >
 
using ScopedKernelHANDLE = base::ScopedGeneric< HANDLE, internal::ScopedKernelHANDLECloseTraits >
 
using ScopedSearchHANDLE = base::ScopedGeneric< HANDLE, internal::ScopedSearchHANDLECloseTraits >
 
using ScopedLocalAlloc = base::ScopedGeneric< HLOCAL, internal::LocalAllocTraits >
 
using ScopedRegistryKey = base::ScopedGeneric< HKEY, ScopedRegistryKeyCloseTraits >
 

Enumerations

enum  MinidumpContextFlags : uint32_t
 Architecture-independent flags for context_flags fields in Minidump context structures. More...
 
enum  MinidumpContextX86Flags : uint32_t
 32-bit x86-specifc flags for MinidumpContextX86::context_flags. More...
 
enum  MinidumpContextAMD64Flags : uint32_t
 x86_64-specific flags for MinidumpContextAMD64::context_flags. More...
 
enum  MinidumpContextARMFlags : uint32_t
 32-bit ARM-specifc flags for MinidumpContextARM::context_flags. More...
 
enum  MinidumpContextARM64Flags : uint32_t
 64-bit ARM-specifc flags for MinidumpContextARM64::context_flags. More...
 
enum  MinidumpContextMIPSFlags : uint32_t
 32bit MIPS-specifc flags for MinidumpContextMIPS::context_flags. Based on minidump_cpu_mips.h from breakpad More...
 
enum  MinidumpContextMIPS64Flags : uint32_t
 64bit MIPS-specifc flags for MinidumpContextMIPS64::context_flags. Based on minidump_cpu_mips.h from breakpad More...
 
enum  MinidumpStreamType : uint32_t
 Minidump stream type values for MINIDUMP_DIRECTORY::StreamType. Each stream structure has a corresponding stream type value to identify it. More...
 
enum  MinidumpCPUArchitecture : uint16_t
 CPU type values for MINIDUMP_SYSTEM_INFO::ProcessorArchitecture. More...
 
enum  MinidumpOSType : uint8_t
 Operating system type values for MINIDUMP_SYSTEM_INFO::ProductType. More...
 
enum  MinidumpOS : uint32_t
 Operating system family values for MINIDUMP_SYSTEM_INFO::PlatformId. More...
 
enum  CPUArchitecture
 A system’s CPU architecture. More...
 
enum  ProcessSuspensionState : bool
 State of process being read by ProcessReaderWin. More...
 
enum  FileWriteMode
 Determines the mode that LoggingOpenFileForWrite() uses. More...
 
enum  FilePermissions : bool
 Determines the permissions bits for files created on POSIX systems. More...
 
enum  FileLocking : bool
 Determines the locking mode that LoggingLockFile() uses. More...
 
enum  StdioStream
 Determines the FileHandle that StdioFileHandle() returns. More...
 
enum  XattrStatus
 The result code for a ReadXattr operation. More...
 
enum  : mach_msg_timeout_t
 Special constants used as mach_msg_timeout_t values. More...
 
enum  : MachMessageDeadline
 Special constants used as MachMessageDeadline values. More...
 
enum  SymbolicConstantToStringOptionBits
 Options for various *ToString functions in symbolic_constants_* files. More...
 
enum  StringToSymbolicConstantOptionBits
 Options for various StringTo* functions in symbolic_constants_* files. More...
 
enum  TriState : uint8_t
 A tri-state value that can be unset, on, or off. More...
 
enum  
 
enum  
 
enum  TerminationCodes : unsigned int
 Crashpad-specific codes that are used as arguments to SafeTerminateProcess() or TerminateProcess() in unusual circumstances. More...
 
enum  
 

Functions

std::vector< std::string > BuildHandlerArgvStrings (const base::FilePath &handler, const base::FilePath &database, const base::FilePath &metrics_dir, const std::string &url, const std::map< std::string, std::string > &annotations, const std::vector< std::string > &arguments)
 Builds a vector of arguments suitable for invoking a handler process based on arguments passed to StartHandler-type(). More...
 
void StringVectorToCStringVector (const std::vector< std::string > &strings, std::vector< const char * > *c_strings)
 Flattens a string vector into a const char* vector suitable for use in an exec() call. More...
 
std::unique_ptr< CrashReportDatabaseInitializeInternal (const base::FilePath &path, bool may_create)
 
size_t PruneCrashReportDatabase (CrashReportDatabase *database, PruneCondition *condition)
 Deletes crash reports from database that match condition. More...
 
std::unique_ptr< PruneConditionGetDefaultDatabasePruneCondition ()
 
void SimulateCrash (const NativeCPUContext &cpu_context)
 Simulates a exception without crashing. More...
 
int CrashpadHandlerMain (int argc, char *argv[])
 
int HandlerMain (int argc, char *argv[], const UserStreamDataSources *user_stream_sources)
 The main() of the crashpad_handler binary. More...
 
bool CaptureSnapshot (PtraceConnection *connection, const ExceptionHandlerProtocol::ClientInformation &info, const std::map< std::string, std::string > &process_annotations, uid_t client_uid, VMAddress requesting_thread_stack_address, pid_t *requesting_thread_id, std::unique_ptr< ProcessSnapshotLinux > *process_snapshot, std::unique_ptr< ProcessSnapshotSanitized > *sanitized_snapshot)
 Captures a snapshot of a client over connection. More...
 
void RecordFileLimitAnnotation ()
 Records a "file-limits" simple annotation for the process. More...
 
std::map< std::string, std::string > BreakpadHTTPFormParametersFromMinidump (const ProcessSnapshot *process_snapshot)
 Given a ProcessSnapshot, returns a map of key-value pairs to use as HTTP form parameters for upload to a Breakpad crash report colleciton server. More...
 
void AddUserExtensionStreams (const UserStreamDataSources *user_stream_data_sources, ProcessSnapshot *process_snapshot, MinidumpFileWriter *minidump_file_writer)
 Adds user extension streams to a minidump. More...
 
void BuildMinidumpThreadIDMap (const std::vector< const ThreadSnapshot * > &thread_snapshots, MinidumpThreadIDMap *thread_id_map)
 Builds a MinidumpThreadIDMap for a group of ThreadSnapshot objects. More...
 
 DEFINE_GETTER (TriState, SystemCrashReporterForwarding, system_crash_reporter_forwarding) DEFINE_GETTER(TriState
 
gather_indirectly_referenced_memory DEFINE_GETTER (uint32_t, IndirectlyReferencedMemoryCap, indirectly_referenced_memory_cap) DEFINE_GETTER(VMAddress
 
bool IsMalformedCLKernelsModule (uint32_t mach_o_file_type, const std::string &module_name, bool *has_timestamp)
 Determines whether a module appears to be a malformed OpenCL cl_kernels module based on its name and Mach-O file type. More...
 
bool LoggingDetermineMergedRange (const MemorySnapshot *a, const MemorySnapshot *b, CheckedRange< uint64_t, size_t > *merged)
 Given two memory snapshots, checks if they're overlapping or abutting, and if so, returns the result of merging the two ranges. More...
 
bool DetermineMergedRange (const MemorySnapshot *a, const MemorySnapshot *b, CheckedRange< uint64_t, size_t > *merged)
 The same as LoggingDetermineMergedRange but with no errors logged. More...
 
bool ReadAnnotationsWhitelist (const ProcessMemoryRange &memory, VMAddress whitelist_address, std::vector< std::string > *whitelist)
 Reads an annotations whitelist from another process. More...
 
bool ReadMemoryRangeWhitelist (const ProcessMemoryRange &memory, VMAddress whitelist_address, std::vector< std::pair< VMAddress, VMAddress >> *whitelist)
 Reads a memory range whitelist from another process. More...
 
void InitializeX86Context (const CONTEXT &context, CPUContextX86 *out)
 Initializes a CPUContextX86 structure from a native context structure on Windows.
 
void InitializeX86Context (const WOW64_CONTEXT &context, CPUContextX86 *out)
 Initializes a CPUContextX86 structure from a native context structure on Windows.
 
void InitializeX64Context (const CONTEXT &context, CPUContextX86_64 *out)
 Initializes a CPUContextX86_64 structure from a native context structure on Windows.
 
void InitializeARM64Context (const CONTEXT &context, CPUContextARM64 *out)
 Initializes a CPUContextARM64 structure from a native context structure on Windows.
 
template bool PEImageReader::GetCrashpadInfo< process_types::internal::Traits32 > (process_types::CrashpadInfo< process_types::internal::Traits32 > *crashpad_info) const
 
template bool PEImageReader::GetCrashpadInfo< process_types::internal::Traits64 > (process_types::CrashpadInfo< process_types::internal::Traits64 > *crashpad_info) const
 
bool ReadFileExactly (FileHandle file, void *buffer, size_t size)
 Wraps ReadFile(), retrying following a short read, ensuring that exactly size bytes are read. More...
 
bool LoggingReadFileExactly (FileHandle file, void *buffer, size_t size)
 Wraps ReadFile(), retrying following a short read, ensuring that exactly size bytes are read. More...
 
bool WriteFile (FileHandle file, const void *buffer, size_t size)
 Writes to a file, retrying when interrupted on POSIX or following a short write. More...
 
bool LoggingWriteFile (FileHandle file, const void *buffer, size_t size)
 Wraps WriteFile(), ensuring that exactly size bytes are written. More...
 
void CheckedReadFileExactly (FileHandle file, void *buffer, size_t size)
 Wraps ReadFile(), ensuring that exactly size bytes are read. More...
 
void CheckedWriteFile (FileHandle file, const void *buffer, size_t size)
 Wraps WriteFile(), ensuring that exactly size bytes are written. More...
 
void CheckedReadFileAtEOF (FileHandle file)
 Wraps ReadFile(), ensuring that it indicates end-of-file. More...
 
bool LoggingReadToEOF (FileHandle file, std::string *contents)
 Wraps ReadFile() to read from the current file position to the end of the file into contents. More...
 
bool LoggingReadEntireFile (const base::FilePath &path, std::string *contents)
 Wraps LoggingOpenFileForRead() and ReadFile() reading the entire file into contents. More...
 
void CheckedCloseFile (FileHandle file)
 Wraps close() or CloseHandle(), ensuring that it succeeds. More...
 
FileOperationResult ReadFile (FileHandle file, void *buffer, size_t size)
 Reads from a file, retrying when interrupted before reading any data on POSIX. More...
 
FileHandle OpenFileForRead (const base::FilePath &path)
 Wraps open() or CreateFile(), opening an existing file for reading. More...
 
FileHandle OpenFileForWrite (const base::FilePath &path, FileWriteMode mode, FilePermissions permissions)
 Wraps open() or CreateFile(), creating a file for output. More...
 
FileHandle OpenFileForReadAndWrite (const base::FilePath &path, FileWriteMode mode, FilePermissions permissions)
 Wraps open() or CreateFile(), creating a file for both input and output. More...
 
FileHandle LoggingOpenFileForRead (const base::FilePath &path)
 Wraps OpenFileForRead(), logging an error if the operation fails. More...
 
FileHandle LoggingOpenFileForWrite (const base::FilePath &path, FileWriteMode mode, FilePermissions permissions)
 Wraps OpenFileForWrite(), logging an error if the operation fails. More...
 
FileHandle LoggingOpenFileForReadAndWrite (const base::FilePath &path, FileWriteMode mode, FilePermissions permissions)
 Wraps OpenFileForReadAndWrite(), logging an error if the operation fails. More...
 
bool LoggingLockFile (FileHandle file, FileLocking locking)
 Locks the given file using flock() on POSIX or LockFileEx() on Windows. More...
 
bool LoggingUnlockFile (FileHandle file)
 Unlocks a file previously locked with LoggingLockFile(). More...
 
FileOffset LoggingSeekFile (FileHandle file, FileOffset offset, int whence)
 Wraps lseek() or SetFilePointerEx(). Logs an error if the operation fails. More...
 
bool LoggingTruncateFile (FileHandle file)
 Truncates the given file to zero bytes in length. More...
 
bool LoggingCloseFile (FileHandle file)
 Wraps close() or CloseHandle(), logging an error if the operation fails. More...
 
FileOffset LoggingFileSizeByHandle (FileHandle file)
 Determines the size of a file. More...
 
FileHandle StdioFileHandle (StdioStream stdio_stream)
 Returns a FileHandle corresponding to the requested standard I/O stream. More...
 
bool FileModificationTime (const base::FilePath &path, timespec *mtime)
 Determines the modification time for a file, directory, or symbolic link, logging a message on failure. More...
 
bool LoggingCreateDirectory (const base::FilePath &path, FilePermissions permissions, bool may_reuse)
 Creates a directory, logging a message on failure. More...
 
bool MoveFileOrDirectory (const base::FilePath &source, const base::FilePath &dest)
 Moves a file, symbolic link, or directory, logging a message on failure. More...
 
bool IsRegularFile (const base::FilePath &path)
 Determines if a path refers to a regular file, logging a message on failure. More...
 
bool IsDirectory (const base::FilePath &path, bool allow_symlinks)
 Determines if a path refers to a directory, logging a message on failure. More...
 
bool LoggingRemoveFile (const base::FilePath &path)
 Removes a file or a symbolic link to a file or directory, logging a message on failure. More...
 
bool LoggingRemoveDirectory (const base::FilePath &path)
 Non-recurseively removes an empty directory, logging a message on failure. More...
 
std::vector< zx_koid_t > GetChildKoids (const zx::object_base &parent, zx_object_info_topic_t child_kind)
 Get a list of child koids for a parent handle. More...
 
std::vector< zx::thread > GetThreadHandles (const zx::process &parent)
 Get handles representing a list of child objects of a given parent. More...
 
std::vector< zx::thread > GetHandlesForThreadKoids (const zx::process &parent, const std::vector< zx_koid_t > &koids)
 Convert a list of koids that are all children of a particular process into thread handles. More...
 
zx::thread GetThreadHandleByKoid (const zx::process &parent, zx_koid_t child_koid)
 Retrieve the handle of a process' thread, based on koid. More...
 
zx_koid_t GetKoidForHandle (const zx::object_base &object)
 Retrieves the koid for a given object handle. More...
 
void InstallObjcExceptionPreprocessor ()
 Installs the Objective-C exception preprocessor. More...
 
void UninstallObjcExceptionPreprocessor ()
 
bool InitializeSignalDispositions ()
 Establishes signal dispositions for a process based on the platform. More...
 
bool ReadThreadIDs (pid_t pid, std::vector< pid_t > *tids)
 Enumerates the thread IDs of a process by reading /proc/pid/task. More...
 
launch_data_t CFPropertyToLaunchData (CFPropertyListRef property_cf)
 Converts a Core Foundation-type property list to a launchd-type launch_data_t. More...
 
int MacOSXMinorVersion ()
 Returns the version of the running operating system. More...
 
bool MacOSXVersion (int *major, int *minor, int *bugfix, std::string *build, bool *server, std::string *version_string)
 Returns the version of the running operating system. More...
 
void MacModelAndBoard (std::string *model, std::string *board_id)
 Returns the model name and board ID of the running system. More...
 
bool ServiceManagementSubmitJob (CFDictionaryRef job_cf)
 Submits a job to the user launchd domain as in SMJobSubmit(). More...
 
bool ServiceManagementRemoveJob (const std::string &label, bool wait)
 Removes a job from the user launchd domain as in SMJobRemove(). More...
 
bool ServiceManagementIsJobLoaded (const std::string &label)
 Determines whether a specified job is loaded in the user launchd domain. More...
 
pid_t ServiceManagementIsJobRunning (const std::string &label)
 Determines whether a specified job is running in the user launchd domain. More...
 
XattrStatus ReadXattr (const base::FilePath &file, const base::StringPiece &name, std::string *value)
 Reads an extended attribute on a file. More...
 
bool WriteXattr (const base::FilePath &file, const base::StringPiece &name, const std::string &value)
 Writes an extended attribute on a file. More...
 
XattrStatus ReadXattrBool (const base::FilePath &file, const base::StringPiece &name, bool *value)
 Reads an extended attribute on a file. More...
 
bool WriteXattrBool (const base::FilePath &file, const base::StringPiece &name, bool value)
 Writes an extended attribute on a file. More...
 
XattrStatus ReadXattrInt (const base::FilePath &file, const base::StringPiece &name, int *value)
 Reads an extended attribute on a file. More...
 
bool WriteXattrInt (const base::FilePath &file, const base::StringPiece &name, int value)
 Writes an extended attribute on a file. More...
 
XattrStatus ReadXattrTimeT (const base::FilePath &file, const base::StringPiece &name, time_t *value)
 Reads an extended attribute on a file. More...
 
bool WriteXattrTimeT (const base::FilePath &file, const base::StringPiece &name, time_t value)
 Writes an extended attribute on a file. More...
 
XattrStatus RemoveXattr (const base::FilePath &file, const base::StringPiece &name)
 Removes an extended attribute from a file. More...
 
base::mac::ScopedMachReceiveRight BootstrapCheckIn (const std::string &service_name)
 Makes a boostrap_check_in() call to the process’ bootstrap server. More...
 
base::mac::ScopedMachSendRight BootstrapLookUp (const std::string &service_name)
 Makes a boostrap_look_up() call to the process’ bootstrap server. More...
 
base::mac::ScopedMachSendRight SystemCrashReporterHandler ()
 Obtains the system’s default Mach exception handler for crash-type exceptions. More...
 
kern_return_t UniversalExceptionRaise (exception_behavior_t behavior, exception_handler_t exception_port, thread_t thread, task_t task, exception_type_t exception, const mach_exception_data_type_t *code, mach_msg_type_number_t code_count, thread_state_flavor_t *flavor, ConstThreadState old_state, mach_msg_type_number_t old_state_count, thread_state_t new_state, mach_msg_type_number_t *new_state_count)
 Calls the appropriate *exception_raise*() function for the specified behavior. More...
 
kern_return_t ExcServerSuccessfulReturnValue (exception_type_t exception, exception_behavior_t behavior, bool set_thread_state)
 Computes an approriate successful return value for an exception handler function. More...
 
void ExcServerCopyState (exception_behavior_t behavior, ConstThreadState old_state, mach_msg_type_number_t old_state_count, thread_state_t new_state, mach_msg_type_number_t *new_state_count)
 Copies the old state to the new state for state-carrying exceptions. More...
 
bool ExceptionBehaviorHasState (exception_behavior_t behavior)
 Determines whether behavior indicates an exception behavior that carries thread state information. More...
 
bool ExceptionBehaviorHasIdentity (exception_behavior_t behavior)
 Determines whether behavior indicates an exception behavior that carries thread and task identities. More...
 
bool ExceptionBehaviorHasMachExceptionCodes (exception_behavior_t behavior)
 Determines whether behavior indicates an exception behavior that carries 64-bit exception codes (“Mach exception codes”). More...
 
exception_behavior_t ExceptionBehaviorBasic (exception_behavior_t behavior)
 Returns the basic behavior value of behavior, its value without MACH_EXCEPTION_CODES set. More...
 
exception_type_t ExcCrashRecoverOriginalException (mach_exception_code_t code_0, mach_exception_code_t *original_code_0, int *signal)
 Recovers the original exception, first exception code, and signal from the encoded form of the first exception code delivered with EXC_CRASH exceptions. More...
 
bool ExcCrashCouldContainException (exception_type_t exception)
 Determines whether a given exception type could plausibly be carried within an EXC_CRASH exception. More...
 
int32_t ExceptionCodeForMetrics (exception_type_t exception, mach_exception_code_t code_0)
 Returns the exception code to report via a configured metrics system. More...
 
bool IsExceptionNonfatalResource (exception_type_t exception, mach_exception_code_t code_0, pid_t pid)
 Determines whether an exception is a non-fatal EXC_RESOURCE. More...
 
thread_t MachThreadSelf ()
 Like mach_thread_self(), but without the obligation to release the send right. More...
 
mach_port_t NewMachPort (mach_port_right_t right)
 Creates a new Mach port in the current task. More...
 
exception_mask_t ExcMaskAll ()
 The value for EXC_MASK_ALL appropriate for the operating system at run time. More...
 
exception_mask_t ExcMaskValid ()
 An exception mask containing every possible exception understood by the operating system at run time. More...
 
MachMessageDeadline MachMessageDeadlineFromTimeout (mach_msg_timeout_t timeout_ms)
 Computes the deadline for a specified timeout value. More...
 
mach_msg_return_t MachMessageWithDeadline (mach_msg_header_t *message, mach_msg_option_t options, mach_msg_size_t receive_size, mach_port_name_t receive_port, MachMessageDeadline deadline, mach_port_name_t notify_port, bool run_even_if_expired)
 Runs mach_msg() with a deadline, as opposed to a timeout. More...
 
void PrepareMIGReplyFromRequest (const mach_msg_header_t *in_header, mach_msg_header_t *out_header)
 Initializes a reply message for a MIG server routine based on its corresponding request. More...
 
void SetMIGReplyError (mach_msg_header_t *out_header, kern_return_t error)
 Sets the error code in a reply message for a MIG server routine. More...
 
const mach_msg_trailer_t * MachMessageTrailerFromHeader (const mach_msg_header_t *header)
 Returns a Mach message trailer for a message that has been received. More...
 
bool MachMessageDestroyReceivedPort (mach_port_t port, mach_msg_type_name_t port_right_type)
 Destroys or deallocates a Mach port received in a Mach message. More...
 
pid_t AuditPIDFromMachMessageTrailer (const mach_msg_trailer_t *trailer)
 Returns the process ID of a Mach message’s sender from its audit trailer. More...
 
std::string ExceptionToString (exception_type_t exception, SymbolicConstantToStringOptions options)
 Converts a Mach exception value to a textual representation. More...
 
bool StringToException (const base::StringPiece &string, StringToSymbolicConstantOptions options, exception_type_t *exception)
 Converts a string to its corresponding Mach exception value. More...
 
std::string ExceptionMaskToString (exception_mask_t exception_mask, SymbolicConstantToStringOptions options)
 Converts a Mach exception mask value to a textual representation. More...
 
bool StringToExceptionMask (const base::StringPiece &string, StringToSymbolicConstantOptions options, exception_mask_t *exception_mask)
 Converts a string to its corresponding Mach exception mask value. More...
 
std::string ExceptionBehaviorToString (exception_behavior_t behavior, SymbolicConstantToStringOptions options)
 Converts a Mach exception behavior value to a textual representation. More...
 
bool StringToExceptionBehavior (const base::StringPiece &string, StringToSymbolicConstantOptions options, exception_behavior_t *behavior)
 Converts a string to its corresponding Mach exception behavior value. More...
 
std::string ThreadStateFlavorToString (thread_state_flavor_t flavor, SymbolicConstantToStringOptions options)
 Converts a thread state flavor value to a textual representation. More...
 
bool StringToThreadStateFlavor (const base::StringPiece &string, StringToSymbolicConstantOptions options, thread_state_flavor_t *flavor)
 Converts a string to its corresponding thread state flavor value. More...
 
task_t TaskForPID (pid_t pid)
 Wraps task_for_pid(). More...
 
template<typename From >
constexpr std::underlying_type< From >::type AsUnderlyingType (From from)
 Casts a value to its underlying type. More...
 
void CaptureContext (NativeCPUContext *cpu_context)
 Saves the CPU context. More...
 
uint64_t ClockMonotonicNanoseconds ()
 Returns the value of the system’s monotonic clock. More...
 
void SleepNanoseconds (uint64_t nanoseconds)
 Sleeps for the specified duration. More...
 
template<typename To , typename From >
 FromPointerCast (From from)
 Casts from a pointer type to an integer. More...
 
template<typename To , typename From >
constexpr To implicit_cast (From const &f)
 
bool AdvancePastPrefix (const char **input, const char *pattern)
 Match a pattern at the start of a char string. More...
 
template<typename T >
bool AdvancePastNumber (const char **input, T *value)
 Convert a prefix of a char string to a numeric value. More...
 
template bool AdvancePastNumber (const char **input, int *value)
 
template bool AdvancePastNumber (const char **input, unsigned int *value)
 
template bool AdvancePastNumber (const char **input, int64_t *value)
 
template bool AdvancePastNumber (const char **input, uint64_t *value)
 
std::string RandomString ()
 Returns a random string. More...
 
template<typename From , typename To >
bool ReinterpretBytes (const From &from, To *to)
 Copies the bytes of from to to. More...
 
void AddTimespec (const timespec &ts1, const timespec &ts2, timespec *result)
 Add timespec ts1 and ts2 and return the result in result.
 
void SubtractTimespec (const timespec &ts1, const timespec &ts2, timespec *result)
 Subtract timespec ts2 from ts1 and return the result in result.
 
bool TimespecToTimeval (const timespec &ts, timeval *tv)
 Convert the timespec ts to a timeval tv. More...
 
void TimevalToTimespec (const timeval &tv, timespec *ts)
 Convert the timeval tv to a timespec ts.
 
FILETIME TimespecToFiletimeEpoch (const timespec &ts)
 Convert a timespec to a Windows FILETIME, converting from POSIX epoch to Windows epoch.
 
timespec FiletimeToTimespecEpoch (const FILETIME &filetime)
 Convert a Windows FILETIME to timespec, converting from Windows epoch to POSIX epoch.
 
timeval FiletimeToTimevalEpoch (const FILETIME &filetime)
 Convert Windows FILETIME to timeval, converting from Windows epoch to POSIX epoch.
 
timeval FiletimeToTimevalInterval (const FILETIME &filetime)
 Convert Windows FILETIME to timeval, treating the values as an interval of elapsed time.
 
void GetTimeOfDay (timeval *tv)
 Similar to POSIX gettimeofday(), gets the current system time in UTC.
 
bool GetBootTime (timespec *ts)
 Get the kernel boot time. Subsequent calls to this function may return different results due to the system clock being changed or imprecision in measuring the boot time. More...
 
int ZlibWindowBitsWithGzipWrapper (int window_bits)
 Obtain a window_bits parameter to pass to deflateInit2() or inflateInit2() that specifies a gzip wrapper instead of the default zlib wrapper. More...
 
std::string ZlibErrorString (int zr)
 Formats a string for an error received from the zlib library. More...
 
std::string URLEncode (const std::string &url)
 Performs percent-encoding (URL encoding) on the input string, following RFC 3986 paragraph 2. More...
 
bool CrackURL (const std::string &url, std::string *scheme, std::string *host, std::string *port, std::string *rest)
 Crack a URL into component parts. More...
 
template<typename Destination , typename Source >
Destination InRangeCast (Source source, Destination default_value)
 Casts to a different type if it can be done without data loss, logging a warning message and returing a default value otherwise. More...
 
template<typename Destination , typename Source >
bool AssignIfInRange (Destination *destination, Source source)
 Performs an assignment if it can be done safely, and signals if it cannot be done safely. More...
 
void CloseMultipleNowOrOnExec (int fd, int preserve_fd)
 Close multiple file descriptors or mark them close-on-exec. More...
 
void CloseStdinAndStdout ()
 Closes stdin and stdout by opening /dev/null over them. More...
 
bool DoubleForkAndExec (const std::vector< std::string > &argv, const std::vector< std::string > *envp, int preserve_fd, bool use_path, void(*child_function)())
 Executes a (grand-)child process. More...
 
void DropPrivileges ()
 Permanently drops privileges conferred by being a setuid or setgid executable. More...
 
std::string SignalToString (int signal, SymbolicConstantToStringOptions options)
 Converts a POSIX signal value to a textual representation. More...
 
bool StringToSignal (const base::StringPiece &string, StringToSymbolicConstantOptions options, int *signal)
 Converts a string to its corresponding POSIX signal value. More...
 
void * AlignedAllocate (size_t alignment, size_t size)
 Allocates memory with the specified alignment constraint. More...
 
void AlignedFree (void *pointer)
 Frees memory allocated by AlignedAllocate(). More...
 
template<class T1 , class T2 , size_t Alignment>
bool operator== (const AlignedAllocator< T1, Alignment > &lhs, const AlignedAllocator< T2, Alignment > &rhs) noexcept
 
template<class T1 , class T2 , size_t Alignment>
bool operator!= (const AlignedAllocator< T1, Alignment > &lhs, const AlignedAllocator< T2, Alignment > &rhs) noexcept
 
template<typename T >
bool MapInsertOrReplace (T *map, const typename T::key_type &key, const typename T::mapped_type &value, typename T::mapped_type *old_value)
 Inserts a mapping from key to value into map, or replaces an existing mapping so that key maps to value. More...
 
size_t c16lcpy (base::char16 *destination, const base::char16 *source, size_t length)
 Copy a NUL-terminated char16-based string to a fixed-size buffer. More...
 
size_t strnlen (const char *string, size_t max_length)
 Returns the length of a string, not to exceed a maximum. More...
 
bool SplitStringFirst (const std::string &string, char delimiter, std::string *left, std::string *right)
 Splits a string into two parts at the first delimiter found. More...
 
std::vector< std::string > SplitString (const std::string &string, char delimiter)
 Splits a string into multiple parts on the given delimiter. More...
 
void AppendCommandLineArgument (const std::wstring &argument, std::wstring *command_line)
 Utility function for building escaped command lines. More...
 
void * ProgramCounterFromCONTEXT (const CONTEXT *context)
 Retrieve program counter from CONTEXT structure for different architectures supported by Windows.
 
bool InitializeCriticalSectionWithDebugInfoIfPossible (CRITICAL_SECTION *critical_section)
 Equivalent to InitializeCritialSection(), but attempts to allocate with a valid .DebugInfo field on versions of Windows where it's possible to do so. More...
 
BOOL CrashpadGetModuleInformation (HANDLE process, HMODULE module, MODULEINFO *module_info, DWORD cb)
 Proxy function for GetModuleInformation().
 
int HandleToInt (HANDLE handle)
 Converts a HANDLE to an int. More...
 
HANDLE IntToHandle (int handle_int)
 Converts an int to an HANDLE. More...
 
bool IsThreadInLoaderLock ()
 
bool GetModuleVersionAndType (const base::FilePath &path, VS_FIXEDFILEINFO *vs_fixedfileinfo)
 Retrieve the type and version information from a given module (exe, dll, etc.) More...
 
NTSTATUS NtClose (HANDLE handle)
 
NTSTATUS NtCreateThreadEx (PHANDLE thread_handle, ACCESS_MASK desired_access, POBJECT_ATTRIBUTES object_attributes, HANDLE process_handle, PVOID start_routine, PVOID argument, ULONG create_flags, SIZE_T zero_bits, SIZE_T stack_size, SIZE_T maximum_stack_size, PVOID attribute_list)
 
NTSTATUS NtQuerySystemInformation (SYSTEM_INFORMATION_CLASS system_information_class, PVOID system_information, ULONG system_information_length, PULONG return_length)
 
NTSTATUS NtQueryInformationThread (HANDLE thread_handle, THREADINFOCLASS thread_information_class, PVOID thread_information, ULONG thread_information_length, PULONG return_length)
 
template<class Traits >
NTSTATUS NtOpenThread (PHANDLE thread_handle, ACCESS_MASK desired_access, POBJECT_ATTRIBUTES object_attributes, const process_types::CLIENT_ID< Traits > *client_id)
 
NTSTATUS NtQueryObject (HANDLE handle, OBJECT_INFORMATION_CLASS object_information_class, void *object_information, ULONG object_information_length, ULONG *return_length)
 
NTSTATUS NtSuspendProcess (HANDLE handle)
 
NTSTATUS NtResumeProcess (HANDLE handle)
 
void RtlGetUnloadEventTraceEx (ULONG **element_size, ULONG **element_count, void **event_trace)
 
template NTSTATUS NtOpenThread< process_types::internal::Traits32 > (PHANDLE thread_handle, ACCESS_MASK desired_access, POBJECT_ATTRIBUTES object_attributes, const process_types::CLIENT_ID< process_types::internal::Traits32 > *client_id)
 
template NTSTATUS NtOpenThread< process_types::internal::Traits64 > (PHANDLE thread_handle, ACCESS_MASK desired_access, POBJECT_ATTRIBUTES object_attributes, const process_types::CLIENT_ID< process_types::internal::Traits64 > *client_id)
 
template<class Traits >
bool GetProcessBasicInformation (HANDLE process, bool is_wow64, ProcessInfo *process_info, WinVMAddress *peb_address, WinVMSize *peb_size)
 
template<class Traits >
bool ReadProcessData (HANDLE process, WinVMAddress peb_address_vmaddr, ProcessInfo *process_info)
 
bool ReadMemoryInfo (HANDLE process, bool is_64_bit, ProcessInfo *process_info)
 
std::vector< CheckedRange< WinVMAddress, WinVMSize > > GetReadableRangesOfMemoryMap (const CheckedRange< WinVMAddress, WinVMSize > &range, const ProcessInfo::MemoryBasicInformation64Vector &memory_info)
 Given a memory map of a process, and a range to be read from the target process, returns a vector of ranges, representing the readable portions of the original range. More...
 
bool SendToCrashHandlerServer (const base::string16 &pipe_name, const ClientToServerMessage &message, ServerToClientMessage *response)
 Connect over the given pipe_name, passing message to the server, storing the server's reply into response. More...
 
HANDLE CreateNamedPipeInstance (const std::wstring &pipe_name, bool first_instance)
 Wraps CreateNamedPipe() to create a single named pipe instance. More...
 
const void * GetFallbackSecurityDescriptorForNamedPipeInstance (size_t *size)
 Returns the SECURITY_DESCRIPTOR blob that will be used for creating the connection pipe in CreateNamedPipeInstance() if the full descriptor can't be created. More...
 
const void * GetSecurityDescriptorForNamedPipeInstance (size_t *size)
 Returns the SECURITY_DESCRIPTOR blob that will be used for creating the connection pipe in CreateNamedPipeInstance(). More...
 
bool SafeTerminateProcess (HANDLE process, UINT exit_code)
 Calls TerminateProcess(). More...
 

Variables

CrashpadInfo g_crashpad_info
 
int * CRASHPAD_NOTE_REFERENCE
 
uint32_t * g_extra_memory_pointer
 
uint32_t * g_extra_memory_not_saved
 
TestCrashpadInfo g_test_crashpad_info
 
 GatherIndirectlyReferencedMemory
 
gather_indirectly_referenced_memory UserDataMinidumpStreamHead
 
constexpr size_t kMaxNumberOfAnnotations = 200
 The maximum number of crashpad::Annotations that will be read from a client process. More...
 
const FileHandle kInvalidFileHandle = -1
 A value that can never be a valid FileHandle.
 
constexpr mach_port_t kMachPortNull = MACH_PORT_NULL
 MACH_PORT_NULL with the correct type for a Mach port, mach_port_t. More...
 
constexpr exception_behavior_t kMachExceptionCodes = MACH_EXCEPTION_CODES
 MACH_EXCEPTION_CODES with the correct type for a Mach exception behavior, exception_behavior_t. More...
 
constexpr exception_type_t kMachExceptionSimulated = 'CPsx'
 An exception type to use for simulated exceptions.
 
constexpr mach_msg_option_t kMachMessageReceiveAuditTrailer
 A Mach message option specifying that an audit trailer should be delivered during a receive operation. More...
 
constexpr uint64_t kNanosecondsPerSecond = static_cast<uint64_t>(1E9)
 
constexpr char kContentType [] = "Content-Type"
 The header name "Content-Type".
 
constexpr char kContentLength [] = "Content-Length"
 The header name "Content-Length".
 
constexpr char kContentEncoding [] = "Content-Encoding"
 The header name "Content-Encoding".
 
constexpr ProcessID kInvalidProcessID = -1
 

Detailed Description

The main namespace.

Typedef Documentation

◆ AlignedVector

template<typename T , size_t Alignment = alignof(T)>
using crashpad::AlignedVector = typedef std::vector<T, AlignedAllocator<T, Alignment> >

A std::vector using AlignedAllocator.

This is similar to std::vector<T>, with the addition of an alignment guarantee. Alignment must be a power of 2. If Alignment is not specified, the default alignment for type T is used.

◆ CheckedLinuxAddressRange

Ensures that a range, composed of a base and a size, does not overflow the pointer type of the process it describes a range in.

This class checks bases of type LinuxVMAddress and sizes of type LinuxVMSize against a process whose pointer type is either 32 or 64 bits wide.

Aside from varying the overall range on the basis of a process’ pointer type width, this class functions very similarly to CheckedRange.

◆ CheckedMachAddressRange

using crashpad::CheckedMachAddressRange = typedef internal::CheckedAddressRangeGeneric<mach_vm_address_t, mach_vm_size_t>

Ensures that a range, composed of a base and a size, does not overflow the pointer type of the process it describes a range in.

This class checks bases of type mach_vm_address_t and sizes of type mach_vm_address_t against a process whose pointer type is either 32 or 64 bits wide.

Aside from varying the overall range on the basis of a process’ pointer type width, this class functions very similarly to CheckedRange.

◆ CheckedVMAddressRange

Ensures that a range, composed of a base and a size, does not overflow the pointer type of the process it describes a range in.

This class checks bases of type VMAddress and sizes of type VMSize against a process whose pointer type is either 32 or 64 bits wide.

Aside from varying the overall range on the basis of a process’ pointer type width, this class functions very similarly to CheckedRange.

◆ CheckedWinAddressRange

Ensures that a range, composed of a base and a size, does not overflow the pointer type of the process it describes a range in.

This class checks bases of type WinVMAddress and sizes of type WinVMSize against a process whose pointer type is either 32 or 64 bits wide.

Aside from varying the overall range on the basis of a process' pointer type width, this class functions very similarly to CheckedRange.

◆ ConstThreadState

using crashpad::ConstThreadState = typedef const natural_t*

A const version of thread_state_t.

This is useful as the old_state parameter to exception handler functions. Normally, these parameters are of type thread_state_t, but this allows modification of the state, which is conceptually const.

◆ MachMessageDeadline

using crashpad::MachMessageDeadline = typedef uint64_t

The time before which a MachMessageWithDeadline() call should complete.

A value of this type may be one of the special constants kMachMessageDeadlineNonblocking or kMachMessageDeadlineWaitIndefinitely. Any other values should be produced by calling MachMessageDeadlineFromTimeout().

Internally, these are currently specified on the same time base as ClockMonotonicNanoseconds(), although this is an implementation detail.

◆ MinidumpThreadIDMap

using crashpad::MinidumpThreadIDMap = typedef std::map<uint64_t, uint32_t>

A map that connects 64-bit snapshot thread IDs to 32-bit minidump thread IDs.

64-bit snapshot thread IDs are obtained from ThreadSnapshot::ThreadID(). 32-bit minidump thread IDs are stored in MINIDUMP_THREAD::ThreadId.

A ThreadIDMap ensures that there are no collisions among the set of 32-bit minidump thread IDs.

◆ ScopedDIR

using crashpad::ScopedDIR = typedef base::ScopedGeneric<DIR*, internal::ScopedDIRCloseTraits>

Maintains a directory opened by opendir.

On destruction, the directory will be closed by calling closedir.

◆ SimpleStringDictionary

A TSimpleStringDictionary with default template parameters.

For historical reasons this specialized version is available with the same size factors as a previous implementation.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
kXPProcessAllAccess 

This is the XP-suitable value of PROCESS_ALL_ACCESS.

Requesting PROCESS_ALL_ACCESS with the value defined when building against a Vista+ SDK results in ERROR_ACCESS_DENIED when running on XP. See https://msdn.microsoft.com/library/ms684880.aspx.

kXPThreadAllAccess 

This is the XP-suitable value of THREAD_ALL_ACCESS.

Requesting THREAD_ALL_ACCESS with the value defined when building against a Vista+ SDK results in ERROR_ACCESS_DENIED when running on XP. See https://msdn.microsoft.com/library/ms686769.aspx.

◆ anonymous enum

anonymous enum : mach_msg_timeout_t

Special constants used as mach_msg_timeout_t values.

Enumerator
kMachMessageTimeoutNonblocking 

When passed to MachMessageDeadlineFromTimeout(), that function will return kMachMessageDeadlineNonblocking.

kMachMessageTimeoutWaitIndefinitely 

When passed to MachMessageDeadlineFromTimeout(), that function will return kMachMessageDeadlineWaitIndefinitely.

◆ anonymous enum

anonymous enum : MachMessageDeadline

Special constants used as MachMessageDeadline values.

Enumerator
kMachMessageDeadlineNonblocking 

MachMessageWithDeadline() should not block at all in its operation.

kMachMessageDeadlineWaitIndefinitely 

MachMessageWithDeadline() should wait indefinitely for the requested operation to complete.

◆ CPUArchitecture

A system’s CPU architecture.

This can be used to represent the CPU architecture of an entire system as in SystemSnapshot::CPUArchitecture(). It can also be used to represent the architecture of a CPUContext structure in its CPUContext::architecture field without reference to external data.

Enumerator
kCPUArchitectureUnknown 

The CPU architecture is unknown.

kCPUArchitectureX86 

32-bit x86.

kCPUArchitectureX86_64 

x86_64.

kCPUArchitectureARM 

32-bit ARM.

kCPUArchitectureARM64 

64-bit ARM.

kCPUArchitectureMIPSEL 

32-bit MIPSEL.

kCPUArchitectureMIPS64EL 

64-bit MIPSEL.

◆ FileLocking

enum crashpad::FileLocking : bool
strong

Determines the locking mode that LoggingLockFile() uses.

Enumerator
kShared 

Equivalent to flock() with LOCK_SH.

kExclusive 

Equivalent to flock() with LOCK_EX.

◆ FilePermissions

enum crashpad::FilePermissions : bool
strong

Determines the permissions bits for files created on POSIX systems.

Enumerator
kOwnerOnly 

Equivalent to 0600.

kWorldReadable 

Equivalent to 0644.

◆ FileWriteMode

Determines the mode that LoggingOpenFileForWrite() uses.

Enumerator
kReuseOrFail 

Opens the file if it exists, or fails if it does not.

kReuseOrCreate 

Opens the file if it exists, or creates a new file.

kTruncateOrCreate 

Creates a new file. If the file already exists, it will be overwritten.

kCreateOrFail 

Creates a new file. If the file already exists, the open will fail.

◆ MinidumpContextAMD64Flags

x86_64-specific flags for MinidumpContextAMD64::context_flags.

Enumerator
kMinidumpContextAMD64 

Identifies the context structure as x86_64. This is the same as CONTEXT_AMD64 on Windows for this architecture.

kMinidumpContextAMD64Control 

Indicates the validity of control registers (CONTEXT_CONTROL).

The cs, ss, eflags, rsp, and rip fields are valid.

kMinidumpContextAMD64Integer 

Indicates the validity of non-control integer registers (CONTEXT_INTEGER).

The rax, rcx, rdx, rbx, rbp, rsi, rdi, and r8 through r15 fields are valid.

kMinidumpContextAMD64Segment 

Indicates the validity of non-control segment registers (CONTEXT_SEGMENTS).

The ds, es, fs, and gs fields are valid.

kMinidumpContextAMD64FloatingPoint 

Indicates the validity of floating-point state (CONTEXT_FLOATING_POINT).

The xmm0 through xmm15 fields are valid.

kMinidumpContextAMD64Debug 

Indicates the validity of debug registers (CONTEXT_DEBUG_REGISTERS).

The dr0 through dr3, dr6, and dr7 fields are valid.

kMinidumpContextAMD64Xstate 

Indicates the validity of xsave data (CONTEXT_XSTATE).

The context contains xsave data. This is used with an extended context structure not currently defined here.

kMinidumpContextAMD64Full 

Indicates the validity of control, integer, and floating-point registers (CONTEXT_FULL).

kMinidumpContextAMD64All 

Indicates the validity of all registers except xsave data (CONTEXT_ALL).

◆ MinidumpContextARM64Flags

64-bit ARM-specifc flags for MinidumpContextARM64::context_flags.

Enumerator
kMinidumpContextARM64 

Identifies the context structure as 64-bit ARM.

kMinidumpContextARM64Control 

Indicates the validity of control registers.

Registers fp, lr, sp, pc, and cpsr.

kMinidumpContextARM64Integer 

Indicates the validty of integer registers.

Registers x0-x28.

kMinidumpContextARM64Fpsimd 

Indicates the validity of fpsimd registers.

Registers v0-v31, fpsr, and fpcr are valid.

kMinidumpContextARM64Debug 

Indicates the validity of debug registers.

bcr, bvr, wcr, and wvr are valid.

kMinidumpContextARM64Full 

Indicates the validity of control, integer and floating point registers.

kMinidumpContextARM64All 

Indicates the validity of all registers.

◆ MinidumpContextARMFlags

32-bit ARM-specifc flags for MinidumpContextARM::context_flags.

Enumerator
kMinidumpContextARM 

Identifies the context structure as 32-bit ARM.

kMinidumpContextARMInteger 

Indicates the validity of integer regsiters.

Regsiters r0-r15 and cpsr are valid.

kMinidumpContextARMVFP 

Inidicates the validity of VFP regsiters.

Registers d0-d31 and fpscr are valid.

kMinidumpContextARMAll 

Indicates the validity of all registers.

◆ MinidumpContextFlags

Architecture-independent flags for context_flags fields in Minidump context structures.

Enumerator
kMinidumpContextExceptionActive 

The thread was executing a trap handler in kernel mode (CONTEXT_EXCEPTION_ACTIVE).

If this bit is set, it indicates that the context is from a thread that was executing a trap handler in the kernel. This bit is only valid when kMinidumpContextExceptionReporting is also set. This bit is only used on Windows.

kMinidumpContextServiceActive 

The thread was executing a system call in kernel mode (CONTEXT_SERVICE_ACTIVE).

If this bit is set, it indicates that the context is from a thread that was executing a system call in the kernel. This bit is only valid when kMinidumpContextExceptionReporting is also set. This bit is only used on Windows.

kMinidumpContextExceptionRequest 

Kernel-mode state reporting is desired (CONTEXT_EXCEPTION_REQUEST).

This bit is not used in context structures containing snapshots of thread CPU context. It used when calling GetThreadContext() on Windows to specify that kernel-mode state reporting (kMinidumpContextExceptionReporting) is desired in the returned context structure.

kMinidumpContextExceptionReporting 

Kernel-mode state reporting is provided (CONTEXT_EXCEPTION_REPORTING).

If this bit is set, it indicates that the bits indicating how the thread had entered kernel mode (kMinidumpContextExceptionActive and kMinidumpContextServiceActive) are valid. This bit is only used on Windows.

◆ MinidumpContextMIPS64Flags

64bit MIPS-specifc flags for MinidumpContextMIPS64::context_flags. Based on minidump_cpu_mips.h from breakpad

Enumerator
kMinidumpContextMIPS64 

Identifies the context structure as MIPS64EL.

kMinidumpContextMIPS64Integer 

Indicates the validity of integer registers.

Registers 0-31, mdhi, mdlo, epc, badvaddr, status and cause are valid.

kMinidumpContextMIPS64FloatingPoint 

Indicates the validity of floating point registers.

Floating point registers 0-31, fpcsr and fir are valid

kMinidumpContextMIPS64DSP 

Indicates the validity of DSP registers.

Registers hi0-hi2, lo0-lo2 and dsp_control are valid.

kMinidumpContextMIPS64All 

Indicates the validity of all registers.

◆ MinidumpContextMIPSFlags

32bit MIPS-specifc flags for MinidumpContextMIPS::context_flags. Based on minidump_cpu_mips.h from breakpad

Enumerator
kMinidumpContextMIPS 

Identifies the context structure as MIPSEL.

kMinidumpContextMIPSInteger 

Indicates the validity of integer registers.

Registers 0-31, mdhi, mdlo, epc, badvaddr, status and cause are valid.

kMinidumpContextMIPSFloatingPoint 

Indicates the validity of floating point registers.

Floating point registers 0-31, fpcsr and fir are valid

kMinidumpContextMIPSDSP 

Indicates the validity of DSP registers.

Registers hi0-hi2, lo0-lo2 and dsp_control are valid

kMinidumpContextMIPSAll 

Indicates the validity of all registers.

◆ MinidumpContextX86Flags

32-bit x86-specifc flags for MinidumpContextX86::context_flags.

Enumerator
kMinidumpContextX86 

Identifies the context structure as 32-bit x86. This is the same as CONTEXT_i386 and CONTEXT_i486 on Windows for this architecture.

kMinidumpContextX86Control 

Indicates the validity of control registers (CONTEXT_CONTROL).

The ebp, eip, cs, eflags, esp, and ss fields are valid.

kMinidumpContextX86Integer 

Indicates the validity of non-control integer registers (CONTEXT_INTEGER).

The edi, esi, ebx, edx, ecx, andeax` fields are valid.

kMinidumpContextX86Segment 

Indicates the validity of non-control segment registers (CONTEXT_SEGMENTS).

The gs, fs, es, and ds fields are valid.

kMinidumpContextX86FloatingPoint 

Indicates the validity of floating-point state (CONTEXT_FLOATING_POINT).

The fsave field is valid. The float_save field is included in this definition, but its members have no practical use asdie from fsave.

kMinidumpContextX86Debug 

Indicates the validity of debug registers (CONTEXT_DEBUG_REGISTERS).

The dr0 through dr3, dr6, and dr7 fields are valid.

kMinidumpContextX86Extended 

Indicates the validity of extended registers in fxsave format (CONTEXT_EXTENDED_REGISTERS).

The extended_registers field is valid and contains fxsave data.

kMinidumpContextX86Xstate 

Indicates the validity of xsave data (CONTEXT_XSTATE).

The context contains xsave data. This is used with an extended context structure not currently defined here.

kMinidumpContextX86Full 

Indicates the validity of control, integer, and segment registers. (CONTEXT_FULL).

kMinidumpContextX86All 

Indicates the validity of all registers except xsave data. (CONTEXT_ALL).

◆ MinidumpCPUArchitecture

CPU type values for MINIDUMP_SYSTEM_INFO::ProcessorArchitecture.

See also
PROCESSOR_ARCHITECTURE_*
Enumerator
kMinidumpCPUArchitectureX86 

32-bit x86.

These systems identify their CPUs generically as “x86” or “ia32”, or with more specific names such as “i386”, “i486”, “i586”, and “i686”.

kMinidumpCPUArchitecturePPC 

32-bit PowerPC.

These systems identify their CPUs generically as “ppc”, or with more specific names such as “ppc6xx”, “ppc7xx”, and “ppc74xx”.

kMinidumpCPUArchitectureARM 

32-bit ARM.

These systems identify their CPUs generically as “arm”, or with more specific names such as “armv6” and “armv7”.

kMinidumpCPUArchitectureAMD64 

64-bit x86.

These systems identify their CPUs as “x86_64”, “amd64”, or “x64”.

kMinidumpCPUArchitectureX86Win64 

A 32-bit x86 process running on IA-64 (Itanium).

Note
This value is not used in minidump files for 32-bit x86 processes running on a 64-bit-capable x86 CPU and operating system. In that configuration, kMinidumpCPUArchitectureX86 is used instead.
kMinidumpCPUArchitectureARM64 

64-bit ARM.

These systems identify their CPUs generically as “arm64” or “aarch64”, or with more specific names such as “armv8”.

See also
kMinidumpCPUArchitectureARM64Breakpad
kMinidumpCPUArchitecturePPC64 

64-bit PowerPC.

These systems identify their CPUs generically as “ppc64”, or with more specific names such as “ppc970”.

kMinidumpCPUArchitectureARM64Breakpad 

Used by Breakpad for 64-bit ARM.

Deprecated:
Use kMinidumpCPUArchitectureARM64 instead.
kMinidumpCPUArchitectureUnknown 

Unknown CPU architecture.

◆ MinidumpOS

enum crashpad::MinidumpOS : uint32_t

Operating system family values for MINIDUMP_SYSTEM_INFO::PlatformId.

See also
VER_PLATFORM_*
Enumerator
kMinidumpOSWin32s 

Windows 3.1.

kMinidumpOSWin32Windows 

Windows 95, Windows 98, and Windows Me.

kMinidumpOSWin32NT 

Windows NT, Windows 2000, and later.

kMinidumpOSMacOSX 

macOS, Darwin for traditional systems.

kMinidumpOSIOS 

iOS, Darwin for mobile devices.

kMinidumpOSLinux 

Linux, not including Android.

kMinidumpOSAndroid 

Android.

kMinidumpOSNaCl 

Native Client (NaCl).

kMinidumpOSFuchsia 

Fuchsia.

kMinidumpOSUnknown 

Unknown operating system.

◆ MinidumpOSType

enum crashpad::MinidumpOSType : uint8_t

Operating system type values for MINIDUMP_SYSTEM_INFO::ProductType.

See also
VER_NT_*
Enumerator
kMinidumpOSTypeWorkstation 

A “desktop” or “workstation” system.

kMinidumpOSTypeDomainController 

A “domain controller” system. Windows-specific.

kMinidumpOSTypeServer 

A “server” system.

◆ MinidumpStreamType

Minidump stream type values for MINIDUMP_DIRECTORY::StreamType. Each stream structure has a corresponding stream type value to identify it.

See also
MINIDUMP_STREAM_TYPE
Enumerator
kMinidumpStreamTypeThreadList 

The stream type for MINIDUMP_THREAD_LIST.

See also
ThreadListStream
kMinidumpStreamTypeModuleList 

The stream type for MINIDUMP_MODULE_LIST.

See also
ModuleListStream
kMinidumpStreamTypeMemoryList 

The stream type for MINIDUMP_MEMORY_LIST.

See also
MemoryListStream
kMinidumpStreamTypeException 

The stream type for MINIDUMP_EXCEPTION_STREAM.

See also
ExceptionStream
kMinidumpStreamTypeSystemInfo 

The stream type for MINIDUMP_SYSTEM_INFO.

See also
SystemInfoStream
kMinidumpStreamTypeHandleData 

The stream type for MINIDUMP_HANDLE_DATA_STREAM.

See also
HandleDataStream
kMinidumpStreamTypeUnloadedModuleList 

The stream type for MINIDUMP_UNLOADED_MODULE_LIST.

See also
UnloadedModuleListStream
kMinidumpStreamTypeMiscInfo 

The stream type for MINIDUMP_MISC_INFO, MINIDUMP_MISC_INFO_2, MINIDUMP_MISC_INFO_3, and MINIDUMP_MISC_INFO_4.

See also
MiscInfoStream
kMinidumpStreamTypeMemoryInfoList 

The stream type for MINIDUMP_MEMORY_INFO_LIST.

See also
MemoryInfoListStream
kMinidumpStreamTypeLastReservedStream 

The last reserved minidump stream.

See also
MemoryInfoListStream
kMinidumpStreamTypeCrashpadInfo 

The stream type for MinidumpCrashpadInfo.

kMinidumpStreamTypeCrashpadLastReservedStream 

The last reserved crashpad stream.

◆ ProcessSuspensionState

State of process being read by ProcessReaderWin.

Enumerator
kRunning 

The process has not been suspended.

kSuspended 

The process is suspended.

◆ StdioStream

enum crashpad::StdioStream
strong

Determines the FileHandle that StdioFileHandle() returns.

Enumerator
kStandardInput 

Standard input, or stdin.

kStandardOutput 

Standard output, or stdout.

kStandardError 

Standard error, or stderr.

◆ StringToSymbolicConstantOptionBits

Options for various StringTo* functions in symbolic_constants_* files.

Not every StringTo* function will implement each of these options. See function-specific documentation for details.

See also
Symbolic constant terminology
Enumerator
kAllowFullName 

Allow conversion from a string containing a symbolic constant by its full name.

kAllowShortName 

Allow conversion from a string containing a symbolic constant by its short name.

kAllowNumber 

Allow conversion from a numeric string.

kAllowOr 

Allow | to combine values in a bitfield.

For families whose values may be constructed as bitfields, allow conversion of strings containing multiple individual components treated as being combined by a bitwise “or” operation. An example family of constants that behaves this way is the suite of Mach exception masks. For constants that are not constructed as bitfields, or constants that are only partially constructed as bitfields, this option has no effect.

◆ SymbolicConstantToStringOptionBits

Options for various *ToString functions in symbolic_constants_* files.

See also
Symbolic constant terminology
Enumerator
kUseFullName 

Return the full name for a given constant.

Attention
API consumers should provide this value when desired, but should provide only one of kUseFullName and kUseShortName. Because kUseFullName is valueless, implementers should check for the absence of kUseShortName instead.
kUseShortName 

Return the short name for a given constant.

kUnknownIsEmpty 

If no symbolic name is known for a given constant, return an empty string.

Attention
API consumers should provide this value when desired, but should provide only one of kUnknownIsEmpty and kUnknownIsNumeric. Because kUnknownIsEmpty is valueless, implementers should check for the absence of kUnknownIsNumeric instead.
kUnknownIsNumeric 

If no symbolic name is known for a given constant, return a numeric string.

The numeric format used will vary by family, but will be appropriate to the family. Families whose values are typically constructed as bitfields will generally use a hexadecimal format, and other families will generally use a signed or unsigned decimal format.

kUseOr 

Use | to combine values in a bitfield.

For families whose values may be constructed as bitfields, allow conversion to strings containing multiple individual components treated as being combined by a bitwise “or” operation. An example family of constants that behaves this way is the suite of Mach exception masks. For constants that are not constructed as bitfields, or constants that are only partially constructed as bitfields, this option has no effect.

◆ TerminationCodes

enum crashpad::TerminationCodes : unsigned int

Crashpad-specific codes that are used as arguments to SafeTerminateProcess() or TerminateProcess() in unusual circumstances.

Enumerator
kTerminationCodeCrashNoDump 

The crash handler did not respond, and the client self-terminated.

kTerminationCodeSnapshotFailed 

The initial process snapshot failed, so the correct client termination code could not be retrieved.

kTerminationCodeNotConnectedToHandler 

A dump was requested for a client that was never registered with the crash handler.

◆ TriState

enum crashpad::TriState : uint8_t
strong

A tri-state value that can be unset, on, or off.

Enumerator
kUnset 

The value has not explicitly been set.

To allow a zero-initialized value to have this behavior, this must have the value 0.

kEnabled 

The value has explicitly been set to on, or a behavior has explicitly been enabled.

kDisabled 

The value has explicitly been set to off, or a behavior has explicitly been disabled.

◆ XattrStatus

enum crashpad::XattrStatus
strong

The result code for a ReadXattr operation.

Enumerator
kOK 

No error occured. No message is logged.

kNoAttribute 

The attribute does not exist. No message is logged.

kOtherError 

An error occurred and an error message was logged.

Function Documentation

◆ AddUserExtensionStreams()

void crashpad::AddUserExtensionStreams ( const UserStreamDataSources *  user_stream_data_sources,
ProcessSnapshot process_snapshot,
MinidumpFileWriter minidump_file_writer 
)

Adds user extension streams to a minidump.

Dispatches to each source in user_stream_data_sources and adds returned extension streams to minidump_file_writer.

Parameters
[in]user_stream_data_sourcesA pointer to the data sources, or nullptr.
[in]process_snapshotAn initialized snapshot to the crashing process.
[in]minidump_file_writerAny extension streams will be added to this minidump.

◆ AdvancePastNumber()

template<typename T >
bool crashpad::AdvancePastNumber ( const char **  input,
T *  value 
)

Convert a prefix of a char string to a numeric value.

Valid values are positive or negative decimal numbers, matching the regular expression "-?\d+", and within the limits of T.

Parameters
[in,out]inputA pointer to the char string to match against. input is advanced past the number if one is found.
[out]valueThe converted number, if one is found.
Returns
true if a number is found at the start of input and input is advanced, otherwise false.

◆ AdvancePastPrefix()

bool crashpad::AdvancePastPrefix ( const char **  input,
const char *  pattern 
)

Match a pattern at the start of a char string.

Parameters
[in,out]inputA pointer to the char string to match against. input is advanced past the matched pattern if it is found.
[in]patternThe pattern to match at the start of input.
Returns
true if the pattern is matched exactly and input is advanced, otherwise false.

◆ AlignedAllocate()

void * crashpad::AlignedAllocate ( size_t  alignment,
size_t  size 
)

Allocates memory with the specified alignment constraint.

This function wraps posix_memalign() or _aligned_malloc(). Memory allocated by this function must be released by AlignFree().

◆ AlignedFree()

void crashpad::AlignedFree ( void *  pointer)

Frees memory allocated by AlignedAllocate().

This function wraps free() or _aligned_free().

◆ AppendCommandLineArgument()

void crashpad::AppendCommandLineArgument ( const std::wstring &  argument,
std::wstring *  command_line 
)

Utility function for building escaped command lines.

This builds a command line so that individual arguments can be reliably decoded by CommandLineToArgvW().

argument is appended to command_line. If necessary, it will be placed in quotation marks and escaped properly. If command_line is initially non-empty, a space will precede argument.

Parameters
[in]argumentThe argument to append to command_line.
[in,out]command_lineThe command line being constructed.

◆ AssignIfInRange()

template<typename Destination , typename Source >
bool crashpad::AssignIfInRange ( Destination *  destination,
Source  source 
)

Performs an assignment if it can be done safely, and signals if it cannot be done safely.

Parameters
[out]destinationA pointer to the variable to be assigned to.
[in]sourceThe value to assign.
Returns
true if source is in the range supported by the type of *destination, with the assignment to *destination having been performed. false if the assignment cannot be completed safely because source is outside of this range.

◆ AsUnderlyingType()

template<typename From >
constexpr std::underlying_type<From>::type crashpad::AsUnderlyingType ( From  from)
constexpr

Casts a value to its underlying type.

Parameters
[in]fromThe value to be casted.
Returns
from casted to its underlying type.

◆ AuditPIDFromMachMessageTrailer()

pid_t crashpad::AuditPIDFromMachMessageTrailer ( const mach_msg_trailer_t *  trailer)

Returns the process ID of a Mach message’s sender from its audit trailer.

For the audit trailer to be present, the message must have been received with kMachMessageReceiveAuditTrailer or its macro equivalent specified in the receive options.

If the kernel is the message’s sender, a process ID of 0 will be returned.

Parameters
[in]trailerThe trailer received with a Mach message.
Returns
The process ID of the message’s sender, or -1 on failure with a message logged. It is considered a failure for trailer to not contain audit information.

◆ BootstrapCheckIn()

base::mac::ScopedMachReceiveRight crashpad::BootstrapCheckIn ( const std::string &  service_name)

Makes a boostrap_check_in() call to the process’ bootstrap server.

This function is provided to make it easier to call bootstrap_check_in() while avoiding accidental leaks of the returned receive right.

Parameters
[in]service_nameThe service name to check in.
Returns
On success, a receive right to the service port. On failure, MACH_PORT_NULL with a message logged.

◆ BootstrapLookUp()

base::mac::ScopedMachSendRight crashpad::BootstrapLookUp ( const std::string &  service_name)

Makes a boostrap_look_up() call to the process’ bootstrap server.

This function is provided to make it easier to call bootstrap_look_up() while avoiding accidental leaks of the returned send right.

Parameters
[in]service_nameThe service name to look up.
Returns
On success, a send right to the service port. On failure, MACH_PORT_NULL with a message logged.

◆ BreakpadHTTPFormParametersFromMinidump()

std::map< std::string, std::string > crashpad::BreakpadHTTPFormParametersFromMinidump ( const ProcessSnapshot process_snapshot)

Given a ProcessSnapshot, returns a map of key-value pairs to use as HTTP form parameters for upload to a Breakpad crash report colleciton server.

The map is built by combining the process simple annotations map with each module’s simple annotations map and annotation objects.

In the case of duplicate simple map keys or annotation names, the map will retain the first value found for any key, and will log a warning about discarded values. The precedence rules for annotation names are: the two reserved keys discussed below, process simple annotations, module simple annotations, and module annotation objects.

For annotation objects, only ones of that are Annotation::Type::kString are included.

Each module’s annotations vector is also examined and built into a single string value, with distinct elements separated by newlines, and stored at the key named “list_annotations”, which supersedes any other key found by that name.

The client ID stored in the minidump is converted to a string and stored at the key named “guid”, which supersedes any other key found by that name.

In the event of an error reading the minidump file, a message will be logged.

Parameters
[in]process_snapshotThe process snapshot from which annotations will be extracted.
Returns
A string map of the annotations.

◆ BuildHandlerArgvStrings()

std::vector< std::string > crashpad::BuildHandlerArgvStrings ( const base::FilePath &  handler,
const base::FilePath &  database,
const base::FilePath &  metrics_dir,
const std::string &  url,
const std::map< std::string, std::string > &  annotations,
const std::vector< std::string > &  arguments 
)

Builds a vector of arguments suitable for invoking a handler process based on arguments passed to StartHandler-type().

See StartHandlerAtCrash() for documentation on the input arguments.

Returns
A vector of arguments suitable for starting the handler with.

◆ BuildMinidumpThreadIDMap()

void crashpad::BuildMinidumpThreadIDMap ( const std::vector< const ThreadSnapshot * > &  thread_snapshots,
MinidumpThreadIDMap thread_id_map 
)

Builds a MinidumpThreadIDMap for a group of ThreadSnapshot objects.

Parameters
[in]thread_snapshotsThe thread snapshots to use as source data.
[out]thread_id_mapA MinidumpThreadIDMap to be built by this method. This map must be empty when this function is called.

The map ensures that for any unique 64-bit thread ID found in a ThreadSnapshot, the 32-bit thread ID used in a minidump file will also be unique.

◆ c16lcpy()

size_t crashpad::c16lcpy ( base::char16 *  destination,
const base::char16 *  source,
size_t  length 
)

Copy a NUL-terminated char16-based string to a fixed-size buffer.

This function behaves identically to strlcpy(), but it operates on char16 data instead of char data. It copies the NUL-terminated string in the buffer beginning at source to the buffer of size length at destination, ensuring that the destination buffer is NUL-terminated. No data will be written outside of the destination buffer, but if length is smaller than the length of the string at source, the string will be truncated.

Parameters
[out]destinationA pointer to a buffer of at least size length char16 units (not bytes). The string will be copied to this buffer, possibly with truncation, and NUL-terminated. Nothing will be written following the NUL terminator.
[in]sourceA pointer to a NUL-terminated string of char16 data. The NUL terminator must be a NUL value in a char16 unit, not just a single NUL byte.
[in]lengthThe length of the destination buffer in char16 units, not bytes. A maximum of length - 1 char16 units from source will be copied to destination.
Returns
The length of the source string in char16 units, not including its NUL terminator. When truncation occurs, the return value will be equal to or greater than than the length parameter.

◆ CaptureContext()

void crashpad::CaptureContext ( NativeCPUContext *  cpu_context)

Saves the CPU context.

The CPU context will be captured as accurately and completely as possible, containing an atomic snapshot at the point of this function’s return. This function does not modify any registers.

This function is a replacement for RtlCaptureContext() and getcontext() which contain bugs and/or limitations.

On 32-bit x86, RtlCaptureContext() requires that ebp be used as a frame pointer, and returns ebp, esp, and eip out of sync with the other registers. Both the 32-bit x86 and 64-bit x86_64 versions of RtlCaptureContext() capture only the state of the integer registers, ignoring floating-point and vector state.

Parameters
[out]cpu_contextThe structure to store the context in.
Note
The ABI may require that this function's argument is passed by register, preventing this fuction from saving the original value of that register. This occurs in the following circumstances:
OS Architecture Register
Win x86_64 %rcx
macOS/Linux/Fuchsia x86_64 %rdi
Linux ARM/ARM64 r0/x0
Linux MIPS/MIPS64 $a0

Additionally, the value LR on ARM/ARM64 will be the return address of this function.

If the value of these register prior to calling this function are needed they must be obtained separately prior to calling this function. For example:

uint64_t rdi;
asm("movq %%rdi, %0" : "=m"(rdi));

◆ CaptureSnapshot()

bool crashpad::CaptureSnapshot ( PtraceConnection connection,
const ExceptionHandlerProtocol::ClientInformation info,
const std::map< std::string, std::string > &  process_annotations,
uid_t  client_uid,
VMAddress  requesting_thread_stack_address,
pid_t *  requesting_thread_id,
std::unique_ptr< ProcessSnapshotLinux > *  process_snapshot,
std::unique_ptr< ProcessSnapshotSanitized > *  sanitized_snapshot 
)

Captures a snapshot of a client over connection.

Parameters
[in]connectionA PtraceConnection to the client to snapshot.
[in]infoInformation about the client configuring the snapshot.
[in]process_annotationsA map of annotations to insert as process-level annotations into the snapshot.
[in]client_uidThe client's user ID.
[in]requesting_thread_stack_addressAn address on the stack of the thread requesting the snapshot. If info includes an exception address, the exception will be assigned to the thread whose stack address range contains this address. If 0, requesting_thread_id will be -1.
[out]requesting_thread_idThe thread ID of the thread corresponding to requesting_thread_stack_address. Set to -1 if the thread ID could not be determined. Optional.
[out]process_snapshotA snapshot of the client process, valid if this function returns true.
[out]sanitized_snapshotA sanitized snapshot of the client process, valid if this function returns true and sanitization was requested in info.
Returns
true if process_snapshot was successfully created. A message will be logged on failure, but not if the snapshot was skipped because handling was disabled by CrashpadInfoClientOptions.

◆ CFPropertyToLaunchData()

launch_data_t crashpad::CFPropertyToLaunchData ( CFPropertyListRef  property_cf)

Converts a Core Foundation-type property list to a launchd-type launch_data_t.

Parameters
[in]property_cfThe Core Foundation-type property list to convert.
Returns
The converted launchd-type launch_data_t. The caller takes ownership of the returned value. On error, returns nullptr.
Note
This function handles all CFPropertyListRef types except for CFDateRef, because there’s no launch_data_type_t analogue. Not all types supported in a launchd-type launch_data_t have CFPropertyListRef analogues.

◆ CheckedCloseFile()

void crashpad::CheckedCloseFile ( FileHandle  file)

Wraps close() or CloseHandle(), ensuring that it succeeds.

If the underlying function fails, this function causes execution to terminate without returning.

◆ CheckedReadFileAtEOF()

void crashpad::CheckedReadFileAtEOF ( FileHandle  file)

Wraps ReadFile(), ensuring that it indicates end-of-file.

Attempts to read a single byte from file, expecting no data to be read. If the underlying ReadFile() fails, or if a byte actually is read, this function causes execution to terminate without returning.

See also
CheckedReadFileExactly
ReadFile

◆ CheckedReadFileExactly()

void crashpad::CheckedReadFileExactly ( FileHandle  file,
void *  buffer,
size_t  size 
)

Wraps ReadFile(), ensuring that exactly size bytes are read.

If the underlying ReadFile() fails, or if fewer than size bytes were read, this function causes execution to terminate without returning.

See also
CheckedWriteFile
ReadFile
LoggingReadFileExactly
CheckedReadFileAtEOF

◆ CheckedWriteFile()

void crashpad::CheckedWriteFile ( FileHandle  file,
const void *  buffer,
size_t  size 
)

Wraps WriteFile(), ensuring that exactly size bytes are written.

if the underlying WriteFile() fails, or if fewer than size bytes were written, this function causes execution to terminate without returning.

See also
CheckedReadFileExactly
WriteFile
LoggingWriteFile

◆ ClockMonotonicNanoseconds()

uint64_t crashpad::ClockMonotonicNanoseconds ( )

Returns the value of the system’s monotonic clock.

The monotonic clock is a tick counter whose epoch is unspecified. It is a monotonically-increasing clock that cannot be set, and never jumps backwards on a running system. The monotonic clock may stop while the system is sleeping, and it may be reset when the system starts up. This clock is suitable for computing durations of events. Subject to the underlying clock’s resolution, successive calls to this function will result in a series of increasing values.

Returns
The value of the system’s monotonic clock, in nanoseconds.

◆ CloseMultipleNowOrOnExec()

void crashpad::CloseMultipleNowOrOnExec ( int  fd,
int  preserve_fd 
)

Close multiple file descriptors or mark them close-on-exec.

This is similar to the BSD/Solaris-style closefrom() routine, which closes all open file descriptors equal to or higher than its fd argument. This function must not be called while other threads are active. It is intended to be used in a child process created by fork(), prior to calling an exec()-family function. This guarantees that a (possibly untrustworthy) child process does not inherit file descriptors that it has no need for.

Unlike the BSD function, this function may not close file descriptors immediately, but may instead mark them as close-on-exec. The actual behavior chosen is specific to the operating system. On macOS, file descriptors are marked close-on-exec instead of being closed outright in order to avoid raising EXC_GUARD exceptions for guarded file descriptors that are protected against close().

Parameters
[in]fdThe lowest file descriptor to close or set as close-on-exec.
[in]preserve_fdA file descriptor to preserve and not close (or set as close-on-exec), even if it is open and its value is greater than fd. To not preserve any file descriptor, pass -1 for this parameter.

◆ CloseStdinAndStdout()

void crashpad::CloseStdinAndStdout ( )

Closes stdin and stdout by opening /dev/null over them.

It is normally inadvisable to close() the three standard input/output streams, because they occupy special file descriptors. Closing them outright could result in their file descriptors being reused. This causes problems for library code (including the standard library) that expects these file descriptors to have special meaning.

This function discards the standard input and standard output streams by opening /dev/null and assigning it to their file descriptors, closing whatever had been at those file descriptors previously.

stderr, the standard error stream, is not closed. It is often useful to retain the ability to send diagnostic messages to the standard error stream.

Note
This function can only maintain its guarantees in a single-threaded process, or in situations where the caller has control of all threads in the process.

◆ CrackURL()

bool crashpad::CrackURL ( const std::string &  url,
std::string *  scheme,
std::string *  host,
std::string *  port,
std::string *  rest 
)

Crack a URL into component parts.

This is not a general function, and works only on the limited style of URLs that are expected to be used by HTTPTransport::SetURL().

Parameters
[in]urlThe URL to crack.
[out]schemeThe request scheme, either http or https.
[out]hostThe hostname.
[out]portThe port.
[out]restThe remainder of the URL (both resource and URL params).
Returns
true on success in which case all output parameters will be filled out, or false on failure, in which case the output parameters will be unmodified and an error will be logged.

◆ CreateNamedPipeInstance()

HANDLE crashpad::CreateNamedPipeInstance ( const std::wstring &  pipe_name,
bool  first_instance 
)

Wraps CreateNamedPipe() to create a single named pipe instance.

Parameters
[in]pipe_nameThe name to use for the pipe.
[in]first_instanceIf true, the named pipe instance will be created with FILE_FLAG_FIRST_PIPE_INSTANCE. This ensures that the the pipe name is not already in use when created. The first instance will be created with an untrusted integrity SACL so instances of this pipe can be connected to by processes of any integrity level.

◆ DetermineMergedRange()

bool crashpad::DetermineMergedRange ( const MemorySnapshot a,
const MemorySnapshot b,
CheckedRange< uint64_t, size_t > *  merged 
)

The same as LoggingDetermineMergedRange but with no errors logged.

See also
LoggingDetermineMergedRange

◆ DoubleForkAndExec()

bool crashpad::DoubleForkAndExec ( const std::vector< std::string > &  argv,
const std::vector< std::string > *  envp,
int  preserve_fd,
bool  use_path,
void(*)()  child_function 
)

Executes a (grand-)child process.

The grandchild process will be started through the double-fork()-and-execv() pattern. This allows the grandchild to fully disassociate from the parent. The grandchild will not be a member of the parent’s process group or session and will not have a controlling terminal, providing isolation from signals not intended for it. The grandchild’s parent process, in terms of the process tree hierarchy, will be the process with process ID 1, relieving any other process of the responsibility to reap it via waitpid(). Aside from the three file descriptors associated with the standard input/output streams and any file descriptor passed in preserve_fd, the grandchild will not inherit any file descriptors from the parent process.

Parameters
[in]argvThe argument vector to start the grandchild process with. argv[0] is used as the path to the executable.
[in]envpA vector of environment variables of the form var=value to be passed to execve(). If this value is nullptr, the current environment is used.
[in]preserve_fdA file descriptor to be inherited by the grandchild process. This file descriptor is inherited in addition to the three file descriptors associated with the standard input/output streams. Use -1 if no additional file descriptors are to be inherited.
[in]use_pathWhether to consult the PATH environment variable when requested to start an executable at a non-absolute path. If false, execv(), which does not consult PATH, will be used. If true, execvp(), which does consult PATH, will be used.
[in]child_functionIf not nullptr, this function will be called in the intermediate child process, prior to the second fork(). Take note that this function will run in the context of a forked process, and must be safe for that purpose.

Setting both envp to a value other than nullptr and use_path to true is not currently supported.

Returns
true on success, and false on failure with a message logged. Only failures that occur in the parent process that indicate a definite failure to start the the grandchild are reported in the return value. Failures in the intermediate child or grandchild processes cannot be reported in the return value, and are addressed by logging a message and terminating. The caller assumes the responsibility for detecting such failures, for example, by observing a failure to perform a successful handshake with the grandchild process.

◆ DropPrivileges()

void crashpad::DropPrivileges ( )

Permanently drops privileges conferred by being a setuid or setgid executable.

The effective user ID and saved set-user ID are set to the real user ID, negating any effects of being a setuid executable. The effective group ID and saved set-group ID are set to the real group ID, negating any effects of being a setgid executable. Because the saved set-user ID and saved set-group ID are reset, there is no way to restore the prior privileges, and the drop is permanent.

This function drops privileges correctly when running setuid root and in other circumstances, including when running setuid non-root. If the program is not a setuid or setgid executable, this function has no effect.

No changes are made to the supplementary group list, which is normally not altered for setuid or setgid executables.

◆ ExcCrashCouldContainException()

bool crashpad::ExcCrashCouldContainException ( exception_type_t  exception)

Determines whether a given exception type could plausibly be carried within an EXC_CRASH exception.

Parameters
[in]exceptionThe exception type to test.
Returns
true if an EXC_CRASH exception could plausibly carry exception.

An EXC_CRASH exception can wrap exceptions that originate as hardware faults, as well as exceptions that originate from certain software sources such as POSIX signals. It cannot wrap another EXC_CRASH exception, nor can it wrap EXC_RESOURCE, EXC_GUARD, or EXC_CORPSE_NOTIFY exceptions. It also cannot wrap Crashpad-specific kMachExceptionSimulated exceptions.

◆ ExcCrashRecoverOriginalException()

exception_type_t crashpad::ExcCrashRecoverOriginalException ( mach_exception_code_t  code_0,
mach_exception_code_t *  original_code_0,
int *  signal 
)

Recovers the original exception, first exception code, and signal from the encoded form of the first exception code delivered with EXC_CRASH exceptions.

EXC_CRASH exceptions are generated when the kernel has committed to terminating a process as a result of a core-generating POSIX signal and, for hardware exceptions, an earlier Mach exception. Information about this earlier exception and signal is made available to the EXC_CRASH handler via its code[0] parameter. This function recovers the original exception, the value of code[0] from the original exception, and the value of the signal responsible for process termination.

Parameters
[in]code_0The first exception code (code[0]) passed to a Mach exception handler in an EXC_CRASH exception. It is invalid to call this function with an exception code from any exception other than EXC_CRASH.
[out]original_code_0The first exception code (code[0]) passed to the Mach exception handler for a hardware exception that resulted in the generation of a POSIX signal that caused process termination. If the signal that caused termination was not sent as a result of a hardware exception, this will be 0. Callers that do not need this value may pass nullptr.
[out]signalThe POSIX signal that caused process termination. Callers that do not need this value may pass nullptr.
Returns
The original exception for a hardware exception that resulted in the generation of a POSIX signal that caused process termination. If the signal that caused termination was not sent as a result of a hardware exception, this will be 0.

◆ ExceptionBehaviorBasic()

exception_behavior_t crashpad::ExceptionBehaviorBasic ( exception_behavior_t  behavior)

Returns the basic behavior value of behavior, its value without MACH_EXCEPTION_CODES set.

Parameters
[in]behaviorAn exception behavior value.
Returns
EXCEPTION_DEFAULT, EXCEPTION_STATE, or EXCEPTION_STATE_IDENTITY, assuming behavior was a correct exception behavior value.

◆ ExceptionBehaviorHasIdentity()

bool crashpad::ExceptionBehaviorHasIdentity ( exception_behavior_t  behavior)

Determines whether behavior indicates an exception behavior that carries thread and task identities.

When this function returns true, an exception message of behavior will carry thread and task identities in the form of send rights to the thread and task ports. Its thread and task fields will be valid. When this function returns false, these fields will not be valid.

Exception behaviors that carry thread and task identity information are EXCEPTION_DEFAULT and EXCEPTION_STATE_IDENTITY. MACH_EXCEPTION_CODES may also be set. These behaviors correspond to exception_raise(), exception_raise_state_identity(), mach_exception_raise(), and mach_exception_raise_state_identity().

Parameters
[in]behaviorAn exception behavior value.
Returns
true if behavior is EXCEPTION_DEFAULT or EXCEPTION_STATE_IDENTITY, possibly with MACH_EXCEPTION_CODES also set.

◆ ExceptionBehaviorHasMachExceptionCodes()

bool crashpad::ExceptionBehaviorHasMachExceptionCodes ( exception_behavior_t  behavior)

Determines whether behavior indicates an exception behavior that carries 64-bit exception codes (“Mach exception codes”).

When this function returns true, an exception message of behavior will carry 64-bit exception codes of type mach_exception_code_t in its code field. When this function returns false, the exception message will carry 32-bit exception codes of type exception_data_type_t in its code field.

Exception behaviors that carry 64-bit exception codes are those that have MACH_EXCEPTION_CODES set. These behaviors correspond to mach_exception_raise(), mach_exception_raise_state(), and mach_exception_raise_state_identity().

Parameters
[in]behaviorAn exception behavior value.
Returns
true if MACH_EXCEPTION_CODES is set in behavior.

◆ ExceptionBehaviorHasState()

bool crashpad::ExceptionBehaviorHasState ( exception_behavior_t  behavior)

Determines whether behavior indicates an exception behavior that carries thread state information.

When this function returns true, an exception message of behavior will carry thread state information. Its flavor, old_state, old_state_count, new_state, and new_state_count fields will be valid. When this function returns false, these fields will not be valid.

Exception behaviors that carry thread state information are EXCEPTION_STATE and EXCEPTION_STATE_IDENTITY. MACH_EXCEPTION_CODES may also be set. These behaviors correspond to exception_raise_state(), exception_raise_state_identity(), mach_exception_raise_state(), and mach_exception_raise_state_identity().

Parameters
[in]behaviorAn exception behavior value.
Returns
true if behavior is EXCEPTION_STATE or EXCEPTION_STATE_IDENTITY, possibly with MACH_EXCEPTION_CODES also set.

◆ ExceptionBehaviorToString()

std::string crashpad::ExceptionBehaviorToString ( exception_behavior_t  behavior,
SymbolicConstantToStringOptions  options 
)

Converts a Mach exception behavior value to a textual representation.

Parameters
[in]behaviorThe Mach exception behavior value to convert.
[in]optionsOptions affecting the conversion. kUseOr is ignored. MACH_EXCEPTION_CODES can always be ORed in, but no other values can be ORed with each other. For kUnknownIsNumeric, the format is "%#x".
Returns
The converted string.

◆ ExceptionCodeForMetrics()

int32_t crashpad::ExceptionCodeForMetrics ( exception_type_t  exception,
mach_exception_code_t  code_0 
)

Returns the exception code to report via a configured metrics system.

Parameters
[in]exceptionThe exception type as received by a Mach exception handler.
[in]code_0The first exception code (code[0]) as received by a Mach exception handler.
Returns
An exception code that maps useful information from exception and code_0 to the more limited data type available for metrics reporting.

For classic Mach exceptions (including hardware faults reported as Mach exceptions), the mapping is (exception << 16) | code_0.

For EXC_CRASH exceptions that originate as Mach exceptions described above, the mapping above is used, with the original exception’s values. For EXC_CRASH exceptions that originate as POSIX signals without an underlying Mach exception, the mapping is (EXC_CRASH << 16) | code_0.

EXC_RESOURCE and EXC_GUARD exceptions both contain exception-specific “type” values and type-specific “flavor” values. In these cases, the mapping is (exception << 16) | (type << 8) | flavor. For EXC_GUARD, the “flavor” value is rewritten to be more space-efficient by replacing the kernel-supplied bitmask having exactly one bit set with the index of the set bit.

EXC_CORPSE_NOTIFY exceptions are reported as classic Mach exceptions with the code_0 field set to 0.

If exception is kMachExceptionSimulated, that value is returned as-is.

Overflow conditions in any field are handled via saturation.

◆ ExceptionMaskToString()

std::string crashpad::ExceptionMaskToString ( exception_mask_t  exception_mask,
SymbolicConstantToStringOptions  options 
)

Converts a Mach exception mask value to a textual representation.

Parameters
[in]exception_maskThe Mach exception mask value to convert.
[in]optionsOptions affecting the conversion. kUseOr is honored. For kUnknownIsNumeric, the format is "%#x".
Returns
The converted string.

◆ ExceptionToString()

std::string crashpad::ExceptionToString ( exception_type_t  exception,
SymbolicConstantToStringOptions  options 
)

Converts a Mach exception value to a textual representation.

Parameters
[in]exceptionThe Mach exception value to convert.
[in]optionsOptions affecting the conversion. kUseOr is ignored. For kUnknownIsNumeric, the format is "%d".
Returns
The converted string.

◆ ExcMaskAll()

exception_mask_t crashpad::ExcMaskAll ( )

The value for EXC_MASK_ALL appropriate for the operating system at run time.

The SDK’s definition of EXC_MASK_ALL has changed over time, with later versions containing more bits set than earlier versions. However, older kernels will reject exception masks that contain bits set that they don’t recognize. Calling this function will return a value for EXC_MASK_ALL appropriate for the system at run time.

Note
EXC_MASK_ALL does not include the value of EXC_MASK_CRASH or EXC_MASK_CORPSE_NOTIFY. Consumers that want EXC_MASK_ALL along with EXC_MASK_CRASH may use ExcMaskAll() | EXC_MASK_CRASH. Consumers may use ExcMaskValid() for EXC_MASK_ALL along with EXC_MASK_CRASH, EXC_MASK_CORPSE_NOTIFY, and any values that come into existence in the future.

◆ ExcMaskValid()

exception_mask_t crashpad::ExcMaskValid ( )

An exception mask containing every possible exception understood by the operating system at run time.

EXC_MASK_ALL, and thus ExcMaskAll(), never includes the value of EXC_MASK_CRASH or EXC_MASK_CORPSE_NOTIFY. For situations where an exception mask corresponding to every possible exception understood by the running kernel is desired, use this function instead.

Should new exception types be introduced in the future, this function will be updated to include their bits in the returned mask value when run time support is present.

◆ ExcServerCopyState()

void crashpad::ExcServerCopyState ( exception_behavior_t  behavior,
ConstThreadState  old_state,
mach_msg_type_number_t  old_state_count,
thread_state_t  new_state,
mach_msg_type_number_t *  new_state_count 
)

Copies the old state to the new state for state-carrying exceptions.

When the kernel sends a state-carrying exception request and the response is successful (MACH_MSG_SUCCESS, a synonym for KERN_SUCCESS), it will set a new thread state based on new_state and new_state_count. To ease initialization of the new state, this function copies old_state and old_state_count. This is only done if behavior indicates a state-carrying exception.

Parameters
[in]behaviorThe behavior of the exception handler as invoked. This may be taken directly from the behavior parameter of internal::SimplifiedExcServer::Interface::CatchException(), for example.
[in]old_stateThe original state value. This may be taken directly from the old_state parameter of internal::SimplifiedExcServer::Interface::CatchException(), for example.
[in]old_state_countThe number of significant natural_t words in old_state. This may be taken directly from the old_state_count parameter of internal::SimplifiedExcServer::Interface::CatchException(), for example.
[out]new_stateThe state value to be set. This may be taken directly from the new_state parameter of internal::SimplifiedExcServer::Interface::CatchException(), for example. This parameter is untouched if behavior is not state-carrying.
[in,out]new_state_countOn entry, the number of natural_t words available to be written to in new_state. On return, the number of significant natural_t words in new_state. This may be taken directly from the new_state_count parameter of internal::SimplifiedExcServer::Interface::CatchException(), for example. This parameter is untouched if behavior is not state-carrying. If behavior is state-carrying, this parameter should be at least as large as old_state_count.

◆ ExcServerSuccessfulReturnValue()

kern_return_t crashpad::ExcServerSuccessfulReturnValue ( exception_type_t  exception,
exception_behavior_t  behavior,
bool  set_thread_state 
)

Computes an approriate successful return value for an exception handler function.

For exception handlers that respond to state-carrying behaviors, when the handler is called by the kernel (as it is normally), the kernel will attempt to set a new thread state when the exception handler returns successfully. Other code that mimics the kernel’s exception-delivery semantics may implement the same or similar behavior. In some situations, it is undesirable to set a new thread state. If the exception handler were to return unsuccessfully, however, the kernel would continue searching for an exception handler at a wider (task or host) scope. This may also be undesirable.

If such exception handlers return MACH_RCV_PORT_DIED, the kernel will not set a new thread state and will also not search for another exception handler. See 10.9.4 xnu-2422.110.17/osfmk/kern/exception.c. exception_deliver() will only set a new thread state if the handler’s return code was MACH_MSG_SUCCESS (a synonym for KERN_SUCCESS), and subsequently, exception_triage() will not search for a new handler if the handler’s return code was KERN_SUCCESS or MACH_RCV_PORT_DIED.

This function allows exception handlers to compute an appropriate return code to influence their caller (the kernel) in the desired way with respect to setting a new thread state while suppressing the caller’s subsequent search for other exception handlers. An exception handler should return the value returned by this function.

This function is useful even for EXC_CRASH handlers, where returning KERN_SUCCESS and allowing the kernel to set a new thread state has been observed to cause a perceptible and unnecessary waste of time. The victim task in an EXC_CRASH handler is already being terminated and is no longer schedulable, so there is no point in setting the states of any of its threads.

On OS X 10.11, the MACH_RCV_PORT_DIED mechanism cannot be used with an EXC_CRASH handler without triggering an undesirable EXC_CORPSE_NOTIFY exception. In that case, KERN_SUCCESS is always returned. Because this function may return KERN_SUCCESS for a state-carrying exception, it is important to ensure that the state returned by a state-carrying exception handler is valid, because it will be passed to thread_set_status(). ExcServerCopyState() may be used to achieve this.

Parameters
[in]exceptionThe exception type passed to the exception handler. This may be taken directly from the exception parameter of internal::SimplifiedExcServer::Interface::CatchException(), for example.
[in]behaviorThe behavior of the exception handler as invoked. This may be taken directly from the behavior parameter of internal::SimplifiedExcServer::Interface::CatchException(), for example.
[in]set_thread_statetrue if the handler would like its caller to set the new thread state using the flavor, new_state, and new_state_count out parameters. This can only happen when behavior is a state-carrying behavior.
Returns
KERN_SUCCESS or MACH_RCV_PORT_DIED. KERN_SUCCESS is used when behavior is not a state-carrying behavior, or when it is a state-carrying behavior and set_thread_state is true, or for EXC_CRASH exceptions on OS X 10.11 and later. Otherwise, MACH_RCV_PORT_DIED is used.

◆ FileModificationTime()

bool crashpad::FileModificationTime ( const base::FilePath &  path,
timespec *  mtime 
)

Determines the modification time for a file, directory, or symbolic link, logging a message on failure.

Parameters
[in]pathThe file to get the modification time for.
[out]mtimeThe modification time as seconds since the POSIX Epoch.
Returns
true on success. false on failure with a message logged.

◆ FromPointerCast()

template<typename To , typename From >
crashpad::FromPointerCast ( From  from)

Casts from a pointer type to an integer.

Compared to reinterpret_cast<>(), FromPointerCast<>() defines whether a pointer type is sign-extended or zero-extended. Casts to signed integral types are sign-extended. Casts to unsigned integral types are zero-extended.

Use FromPointerCast<>() instead of reinterpret_cast<>() when casting a pointer to an integral type that may not be the same width as a pointer. There is no need to prefer FromPointerCast<>() when casting to an integral type that’s definitely the same width as a pointer, such as uintptr_t and intptr_t.

◆ GetBootTime()

bool crashpad::GetBootTime ( timespec *  ts)

Get the kernel boot time. Subsequent calls to this function may return different results due to the system clock being changed or imprecision in measuring the boot time.

Returns
true on success. Otherwise, false with a message logged.

◆ GetChildKoids()

std::vector< zx_koid_t > crashpad::GetChildKoids ( const zx::object_base &  parent,
zx_object_info_topic_t  child_kind 
)

Get a list of child koids for a parent handle.

For example, the list of processes in jobs, or the list of threads in a process.

Parameters
[in]parentThe handle to the parent object.
[in]child_kindThe type of children to retrieve from parent. Valid values depend on the type of parent, but include ZX_INFO_JOB_CHILDREN (child jobs of a job), ZX_INFO_JOB_PROCESSES (child processes of a job), and ZX_INFO_PROCESS_THREADS (child threads of a process).
Returns
A vector of the koids representing the child objects.
See also
GetChildHandles

◆ GetFallbackSecurityDescriptorForNamedPipeInstance()

const void * crashpad::GetFallbackSecurityDescriptorForNamedPipeInstance ( size_t *  size)

Returns the SECURITY_DESCRIPTOR blob that will be used for creating the connection pipe in CreateNamedPipeInstance() if the full descriptor can't be created.

This function is only exposed for testing.

Parameters
[out]sizeThe size of the returned blob. May be nullptr if not required.
Returns
A pointer to a self-relative SECURITY_DESCRIPTOR. Ownership is not transferred to the caller.

◆ GetHandlesForThreadKoids()

std::vector< zx::thread > crashpad::GetHandlesForThreadKoids ( const zx::process &  parent,
const std::vector< zx_koid_t > &  koids 
)

Convert a list of koids that are all children of a particular process into thread handles.

Parameters
[in]parentThe parent object to which the koids belong.
[in]koidsThe list of koids.
Returns
The resulting list of handles corresponding to the koids. If an element of koids is invalid or can't be retrieved, there will be a corresponding ZX_HANDLE_INVALID entry in the return.

◆ GetKoidForHandle()

zx_koid_t crashpad::GetKoidForHandle ( const zx::object_base &  object)

Retrieves the koid for a given object handle.

Parameters
[in]objectThe handle for which the koid is to be retrieved.
Returns
The koid of handle, or ZX_HANDLE_INVALID with an error logged.

◆ GetModuleVersionAndType()

bool crashpad::GetModuleVersionAndType ( const base::FilePath &  path,
VS_FIXEDFILEINFO vs_fixedfileinfo 
)

Retrieve the type and version information from a given module (exe, dll, etc.)

This function calls GetFileVersionInfo(), which can implicitly call LoadLibrary() to load path into the calling process. Do not call this function on an untrusted module, because there is a risk of executing the module’s code.

Parameters
[in]pathThe path to the module to be inspected.
[out]vs_fixedfileinfoThe VS_FIXEDFILEINFO on success. VS_FIXEDFILEINFO::dwFileFlags will have been masked with VS_FIXEDFILEINFO::dwFileFlagsMask already.
Returns
true on success, or false on failure with a message logged. If the module has no VERSIONINFO resource, false will be returned without any messages logged.

◆ GetReadableRangesOfMemoryMap()

std::vector< CheckedRange< WinVMAddress, WinVMSize > > crashpad::GetReadableRangesOfMemoryMap ( const CheckedRange< WinVMAddress, WinVMSize > &  range,
const ProcessInfo::MemoryBasicInformation64Vector memory_info 
)

Given a memory map of a process, and a range to be read from the target process, returns a vector of ranges, representing the readable portions of the original range.

This is a free function for testing, but prefer ProcessInfo::GetReadableRanges().

◆ GetSecurityDescriptorForNamedPipeInstance()

const void * crashpad::GetSecurityDescriptorForNamedPipeInstance ( size_t *  size)

Returns the SECURITY_DESCRIPTOR blob that will be used for creating the connection pipe in CreateNamedPipeInstance().

This function is only exposed for testing.

Parameters
[out]sizeThe size of the returned blob. May be nullptr if not required.
Returns
A pointer to a self-relative SECURITY_DESCRIPTOR. Ownership is not transferred to the caller.

◆ GetThreadHandleByKoid()

zx::thread crashpad::GetThreadHandleByKoid ( const zx::process &  parent,
zx_koid_t  child_koid 
)

Retrieve the handle of a process' thread, based on koid.

Parameters
[in]parentThe parent object to which the child belongs.
[in]child_koidThe koid of the child to retrieve.
Returns
A handle representing child_koid, or ZX_HANDLE_INVALID if the handle could not be retrieved, in which case an error will be logged.

◆ GetThreadHandles()

std::vector< zx::thread > crashpad::GetThreadHandles ( const zx::process &  parent)

Get handles representing a list of child objects of a given parent.

Parameters
[in]parentThe handle to the parent object.
Returns
The resulting list of handles corresponding to the child objects.
See also
GetChildKoids

◆ HandlerMain()

int crashpad::HandlerMain ( int  argc,
char *  argv[],
const UserStreamDataSources *  user_stream_sources 
)

The main() of the crashpad_handler binary.

This is exposed so that crashpad_handler can be embedded into another binary, but called and used as if it were a standalone executable.

Parameters
[in]argcargc as passed to main().
[in]argvargv as passed to main().
[in]user_stream_sourcesAn optional vector containing the extensibility data sources to call on crash. Each time a minidump is created, the sources are called in turn. Any streams returned are added to the minidump.

◆ HandleToInt()

int crashpad::HandleToInt ( HANDLE  handle)

Converts a HANDLE to an int.

HANDLE is a typedef for void *, but kernel HANDLE values aren’t pointers to anything. Only 32 bits of kernel HANDLEs are significant, even in 64-bit processes on 64-bit operating systems. See Interprocess Communication Between 32-bit and 64-bit Applications.

This function safely converts a kernel HANDLE to an int similarly to a cast operation. It checks that the operation can be performed safely, and aborts execution if it cannot.

Parameters
[in]handleThe kernel HANDLE to convert.
Returns
An equivalent int, truncated (if necessary) from handle. If truncation would have resulted in an int that could not be converted back to handle, aborts execution.
See also
IntToHandle()

◆ InitializeCriticalSectionWithDebugInfoIfPossible()

bool crashpad::InitializeCriticalSectionWithDebugInfoIfPossible ( CRITICAL_SECTION *  critical_section)

Equivalent to InitializeCritialSection(), but attempts to allocate with a valid .DebugInfo field on versions of Windows where it's possible to do so.

Returns
true on success, or false on failure with a message logged. Success means that the critical section was successfully initialized, but it does not necessarily have a valid .DebugInfo field.

◆ InitializeSignalDispositions()

bool crashpad::InitializeSignalDispositions ( )

Establishes signal dispositions for a process based on the platform.

Default signal dispositions are normally configured by the kernel, but additional signal handlers might be installed by dependent or preloaded libraries, e.g. Bionic normally installs signal handlers which log stack traces to Android's logcat.

This function initializes signal dispositions when the default dispositions provided by the platform are broken. This function must be called before any application level signal handlers have been installed and should be called early in the process lifetime to reduce the chance of any broken signal handlers being triggered.

When running on Android M (API 23), this function installs SIG_DFL for signals: SIGABRT, SIGFPE, SIGPIPE, SIGSTKFLT, and SIGTRAP.

Returns
true on success. Otherwise false with a message logged.

◆ InRangeCast()

template<typename Destination , typename Source >
Destination crashpad::InRangeCast ( Source  source,
Destination  default_value 
)

Casts to a different type if it can be done without data loss, logging a warning message and returing a default value otherwise.

Parameters
[in]sourceThe value to convert and return.
[in]default_valueThe default value to return, in the event that source cannot be represented in the destination type.
Returns
source if it can be represented in the destination type, otherwise default_value.

◆ InstallObjcExceptionPreprocessor()

void crashpad::InstallObjcExceptionPreprocessor ( )

Installs the Objective-C exception preprocessor.

When code raises an Objective-C exception, unwind the stack looking for any exception handlers. If an exception handler is encountered, test to see if it is a function known to be a catch-and-rethrow 'sinkhole' exception handler. Various routines in UIKit do this, and they obscure the crashing stack, since the original throw location is no longer present on the stack (just the re-throw) when Crashpad captures the crash report. In the case of sinkholes, trigger an immediate exception to capture the original stack.

This should be installed at the same time the CrashpadClient installs the signal handler. It should only be installed once.

◆ IntToHandle()

HANDLE crashpad::IntToHandle ( int  handle_int)

Converts an int to an HANDLE.

HANDLE is a typedef for void *, but kernel HANDLE values aren’t pointers to anything. Only 32 bits of kernel HANDLEs are significant, even in 64-bit processes on 64-bit operating systems. See Interprocess Communication Between 32-bit and 64-bit Applications.

This function safely convert an int to a kernel HANDLE similarly to a cast operation.

Parameters
[in]handle_intThe int to convert. This must have been produced by HandleToInt(), possibly in a different process.
Returns
An equivalent kernel HANDLE, sign-extended (if necessary) from handle_int.
See also
HandleToInt()

◆ IsDirectory()

bool crashpad::IsDirectory ( const base::FilePath &  path,
bool  allow_symlinks 
)

Determines if a path refers to a directory, logging a message on failure.

On POSIX, if this function fails because path does not exist, then no message is logged.

Parameters
[in]pathThe path to check.
[in]allow_symlinksWhether to allow the final component in the path to be a symbolic link to a directory.
Returns
true if the path exists and is a directory. Otherwise false.

◆ IsExceptionNonfatalResource()

bool crashpad::IsExceptionNonfatalResource ( exception_type_t  exception,
mach_exception_code_t  code_0,
pid_t  pid 
)

Determines whether an exception is a non-fatal EXC_RESOURCE.

Parameters
[in]exceptionThe exception type as received by a Mach exception handler.
[in]code_0The first exception code (code[0]) as received by a Mach exception handler.
[in]pidThe process ID that the exception occurred in. In some cases, process may need to be queried to determine whether an EXC_RESOURCE exception is fatal.
Returns
true if the exception is a non-fatal EXC_RESOURCE. false otherwise. If the exception is EXC_RESOURCE of a recognized type but it is not possible to determine whether it is fatal, returns true under the assumption that all known EXC_RESOURCE exceptions are non-fatal by default. If the exception is not EXC_RESOURCE or is an unknown EXC_RESOURCE type, returns false.

◆ IsMalformedCLKernelsModule()

bool crashpad::IsMalformedCLKernelsModule ( uint32_t  mach_o_file_type,
const std::string &  module_name,
bool *  has_timestamp 
)

Determines whether a module appears to be a malformed OpenCL cl_kernels module based on its name and Mach-O file type.

cl_kernels modules require special handling because they’re malformed on OS X 10.10 and later. A cl_kernels module always has Mach-O type MH_BUNDLE and is named "cl_kernels" until macOS 10.14, and "/private/var/db/CVMS/cvmsCodeSignObj" plus 16 random characters on macOS 10.14.

Malformed cl_kernels modules have a single __TEXT segment, but one of the sections within it claims to belong to the __LD segment. This mismatch shouldn’t happen. This errant section also has the S_ATTR_DEBUG flag set, which shouldn’t happen unless all of the other sections in the segment also have this bit set (they don’t). These odd sections are reminiscent of unwind information stored in MH_OBJECT images, although cl_kernels images claim to be MH_BUNDLE.

This function is exposed for testing purposes only.

Parameters
[in]mach_o_file_typeThe Mach-O type of the module being examined.
[in]module_nameThe pathname that dyld reported having loaded the module from.
[out]has_timestampOptional, may be nullptr. If provided, and the module is a maformed cl_kernels module, this will be set to true if the module was loaded from the filesystem (as is the case when loaded from the CVMS directory) and is expected to have a timestamp, and false otherwise. Note that even when loaded from the filesystem, these modules are unlinked from the filesystem after loading.
Returns
true if the module appears to be a malformed cl_kernels module based on the provided information, false otherwise.

◆ IsRegularFile()

bool crashpad::IsRegularFile ( const base::FilePath &  path)

Determines if a path refers to a regular file, logging a message on failure.

On POSIX, this function returns true if path refers to a file that is not a symbolic link, directory, or other kind of special file. If this function fails because path does not exist, then no message is logged.

On Windows, this function returns true if path refers to a file that is not a symbolic link or directory.

Parameters
[in]pathThe path to the file to check.
Returns
true if the file exists and is a regular file. Otherwise false.

◆ IsThreadInLoaderLock()

bool crashpad::IsThreadInLoaderLock ( )
Returns
true if the current thread holds the loader lock.

◆ LaunchDataAlloc()

launch_data_t crashpad::LaunchDataAlloc ( launch_data_type_t  type)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataArrayGetCount()

size_t crashpad::LaunchDataArrayGetCount ( launch_data_t  array)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataArrayGetIndex()

launch_data_t crashpad::LaunchDataArrayGetIndex ( launch_data_t  array,
size_t  index 
)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataArraySetIndex()

bool crashpad::LaunchDataArraySetIndex ( launch_data_t  array,
const launch_data_t  value,
size_t  index 
)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataDictGetCount()

size_t crashpad::LaunchDataDictGetCount ( launch_data_t  dict)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataDictInsert()

bool crashpad::LaunchDataDictInsert ( launch_data_t  dict,
const launch_data_t  value,
const char *  key 
)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataDictLookup()

launch_data_t crashpad::LaunchDataDictLookup ( const launch_data_t  dict,
const char *  key 
)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataFree()

void crashpad::LaunchDataFree ( launch_data_t  data)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataGetBool()

bool crashpad::LaunchDataGetBool ( const launch_data_t  data)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataGetErrno()

int crashpad::LaunchDataGetErrno ( const launch_data_t  data)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataGetInteger()

long long crashpad::LaunchDataGetInteger ( const launch_data_t  data)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataGetOpaque()

void* crashpad::LaunchDataGetOpaque ( const launch_data_t  data)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataGetOpaqueSize()

size_t crashpad::LaunchDataGetOpaqueSize ( const launch_data_t  data)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataGetReal()

double crashpad::LaunchDataGetReal ( const launch_data_t  data)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataGetString()

const char* crashpad::LaunchDataGetString ( const launch_data_t  data)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataGetType()

launch_data_type_t crashpad::LaunchDataGetType ( const launch_data_t  data)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataNewBool()

launch_data_t crashpad::LaunchDataNewBool ( bool  boolean)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataNewInteger()

launch_data_t crashpad::LaunchDataNewInteger ( long long  integer)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataNewOpaque()

launch_data_t crashpad::LaunchDataNewOpaque ( const void *  opaque,
size_t  size 
)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataNewReal()

launch_data_t crashpad::LaunchDataNewReal ( double  real)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchDataNewString()

launch_data_t crashpad::LaunchDataNewString ( const char *  string)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LaunchMsg()

launch_data_t crashpad::LaunchMsg ( const launch_data_t  data)
inline

Wraps the <launch.h> function of the same name.

The OS X 10.10 SDK deprecates <launch.h>, although the functionality it provides is still useful. These wrappers allow the deprecated functions to be called without triggering deprecated-declaration warnings.

◆ LoggingCloseFile()

bool crashpad::LoggingCloseFile ( FileHandle  file)

Wraps close() or CloseHandle(), logging an error if the operation fails.

Returns
On success, true is returned. On failure, an error is logged and false is returned.

◆ LoggingCreateDirectory()

bool crashpad::LoggingCreateDirectory ( const base::FilePath &  path,
FilePermissions  permissions,
bool  may_reuse 
)

Creates a directory, logging a message on failure.

Parameters
[in]pathThe path to the directory to create.
[in]permissionsThe permissions to use if the directory is created.
[in]may_reuseIf true, this function will return true if a directory or symbolic link to a directory with path path already exists. If the directory already exists, it's permissions may differ from permissions.
Returns
true if the directory is successfully created or it already existed and may_reuse is true. Otherwise, false.

◆ LoggingDetermineMergedRange()

bool crashpad::LoggingDetermineMergedRange ( const MemorySnapshot a,
const MemorySnapshot b,
CheckedRange< uint64_t, size_t > *  merged 
)

Given two memory snapshots, checks if they're overlapping or abutting, and if so, returns the result of merging the two ranges.

This function is useful to implement MemorySnapshot::MergeWithOtherSnapshot().

Parameters
[in]aThe first range. Must have Size() > 0.
[in]bThe second range. Must have Size() > 0.
[out]mergedThe resulting merged range. May be nullptr if only a characterization of the ranges is desired.
Returns
true if the input ranges overlap or abut, with merged filled out, otherwise, false with an error logged if log is true.

◆ LoggingFileSizeByHandle()

FileOffset crashpad::LoggingFileSizeByHandle ( FileHandle  file)

Determines the size of a file.

Parameters
[in]fileThe handle to the file for which the size should be retrieved.
Returns
The size of the file. If an error occurs when attempting to determine its size, returns -1 with an error logged.

◆ LoggingLockFile()

bool crashpad::LoggingLockFile ( FileHandle  file,
FileLocking  locking 
)

Locks the given file using flock() on POSIX or LockFileEx() on Windows.

It is an error to attempt to lock a file in a different mode when it is already locked. This call will block until the lock is acquired. The entire file is locked.

If locking is FileLocking::kShared, file must have been opened for reading, and if it's FileLocking::kExclusive, file must have been opened for writing.

Parameters
[in]fileThe open file handle to be locked.
[in]lockingControls whether the lock is a shared reader lock, or an exclusive writer lock.
Returns
true on success, or false and a message will be logged.

◆ LoggingOpenFileForRead()

FileHandle crashpad::LoggingOpenFileForRead ( const base::FilePath &  path)

Wraps OpenFileForRead(), logging an error if the operation fails.

Returns
The newly opened FileHandle, or an invalid FileHandle on failure.
See also
ScopedFileHandle
LoggingOpenFileForWrite
LoggingOpenFileForReadAndWrite

◆ LoggingOpenFileForReadAndWrite()

FileHandle crashpad::LoggingOpenFileForReadAndWrite ( const base::FilePath &  path,
FileWriteMode  mode,
FilePermissions  permissions 
)

Wraps OpenFileForReadAndWrite(), logging an error if the operation fails.

Returns
The newly opened FileHandle, or an invalid FileHandle on failure.
See also
ScopedFileHandle
LoggingOpenFileForRead
LoggingOpenFileForWrite

◆ LoggingOpenFileForWrite()

FileHandle crashpad::LoggingOpenFileForWrite ( const base::FilePath &  path,
FileWriteMode  mode,
FilePermissions  permissions 
)

Wraps OpenFileForWrite(), logging an error if the operation fails.

Returns
The newly opened FileHandle, or an invalid FileHandle on failure.
See also
ScopedFileHandle
LoggingOpenFileForRead
LoggingOpenFileForReadAndWrite

◆ LoggingReadEntireFile()

bool crashpad::LoggingReadEntireFile ( const base::FilePath &  path,
std::string *  contents 
)

Wraps LoggingOpenFileForRead() and ReadFile() reading the entire file into contents.

Returns
true on success, or false with a message logged.

◆ LoggingReadFileExactly()

bool crashpad::LoggingReadFileExactly ( FileHandle  file,
void *  buffer,
size_t  size 
)

Wraps ReadFile(), retrying following a short read, ensuring that exactly size bytes are read.

Returns
true on success. If the underlying ReadFile() fails, or if fewer than size bytes were read, this function logs a message and returns false.
See also
LoggingWriteFile
ReadFile
ReadFileExactly
CheckedReadFileExactly
CheckedReadFileAtEOF

◆ LoggingReadToEOF()

bool crashpad::LoggingReadToEOF ( FileHandle  file,
std::string *  contents 
)

Wraps ReadFile() to read from the current file position to the end of the file into contents.

Returns
true on success, or false with a message logged.

◆ LoggingRemoveDirectory()

bool crashpad::LoggingRemoveDirectory ( const base::FilePath &  path)

Non-recurseively removes an empty directory, logging a message on failure.

This function will not remove symbolic links to directories.

Parameters
[in]pathThe to the directory to remove.
Returns
true if the directory was removed. Otherwise, false.

◆ LoggingRemoveFile()

bool crashpad::LoggingRemoveFile ( const base::FilePath &  path)

Removes a file or a symbolic link to a file or directory, logging a message on failure.

Parameters
[in]pathThe path to the file to remove.
Returns
true on success. false on failure with a message logged.

◆ LoggingSeekFile()

FileOffset crashpad::LoggingSeekFile ( FileHandle  file,
FileOffset  offset,
int  whence 
)

Wraps lseek() or SetFilePointerEx(). Logs an error if the operation fails.

Repositions the offset of the open file to the specified offset, relative to whence. whence must be one of SEEK_SET, SEEK_CUR, or SEEK_END, and is interpreted in the usual way.

Returns
The resulting offset in bytes from the beginning of the file, or -1 on failure.

◆ LoggingTruncateFile()

bool crashpad::LoggingTruncateFile ( FileHandle  file)

Truncates the given file to zero bytes in length.

Returns
true on success, or false, and a message will be logged.

◆ LoggingUnlockFile()

bool crashpad::LoggingUnlockFile ( FileHandle  file)

Unlocks a file previously locked with LoggingLockFile().

It is an error to attempt to unlock a file that was not previously locked. A previously-locked file should be unlocked before closing the file handle, otherwise on some OSs the lock may not be released immediately.

Parameters
[in]fileThe open locked file handle to be unlocked.
Returns
true on success, or false and a message will be logged.

◆ LoggingWriteFile()

bool crashpad::LoggingWriteFile ( FileHandle  file,
const void *  buffer,
size_t  size 
)

Wraps WriteFile(), ensuring that exactly size bytes are written.

Returns
true on success. If the underlying WriteFile() fails, or if fewer than size bytes were written, this function logs a message and returns false.
See also
LoggingReadFileExactly
WriteFile
CheckedWriteFile

◆ MachMessageDeadlineFromTimeout()

MachMessageDeadline crashpad::MachMessageDeadlineFromTimeout ( mach_msg_timeout_t  timeout_ms)

Computes the deadline for a specified timeout value.

While deadlines exist on an absolute time scale, timeouts are relative. This function calculates the deadline as timeout_ms milliseconds after it executes.

If timeout_ms is kMachMessageDeadlineNonblocking, this function will return kMachMessageDeadlineNonblocking. If timeout_ms is kMachMessageTimeoutWaitIndefinitely, this function will return kMachMessageDeadlineWaitIndefinitely.

◆ MachMessageDestroyReceivedPort()

bool crashpad::MachMessageDestroyReceivedPort ( mach_port_t  port,
mach_msg_type_name_t  port_right_type 
)

Destroys or deallocates a Mach port received in a Mach message.

This function disposes of port rights received in a Mach message. Receive rights will be destroyed with mach_port_mod_refs(). Send and send-once rights will be deallocated with mach_port_deallocate().

Parameters
[in]portThe port to destroy or deallocate.
[in]port_right_typeThe right type held for port: MACH_MSG_TYPE_PORT_RECEIVE, MACH_MSG_TYPE_PORT_SEND, or MACH_MSG_TYPE_PORT_SEND_ONCE.
Returns
true on success, or false on failure with a message logged.

◆ MachMessageTrailerFromHeader()

const mach_msg_trailer_t * crashpad::MachMessageTrailerFromHeader ( const mach_msg_header_t *  header)

Returns a Mach message trailer for a message that has been received.

This function must only be called on Mach messages that have been received via the Mach messaging interface, such as mach_msg(). Messages constructed for sending do not contain trailers.

Parameters
[in]headerA pointer to a received Mach message.
Returns
A pointer to the trailer following the received Mach message’s body. The contents of the trailer depend on the options provided to mach_msg() or a similar function when the message was received.

◆ MachMessageWithDeadline()

mach_msg_return_t crashpad::MachMessageWithDeadline ( mach_msg_header_t *  message,
mach_msg_option_t  options,
mach_msg_size_t  receive_size,
mach_port_name_t  receive_port,
MachMessageDeadline  deadline,
mach_port_name_t  notify_port,
bool  run_even_if_expired 
)

Runs mach_msg() with a deadline, as opposed to a timeout.

This function is similar to mach_msg(), with the following differences:

  • The timeout parameter has been replaced by deadline. The deadline applies uniformly to a call that is requested to both send and receive a message.
  • The MACH_SEND_TIMEOUT and MACH_RCV_TIMEOUT bits in options are not used. Timeouts are specified by the deadline argument.
  • The send_size parameter has been removed. Its value is implied by message when options contains MACH_SEND_MSG.
  • The run_even_if_expired parameter has been added.

Like the mach_msg() wrapper in libsyscall, this function will retry operations when experiencing MACH_SEND_INTERRUPTED and MACH_RCV_INTERRUPTED, unless options contains MACH_SEND_INTERRUPT or MACH_RCV_INTERRUPT. Unlike mach_msg(), which restarts the call with the full timeout when this occurs, this function continues enforcing the user-specified deadline.

Except as noted, the parameters and return value are identical to those of mach_msg().

Parameters
[in,out]message
[in]options
[in]receive_size
[in]receive_port
[in]deadlineThe time by which this call should complete. If the deadline is exceeded, this call will return MACH_SEND_TIMED_OUT or MACH_RCV_TIMED_OUT.
[in]notify_port
[in]run_even_if_expiredIf true, a deadline that is expired when this function is called will be treated as though a deadline of kMachMessageDeadlineNonblocking had been specified. When false, an expired deadline will result in a MACH_SEND_TIMED_OUT or MACH_RCV_TIMED_OUT return value, even if the deadline is already expired when the function is called.
Returns
The return value of mach_msg()

◆ MachThreadSelf()

thread_t crashpad::MachThreadSelf ( )

Like mach_thread_self(), but without the obligation to release the send right.

mach_thread_self() returns a send right to the current thread port, incrementing its reference count. This burdens the caller with maintaining this send right, and calling mach_port_deallocate() when it is no longer needed. This is burdensome, and is at odds with the normal operation of mach_task_self(), which does not increment the task port’s reference count whose result must not be deallocated.

Callers can use this function in preference to mach_thread_self(). This function returns an extant reference to the current thread’s port without incrementing its reference count.

Returns
The value of mach_thread_self() without incrementing its reference count. The returned port must not be deallocated by mach_port_deallocate(). The returned value is valid as long as the thread continues to exist as a pthread_t.

◆ MacModelAndBoard()

void crashpad::MacModelAndBoard ( std::string *  model,
std::string *  board_id 
)

Returns the model name and board ID of the running system.

Parameters
[out]modelThe system’s model name. A mid-2012 15" MacBook Pro would report “MacBookPro10,1”.
[out]board_idThe system’s board ID. A mid-2012 15" MacBook Pro would report “Mac-C3EC7CD22292981F”.

If a value cannot be determined, its string is cleared.

◆ MacOSXMinorVersion()

int crashpad::MacOSXMinorVersion ( )

Returns the version of the running operating system.

Returns
The minor version of the operating system, such as 12 for macOS 10.12.1.
Note
This is similar to the base::mac::IsOS*() family of functions, but is provided for situations where the caller needs to obtain version information beyond what is provided by Chromium’s base, or for when the caller needs the actual minor version value.

◆ MacOSXVersion()

bool crashpad::MacOSXVersion ( int *  major,
int *  minor,
int *  bugfix,
std::string *  build,
bool *  server,
std::string *  version_string 
)

Returns the version of the running operating system.

All parameters are required. No parameter may be nullptr.

Parameters
[out]majorThe major version of the operating system, such as 10 for macOS 10.12.1.
[out]minorThe major version of the operating system, such as 12 for macOS 10.12.1.
[out]bugfixThe bugfix version of the operating system, such as 1 for macOS 10.12.1.
[out]buildThe operating system’s build string, such as "16B2657" for macOS 10.12.1.
[out]servertrue for a macOS Server installation, false otherwise (for a desktop/laptop, client, or workstation system).
[out]version_stringA string representing the full operating system version, such as "macOS 10.12.1 (16B2657)".
Returns
true on success, false on failure, with an error message logged. A failure is considered to have occurred if any element could not be determined. When this happens, their values will be untouched, but other values that could be determined will still be set properly.

◆ MapInsertOrReplace()

template<typename T >
bool crashpad::MapInsertOrReplace ( T *  map,
const typename T::key_type &  key,
const typename T::mapped_type &  value,
typename T::mapped_type *  old_value 
)

Inserts a mapping from key to value into map, or replaces an existing mapping so that key maps to value.

This behaves similarly to std::map<>::insert_or_assign() proposed for C++17, except that the old_value parameter is added.

Parameters
[in,out]mapThe map to operate on.
[in]keyThe key that should be mapped to value.
[in]valueThe value that key should map to.
[out]old_valueIf key was previously present in map, this will be set to its previous value. This parameter is optional and may be nullptr if this information is not required.
Returns
false if key was previously present in map. If old_value is not nullptr, it will be set to the previous value. true if key was not present in the map and was inserted.

◆ MoveFileOrDirectory()

bool crashpad::MoveFileOrDirectory ( const base::FilePath &  source,
const base::FilePath &  dest 
)

Moves a file, symbolic link, or directory, logging a message on failure.

source must exist and refer to a file, symbolic link, or directory.

source and dest must be on the same filesystem.

If dest exists, it may be overwritten:

If dest exists and refers to a file or to a live or dangling symbolic link to a file, it will be overwritten if source also refers to a file or to a live or dangling symbolic link to a file or directory.

On POSIX, if dest refers to a directory, it will be overwritten only if it is empty and source also refers to a directory.

On Windows, if dest refers to a directory or to a live or dangling symbolic link to a directory, it will not be overwritten.

Parameters
[in]sourceThe path to the file to be moved.
[in]destThe new path for the file.
Returns
true on success. false on failure with a message logged.

◆ NewMachPort()

mach_port_t crashpad::NewMachPort ( mach_port_right_t  right)

Creates a new Mach port in the current task.

This function wraps the mach_port_allocate() providing a simpler interface.

Parameters
[in]rightThe type of right to create.
Returns
The new Mach port. On failure, MACH_PORT_NULL with a message logged.

◆ OpenFileForRead()

FileHandle crashpad::OpenFileForRead ( const base::FilePath &  path)

Wraps open() or CreateFile(), opening an existing file for reading.

Returns
The newly opened FileHandle, or an invalid FileHandle on failure.
See also
ScopedFileHandle
OpenFileForWrite
OpenFileForReadAndWrite
LoggingOpenFileForRead

◆ OpenFileForReadAndWrite()

FileHandle crashpad::OpenFileForReadAndWrite ( const base::FilePath &  path,
FileWriteMode  mode,
FilePermissions  permissions 
)

Wraps open() or CreateFile(), creating a file for both input and output.

mode determines the style (truncate, reuse, etc.) that is used to open the file. On POSIX, permissions determines the value that is passed as mode to open(). On Windows, the file is always opened in binary mode (that is, no CRLF translation). On Windows, the file is opened for sharing, see LoggingLockFile() and LoggingUnlockFile() to control concurrent access.

Returns
The newly opened FileHandle, or an invalid FileHandle on failure.
See also
ScopedFileHandle
OpenFileForRead
OpenFileForWrite
LoggingOpenFileForReadAndWrite

◆ OpenFileForWrite()

FileHandle crashpad::OpenFileForWrite ( const base::FilePath &  path,
FileWriteMode  mode,
FilePermissions  permissions 
)

Wraps open() or CreateFile(), creating a file for output.

mode determines the style (truncate, reuse, etc.) that is used to open the file. On POSIX, permissions determines the value that is passed as mode to open(). On Windows, the file is always opened in binary mode (that is, no CRLF translation). On Windows, the file is opened for sharing, see LoggingLockFile() and LoggingUnlockFile() to control concurrent access.

Returns
The newly opened FileHandle, or an invalid FileHandle on failure.
See also
ScopedFileHandle
OpenFileForRead
OpenFileForReadAndWrite
LoggingOpenFileForWrite

◆ PrepareMIGReplyFromRequest()

void crashpad::PrepareMIGReplyFromRequest ( const mach_msg_header_t *  in_header,
mach_msg_header_t *  out_header 
)

Initializes a reply message for a MIG server routine based on its corresponding request.

If a request is handled by a server routine, it may be necessary to revise some of the fields set by this function, such as msgh_size and any fields defined in a routine’s reply structure type.

Parameters
[in]in_headerThe request message to base the reply on.
[out]out_headerThe reply message to initialize. out_header will be treated as a mig_reply_error_t* and all of its fields will be set except for RetCode, which must be set by SetMIGReplyError(). This argument is accepted as a mach_msg_header_t* instead of a mig_reply_error_t* because that is the type that callers are expected to possess in the C API.

◆ PruneCrashReportDatabase()

size_t crashpad::PruneCrashReportDatabase ( CrashReportDatabase database,
PruneCondition condition 
)

Deletes crash reports from database that match condition.

This function can be used to remove old or large reports from the database. The condition will be evaluated against each report in the database, sorted in descending order by CrashReportDatabase::Report::creation_time. This guarantee allows conditions to be stateful.

Parameters
[in]databaseThe database from which crash reports will be deleted.
[in]conditionThe condition against which all reports in the database will be evaluated.
Returns
The number of deleted crash reports.

◆ RandomString()

std::string crashpad::RandomString ( )

Returns a random string.

The string consists of 16 uppercase characters chosen at random. The returned string has over 75 bits of randomness (2616 > 275).

◆ ReadAnnotationsWhitelist()

bool crashpad::ReadAnnotationsWhitelist ( const ProcessMemoryRange memory,
VMAddress  whitelist_address,
std::vector< std::string > *  whitelist 
)

Reads an annotations whitelist from another process.

Parameters
[in]memoryA memory reader for the target process.
[in]whitelist_addressThe address in the target process' address space of a nullptr terminated array of NUL-terminated strings.
[out]whitelistThe whitelist read, valid only if this function returns true.
Returns
true on success, false on failure with a message logged.

◆ ReadFile()

FileOperationResult crashpad::ReadFile ( FileHandle  file,
void *  buffer,
size_t  size 
)

Reads from a file, retrying when interrupted before reading any data on POSIX.

This function reads into buffer. Fewer than size bytes may be read. On Windows, reading from sockets is not currently supported.

Returns
The number of bytes read and placed into buffer, or -1 on error, with errno or GetLastError() set appropriately. On error, a portion of file may have been read into buffer.
See also
WriteFile
ReadFileExactly
LoggingReadFileExactly
CheckedReadFileExactly
CheckedReadFileAtEOF

◆ ReadFileExactly()

bool crashpad::ReadFileExactly ( FileHandle  file,
void *  buffer,
size_t  size 
)

Wraps ReadFile(), retrying following a short read, ensuring that exactly size bytes are read.

Returns
true on success. If the underlying ReadFile() fails, or if fewer than size bytes were read, this function logs a message and returns false.
See also
LoggingWriteFile
ReadFile
LoggingReadFileExactly
CheckedReadFileExactly
CheckedReadFileAtEOF

◆ ReadMemoryRangeWhitelist()

bool crashpad::ReadMemoryRangeWhitelist ( const ProcessMemoryRange memory,
VMAddress  whitelist_address,
std::vector< std::pair< VMAddress, VMAddress >> *  whitelist 
)

Reads a memory range whitelist from another process.

Parameters
[in]memoryA memory reader for the target process.
[in]whitelist_addressThe address in the target process' address space of a nullptr terminated array of NUL-terminated strings.
[out]whitelistA list of whitelisted memory regions, valid only if this function returns true.
Returns
true on success, false on failure with a message logged.

◆ ReadThreadIDs()

bool crashpad::ReadThreadIDs ( pid_t  pid,
std::vector< pid_t > *  tids 
)

Enumerates the thread IDs of a process by reading /proc/pid/task.

Parameters
[in]pidThe process ID for which to read thread IDs.
[out]tidsThe read thread IDs.
Returns
true if the task directory was successfully read. Format errors are logged, but won't cause this function to return false.

◆ ReadXattr()

XattrStatus crashpad::ReadXattr ( const base::FilePath &  file,
const base::StringPiece &  name,
std::string *  value 
)

Reads an extended attribute on a file.

Parameters
[in]fileThe path to the file.
[in]nameThe name of the extended attribute to read.
[out]valueThe value of the attribute.
Returns
XattrStatus

◆ ReadXattrBool()

XattrStatus crashpad::ReadXattrBool ( const base::FilePath &  file,
const base::StringPiece &  name,
bool *  value 
)

Reads an extended attribute on a file.

Parameters
[in]fileThe path to the file.
[in]nameThe name of the extended attribute to read.
[out]valueThe value of the attribute.
Returns
XattrStatus

Only the values "0" and "1", for false and true respectively, are valid conversions.

◆ ReadXattrInt()

XattrStatus crashpad::ReadXattrInt ( const base::FilePath &  file,
const base::StringPiece &  name,
int *  value 
)

Reads an extended attribute on a file.

Parameters
[in]fileThe path to the file.
[in]nameThe name of the extended attribute to read.
[out]valueThe value of the attribute.
Returns
XattrStatus

◆ ReadXattrTimeT()

XattrStatus crashpad::ReadXattrTimeT ( const base::FilePath &  file,
const base::StringPiece &  name,
time_t *  value 
)

Reads an extended attribute on a file.

Parameters
[in]fileThe path to the file.
[in]nameThe name of the extended attribute to read.
[out]valueThe value of the attribute.
Returns
XattrStatus

◆ RecordFileLimitAnnotation()

void crashpad::RecordFileLimitAnnotation ( )

Records a "file-limits" simple annotation for the process.

This annotation will be used to confirm the theory that certain crashes are caused by systems at or near their file descriptor table size limits.

The format of the annotation is four comma-separated values: the system-wide kern.num_files and kern.maxfiles values from sysctl(), and the process-specific current and maximum file descriptor limits from getrlimit(RLIMIT_NOFILE, …).

See https://crashpad.chromium.org/bug/180.

TODO(mark): Remove this annotation after sufficient data has been collected for analysis.

◆ ReinterpretBytes()

template<typename From , typename To >
bool crashpad::ReinterpretBytes ( const From &  from,
To *  to 
)

Copies the bytes of from to to.

This function is similar to bit_cast, except that it can operate on differently sized types.

Returns
true if the copy is possible without information loss, otherwise false with a message logged.

◆ RemoveXattr()

XattrStatus crashpad::RemoveXattr ( const base::FilePath &  file,
const base::StringPiece &  name 
)

Removes an extended attribute from a file.

Parameters
[in]fileThe path to the file.
[in]nameThe name of the extended attribute to remove.
Returns
XattrStatus

◆ SafeTerminateProcess()

bool crashpad::SafeTerminateProcess ( HANDLE  process,
UINT  exit_code 
)
inline

Calls TerminateProcess().

TerminateProcess() has been observed in the wild as being patched badly on 32-bit x86: it’s patched with code adhering to the cdecl (caller clean-up) convention, although it’s supposed to be stdcall (callee clean-up). The mix-up means that neither caller nor callee perform parameter clean-up from the stack, causing the stack pointer to have an unexpected value on return from the patched function. This typically results in a crash shortly thereafter. See Crashpad bug 179.

On 32-bit x86, this replacement function calls TerminateProcess() without making any assumptions about the stack pointer on its return. As such, it’s compatible with the badly patched cdecl version as well as the native stdcall version (and other less badly patched versions).

Elsewhere, this function calls TerminateProcess() directly without any additional fanfare.

Call this function instead of TerminateProcess() anywhere that TerminateProcess() would normally be called.

◆ SendToCrashHandlerServer()

bool crashpad::SendToCrashHandlerServer ( const base::string16 &  pipe_name,
const ClientToServerMessage message,
ServerToClientMessage response 
)

Connect over the given pipe_name, passing message to the server, storing the server's reply into response.

Typically clients will not use this directly, instead using CrashpadClient::SetHandler().

See also
CrashpadClient::SetHandler()

◆ ServiceManagementIsJobLoaded()

bool crashpad::ServiceManagementIsJobLoaded ( const std::string &  label)

Determines whether a specified job is loaded in the user launchd domain.

Parameters
[in]labelThe label for the job to look up.
Returns
true if the job is loaded, otherwise false.
Note
A loaded job is not necessarily presently running, nor has it necessarily ever run in the past.
This function is provided because SMJobCopyDictionary() is deprecated in OS X 10.10. It may or may not be implemented using SMJobCopyDictionary() from ServiceManagement.framework.

◆ ServiceManagementIsJobRunning()

pid_t crashpad::ServiceManagementIsJobRunning ( const std::string &  label)

Determines whether a specified job is running in the user launchd domain.

Parameters
[in]labelThe label for the job to look up.
Returns
The job’s process ID if running, otherwise 0.
Note
This function is provided because SMJobCopyDictionary() is deprecated in OS X 10.10. It may or may not be implemented using SMJobCopyDictionary() from ServiceManagement.framework.

◆ ServiceManagementRemoveJob()

bool crashpad::ServiceManagementRemoveJob ( const std::string &  label,
bool  wait 
)

Removes a job from the user launchd domain as in SMJobRemove().

Parameters
[in]labelThe label for the job to remove.
[in]waittrue if this function should block, waiting for the job to be removed. false if the job may be removed asynchronously.
Returns
true if the job was removed successfully or if an asynchronous attempt to remove the job was started successfully, otherwise false.
Note
This function is provided because SMJobRemove() is deprecated in OS X 10.10. On OS X 10.10, observed in DP8 14A361c, it also blocks for far too long (_block_until_job_exits() contains a one-second sleep(), filed as radar 18398683) and does not signal failure via its return value when asked to remove a nonexistent job (filed as radar 18268941).

◆ ServiceManagementSubmitJob()

bool crashpad::ServiceManagementSubmitJob ( CFDictionaryRef  job_cf)

Submits a job to the user launchd domain as in SMJobSubmit().

Parameters
[in]job_cfA dictionary describing a job.
Returns
true if the job was submitted successfully, otherwise false.
Note
This function is provided because SMJobSubmit() is deprecated in OS X 10.10. It may or may not be implemented using SMJobSubmit() from ServiceManagement.framework.

◆ SetMIGReplyError()

void crashpad::SetMIGReplyError ( mach_msg_header_t *  out_header,
kern_return_t  error 
)

Sets the error code in a reply message for a MIG server routine.

Parameters
[in,out]out_headerThe reply message to operate on. out_header will be treated as a mig_reply_error_t* and its RetCode field will be set. This argument is accepted as a mach_msg_header_t* instead of a mig_reply_error_t* because that is the type that callers are expected to possess in the C API.
[in]errorThe error code to store in out_header.
See also
PrepareMIGReplyFromRequest()

◆ SignalToString()

std::string crashpad::SignalToString ( int  signal,
SymbolicConstantToStringOptions  options 
)

Converts a POSIX signal value to a textual representation.

Parameters
[in]signalThe signal value to convert.
[in]optionsOptions affecting the conversion. kUseOr is ignored. For kUnknownIsNumeric, the format is "%d".
Returns
The converted string.

◆ SimulateCrash()

void crashpad::SimulateCrash ( const NativeCPUContext &  cpu_context)

Simulates a exception without crashing.

This function searches for an EXC_CRASH handler in the same manner that the kernel does, and sends it an exception message to that handler in the format that the handler expects, considering the behavior and thread state flavor that are registered for it. The exception sent to the handler will be kMachExceptionSimulated, not EXC_CRASH.

Typically, the CRASHPAD_SIMULATE_CRASH() macro will be used in preference to this function, because it combines the context-capture operation with the raising of a simulated exception.

This function returns normally after the exception message is processed. If no valid handler was found, or no handler processed the exception successfully, a warning will be logged, but these conditions are not considered fatal.

Parameters
[in]cpu_contextThe thread state to pass to the exception handler as the exception context, provided that it is compatible with the thread state flavor that the exception handler accepts. If it is not compatible, the correct thread state for the handler will be obtained by calling thread_get_state().

◆ SleepNanoseconds()

void crashpad::SleepNanoseconds ( uint64_t  nanoseconds)

Sleeps for the specified duration.

Parameters
[in]nanosecondsThe number of nanoseconds to sleep. The actual sleep may be slightly longer due to latencies and timer resolution.

On POSIX, this function is resilient against the underlying nanosleep() system call being interrupted by a signal.

◆ SplitString()

std::vector< std::string > crashpad::SplitString ( const std::string &  string,
char  delimiter 
)

Splits a string into multiple parts on the given delimiter.

Parameters
[in]stringThe string to split.
[in]delimiterThe delimiter to split at.
Returns
The individual parts of the string.

◆ SplitStringFirst()

bool crashpad::SplitStringFirst ( const std::string &  string,
char  delimiter,
std::string *  left,
std::string *  right 
)

Splits a string into two parts at the first delimiter found.

Parameters
[in]stringThe string to split.
[in]delimiterThe delimiter to split at.
[out]leftThe portion of string up to, but not including, the first delimiter character.
[out]rightThe portion of string after the first delimiter character.
Returns
true if string was split successfully. false if string did not contain a delimiter character or began with a delimiter character.

◆ StdioFileHandle()

FileHandle crashpad::StdioFileHandle ( StdioStream  stdio_stream)

Returns a FileHandle corresponding to the requested standard I/O stream.

The returned FileHandle should not be closed on POSIX, where it is important to maintain valid file descriptors occupying the slots reserved for these streams. If a need to close such a stream arises on POSIX, dup2() should instead be used to replace the existing file descriptor with one opened to /dev/null. See CloseStdinAndStdout().

Parameters
[in]stdio_streamThe requested standard I/O stream.
Returns
A corresponding FileHandle on success. kInvalidFileHandle on error, with a message logged.

◆ StringToException()

bool crashpad::StringToException ( const base::StringPiece &  string,
StringToSymbolicConstantOptions  options,
exception_type_t *  exception 
)

Converts a string to its corresponding Mach exception value.

Parameters
[in]stringThe string to convert.
[in]optionsOptions affecting the conversion. kAllowOr is ignored.
[out]exceptionThe converted Mach exception value.
Returns
true on success, false if string could not be converted as requested.

◆ StringToExceptionBehavior()

bool crashpad::StringToExceptionBehavior ( const base::StringPiece &  string,
StringToSymbolicConstantOptions  options,
exception_behavior_t *  behavior 
)

Converts a string to its corresponding Mach exception behavior value.

Parameters
[in]stringThe string to convert.
[in]optionsOptions affecting the conversion. kAllowOr is ignored. MACH_EXCEPTION_CODES can always be ORed in, but no other values can be ORed with each other.
[out]behaviorThe converted Mach exception behavior value.
Returns
true on success, false if string could not be converted as requested.

◆ StringToExceptionMask()

bool crashpad::StringToExceptionMask ( const base::StringPiece &  string,
StringToSymbolicConstantOptions  options,
exception_mask_t *  exception_mask 
)

Converts a string to its corresponding Mach exception mask value.

Parameters
[in]stringThe string to convert.
[in]optionsOptions affecting the conversion. kAllowOr is honored.
[out]exception_maskThe converted Mach exception mask value.
Returns
true on success, false if string could not be converted as requested.

◆ StringToNumber() [1/6]

bool crashpad::StringToNumber ( const std::string &  string,
int *  number 
)

Convert a string to a number.

A conversion will only be performed if it can be done perfectly: if string contains no leading or trailing characters (including whitespace) other than the number to convert, and does not overflow the targeted data type.

Parameters
[in]stringThe string to convert to a number. As in strtol() with a base parameter of 0, the string is treated as decimal unless it begins with a "0x" or "0X" prefix, in which case it is treated as hexadecimal, or a "0" prefix, in which case it is treated as octal.
[out]numberThe converted number. This will only be set if a perfect conversion can be performed.
Returns
true if a perfect conversion could be performed, with number set appropriately. false if a perfect conversion was not possible.
Note
The interface in base/strings/string_number_conversions.h doesn’t allow arbitrary bases based on whether the string begins with a prefix indicating its base. The functions here are provided for situations where such prefix recognition is desirable.

◆ StringToNumber() [2/6]

bool crashpad::StringToNumber ( const std::string &  string,
long *  number 
)

Convert a string to a number.

A conversion will only be performed if it can be done perfectly: if string contains no leading or trailing characters (including whitespace) other than the number to convert, and does not overflow the targeted data type.

Parameters
[in]stringThe string to convert to a number. As in strtol() with a base parameter of 0, the string is treated as decimal unless it begins with a "0x" or "0X" prefix, in which case it is treated as hexadecimal, or a "0" prefix, in which case it is treated as octal.
[out]numberThe converted number. This will only be set if a perfect conversion can be performed.
Returns
true if a perfect conversion could be performed, with number set appropriately. false if a perfect conversion was not possible.
Note
The interface in base/strings/string_number_conversions.h doesn’t allow arbitrary bases based on whether the string begins with a prefix indicating its base. The functions here are provided for situations where such prefix recognition is desirable.

◆ StringToNumber() [3/6]

bool crashpad::StringToNumber ( const std::string &  string,
long long *  number 
)

Convert a string to a number.

A conversion will only be performed if it can be done perfectly: if string contains no leading or trailing characters (including whitespace) other than the number to convert, and does not overflow the targeted data type.

Parameters
[in]stringThe string to convert to a number. As in strtol() with a base parameter of 0, the string is treated as decimal unless it begins with a "0x" or "0X" prefix, in which case it is treated as hexadecimal, or a "0" prefix, in which case it is treated as octal.
[out]numberThe converted number. This will only be set if a perfect conversion can be performed.
Returns
true if a perfect conversion could be performed, with number set appropriately. false if a perfect conversion was not possible.
Note
The interface in base/strings/string_number_conversions.h doesn’t allow arbitrary bases based on whether the string begins with a prefix indicating its base. The functions here are provided for situations where such prefix recognition is desirable.

◆ StringToNumber() [4/6]

bool crashpad::StringToNumber ( const std::string &  string,
unsigned int *  number 
)

Convert a string to a number.

A conversion will only be performed if it can be done perfectly: if string contains no leading or trailing characters (including whitespace) other than the number to convert, and does not overflow the targeted data type.

Parameters
[in]stringThe string to convert to a number. As in strtol() with a base parameter of 0, the string is treated as decimal unless it begins with a "0x" or "0X" prefix, in which case it is treated as hexadecimal, or a "0" prefix, in which case it is treated as octal.
[out]numberThe converted number. This will only be set if a perfect conversion can be performed.
Returns
true if a perfect conversion could be performed, with number set appropriately. false if a perfect conversion was not possible.
Note
The interface in base/strings/string_number_conversions.h doesn’t allow arbitrary bases based on whether the string begins with a prefix indicating its base. The functions here are provided for situations where such prefix recognition is desirable.

◆ StringToNumber() [5/6]

bool crashpad::StringToNumber ( const std::string &  string,
unsigned long *  number 
)

Convert a string to a number.

A conversion will only be performed if it can be done perfectly: if string contains no leading or trailing characters (including whitespace) other than the number to convert, and does not overflow the targeted data type.

Parameters
[in]stringThe string to convert to a number. As in strtol() with a base parameter of 0, the string is treated as decimal unless it begins with a "0x" or "0X" prefix, in which case it is treated as hexadecimal, or a "0" prefix, in which case it is treated as octal.
[out]numberThe converted number. This will only be set if a perfect conversion can be performed.
Returns
true if a perfect conversion could be performed, with number set appropriately. false if a perfect conversion was not possible.
Note
The interface in base/strings/string_number_conversions.h doesn’t allow arbitrary bases based on whether the string begins with a prefix indicating its base. The functions here are provided for situations where such prefix recognition is desirable.

◆ StringToNumber() [6/6]

bool crashpad::StringToNumber ( const std::string &  string,
unsigned long long *  number 
)

Convert a string to a number.

A conversion will only be performed if it can be done perfectly: if string contains no leading or trailing characters (including whitespace) other than the number to convert, and does not overflow the targeted data type.

Parameters
[in]stringThe string to convert to a number. As in strtol() with a base parameter of 0, the string is treated as decimal unless it begins with a "0x" or "0X" prefix, in which case it is treated as hexadecimal, or a "0" prefix, in which case it is treated as octal.
[out]numberThe converted number. This will only be set if a perfect conversion can be performed.
Returns
true if a perfect conversion could be performed, with number set appropriately. false if a perfect conversion was not possible.
Note
The interface in base/strings/string_number_conversions.h doesn’t allow arbitrary bases based on whether the string begins with a prefix indicating its base. The functions here are provided for situations where such prefix recognition is desirable.

◆ StringToSignal()

bool crashpad::StringToSignal ( const base::StringPiece &  string,
StringToSymbolicConstantOptions  options,
int *  signal 
)

Converts a string to its corresponding POSIX signal value.

Parameters
[in]stringThe string to convert.
[in]optionsOptions affecting the conversion. kAllowOr is ignored.
[out]signalThe converted POSIX signal value.
Returns
true on success, false if string could not be converted as requested.

◆ StringToThreadStateFlavor()

bool crashpad::StringToThreadStateFlavor ( const base::StringPiece &  string,
StringToSymbolicConstantOptions  options,
thread_state_flavor_t *  flavor 
)

Converts a string to its corresponding thread state flavor value.

Parameters
[in]stringThe string to convert.
[in]optionsOptions affecting the conversion. kAllowOr is ignored.
[out]flavorThe converted thread state flavor value.
Returns
true on success, false if string could not be converted as requested.

◆ StringVectorToCStringVector()

void crashpad::StringVectorToCStringVector ( const std::vector< std::string > &  strings,
std::vector< const char * > *  c_strings 
)

Flattens a string vector into a const char* vector suitable for use in an exec() call.

Parameters
[in]stringsA vector of string data. This vector must remain valid for the lifetime of c_strings.
[out]c_stringsA vector of pointers to the string data in strings.

◆ strnlen()

size_t crashpad::strnlen ( const char *  string,
size_t  max_length 
)
inline

Returns the length of a string, not to exceed a maximum.

Parameters
[in]stringThe string whose length is to be calculated.
[in]max_lengthThe maximum length to return.
Returns
The length of string, determined as the index of the first NUL byte found, not exceeding max_length.
Note
This function is provided because it was introduced in POSIX.1-2008, and not all systems’ standard libraries provide an implementation.

◆ SystemCrashReporterHandler()

base::mac::ScopedMachSendRight crashpad::SystemCrashReporterHandler ( )

Obtains the system’s default Mach exception handler for crash-type exceptions.

This is obtained by looking up "com.apple.ReportCrash" with the bootstrap server. The service name comes from the first launch agent loaded by launchd with a MachServices entry having ExceptionServer set. This launch agent is normally loaded from /System/Library/LaunchAgents/com.apple.ReportCrash.plist.

Returns
On success, a send right to an exception_handler_t corresponding to the system’s default crash reporter. On failure, MACH_PORT_NULL, with a message logged.

◆ TaskForPID()

task_t crashpad::TaskForPID ( pid_t  pid)

Wraps task_for_pid().

This function exists to support task_for_pid() access checks in a setuid environment. Normally, task_for_pid() can only return an arbitrary task’s port when running as root or when taskgated(8) approves. When not running as root, a series of access checks are perfomed to ensure that the running process has permission to obtain the other process’ task port.

It is possible to make an executable setuid root to give it broader task_for_pid() access by bypassing taskgated(8) checks, but this also has the effect of bypassing the access checks, allowing any process’ task port to be obtained. In most situations, these access checks are desirable to prevent security and privacy breaches.

When running as setuid root, this function wraps task_for_pid(), reimplementing those access checks. A process whose effective user ID is 0 and whose real user ID is nonzero is understood to be running setuid root. In this case, the requested task’s real, effective, and saved set-user IDs must all equal the running process’ real user ID, the requested task must not have changed privileges, and the requested task’s set of all group IDs (including its real, effective, and saved set-group IDs and supplementary group list) must be a subset of the running process’ set of all group IDs. These access checks mimic those that the kernel performs.

When not running as setuid root, task_for_pid() is called directly, without imposing any additional checks beyond what the kernel does.

Parameters
[in]pidThe process ID of the task whose task port is desired.
Returns
A send right to the task port if it could be obtained, or TASK_NULL otherwise, with an error message logged. If a send right is returned, the caller takes ownership of it.

◆ ThreadStateFlavorToString()

std::string crashpad::ThreadStateFlavorToString ( thread_state_flavor_t  flavor,
SymbolicConstantToStringOptions  options 
)

Converts a thread state flavor value to a textual representation.

Parameters
[in]flavorThe thread state flavor value to convert.
[in]optionsOptions affecting the conversion. kUseOr is ignored. For kUnknownIsNumeric, the format is "%d".
Returns
The converted string.

◆ TimespecToTimeval()

bool crashpad::TimespecToTimeval ( const timespec &  ts,
timeval *  tv 
)

Convert the timespec ts to a timeval tv.

Returns
true if the assignment is possible without truncation.

◆ UniversalExceptionRaise()

kern_return_t crashpad::UniversalExceptionRaise ( exception_behavior_t  behavior,
exception_handler_t  exception_port,
thread_t  thread,
task_t  task,
exception_type_t  exception,
const mach_exception_data_type_t *  code,
mach_msg_type_number_t  code_count,
thread_state_flavor_t *  flavor,
ConstThreadState  old_state,
mach_msg_type_number_t  old_state_count,
thread_state_t  new_state,
mach_msg_type_number_t *  new_state_count 
)

Calls the appropriate *exception_raise*() function for the specified behavior.

The function called will be exception_raise() for EXCEPTION_DEFAULT, exception_raise_state() for EXCEPTION_STATE, or exception_raise_state_identity() for EXCEPTION_STATE_IDENTITY. If MACH_EXCEPTION_CODES is also set, the function called will instead be mach_exception_raise(), mach_exception_raise_state() or mach_exception_raise_state_identity(), respectively.

This function does not fetch the existing thread state for behavior values that require a thread state. The caller must provide the existing thread state in the flavor, old_state, and old_state_count parameters for behavior values that require a thread state. Thread states may be obtained by calling thread_get_state() if needed. Similarly, this function does not do anything with the new thread state returned for these behavior values. Callers that wish to make use of the new thread state may do so by using the returned flavor, new_state, and new_state_count values. Thread states may be set by calling thread_set_state() if needed.

thread and task are only used when behavior indicates that the exception message will carry identity information, when it has the value EXCEPTION_DEFAULT or EXCEPTION_STATE_IDENTITY, possibly with MACH_EXCEPTION_CODES also set. In other cases, these parameters are unused and may be set to THREAD_NULL and TASK_NULL, respectively.

flavor, old_state, old_state_count, new_state, and new_state_count are only used when behavior indicates that the exception message will carry thread state information, when it has the value EXCEPTION_STATE or EXCEPTION_STATE_IDENTITY, possibly with MACH_EXCEPTION_CODES also set. In other cases, these parameters are unused and may be set to 0 (old_state_count) or nullptr (the remaining parameters).

Except as noted, the parameters and return value are equivalent to those of the *exception_raise*() family of functions.

Parameters
[in]behaviorThe exception behavior, which dictates which function will be called. It is an error to call this function with an invalid value for behavior.
[in]exception_port
[in]thread
[in]task
[in]exception
[in]codeIf behavior indicates a behavior without MACH_EXCEPTION_CODES, the elements of code will be truncated in order to be passed to the appropriate exception handler.
[in]code_count
[in,out]flavor
[in]old_state
[in]old_state_count
[out]new_state
[out]new_state_count
Returns
The return value of the function called.

◆ URLEncode()

std::string crashpad::URLEncode ( const std::string &  url)

Performs percent-encoding (URL encoding) on the input string, following RFC 3986 paragraph 2.

Parameters
[in]urlThe string to be encoded.
Returns
The encoded string.

◆ WriteFile()

bool crashpad::WriteFile ( FileHandle  file,
const void *  buffer,
size_t  size 
)

Writes to a file, retrying when interrupted on POSIX or following a short write.

This function writes to file, stopping only when size bytes have been written.

Returns
true on success. false on error, with errno or GetLastError() set appropriately. On error, a portion of buffer may have been written to file.
See also
ReadFile
LoggingWriteFile
CheckedWriteFile

◆ WriteXattr()

bool crashpad::WriteXattr ( const base::FilePath &  file,
const base::StringPiece &  name,
const std::string &  value 
)

Writes an extended attribute on a file.

Parameters
[in]fileThe path to the file.
[in]nameThe name of the extended attribute to write.
[in]valueThe value of the attribute.
Returns
true if the write was successful. false on error, with a message logged.

◆ WriteXattrBool()

bool crashpad::WriteXattrBool ( const base::FilePath &  file,
const base::StringPiece &  name,
bool  value 
)

Writes an extended attribute on a file.

Parameters
[in]fileThe path to the file.
[in]nameThe name of the extended attribute to write.
[in]valueThe value of the attribute.
Returns
true if the write was successful. false on error, with a message logged.

◆ WriteXattrInt()

bool crashpad::WriteXattrInt ( const base::FilePath &  file,
const base::StringPiece &  name,
int  value 
)

Writes an extended attribute on a file.

Parameters
[in]fileThe path to the file.
[in]nameThe name of the extended attribute to write.
[in]valueThe value of the attribute.
Returns
true if the write was successful. false on error, with a message logged.

◆ WriteXattrTimeT()

bool crashpad::WriteXattrTimeT ( const base::FilePath &  file,
const base::StringPiece &  name,
time_t  value 
)

Writes an extended attribute on a file.

Parameters
[in]fileThe path to the file.
[in]nameThe name of the extended attribute to write.
[in]valueThe value of the attribute.
Returns
true if the write was successful. false on error, with a message logged.

◆ ZlibErrorString()

std::string crashpad::ZlibErrorString ( int  zr)

Formats a string for an error received from the zlib library.

Parameters
[in]zrA zlib result code, such as Z_STREAM_ERROR.
Returns
A formatted string.

◆ ZlibWindowBitsWithGzipWrapper()

int crashpad::ZlibWindowBitsWithGzipWrapper ( int  window_bits)

Obtain a window_bits parameter to pass to deflateInit2() or inflateInit2() that specifies a gzip wrapper instead of the default zlib wrapper.

Parameters
[in]window_bitsA window_bits value that only specifies the base-2 logarithm of the deflate sliding window size.
Returns
window_bits adjusted to specify a gzip wrapper, to be passed to deflateInit2() or inflateInit2().

Variable Documentation

◆ g_test_crashpad_info

TestCrashpadInfo crashpad::g_test_crashpad_info
Initial value:
= {'CPad',
sizeof(TestCrashpadInfo),
1,
0,
0,
0,
0,
0,
0,
nullptr,
nullptr,
nullptr,
nullptr,
}

◆ kMachExceptionCodes

constexpr exception_behavior_t crashpad::kMachExceptionCodes = MACH_EXCEPTION_CODES
constexpr

MACH_EXCEPTION_CODES with the correct type for a Mach exception behavior, exception_behavior_t.

Signedness problems can occur when ORing MACH_EXCEPTION_CODES as a signed integer, because a signed integer overflow results. This constant can be used instead of MACH_EXCEPTION_CODES in such cases.

◆ kMachMessageReceiveAuditTrailer

constexpr mach_msg_option_t crashpad::kMachMessageReceiveAuditTrailer
constexpr
Initial value:
=
MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0) |
MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_AUDIT)

A Mach message option specifying that an audit trailer should be delivered during a receive operation.

This constant is provided because the macros normally used to request this behavior are cumbersome.

◆ kMachPortNull

constexpr mach_port_t crashpad::kMachPortNull = MACH_PORT_NULL
constexpr

MACH_PORT_NULL with the correct type for a Mach port, mach_port_t.

For situations where implicit conversions between signed and unsigned types are not performed, use kMachPortNull instead of an explicit implicit_cast of MACH_PORT_NULL to mach_port_t. This is useful for logging and testing assertions.

◆ kMaxNumberOfAnnotations

constexpr size_t crashpad::kMaxNumberOfAnnotations = 200
constexpr

The maximum number of crashpad::Annotations that will be read from a client process.

Note
This maximum was chosen arbitrarily and may change in the future.