Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Tools / Scripts / debug-renderer
blob99dd3b96a1872e3b10e4317b5b446f6f1a509b33
1 #!/bin/bash
2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 # Runs Chrome / content_shell and attaches to the first renderer process in gdb.
8 RENDERER_PID_RE='Renderer \(([0-9]+)\) paused waiting for debugger'
9 TARGET_FLAGS="--no-sandbox --renderer-startup-dialog"
10 TARGET=$1
11 shift
13 if [ -z "$TARGET" ]; then
14 echo "usage: $(basename $0) <path-to-content-shell> [more-args...]"
15 exit 1
18 if [ -z "$DEBUGGER" ]; then
19 if which lldb > /dev/null; then
20 DEBUGGER="lldb"
21 CONTINUE="continue"
22 elif which gdb > /dev/null; then
23 DEBUGGER="gdb -q"
24 CONTINUE="signal SIGUSR1"
25 else
26 echo "no debugger found"
27 exit 1
31 OUTPUT=$(mktemp "${TMPDIR:-/tmp}"/"$(basename $0)".XXXXX)
32 "$TARGET" $TARGET_FLAGS "$@" 2>&1 | tee $OUTPUT &
33 BROWSER_PID=$!
35 wait_renderer_pid() {
36 for i in {1..100}; do
37 browser_running || return
38 RENDERER_PID=$(renderer_pid)
39 [ -n "$RENDERER_PID" ] && return
40 sleep 0.2
41 done
44 browser_running() { ps -p $BROWSER_PID > /dev/null; }
45 renderer_pid() { [[ "$(cat $OUTPUT)" =~ $RENDERER_PID_RE ]] && echo ${BASH_REMATCH[1]}; }
47 wait_renderer_pid
48 if [ -n "$RENDERER_PID" ]; then
49 # print yellow message
50 echo -e "\n\033[1;33mDebugging renderer, use '$CONTINUE' to run.\033[0m\n"
51 $DEBUGGER -p $RENDERER_PID
54 wait
55 rm $OUTPUT