chromecrash

package
v0.0.0-...-683b059 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package chromecrash contains functionality shared by tests that exercise Chrome crash-dumping.

Index

Constants

View Source
const (
	// CryptohomePattern is a glob pattern that matches all of the cryptohome links
	// inside of /run/daemon-store
	CryptohomePattern = "/run/daemon-store/crash/*"

	// TestModeSuccessfulFile is the special file that crash_sender creates if it
	// successfully got the crash report. MUST MATCH kTestModeSuccessfulFile in
	// crash_sender_util.cc
	TestModeSuccessfulFile = "/var/spool/crash/crash_sender_test_mode_successful"
)

Variables

This section is empty.

Functions

func FindBreakpadDmpFilesIn

func FindBreakpadDmpFilesIn(dirPattern string, files []string) error

FindBreakpadDmpFilesIn looks through the list of files returned from KillAndGetCrashFiles, expecting to find .dmp output files written by breakpad if it writes the dump directly (without invoking crash_reporter).

func FindCrashFilesIn

func FindCrashFilesIn(dirPattern string, files []string) error

FindCrashFilesIn looks through the list of files returned from KillAndGetCrashFiles, expecting to find the crash output files written by crash_reporter after a Chrome crash. In particular, it expects to find a .meta file and a matching .dmp file. dirPattern is a glob-style pattern indicating where the crash files should be found. FindCrashFilesIn returns an error if the files are not found in the expected directory; otherwise, it returns nil.

func GetExtraArgs

func GetExtraArgs(handler CrashHandler, consentType crash.ConsentType) []string

GetExtraArgs gives the list of arguments we should pass via chrome.ExtraArgs into the chrome.New() function.

func KillCrashpad

func KillCrashpad(ctx context.Context) error

KillCrashpad kills all chrome_crashpad_handler processes running in the system. It returns when there are no more chrome_crashpad_handler processes running.

Types

type CrashFileType

type CrashFileType int

CrashFileType is an enum listing the types of crash output files the crash system might produce.

const (
	// MetaFile refers to the .meta files created by crash_reporter. This is the
	// normal crash file type.
	MetaFile CrashFileType = iota
	// BreakpadDmp indicates the .dmp files generated directly by breakpad and
	// crashpad. We only see these when we are skipping crash_reporter and having
	// breakpad / crashpad dump directly.
	BreakpadDmp
	// NoCrashFile indicates that we don't expect to see any crash files from the
	// kill. Note that this means KillAndGetCrashFiles() may not wait for anything
	// after sending a signal to the target process; the target process will
	// often not be completely finished crashing after KillAndGetCrashFiles()
	// returns.
	NoCrashFile
)

func (CrashFileType) String

func (cfType CrashFileType) String() string

String returns a string naming the given CrashFileType, suitable for displaying in log and error messages.

type CrashHandler

type CrashHandler int

CrashHandler indicates which crash handler the test wants Chrome to use: breakpad or crashpad.

const (
	// Breakpad indicates Chrome should install the older breakpad crash handler. Breakpad
	// is an in-process crash handler.
	Breakpad CrashHandler = iota
	// Crashpad indicates Chrome should install the new crashpad crash handler. Crashpad
	// runs as a separate "chrome_crashpad_handler" process which monitors the chrome processes.
	Crashpad
)

type CrashTester

type CrashTester struct {
	// contains filtered or unexported fields
}

CrashTester maintains state between different parts of the Chrome crash tests. It should be created (via NewCrashTester) before chrome.New is called. Close should be called at the end of the test.

func NewCrashTester

func NewCrashTester(ctx context.Context, ptype ProcessType, waitFor CrashFileType) (*CrashTester, error)

NewCrashTester returns a CrashTester. This must be called before chrome.New. ptype indicates the type of process the KillAndGetCrashFiles will kill. For some process types, we wait for the crash file to appear. In these cases, waitFor indicates the type of file we are waiting for.

func (*CrashTester) Close

func (ct *CrashTester) Close()

Close closes a CrashTester. It must be called on all CrashTesters returned from NewCrashTester.

func (*CrashTester) KillAndGetCrashFiles

func (ct *CrashTester) KillAndGetCrashFiles(ctx context.Context) ([]string, error)

KillAndGetCrashFiles sends SIGSEGV to the given Chrome process, waits for it to crash, finds all the new crash files, and then deletes them and returns their paths.

type ProcessType

type ProcessType int

ProcessType is an enum listed the types of Chrome processes we can kill.

const (
	// Browser indicates the root Chrome process, the one without a --type flag.
	Browser ProcessType = iota
	// GPUProcess indicates a process with --type=gpu-process. We use GPUProcess
	// to stand in for most types of non-Browser processes, including renderer and
	// zygote; given the comments above Chrome's NonBrowserCrashHandler class, the
	// code path should be similar enough that we don't need separate tests for
	// those process types.
	GPUProcess
	// Broker indicates a process with --type=broker. Broker processes go through
	// a special code path because they are forked directly.
	Broker
)

func (ProcessType) String

func (ptype ProcessType) String() string

String returns a string naming the given ProcessType, suitable for displaying in log and error messages.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL