OLD | NEW |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 # | 2 # |
3 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 3 # Copyright 2012 The Native Client Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can |
5 # found in the LICENSE file. | 5 # be found in the LICENSE file. |
6 # Copyright 2012, Google Inc. | |
robertm
2012/08/07 17:55:19
why the second copyright notice
| |
6 | 7 |
7 set -o nounset | 8 set -o nounset |
8 set -o errexit | 9 set -o errexit |
9 | 10 |
10 #@ Various commands to emulate arm code using qemu | 11 #@ Various commands to emulate mips32 code using qemu |
11 #@ | 12 #@ |
12 #@ Note: this script is not meant to be run as | 13 #@ Note: this script is not meant to be run as |
13 #@ tools/trusted_cross_toolchains/qemu_tool_arm.sh | 14 #@ tools/llvm/qemu_tool.sh |
14 #@ but rather as: | 15 #@ but rather as: |
15 #@ toolchain/linux_arm-trusted/qemu_tool_arm.sh | 16 #@ toolchain/linux_mips-trusted/qemu-mips32 |
16 | 17 |
17 # From a qemu build based on qemu-0.10.1.tar.gz | 18 # From a qemu build based on qemu-0.12.5.tar.gz |
18 readonly SDK_ROOT=$(dirname $0) | 19 readonly SDK_ROOT=$(dirname $0) |
19 readonly QEMU=${SDK_ROOT}/qemu-arm | 20 readonly QEMU=${SDK_ROOT}/qemu-mips32 |
20 readonly QEMU_STOCK=/usr/bin/qemu-arm | 21 readonly QEMU_JAIL=${SDK_ROOT}/mips-release/mips-linux-gnu/libc/el |
21 readonly QEMU_JAIL=${SDK_ROOT} | |
22 # NOTE: some useful debugging options for qemu: | 22 # NOTE: some useful debugging options for qemu: |
23 # env vars: | 23 # env vars: |
24 # QEMU_STRACE=1 | 24 # QEMU_STRACE=1 |
25 # args: | 25 # args: |
26 # -strace | 26 # -strace |
27 # -d out_asm,in_asm,op,int,exec,cpu | 27 # -d out_asm,in_asm,op,int,exec,cpu |
28 # c.f. cpu_log_items in qemu-XXX/exec.c | 28 # c.f. cpu_log_items in qemu-XXX/exec.c |
29 readonly QEMU_ARGS="-cpu cortex-a8" | 29 readonly QEMU_ARGS="" |
30 readonly QEMU_ARGS_DEBUG="-d in_asm,int,exec,cpu" | 30 readonly QEMU_ARGS_DEBUG="-d in_asm,int,exec,cpu" |
31 readonly QEMU_ARGS_DEBUG_SR="-d in_asm,int,exec,cpu,service_runtime" | 31 readonly QEMU_ARGS_DEBUG_SR="-d in_asm,int,exec,cpu,service_runtime" |
32 | 32 |
33 ###################################################################### | 33 ###################################################################### |
34 # Helpers | 34 # Helpers |
35 ###################################################################### | 35 ###################################################################### |
36 | 36 |
37 Banner() { | 37 Banner() { |
38 echo "######################################################################" | 38 echo "######################################################################" |
39 echo $* | 39 echo $* |
(...skipping 26 matching lines...) Expand all Loading... | |
66 #@ help | 66 #@ help |
67 #@ | 67 #@ |
68 #@ print help for all modes | 68 #@ print help for all modes |
69 help () { | 69 help () { |
70 Usage | 70 Usage |
71 } | 71 } |
72 | 72 |
73 #@ | 73 #@ |
74 #@ run | 74 #@ run |
75 #@ | 75 #@ |
76 #@ run emulation using a locally patched qemu | 76 #@ run stuff |
77 run() { | 77 run() { |
78 CheckPrerequisites | 78 CheckPrerequisites |
79 exec ${QEMU} -L ${QEMU_JAIL} ${QEMU_ARGS} "$@" | 79 exec ${QEMU} -L ${QEMU_JAIL} ${QEMU_ARGS} "$@" |
80 } | 80 } |
81 | 81 |
82 #@ | 82 #@ |
83 #@ run_stock | |
84 #@ | |
85 #@ run emulation using the stock qemu | |
86 run_stock() { | |
87 exec ${QEMU_STOCK} -L ${QEMU_JAIL} ${QEMU_ARGS} "$@" | |
88 } | |
89 | |
90 #@ | |
91 #@ run_debug | 83 #@ run_debug |
92 #@ | 84 #@ |
93 #@ run emulation but also generate trace in /tmp | 85 #@ run stuff but also generate trace in /tmp |
94 run_debug() { | 86 run_debug() { |
95 Hints | 87 Hints |
96 CheckPrerequisites | 88 CheckPrerequisites |
97 exec ${QEMU} -L ${QEMU_JAIL} ${QEMU_ARGS} ${QEMU_ARGS_DEBUG} "$@" | 89 exec ${QEMU} -L ${QEMU_JAIL} ${QEMU_ARGS} ${QEMU_ARGS_DEBUG} "$@" |
98 } | 90 } |
99 | 91 |
100 #@ | 92 #@ |
101 #@ run_debug_service_runtime | 93 #@ run_debug_service_runtime |
102 #@ | 94 #@ |
103 #@ run emulation but also generate trace in /tmp even for service_runtime | 95 #@ run stuff but also generate trace in /tmp even for service_runtime |
104 run_debug_service_runtime() { | 96 run_debug_service_runtime() { |
105 Hints | 97 Hints |
106 CheckPrerequisites | 98 CheckPrerequisites |
107 exec ${QEMU} -L ${QEMU_JAIL} ${QEMU_ARGS} ${QEMU_ARGS_DEBUG_SR} "$@" | 99 exec ${QEMU} -L ${QEMU_JAIL} ${QEMU_ARGS} ${QEMU_ARGS_DEBUG_SR} "$@" |
108 } | 100 } |
109 | 101 |
110 #@ | |
111 #@ install_stock | |
112 #@ | |
113 #@ install stock qemu emulator (for user mode) | |
114 install_stock_qemu() { | |
115 sudo apt-get install qemu-user | |
116 } | |
117 | |
118 ###################################################################### | 102 ###################################################################### |
119 if [[ "$0" == *run_under_qemu_arm ]] ; then | 103 if [[ "$0" == *run_under_qemu_mips32 ]] ; then |
120 run "$@" | 104 run "$@" |
121 elif [[ $# -eq 0 ]] ; then | 105 elif [[ $# -eq 0 ]] ; then |
122 echo "you must specify a mode on the commandline:" | 106 echo "you must specify a mode on the commandline:" |
123 echo | 107 echo |
124 Usage | 108 Usage |
125 exit -1 | 109 exit -1 |
126 elif [[ "$(type -t $1)" != "function" ]]; then | 110 elif [[ "$(type -t $1)" != "function" ]]; then |
127 echo "ERROR: unknown function '$1'." >&2 | 111 echo "ERROR: unknown function '$1'." >&2 |
128 echo "For help, try:" | 112 echo "For help, try:" |
129 echo " $0 help" | 113 echo " $0 help" |
130 exit 1 | 114 exit 1 |
131 else | 115 else |
132 "$@" | 116 "$@" |
133 fi | 117 fi |
OLD | NEW |