MallocDebug

public class MallocDebug
extends Object implements AutoCloseable

java.lang.Object
   ↳ com.android.sts.common.MallocDebug


Utilities to setup malloc debug options on a process, check for malloc debug errors, and cleaning up afterwards.

Summary

Public methods

void close()
static AutoCloseable withLibcMallocDebugOnAllNewProcesses(ITestDevice device, String mallocDebugOptions)

Start attaching libc malloc debug to all processes launching after this call, asserting no malloc debug error upon closing.

static AutoCloseable withLibcMallocDebugOnNewProcess(ITestDevice device, String mallocDebugOptions, String processName)

Set up so that malloc debug will attach to the given processName, and assert no malloc debug error upon closing.

static AutoCloseable withLibcMallocDebugOnService(ITestDevice device, String mallocDebugOptions, String processName)

Restart the given service and enable malloc debug on it, asserting no malloc debug error upon closing.

Public methods

close

public void close ()

Throws
Exception

withLibcMallocDebugOnAllNewProcesses

public static AutoCloseable withLibcMallocDebugOnAllNewProcesses (ITestDevice device, 
                String mallocDebugOptions)

Start attaching libc malloc debug to all processes launching after this call, asserting no malloc debug error upon closing.

Parameters
device ITestDevice: the device to use

mallocDebugOptions String: value to set libc.debug.malloc.options to.

Returns
AutoCloseable The AutoCloseable object that will disable libc malloc debug and check for malloc debug errors when closed.

Throws
DeviceNotAvailableException
TimeoutException
ProcessUtil.KillException

withLibcMallocDebugOnNewProcess

public static AutoCloseable withLibcMallocDebugOnNewProcess (ITestDevice device, 
                String mallocDebugOptions, 
                String processName)

Set up so that malloc debug will attach to the given processName, and assert no malloc debug error upon closing. Note that processName will need to be manually launched after this call.

Parameters
device ITestDevice: the device to use

mallocDebugOptions String: value to set libc.debug.malloc.options to.

processName String: the process to attach libc malloc debug to. Should not be running yet.

Returns
AutoCloseable The AutoCloseable object that will disable libc malloc debug and check for malloc debug errors when closed.

Throws
DeviceNotAvailableException
IllegalArgumentException
TimeoutException
ProcessUtil.KillException

withLibcMallocDebugOnService

public static AutoCloseable withLibcMallocDebugOnService (ITestDevice device, 
                String mallocDebugOptions, 
                String processName)

Restart the given service and enable malloc debug on it, asserting no malloc debug error upon closing.

Parameters
device ITestDevice: the device to use

mallocDebugOptions String: value to set libc.debug.malloc.options to.

processName String: the service process to attach libc malloc debug to. Should be running.

Returns
AutoCloseable The AutoCloseable object that will restart/unattach the service, disable libc malloc debug, and check for malloc debug errors when closed.

Throws
DeviceNotAvailableException
IllegalArgumentException
TimeoutException
ProcessUtil.KillException