Crashpad
Public Member Functions | List of all members
crashpad::Ptracer Class Reference

Provides an architecturally agnostic interface for collecting information with ptrace. More...

#include "util/linux/ptracer.h"

Public Member Functions

 Ptracer (bool is_64_bit, bool can_log)
 Constructs this object with a pre-determined bitness. More...
 
 Ptracer (bool can_log)
 Constructs this object without a pre-determined bitness. More...
 
bool Initialize (pid_t pid)
 Initializes this object to the bitness of the process whose process ID is pid. More...
 
bool Is64Bit ()
 Return true if this object is configured for 64-bit.
 
bool GetThreadInfo (pid_t tid, ThreadInfo *info)
 Uses ptrace to collect information about the thread with thread ID tid. More...
 
ssize_t ReadUpTo (pid_t pid, LinuxVMAddress address, size_t size, char *buffer)
 Uses ptrace to read memory from the process with process ID pid, up to a maximum number of bytes. More...
 

Detailed Description

Provides an architecturally agnostic interface for collecting information with ptrace.

A ptracer is configured for a particular bitness. It is an error to make any calls via this object against a thread whose bitness does not match the bitness this object was initialized with.

Constructor & Destructor Documentation

◆ Ptracer() [1/2]

crashpad::Ptracer::Ptracer ( bool  is_64_bit,
bool  can_log 
)

Constructs this object with a pre-determined bitness.

Parameters
[in]is_64_bittrue if this object is to be configured for 64-bit.
[in]can_logWhether methods in this class can log error messages.

◆ Ptracer() [2/2]

crashpad::Ptracer::Ptracer ( bool  can_log)
explicit

Constructs this object without a pre-determined bitness.

Initialize() must be successfully called before making any other calls on this object.

Parameters
[in]can_logWhether methods in this class can log error messages.

Member Function Documentation

◆ GetThreadInfo()

bool crashpad::Ptracer::GetThreadInfo ( pid_t  tid,
ThreadInfo info 
)

Uses ptrace to collect information about the thread with thread ID tid.

The target thread should be attached before calling this method.

See also
ScopedPtraceAttach
Parameters
[in]tidThe thread ID of the thread to collect information for.
[out]infoA ThreadInfo for the thread.
Returns
true on success. false on failure with a message logged, if enabled.

◆ Initialize()

bool crashpad::Ptracer::Initialize ( pid_t  pid)

Initializes this object to the bitness of the process whose process ID is pid.

Parameters
[in]pidThe process ID of the process to initialize with.
Returns
true on success. false on failure with a message logged, if enabled.

◆ ReadUpTo()

ssize_t crashpad::Ptracer::ReadUpTo ( pid_t  pid,
LinuxVMAddress  address,
size_t  size,
char *  buffer 
)

Uses ptrace to read memory from the process with process ID pid, up to a maximum number of bytes.

The target process should already be attached before calling this method.

See also
ScopedPtraceAttach
Parameters
[in]pidThe process ID whose memory to read.
[in]addressThe base address of the region to read.
[in]sizeThe size of the memory region to read. buffer must be at least this size.
[out]bufferThe buffer to fill with the data read.
Returns
the number of bytes read, 0 if there are no more bytes to read, or -1 on failure with a message logged if logging is enabled.

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