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