heuristic

package
v0.0.0-...-d3da680 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Patterns for Python stack trace frames.
	PYTHON_STACK_TRACE_FRAME_PATTERN_1 = `File "(?P<file>.+\.py)", line (?P<line>[0-9]+), in (?P<function>.+)`
	PYTHON_STACK_TRACE_FRAME_PATTERN_2 = `(?P<function>[^\s]+) at (?P<file>.+\.py):(?P<line>[0-9]+)`
	// Match file path separator: "/", "//", "\", "\\".
	PATH_SEPARATOR_PATTERN = `(?:/{1,2}|\\{1,2})`

	// Match drive root directory on Windows, like "C:/" or "C:\\".
	WINDOWS_ROOT_PATTERN = `[a-zA-Z]:` + PATH_SEPARATOR_PATTERN

	// Match system root directory on Linux/Mac.
	UNIX_ROOT_PATTERN = `/+`

	// Match system/drive root on Linux/Mac/Windows.
	ROOT_DIR_PATTERN = "(?:" + WINDOWS_ROOT_PATTERN + "|" + UNIX_ROOT_PATTERN + ")"

	// Match file/directory names and also match ., ..
	FILE_NAME_PATTERN = `[\w\.-]+`

	// Mark the beginning of the failure section in stdout log
	FAILURE_SECTION_START_PREFIX = "FAILED: "

	// Mark the end of the failure section in stdout log
	FAILURE_SECTION_END_PATTERN_1 = `^\d+ errors? generated.`
	FAILURE_SECTION_END_PATTERN_2 = `failed with exit code \d+`
	// If it reads this line, it is also ends of failure section
	OUTSIDE_FAILURE_SECTION_PATTERN = `\[\d+/\d+\]`

	NINJA_FAILURE_LINE_END_PREFIX = `ninja: build stopped`
	NINJA_ERROR_LINE_PREFIX       = `ninja: error`

	STDLOG_NODE_PATTERN = `(?:"([^"]+)")|(\S+)`
)

Variables

This section is empty.

Functions

func AnalyzeChangeLogs

func AnalyzeChangeLogs(c context.Context, signal *model.CompileFailureSignal, changelogs []*model.ChangeLog) (*model.HeuristicAnalysisResult, error)

AnalyzeChangeLogs analyzes the changelogs based on the failure signals. Returns a dictionary that maps the commits and the result found.

func AnalyzeOneChangeLog

func AnalyzeOneChangeLog(c context.Context, signal *model.CompileFailureSignal, changelog *model.ChangeLog) (*model.SuspectJustification, error)

AnalyzeOneChangeLog analyzes one changelog(revision) and returns the justification of how likely that changelog is the culprit.

func AreRelelatedExtensions

func AreRelelatedExtensions(ext1 string, ext2 string) bool

AreRelelatedExtensions checks if 2 extensions are related

func ExtractSignals

func ExtractSignals(c context.Context, compileLogs *model.CompileLogs) (*model.CompileFailureSignal, error)

ExtractSignals extracts necessary signals for heuristic analysis from logs

func ExtractSignalsFromNinjaLog

func ExtractSignalsFromNinjaLog(c context.Context, ninjaLog *model.NinjaLog) (*model.CompileFailureSignal, error)

ExtractSignalsFromNinjaLog extracts necessary signals for heuristic analysis from ninja log

func ExtractSignalsFromStdoutLog

func ExtractSignalsFromStdoutLog(c context.Context, stdoutLog string) (*model.CompileFailureSignal, error)

ExtractSignalsFromStdoutLog extracts necessary signals for heuristic analysis from stdout log

func GetConfidenceLevel

func GetConfidenceLevel(score int) pb.SuspectConfidenceLevel

GetConfidenceLevel returns a description of how likely a suspect to be the real culprit.

func IsRelated

func IsRelated(fullFilePath string, fileInLog string) bool

IsRelated checks if 2 files are related. Example: file.h <-> file_impl.cc x.h <-> x.cc

func IsSameFile

func IsSameFile(fullFilePath string, fileInLog string) bool

IsSameFile makes the best effort in guessing if the file in the failure log is the same as the file in the changelog or not. Args: fullFilePath: Full path of a file committed to git repo. fileInLog: File path appearing in a failure log. It may or may not be a full path. Example: ("chrome/test/base/chrome_process_util.h", "base/chrome_process_util.h") -> True ("a/b/x.cc", "a/b/x.cc") -> True ("c/x.cc", "a/b/c/x.cc") -> False

func NormalizeObjectFilePath

func NormalizeObjectFilePath(filePath string) string

NormalizeObjectFilePath normalizes the file path to an c/c++ object file. During compile, a/b/c/file.cc in TARGET will be compiled into object file obj/a/b/c/TARGET.file.o, thus 'obj/' and TARGET need to be removed from path.

Types

type ScoringCriteria

type ScoringCriteria struct {
	// The score if the suspect touched the same file in the failure log.
	TouchedSameFile int
	// The score if the suspect touched a related file to a file in the failure log.
	TouchedRelatedFile int
	// The score if the suspect touched the same file and the same line as in the failure log.
	TouchedSameLine int
}

ScoringCriteria represents how we score in the heuristic analysis.

Jump to

Keyboard shortcuts

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