#!/usr/bin/env python3
"""
This script uses a regex to validate the output of our backtraces.
The layout we assume is:
+
It currently just checks that the backtrace results in at least one correctly
formatted entry. It does not directly validate the input since the output
would not be robust against standard library changes.
TODO: We could have the user pass in the frame number, library name, and
demangled name. These we can always validate as true in a robust way. On the
other hand, address and offset are more difficult to validate in a robust way
in the face of small codegen differences, so without any further thought I
imagine we can just check the format.
11 libswiftCore.dylib 0x000000000dce84d0l _fatalErrorMessage(StaticString,
StaticString, StaticString, UInt, flags : UInt32) -> () + 444
"""
import argparse
import re
import sys
# -----------------------------------------------------------------------------
# Constants
DESCRIPTION = """
Checks that a stacktrace dump follows canonical formatting.
"""
TARGET_PATTERN = re.compile(
r'(?P\d+) +(?P