Home | History | Annotate | Download | only in scripts
      1 # -*- coding: utf-8 -*-
      2 
      3 #-------------------------------------------------------------------------
      4 # drawElements Quality Program utilities
      5 # --------------------------------------
      6 #
      7 # Copyright 2015 The Android Open Source Project
      8 #
      9 # Licensed under the Apache License, Version 2.0 (the "License");
     10 # you may not use this file except in compliance with the License.
     11 # You may obtain a copy of the License at
     12 #
     13 #      http://www.apache.org/licenses/LICENSE-2.0
     14 #
     15 # Unless required by applicable law or agreed to in writing, software
     16 # distributed under the License is distributed on an "AS IS" BASIS,
     17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     18 # See the License for the specific language governing permissions and
     19 # limitations under the License.
     20 #
     21 #-------------------------------------------------------------------------
     22 
     23 import sys
     24 import os
     25 import time
     26 import string
     27 import shutil
     28 import subprocess
     29 import signal
     30 import argparse
     31 
     32 import common
     33 
     34 def getADBProgramPID (adbCmd, program, serial):
     35 	pid		= -1
     36 
     37 	process = subprocess.Popen([adbCmd]
     38 								+ (["-s", serial] if serial != None else [])
     39 								+ ["shell", "ps"], stdout=subprocess.PIPE)
     40 
     41 	firstLine = True
     42 	for line in process.stdout.readlines():
     43 		if firstLine:
     44 			firstLine = False
     45 			continue
     46 
     47 		fields = string.split(line)
     48 		fields = filter(lambda x: len(x) > 0, fields)
     49 
     50 		if len(fields) < 9:
     51 			continue
     52 
     53 		if fields[8] == program:
     54 			assert pid == -1
     55 			pid = int(fields[1])
     56 
     57 	process.wait()
     58 
     59 	if process.returncode != 0:
     60 		print("adb shell ps returned %s" % str(process.returncode))
     61 		pid = -1
     62 
     63 	return pid
     64 
     65 def debug (
     66 	adbCmd,
     67 	deqpCmdLine,
     68 	targetGDBPort,
     69 	hostGDBPort,
     70 	jdbPort,
     71 	jdbCmd,
     72 	gdbCmd,
     73 	buildDir,
     74 	deviceLibs,
     75 	breakpoints,
     76 	serial,
     77 	deviceGdbCmd,
     78 	appProcessName,
     79 	linkerName
     80 	):
     81 
     82 	programPid			= -1
     83 	gdbServerProcess	= None
     84 	gdbProcess			= None
     85 	jdbProcess			= None
     86 	curDir				= os.getcwd()
     87 	debugDir			= os.path.join(common.ANDROID_DIR, "debug")
     88 	serialArg			= "-s " + serial if serial != None else ""
     89 
     90 	if os.path.exists(debugDir):
     91 		shutil.rmtree(debugDir)
     92 
     93 	os.makedirs(debugDir)
     94 	os.chdir(debugDir)
     95 	try:
     96 		# Start execution
     97 		print("Starting intent...")
     98 		common.execArgs([adbCmd]
     99 						+ (["-s", serial] if serial != None else [])
    100 						+ ["shell", "am", "start", "-W", "-D", "-n", "com.drawelements.deqp/android.app.NativeActivity", "-e", "cmdLine", "\"\"unused " + deqpCmdLine  + "\"\""])
    101 		print("Intent started")
    102 
    103 		# Kill existing gdbservers
    104 		print("Check and kill existing gdbserver")
    105 		gdbPid = getADBProgramPID(adbCmd, "gdbserver", serial)
    106 		if gdbPid != -1:
    107 			print("Found gdbserver with PID %i" % gdbPid)
    108 			common.execArgs([adbCmd]
    109 							+ (["-s", serial] if serial != None else [])
    110 							+ ["shell", "run-as", "com.drawelements.deqp", "kill", "-9", str(gdbPid)])
    111 			print("Killed gdbserver")
    112 		else:
    113 			print("Couldn't find existing gdbserver")
    114 
    115 		programPid = getADBProgramPID(adbCmd, "com.drawelements.deqp:testercore", serial)
    116 
    117 		print("Find process PID")
    118 		if programPid == -1:
    119 			common.die("Couldn't get PID of testercore")
    120 		print("Process running with PID %i" % programPid)
    121 
    122 		# Start gdbserver
    123 		print("Start gdbserver for PID %i redirect stdout to gdbserver-stdout.txt" % programPid)
    124 		gdbServerProcess = subprocess.Popen([adbCmd]
    125 											+ (["-s", serial] if serial != None else [])
    126 											+ ["shell", "run-as", "com.drawelements.deqp", deviceGdbCmd, "localhost:" + str(targetGDBPort), "--attach", str(programPid)], stdin=subprocess.PIPE, stdout=open("gdbserver-stdout.txt", "wb"), stderr=open("gdbserver-stderr.txt", "wb"))
    127 		print("gdbserver started")
    128 
    129 		time.sleep(1)
    130 
    131 		gdbServerProcess.poll()
    132 
    133 		if gdbServerProcess.returncode != None:
    134 			common.die("gdbserver returned unexpectly with return code %i see gdbserver-stdout.txt for more info" % gdbServerProcess.returncode)
    135 
    136 		# Setup port forwarding
    137 		print("Forwarding local port to gdbserver port")
    138 		common.execArgs([adbCmd]
    139 						+ (["-s", serial] if serial != None else [])
    140 						+ ["forward", "tcp:" + str(hostGDBPort), "tcp:" + str(targetGDBPort)])
    141 
    142 		# Pull some data files for debugger
    143 		print("Pull /system/bin/%s from device" % appProcessName)
    144 		common.execArgs([adbCmd]
    145 						+ (["-s", serial] if serial != None else [])
    146 						+ ["pull", "/system/bin/" + str(appProcessName)])
    147 
    148 		print("Pull /system/bin/%s from device" % linkerName)
    149 		common.execArgs([adbCmd]
    150 						+ (["-s", serial] if serial != None else [])
    151 						+ ["pull", "/system/bin/" + str(linkerName)])
    152 
    153 		for lib in deviceLibs:
    154 			print("Pull library %s from device" % lib)
    155 			try:
    156 				common.execArgs([adbCmd]
    157 								+ (["-s", serial] if serial != None else [])
    158 								+ ["pull", lib])
    159 			except Exception as e:
    160 				print("Failed to pull library '%s'. Error: %s" % (lib, str(e)))
    161 
    162 		print("Copy %s from build dir" % common.NATIVE_LIB_NAME)
    163 		shutil.copyfile(os.path.join(buildDir, common.NATIVE_LIB_NAME), common.NATIVE_LIB_NAME)
    164 
    165 		# Forward local port for jdb
    166 		print("Forward local port to jdb port")
    167 		common.execArgs([adbCmd]
    168 						+ (["-s", serial] if serial != None else [])
    169 						+ ["forward", "tcp:" + str(jdbPort), "jdwp:" + str(programPid)])
    170 
    171 		# Connect JDB
    172 		print("Start jdb process redirectd stdout to jdb-stdout.txt")
    173 		jdbProcess = subprocess.Popen([jdbCmd, "-connect", "com.sun.jdi.SocketAttach:hostname=localhost,port=" + str(jdbPort), "-sourcepath", "../package"], stdin=subprocess.PIPE, stdout=open("jdb-stdout.txt", "wb"), stderr=open("jdb-stderr.txt", "wb"))
    174 		print("Started jdb process")
    175 
    176 		# Write gdb.setup
    177 		print("Write gdb.setup")
    178 		gdbSetup = open("gdb.setup", "wb")
    179 		gdbSetup.write("file %s\n" % appProcessName)
    180 		gdbSetup.write("set solib-search-path .\n")
    181 		gdbSetup.write("target remote :%i\n" % hostGDBPort)
    182 		gdbSetup.write("set breakpoint pending on\n")
    183 
    184 		for breakpoint in breakpoints:
    185 			print("Set breakpoint at %s" % breakpoint)
    186 			gdbSetup.write("break %s\n" % breakpoint)
    187 
    188 		gdbSetup.write("set breakpoint pending off\n")
    189 		gdbSetup.close()
    190 
    191 		print("Start gdb")
    192 		gdbProcess = subprocess.Popen(common.shellquote(gdbCmd) + " -x gdb.setup", shell=True)
    193 
    194 		gdbProcess.wait()
    195 
    196 		print("gdb returned with %i" % gdbProcess.returncode)
    197 		gdbProcess=None
    198 
    199 		print("Close jdb process with 'quit'")
    200 		jdbProcess.stdin.write("quit\n")
    201 		jdbProcess.wait()
    202 		print("JDB returned %s" % str(jdbProcess.returncode))
    203 		jdbProcess=None
    204 
    205 		print("Kill gdbserver process")
    206 		gdbServerProcess.kill()
    207 		gdbServerProcess=None
    208 		print("Killed gdbserver process")
    209 
    210 		print("Kill program %i" % programPid)
    211 		common.execArgs([adbCmd]
    212 						+ (["-s", serial] if serial != None else [])
    213 						+ ["shell", "run-as", "com.drawelements.deqp", "kill", "-9", str(programPid)])
    214 		print("Killed program")
    215 
    216 	finally:
    217 		if jdbProcess and jdbProcess.returncode == None:
    218 			print("Kill jdb")
    219 			jdbProcess.kill()
    220 		elif jdbProcess:
    221 			print("JDB returned %i" % jdbProcess.returncode)
    222 
    223 		if gdbProcess and gdbProcess.returncode == None:
    224 			print("Kill gdb")
    225 			gdbProcess.kill()
    226 		elif gdbProcess:
    227 			print("GDB returned %i" % gdbProcess.returncode)
    228 
    229 		if gdbServerProcess and gdbServerProcess.returncode == None:
    230 			print("Kill gdbserver")
    231 			gdbServerProcess.kill()
    232 		elif gdbServerProcess:
    233 			print("GDB server returned %i" % gdbServerProcess.returncode)
    234 
    235 		if programPid != -1:
    236 			print("Kill program %i" % programPid)
    237 			common.execArgs([adbCmd]
    238 							+ (["-s", serial] if serial != None else [])
    239 							+ ["shell", "run-as", "com.drawelements.deqp", "kill", "-9", str(programPid)])
    240 			print("Killed program")
    241 
    242 		os.chdir(curDir)
    243 
    244 class Device:
    245 	def __init__ (self, libraries=[], nativeBuildDir=None, hostGdbBins=None, deviceGdbCmd=None, appProcessName=None, linkerName=None):
    246 		self.libraries = libraries
    247 		self.nativeBuildDir = nativeBuildDir
    248 		self.hostGdbBins = hostGdbBins
    249 		self.deviceGdbCmd = deviceGdbCmd
    250 		self.appProcessName = appProcessName
    251 		self.linkerName = linkerName
    252 
    253 	def getBuildDir (self):
    254 		return self.nativeBuildDir
    255 
    256 	def getGdbCommand (self, platform):
    257 		return self.hostGdbBins[platform]
    258 
    259 	def getDeviceGdbCommand (self):
    260 		return self.deviceGdbCmd
    261 
    262 	def getLibs (self):
    263 		return self.libraries
    264 
    265 	def getLinkerName (self):
    266 		return self.linkerName
    267 
    268 	def getAppProcessName (self):
    269 		return self.appProcessName
    270 
    271 if __name__ == "__main__":
    272 	parser = argparse.ArgumentParser()
    273 
    274 	devices = {
    275 		"nexus-4" : Device(
    276 			nativeBuildDir = "../native/debug-13-armeabi-v7a",
    277 			deviceGdbCmd = "lib/gdbserver",
    278 			hostGdbBins = {
    279 				"linux" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gdb")),
    280 				"windows" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi-gdb"))
    281 			},
    282 			appProcessName = "app_process",
    283 			linkerName = "linker",
    284 			libraries = [
    285 				"/system/lib/libgenlock.so",
    286 				"/system/lib/libmemalloc.so",
    287 				"/system/lib/libqdutils.so",
    288 				"/system/lib/libsc-a3xx.so"
    289 			]),
    290 		"nexus-6" : Device(
    291 			nativeBuildDir = "../native/debug-13-armeabi-v7a",
    292 			deviceGdbCmd = "lib/gdbserver",
    293 			hostGdbBins = {
    294 				"linux" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gdb")),
    295 				"windows" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi-gdb"))
    296 			},
    297 			appProcessName = "app_process",
    298 			linkerName = "linker",
    299 			libraries = [
    300 				"/system/lib/libutils.so",
    301 				"/system/lib/libstdc++.so",
    302 				"/system/lib/libm.so",
    303 				"/system/lib/liblog.so",
    304 				"/system/lib/libhardware.so",
    305 				"/system/lib/libbinder.so",
    306 				"/system/lib/libcutils.so",
    307 				"/system/lib/libc++.so",
    308 				"/system/lib/libLLVM.so",
    309 				"/system/lib/libbcinfo.so",
    310 				"/system/lib/libunwind.so",
    311 				"/system/lib/libz.so",
    312 				"/system/lib/libpng.so",
    313 				"/system/lib/libcommon_time_client.so",
    314 				"/system/lib/libstlport.so",
    315 				"/system/lib/libui.so",
    316 				"/system/lib/libsync.so",
    317 				"/system/lib/libgui.so",
    318 				"/system/lib/libft2.so",
    319 				"/system/lib/libbcc.so",
    320 				"/system/lib/libGLESv2.so",
    321 				"/system/lib/libGLESv1_CM.so",
    322 				"/system/lib/libEGL.so",
    323 				"/system/lib/libunwind-ptrace.so",
    324 				"/system/lib/libgccdemangle.so",
    325 				"/system/lib/libcrypto.so",
    326 				"/system/lib/libicuuc.so",
    327 				"/system/lib/libicui18n.so",
    328 				"/system/lib/libjpeg.so",
    329 				"/system/lib/libexpat.so",
    330 				"/system/lib/libpcre.so",
    331 				"/system/lib/libharfbuzz_ng.so",
    332 				"/system/lib/libstagefright_foundation.so",
    333 				"/system/lib/libsonivox.so",
    334 				"/system/lib/libnbaio.so",
    335 				"/system/lib/libcamera_client.so",
    336 				"/system/lib/libaudioutils.so",
    337 				"/system/lib/libinput.so",
    338 				"/system/lib/libhardware_legacy.so",
    339 				"/system/lib/libcamera_metadata.so",
    340 				"/system/lib/libgabi++.so",
    341 				"/system/lib/libskia.so",
    342 				"/system/lib/libRScpp.so",
    343 				"/system/lib/libRS.so",
    344 				"/system/lib/libwpa_client.so",
    345 				"/system/lib/libnetutils.so",
    346 				"/system/lib/libspeexresampler.so",
    347 				"/system/lib/libGLES_trace.so",
    348 				"/system/lib/libbacktrace.so",
    349 				"/system/lib/libusbhost.so",
    350 				"/system/lib/libssl.so",
    351 				"/system/lib/libsqlite.so",
    352 				"/system/lib/libsoundtrigger.so",
    353 				"/system/lib/libselinux.so",
    354 				"/system/lib/libprocessgroup.so",
    355 				"/system/lib/libpdfium.so",
    356 				"/system/lib/libnetd_client.so",
    357 				"/system/lib/libnativehelper.so",
    358 				"/system/lib/libnativebridge.so",
    359 				"/system/lib/libminikin.so",
    360 				"/system/lib/libmemtrack.so",
    361 				"/system/lib/libmedia.so",
    362 				"/system/lib/libinputflinger.so",
    363 				"/system/lib/libimg_utils.so",
    364 				"/system/lib/libhwui.so",
    365 				"/system/lib/libandroidfw.so",
    366 				"/system/lib/libETC1.so",
    367 				"/system/lib/libandroid_runtime.so",
    368 				"/system/lib/libsigchain.so",
    369 				"/system/lib/libbacktrace_libc++.so",
    370 				"/system/lib/libart.so",
    371 				"/system/lib/libjavacore.so",
    372 				"/system/lib/libvorbisidec.so",
    373 				"/system/lib/libstagefright_yuv.so",
    374 				"/system/lib/libstagefright_omx.so",
    375 				"/system/lib/libstagefright_enc_common.so",
    376 				"/system/lib/libstagefright_avc_common.so",
    377 				"/system/lib/libpowermanager.so",
    378 				"/system/lib/libopus.so",
    379 				"/system/lib/libdrmframework.so",
    380 				"/system/lib/libstagefright_amrnb_common.so",
    381 				"/system/lib/libstagefright.so",
    382 				"/system/lib/libmtp.so",
    383 				"/system/lib/libjhead.so",
    384 				"/system/lib/libexif.so",
    385 				"/system/lib/libmedia_jni.so",
    386 				"/system/lib/libsoundpool.so",
    387 				"/system/lib/libaudioeffect_jni.so",
    388 				"/system/lib/librs_jni.so",
    389 				"/system/lib/libjavacrypto.so",
    390 				"/system/lib/libqservice.so",
    391 				"/system/lib/libqdutils.so",
    392 				"/system/lib/libqdMetaData.so",
    393 				"/system/lib/libmemalloc.so",
    394 				"/system/lib/libandroid.so",
    395 				"/system/lib/libcompiler_rt.so",
    396 				"/system/lib/libjnigraphics.so",
    397 				"/system/lib/libwebviewchromium_loader.so",
    398 
    399 				"/system/lib/hw/gralloc.msm8084.so",
    400 				"/system/lib/hw/memtrack.msm8084.so",
    401 
    402 				"/vendor/lib/libgsl.so",
    403 				"/vendor/lib/libadreno_utils.so",
    404 				"/vendor/lib/egl/libEGL_adreno.so",
    405 				"/vendor/lib/egl/libGLESv1_CM_adreno.so",
    406 				"/vendor/lib/egl/libGLESv2_adreno.so",
    407 				"/vendor/lib/egl/eglSubDriverAndroid.so",
    408 				"/vendor/lib/libllvm-glnext.so",
    409 			]),
    410 		"nexus-7" : Device(
    411 			nativeBuildDir = "../native/debug-13-armeabi-v7a",
    412 			deviceGdbCmd = "lib/gdbserver",
    413 			hostGdbBins = {
    414 				"linux" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gdb")),
    415 				"windows" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi-gdb"))
    416 			},
    417 			appProcessName = "app_process",
    418 			linkerName = "linker",
    419 			libraries = [
    420 				"/system/lib/libm.so",
    421 				"/system/lib/libqdutils.so",
    422 				"/system/lib/libmemalloc.so",
    423 				"/system/lib/hw/gralloc.msm8960.so",
    424 				"/system/lib/libstdc++.so",
    425 				"/system/lib/liblog.so.",
    426 				"/system/lib/libstdc++.so",
    427 				"/system/lib/liblog.so",
    428 				"/system/lib/libsigchain.so",
    429 				"/system/lib/libcutils.so",
    430 				"/system/lib/libstlport.so",
    431 				"/system/lib/libgccdemangle.so",
    432 				"/system/lib/libunwind.so",
    433 				"/system/lib/libunwind-ptrace.so",
    434 				"/system/lib/libbacktrace.so",
    435 				"/system/lib/libutils.so",
    436 				"/system/lib/libGLES_trace.so",
    437 				"/system/lib/libEGL.so",
    438 				"/system/lib/libETC1.so",
    439 				"/system/lib/libGLESv1_CM.so",
    440 				"/system/lib/libGLESv2.so",
    441 				"/system/lib/libbinder.so",
    442 				"/system/lib/libz.so",
    443 				"/system/lib/libandroidfw.so",
    444 				"/system/lib/libspeexresampler.so",
    445 				"/system/lib/libaudioutils.so",
    446 				"/system/lib/libcamera_metadata.so",
    447 				"/system/lib/libsync.so",
    448 				"/system/lib/libhardware.so",
    449 				"/system/lib/libui.so",
    450 				"/vendor/lib/egl/eglsubAndroid.so",
    451 				"/vendor/lib/libsc-a3xx.so",
    452 				"/system/lib/libgui.so",
    453 				"/system/lib/libcamera_client.so",
    454 				"/system/lib/libcrypto.so",
    455 				"/system/lib/libexpat.so",
    456 				"/system/lib/libnetutils.so",
    457 				"/system/lib/libwpa_client.so",
    458 				"/system/lib/libhardware_legacy.so",
    459 				"/system/lib/libgabi++.so",
    460 				"/system/lib/libicuuc.so",
    461 				"/system/lib/libicui18n.so",
    462 				"/system/lib/libharfbuzz_ng.so",
    463 				"/system/lib/libc++.so",
    464 				"/system/lib/libLLVM.so",
    465 				"/system/lib/libbcinfo.so",
    466 				"/system/lib/libbcc.so",
    467 				"/system/lib/libpng.so",
    468 				"/system/lib/libft2.so",
    469 				"/system/lib/libRS.so",
    470 				"/system/lib/libRScpp.so",
    471 				"/system/lib/libjpeg.so",
    472 				"/system/lib/libskia.so",
    473 				"/system/lib/libhwui.so",
    474 				"/system/lib/libimg_utils.so",
    475 				"/system/lib/libinput.so",
    476 				"/system/lib/libinputflinger.so",
    477 				"/system/lib/libcommon_time_client.so",
    478 				"/system/lib/libnbaio.so",
    479 				"/system/lib/libsonivox.so",
    480 				"/system/lib/libstagefright_foundation.so",
    481 				"/system/lib/libmedia.so",
    482 				"/system/lib/libmemtrack.so",
    483 				"/system/lib/libminikin.so",
    484 				"/system/lib/libnativebridge.so",
    485 				"/system/lib/libnativehelper.so",
    486 				"/system/lib/libnetd_client.so",
    487 				"/system/lib/libpdfium.so",
    488 				"/system/lib/libprocessgroup.so",
    489 				"/system/lib/libselinux.so",
    490 				"/system/lib/libsoundtrigger.so",
    491 				"/system/lib/libsqlite.so",
    492 				"/system/lib/libssl.so",
    493 				"/system/lib/libusbhost.so",
    494 				"/system/lib/libandroid_runtime.so",
    495 				"/system/lib/libbacktrace_libc++.so",
    496 				"/system/lib/libart.so",
    497 				"/system/lib/libjavacore.so",
    498 				"/system/lib/libexif.so",
    499 				"/system/lib/libjhead.so",
    500 				"/system/lib/libmtp.so",
    501 				"/system/lib/libdrmframework.so",
    502 				"/system/lib/libopus.so",
    503 				"/system/lib/libpowermanager.so",
    504 				"/system/lib/libstagefright_avc_common.so",
    505 				"/system/lib/libstagefright_enc_common.so",
    506 				"/system/lib/libstagefright_omx.so",
    507 				"/system/lib/libstagefright_yuv.so",
    508 				"/system/lib/libvorbisidec.so",
    509 				"/system/lib/libstagefright.so",
    510 				"/system/lib/libstagefright_amrnb_common.so",
    511 				"/system/lib/libmedia_jni.so",
    512 				"/system/lib/libsoundpool.so",
    513 				"/system/lib/libaudioeffect_jni.so",
    514 				"/system/lib/librs_jni.so",
    515 				"/system/lib/libjavacrypto.so",
    516 				"/system/lib/libandroid.so",
    517 				"/system/lib/libcompiler_rt.so",
    518 				"/system/lib/libjnigraphics.so",
    519 				"/system/lib/libwebviewchromium_loader.so",
    520 
    521 				"/system/lib/hw/memtrack.msm8960.so",
    522 
    523 				"/vendor/lib/libgsl.so",
    524 				"/vendor/lib/libadreno_utils.so",
    525 				"/vendor/lib/egl/libEGL_adreno.so",
    526 				"/vendor/lib/egl/libGLESv1_CM_adreno.so",
    527 				"/vendor/lib/egl/libGLESv2_adreno.so",
    528 			]),
    529 		"nexus-10" : Device(
    530 			nativeBuildDir = "../native/debug-13-armeabi-v7a",
    531 			deviceGdbCmd = "lib/gdbserver",
    532 			hostGdbBins = {
    533 				"linux" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gdb")),
    534 				"windows" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi-gdb"))
    535 			},
    536 			appProcessName = "app_process",
    537 			linkerName = "linker",
    538 			libraries = [
    539 				"/system/lib/libutils.so",
    540 				"/system/lib/libstdc++.so",
    541 				"/system/lib/libm.so",
    542 				"/system/lib/liblog.so",
    543 				"/system/lib/libhardware.so",
    544 				"/system/lib/libbinder.so",
    545 				"/system/lib/libcutils.so",
    546 				"/system/lib/libc++.so",
    547 				"/system/lib/libLLVM.so",
    548 				"/system/lib/libbcinfo.so",
    549 				"/system/lib/libunwind.so",
    550 				"/system/lib/libz.so",
    551 				"/system/lib/libpng.so",
    552 				"/system/lib/libcommon_time_client.so",
    553 				"/system/lib/libstlport.so",
    554 				"/system/lib/libui.so",
    555 				"/system/lib/libsync.so",
    556 				"/system/lib/libgui.so",
    557 				"/system/lib/libft2.so",
    558 				"/system/lib/libbcc.so",
    559 				"/system/lib/libGLESv2.so",
    560 				"/system/lib/libGLESv1_CM.so",
    561 				"/system/lib/libEGL.so",
    562 				"/system/lib/libunwind-ptrace.so",
    563 				"/system/lib/libgccdemangle.so",
    564 				"/system/lib/libcrypto.so",
    565 				"/system/lib/libicuuc.so",
    566 				"/system/lib/libicui18n.so",
    567 				"/system/lib/libjpeg.so",
    568 				"/system/lib/libexpat.so",
    569 				"/system/lib/libpcre.so",
    570 				"/system/lib/libharfbuzz_ng.so",
    571 				"/system/lib/libstagefright_foundation.so",
    572 				"/system/lib/libsonivox.so",
    573 				"/system/lib/libnbaio.so",
    574 				"/system/lib/libcamera_client.so",
    575 				"/system/lib/libaudioutils.so",
    576 				"/system/lib/libinput.so",
    577 				"/system/lib/libhardware_legacy.so",
    578 				"/system/lib/libcamera_metadata.so",
    579 				"/system/lib/libgabi++.so",
    580 				"/system/lib/libskia.so",
    581 				"/system/lib/libRScpp.so",
    582 				"/system/lib/libRS.so",
    583 				"/system/lib/libwpa_client.so",
    584 				"/system/lib/libnetutils.so",
    585 				"/system/lib/libspeexresampler.so",
    586 				"/system/lib/libGLES_trace.so",
    587 				"/system/lib/libbacktrace.so",
    588 				"/system/lib/libusbhost.so",
    589 				"/system/lib/libssl.so",
    590 				"/system/lib/libsqlite.so",
    591 				"/system/lib/libsoundtrigger.so",
    592 				"/system/lib/libselinux.so",
    593 				"/system/lib/libprocessgroup.so",
    594 				"/system/lib/libpdfium.so",
    595 				"/system/lib/libnetd_client.so",
    596 				"/system/lib/libnativehelper.so",
    597 				"/system/lib/libnativebridge.so",
    598 				"/system/lib/libminikin.so",
    599 				"/system/lib/libmemtrack.so",
    600 				"/system/lib/libmedia.so",
    601 				"/system/lib/libinputflinger.so",
    602 				"/system/lib/libimg_utils.so",
    603 				"/system/lib/libhwui.so",
    604 				"/system/lib/libandroidfw.so",
    605 				"/system/lib/libETC1.so",
    606 				"/system/lib/libandroid_runtime.so",
    607 				"/system/lib/libsigchain.so",
    608 				"/system/lib/libbacktrace_libc++.so",
    609 				"/system/lib/libart.so",
    610 				"/system/lib/libjavacore.so",
    611 				"/system/lib/libvorbisidec.so",
    612 				"/system/lib/libstagefright_yuv.so",
    613 				"/system/lib/libstagefright_omx.so",
    614 				"/system/lib/libstagefright_enc_common.so",
    615 				"/system/lib/libstagefright_avc_common.so",
    616 				"/system/lib/libpowermanager.so",
    617 				"/system/lib/libopus.so",
    618 				"/system/lib/libdrmframework.so",
    619 				"/system/lib/libstagefright_amrnb_common.so",
    620 				"/system/lib/libstagefright.so",
    621 				"/system/lib/libmtp.so",
    622 				"/system/lib/libjhead.so",
    623 				"/system/lib/libexif.so",
    624 				"/system/lib/libmedia_jni.so",
    625 				"/system/lib/libsoundpool.so",
    626 				"/system/lib/libaudioeffect_jni.so",
    627 				"/system/lib/librs_jni.so",
    628 				"/system/lib/libjavacrypto.so",
    629 				"/system/lib/libandroid.so",
    630 				"/system/lib/libcompiler_rt.so",
    631 				"/system/lib/libjnigraphics.so",
    632 				"/system/lib/libwebviewchromium_loader.so",
    633 				"/system/lib/libion.so",
    634 				"/vendor/lib/hw/gralloc.exynos5.so",
    635 				"/vendor/lib/egl/libGLES_mali.so",
    636 			]),
    637 		"default" : Device(
    638 			nativeBuildDir = "../native/debug-13-armeabi-v7a",
    639 			deviceGdbCmd = "lib/gdbserver",
    640 			hostGdbBins = {
    641 				"linux" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gdb")),
    642 				"windows" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi-gdb"))
    643 			},
    644 			appProcessName = "app_process",
    645 			linkerName = "linker",
    646 			libraries = [
    647 			]),
    648 	}
    649 
    650 	parser.add_argument('--adb',				dest='adbCmd',			default=common.ADB_BIN, help="Path to adb command. Use absolute paths.")
    651 	parser.add_argument('--deqp-commandline',	dest='deqpCmdLine',		default="--deqp-log-filename=/sdcard/TestLog.qpa", help="Command line arguments passed to dEQP test binary.")
    652 	parser.add_argument('--gdb',				dest='gdbCmd',			default=None, help="gdb command used by script. Use absolute paths")
    653 	parser.add_argument('--device-gdb',			dest='deviceGdbCmd',	default=None, help="gdb command used by script on device.")
    654 	parser.add_argument('--target-gdb-port',	dest='targetGDBPort',	default=60001, type=int, help="Port used by gdbserver on target.")
    655 	parser.add_argument('--host-gdb-port',		dest='hostGDBPort',		default=60002, type=int, help="Host port that is forwarded to device gdbserver port.")
    656 	parser.add_argument('--jdb',				dest='jdbCmd',			default="jdb", help="Path to jdb command. Use absolute paths.")
    657 	parser.add_argument('--jdb-port',			dest='jdbPort',			default=60003, type=int, help="Host port used to forward jdb commands to device.")
    658 	parser.add_argument('--build-dir',			dest='buildDir',		default=None, help="Path to dEQP native build directory.")
    659 	parser.add_argument('--device-libs',		dest='deviceLibs',		default=[], nargs='+', help="List of libraries that should be pulled from device for debugging.")
    660 	parser.add_argument('--breakpoints',		dest='breakpoints',		default=["tcu::App::App"], nargs='+', help="List of breakpoints that are set by gdb.")
    661 	parser.add_argument('--app-process-name',	dest='appProcessName',	default=None, help="Name of the app_process binary.")
    662 	parser.add_argument('--linker-name',		dest='linkerName',		default=None, help="Name of the linker binary.")
    663 	parser.add_argument('--device',				dest='device',			default="default", choices=devices, help="Pull default libraries for this device.")
    664 	parser.add_argument('--serial','-s',		dest='serial',			default=None, help="-s Argument for adb.")
    665 
    666 	args = parser.parse_args()
    667 	device = devices[args.device]
    668 
    669 	if args.deviceGdbCmd == None:
    670 		args.deviceGdbCmd = device.getDeviceGdbCommand()
    671 
    672 	if args.buildDir == None:
    673 		args.buildDir = device.getBuildDir()
    674 
    675 	if args.gdbCmd == None:
    676 		args.gdbCmd = device.getGdbCommand(common.getPlatform())
    677 
    678 	if args.linkerName == None:
    679 		args.linkerName = device.getLinkerName()
    680 
    681 	if args.appProcessName == None:
    682 		args.appProcessName = device.getAppProcessName()
    683 
    684 	debug(adbCmd=os.path.normpath(args.adbCmd),
    685 		  gdbCmd=os.path.normpath(args.gdbCmd),
    686 		  targetGDBPort=args.targetGDBPort,
    687 		  hostGDBPort=args.hostGDBPort,
    688 		  jdbCmd=os.path.normpath(args.jdbCmd),
    689 		  jdbPort=args.jdbPort,
    690 		  deqpCmdLine=args.deqpCmdLine,
    691 		  buildDir=args.buildDir,
    692 		  deviceLibs=["/system/lib/libc.so", "/system/lib/libdl.so"] + args.deviceLibs + device.getLibs(),
    693 		  breakpoints=args.breakpoints,
    694 		  serial=args.serial,
    695 		  deviceGdbCmd=args.deviceGdbCmd,
    696 		  appProcessName=args.appProcessName,
    697 		  linkerName=args.linkerName)
    698