Merge "Check configs before mutable_render_buffer negative test"
[platform/upstream/VK-GL-CTS.git] / android / scripts / debug.py
index 94891d9..a74a096 100644 (file)
@@ -31,11 +31,12 @@ import argparse
 
 import common
 
-def getADBProgramPID(program):
-       adbCmd  = common.shellquote(common.ADB_BIN)
+def getADBProgramPID (adbCmd, program, serial):
        pid             = -1
 
-       process = subprocess.Popen("%s shell ps" % adbCmd, shell=True, stdout=subprocess.PIPE)
+       process = subprocess.Popen([adbCmd]
+                                                               + (["-s", serial] if serial != None else [])
+                                                               + ["shell", "ps"], stdout=subprocess.PIPE)
 
        firstLine = True
        for line in process.stdout.readlines():
@@ -61,7 +62,7 @@ def getADBProgramPID(program):
 
        return pid
 
-def debug(
+def debug (
        adbCmd,
        deqpCmdLine,
        targetGDBPort,
@@ -71,7 +72,11 @@ def debug(
        gdbCmd,
        buildDir,
        deviceLibs,
-       breakpoints
+       breakpoints,
+       serial,
+       deviceGdbCmd,
+       appProcessName,
+       linkerName
        ):
 
        programPid                      = -1
@@ -80,30 +85,34 @@ def debug(
        jdbProcess                      = None
        curDir                          = os.getcwd()
        debugDir                        = os.path.join(common.ANDROID_DIR, "debug")
+       serialArg                       = "-s " + serial if serial != None else ""
 
        if os.path.exists(debugDir):
                shutil.rmtree(debugDir)
 
        os.makedirs(debugDir)
        os.chdir(debugDir)
-
        try:
                # Start execution
                print("Starting intent...")
-               common.execute("%s shell am start -W -D -n com.drawelements.deqp/android.app.NativeActivity -e cmdLine \"unused %s\"" % (adbCmd, deqpCmdLine.replace("\"", "\\\"")))
+               common.execArgs([adbCmd]
+                                               + (["-s", serial] if serial != None else [])
+                                               + ["shell", "am", "start", "-W", "-D", "-n", "com.drawelements.deqp/android.app.NativeActivity", "-e", "cmdLine", "\"\"unused " + deqpCmdLine  + "\"\""])
                print("Intent started")
 
                # Kill existing gdbservers
                print("Check and kill existing gdbserver")
-               gdbPid = getADBProgramPID("lib/gdbserver")
+               gdbPid = getADBProgramPID(adbCmd, "gdbserver", serial)
                if gdbPid != -1:
                        print("Found gdbserver with PID %i" % gdbPid)
-                       common.execute("%s shell run-as com.drawelements.deqp kill -9 %i" % (adbCmd, gdbPid))
+                       common.execArgs([adbCmd]
+                                                       + (["-s", serial] if serial != None else [])
+                                                       + ["shell", "run-as", "com.drawelements.deqp", "kill", "-9", str(gdbPid)])
                        print("Killed gdbserver")
                else:
                        print("Couldn't find existing gdbserver")
 
-               programPid = getADBProgramPID("com.drawelements.deqp:testercore")
+               programPid = getADBProgramPID(adbCmd, "com.drawelements.deqp:testercore", serial)
 
                print("Find process PID")
                if programPid == -1:
@@ -112,7 +121,9 @@ def debug(
 
                # Start gdbserver
                print("Start gdbserver for PID %i redirect stdout to gdbserver-stdout.txt" % programPid)
-               gdbServerProcess = subprocess.Popen("%s shell run-as com.drawelements.deqp lib/gdbserver localhost:%i --attach %i" % (adbCmd, targetGDBPort, programPid), shell=True, stdin=subprocess.PIPE, stdout=open("gdbserver-stdout.txt", "wb"), stderr=open("gdbserver-stderr.txt", "wb"))
+               gdbServerProcess = subprocess.Popen([adbCmd]
+                                                                                       + (["-s", serial] if serial != None else [])
+                                                                                       + ["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"))
                print("gdbserver started")
 
                time.sleep(1)
@@ -124,35 +135,48 @@ def debug(
 
                # Setup port forwarding
                print("Forwarding local port to gdbserver port")
-               common.execute("%s forward tcp:%i tcp:%i" % (adbCmd, hostGDBPort, targetGDBPort))
+               common.execArgs([adbCmd]
+                                               + (["-s", serial] if serial != None else [])
+                                               + ["forward", "tcp:" + str(hostGDBPort), "tcp:" + str(targetGDBPort)])
 
                # Pull some data files for debugger
-               print("Pull /system/bin/app_process from device")
-               common.execute("%s pull /system/bin/app_process" % adbCmd)
+               print("Pull /system/bin/%s from device" % appProcessName)
+               common.execArgs([adbCmd]
+                                               + (["-s", serial] if serial != None else [])
+                                               + ["pull", "/system/bin/" + str(appProcessName)])
 
-               print("Pull /system/bin/linker from device")
-               common.execute("%s pull /system/bin/linker" % adbCmd)
+               print("Pull /system/bin/%s from device" % linkerName)
+               common.execArgs([adbCmd]
+                                               + (["-s", serial] if serial != None else [])
+                                               + ["pull", "/system/bin/" + str(linkerName)])
 
                for lib in deviceLibs:
                        print("Pull library %s from device" % lib)
-                       common.execute("%s pull %s" % (adbCmd, lib))
+                       try:
+                               common.execArgs([adbCmd]
+                                                               + (["-s", serial] if serial != None else [])
+                                                               + ["pull", lib])
+                       except Exception as e:
+                               print("Failed to pull library '%s'. Error: %s" % (lib, str(e)))
 
                print("Copy %s from build dir" % common.NATIVE_LIB_NAME)
                shutil.copyfile(os.path.join(buildDir, common.NATIVE_LIB_NAME), common.NATIVE_LIB_NAME)
 
                # Forward local port for jdb
                print("Forward local port to jdb port")
-               common.execute("%s forward tcp:%i jdwp:%i" % (adbCmd, jdbPort, programPid))
+               common.execArgs([adbCmd]
+                                               + (["-s", serial] if serial != None else [])
+                                               + ["forward", "tcp:" + str(jdbPort), "jdwp:" + str(programPid)])
 
                # Connect JDB
                print("Start jdb process redirectd stdout to jdb-stdout.txt")
-               jdbProcess = subprocess.Popen("%s -connect com.sun.jdi.SocketAttach:hostname=localhost,port=%i -sourcepath ../package" % (jdbCmd, jdbPort), shell=True, stdin=subprocess.PIPE, stdout=open("jdb-stdout.txt", "wb"), stderr=open("jdb-stderr.txt", "wb"))
+               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"))
                print("Started jdb process")
 
                # Write gdb.setup
                print("Write gdb.setup")
                gdbSetup = open("gdb.setup", "wb")
-               gdbSetup.write("file app_process\n")
+               gdbSetup.write("file %s\n" % appProcessName)
                gdbSetup.write("set solib-search-path .\n")
                gdbSetup.write("target remote :%i\n" % hostGDBPort)
                gdbSetup.write("set breakpoint pending on\n")
@@ -165,7 +189,7 @@ def debug(
                gdbSetup.close()
 
                print("Start gdb")
-               gdbProcess = subprocess.Popen("%s -x gdb.setup" % common.shellquote(gdbCmd), shell=True)
+               gdbProcess = subprocess.Popen(common.shellquote(gdbCmd) + " -x gdb.setup", shell=True)
 
                gdbProcess.wait()
 
@@ -184,7 +208,9 @@ def debug(
                print("Killed gdbserver process")
 
                print("Kill program %i" % programPid)
-               common.execute("%s shell run-as com.drawelements.deqp -9 %i" % (adbCmd, programPid))
+               common.execArgs([adbCmd]
+                                               + (["-s", serial] if serial != None else [])
+                                               + ["shell", "run-as", "com.drawelements.deqp", "kill", "-9", str(programPid)])
                print("Killed program")
 
        finally:
@@ -206,55 +232,466 @@ def debug(
                elif gdbServerProcess:
                        print("GDB server returned %i" % gdbServerProcess.returncode)
 
-               print("Kill program %i" % programPid)
-               common.execute("%s shell run-as com.drawelements.deqp kill -9 %i" % (adbCmd, programPid))
-               print("Killed program")
+               if programPid != -1:
+                       print("Kill program %i" % programPid)
+                       common.execArgs([adbCmd]
+                                                       + (["-s", serial] if serial != None else [])
+                                                       + ["shell", "run-as", "com.drawelements.deqp", "kill", "-9", str(programPid)])
+                       print("Killed program")
 
                os.chdir(curDir)
 
-if __name__ == "__main__":
-       parser = argparse.ArgumentParser()
+class Device:
+       def __init__ (self, libraries=[], nativeBuildDir=None, hostGdbBins=None, deviceGdbCmd=None, appProcessName=None, linkerName=None):
+               self.libraries = libraries
+               self.nativeBuildDir = nativeBuildDir
+               self.hostGdbBins = hostGdbBins
+               self.deviceGdbCmd = deviceGdbCmd
+               self.appProcessName = appProcessName
+               self.linkerName = linkerName
 
-       defaultDeviceLibs = {
-               "nexus-4" : [
-                       "/system/lib/libgenlock.so",
-                       "/system/lib/libmemalloc.so",
-                       "/system/lib/libqdutils.so",
-                       "/system/lib/libsc-a3xx.so"
-               ]
-       }
+       def getBuildDir (self):
+               return self.nativeBuildDir
 
-       defaultDevices = []
+       def getGdbCommand (self, platform):
+               return self.hostGdbBins[platform]
 
-       for device in defaultDeviceLibs:
-               defaultDevices += [device]
+       def getDeviceGdbCommand (self):
+               return self.deviceGdbCmd
 
-       parser.add_argument('--adb',                            dest='adbCmd',                  default=common.shellquote(common.ADB_BIN), help="Path to adb command. Use absolute paths.")
-       parser.add_argument('--deqp-commandline',       dest='deqpCmdLine',             default="--deqp-log-filename=/sdcard/TestLog.qpa", help="Command line arguments passed to dEQP test binary.")
+       def getLibs (self):
+               return self.libraries
+
+       def getLinkerName (self):
+               return self.linkerName
 
-       if common.getPlatform() == "linux":
-               parser.add_argument('--gdb',                            dest='gdbCmd',                  default=common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gdb")), help="gdb command used by script. Use absolute paths")
-       else:
-               parser.add_argument('--gdb',                            dest='gdbCmd',                  default=common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi-gdb")), help="gdb command used by script. Use absolute paths")
+       def getAppProcessName (self):
+               return self.appProcessName
 
+if __name__ == "__main__":
+       parser = argparse.ArgumentParser()
+
+       devices = {
+               "nexus-4" : Device(
+                       nativeBuildDir = "../native/debug-13-armeabi-v7a",
+                       deviceGdbCmd = "lib/gdbserver",
+                       hostGdbBins = {
+                               "linux" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gdb")),
+                               "windows" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi-gdb"))
+                       },
+                       appProcessName = "app_process",
+                       linkerName = "linker",
+                       libraries = [
+                               "/system/lib/libgenlock.so",
+                               "/system/lib/libmemalloc.so",
+                               "/system/lib/libqdutils.so",
+                               "/system/lib/libsc-a3xx.so"
+                       ]),
+               "nexus-6" : Device(
+                       nativeBuildDir = "../native/debug-13-armeabi-v7a",
+                       deviceGdbCmd = "lib/gdbserver",
+                       hostGdbBins = {
+                               "linux" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gdb")),
+                               "windows" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi-gdb"))
+                       },
+                       appProcessName = "app_process",
+                       linkerName = "linker",
+                       libraries = [
+                               "/system/lib/libutils.so",
+                               "/system/lib/libstdc++.so",
+                               "/system/lib/libm.so",
+                               "/system/lib/liblog.so",
+                               "/system/lib/libhardware.so",
+                               "/system/lib/libbinder.so",
+                               "/system/lib/libcutils.so",
+                               "/system/lib/libc++.so",
+                               "/system/lib/libLLVM.so",
+                               "/system/lib/libbcinfo.so",
+                               "/system/lib/libunwind.so",
+                               "/system/lib/libz.so",
+                               "/system/lib/libpng.so",
+                               "/system/lib/libcommon_time_client.so",
+                               "/system/lib/libstlport.so",
+                               "/system/lib/libui.so",
+                               "/system/lib/libsync.so",
+                               "/system/lib/libgui.so",
+                               "/system/lib/libft2.so",
+                               "/system/lib/libbcc.so",
+                               "/system/lib/libGLESv2.so",
+                               "/system/lib/libGLESv1_CM.so",
+                               "/system/lib/libEGL.so",
+                               "/system/lib/libunwind-ptrace.so",
+                               "/system/lib/libgccdemangle.so",
+                               "/system/lib/libcrypto.so",
+                               "/system/lib/libicuuc.so",
+                               "/system/lib/libicui18n.so",
+                               "/system/lib/libjpeg.so",
+                               "/system/lib/libexpat.so",
+                               "/system/lib/libpcre.so",
+                               "/system/lib/libharfbuzz_ng.so",
+                               "/system/lib/libstagefright_foundation.so",
+                               "/system/lib/libsonivox.so",
+                               "/system/lib/libnbaio.so",
+                               "/system/lib/libcamera_client.so",
+                               "/system/lib/libaudioutils.so",
+                               "/system/lib/libinput.so",
+                               "/system/lib/libhardware_legacy.so",
+                               "/system/lib/libcamera_metadata.so",
+                               "/system/lib/libgabi++.so",
+                               "/system/lib/libskia.so",
+                               "/system/lib/libRScpp.so",
+                               "/system/lib/libRS.so",
+                               "/system/lib/libwpa_client.so",
+                               "/system/lib/libnetutils.so",
+                               "/system/lib/libspeexresampler.so",
+                               "/system/lib/libGLES_trace.so",
+                               "/system/lib/libbacktrace.so",
+                               "/system/lib/libusbhost.so",
+                               "/system/lib/libssl.so",
+                               "/system/lib/libsqlite.so",
+                               "/system/lib/libsoundtrigger.so",
+                               "/system/lib/libselinux.so",
+                               "/system/lib/libprocessgroup.so",
+                               "/system/lib/libpdfium.so",
+                               "/system/lib/libnetd_client.so",
+                               "/system/lib/libnativehelper.so",
+                               "/system/lib/libnativebridge.so",
+                               "/system/lib/libminikin.so",
+                               "/system/lib/libmemtrack.so",
+                               "/system/lib/libmedia.so",
+                               "/system/lib/libinputflinger.so",
+                               "/system/lib/libimg_utils.so",
+                               "/system/lib/libhwui.so",
+                               "/system/lib/libandroidfw.so",
+                               "/system/lib/libETC1.so",
+                               "/system/lib/libandroid_runtime.so",
+                               "/system/lib/libsigchain.so",
+                               "/system/lib/libbacktrace_libc++.so",
+                               "/system/lib/libart.so",
+                               "/system/lib/libjavacore.so",
+                               "/system/lib/libvorbisidec.so",
+                               "/system/lib/libstagefright_yuv.so",
+                               "/system/lib/libstagefright_omx.so",
+                               "/system/lib/libstagefright_enc_common.so",
+                               "/system/lib/libstagefright_avc_common.so",
+                               "/system/lib/libpowermanager.so",
+                               "/system/lib/libopus.so",
+                               "/system/lib/libdrmframework.so",
+                               "/system/lib/libstagefright_amrnb_common.so",
+                               "/system/lib/libstagefright.so",
+                               "/system/lib/libmtp.so",
+                               "/system/lib/libjhead.so",
+                               "/system/lib/libexif.so",
+                               "/system/lib/libmedia_jni.so",
+                               "/system/lib/libsoundpool.so",
+                               "/system/lib/libaudioeffect_jni.so",
+                               "/system/lib/librs_jni.so",
+                               "/system/lib/libjavacrypto.so",
+                               "/system/lib/libqservice.so",
+                               "/system/lib/libqdutils.so",
+                               "/system/lib/libqdMetaData.so",
+                               "/system/lib/libmemalloc.so",
+                               "/system/lib/libandroid.so",
+                               "/system/lib/libcompiler_rt.so",
+                               "/system/lib/libjnigraphics.so",
+                               "/system/lib/libwebviewchromium_loader.so",
+
+                               "/system/lib/hw/gralloc.msm8084.so",
+                               "/system/lib/hw/memtrack.msm8084.so",
+
+                               "/vendor/lib/libgsl.so",
+                               "/vendor/lib/libadreno_utils.so",
+                               "/vendor/lib/egl/libEGL_adreno.so",
+                               "/vendor/lib/egl/libGLESv1_CM_adreno.so",
+                               "/vendor/lib/egl/libGLESv2_adreno.so",
+                               "/vendor/lib/egl/eglSubDriverAndroid.so",
+                               "/vendor/lib/libllvm-glnext.so",
+                       ]),
+               "nexus-7" : Device(
+                       nativeBuildDir = "../native/debug-13-armeabi-v7a",
+                       deviceGdbCmd = "lib/gdbserver",
+                       hostGdbBins = {
+                               "linux" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gdb")),
+                               "windows" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi-gdb"))
+                       },
+                       appProcessName = "app_process",
+                       linkerName = "linker",
+                       libraries = [
+                               "/system/lib/libm.so",
+                               "/system/lib/libqdutils.so",
+                               "/system/lib/libmemalloc.so",
+                               "/system/lib/hw/gralloc.msm8960.so",
+                               "/system/lib/libstdc++.so",
+                               "/system/lib/liblog.so.",
+                               "/system/lib/libstdc++.so",
+                               "/system/lib/liblog.so",
+                               "/system/lib/libsigchain.so",
+                               "/system/lib/libcutils.so",
+                               "/system/lib/libstlport.so",
+                               "/system/lib/libgccdemangle.so",
+                               "/system/lib/libunwind.so",
+                               "/system/lib/libunwind-ptrace.so",
+                               "/system/lib/libbacktrace.so",
+                               "/system/lib/libutils.so",
+                               "/system/lib/libGLES_trace.so",
+                               "/system/lib/libEGL.so",
+                               "/system/lib/libETC1.so",
+                               "/system/lib/libGLESv1_CM.so",
+                               "/system/lib/libGLESv2.so",
+                               "/system/lib/libbinder.so",
+                               "/system/lib/libz.so",
+                               "/system/lib/libandroidfw.so",
+                               "/system/lib/libspeexresampler.so",
+                               "/system/lib/libaudioutils.so",
+                               "/system/lib/libcamera_metadata.so",
+                               "/system/lib/libsync.so",
+                               "/system/lib/libhardware.so",
+                               "/system/lib/libui.so",
+                               "/vendor/lib/egl/eglsubAndroid.so",
+                               "/vendor/lib/libsc-a3xx.so",
+                               "/system/lib/libgui.so",
+                               "/system/lib/libcamera_client.so",
+                               "/system/lib/libcrypto.so",
+                               "/system/lib/libexpat.so",
+                               "/system/lib/libnetutils.so",
+                               "/system/lib/libwpa_client.so",
+                               "/system/lib/libhardware_legacy.so",
+                               "/system/lib/libgabi++.so",
+                               "/system/lib/libicuuc.so",
+                               "/system/lib/libicui18n.so",
+                               "/system/lib/libharfbuzz_ng.so",
+                               "/system/lib/libc++.so",
+                               "/system/lib/libLLVM.so",
+                               "/system/lib/libbcinfo.so",
+                               "/system/lib/libbcc.so",
+                               "/system/lib/libpng.so",
+                               "/system/lib/libft2.so",
+                               "/system/lib/libRS.so",
+                               "/system/lib/libRScpp.so",
+                               "/system/lib/libjpeg.so",
+                               "/system/lib/libskia.so",
+                               "/system/lib/libhwui.so",
+                               "/system/lib/libimg_utils.so",
+                               "/system/lib/libinput.so",
+                               "/system/lib/libinputflinger.so",
+                               "/system/lib/libcommon_time_client.so",
+                               "/system/lib/libnbaio.so",
+                               "/system/lib/libsonivox.so",
+                               "/system/lib/libstagefright_foundation.so",
+                               "/system/lib/libmedia.so",
+                               "/system/lib/libmemtrack.so",
+                               "/system/lib/libminikin.so",
+                               "/system/lib/libnativebridge.so",
+                               "/system/lib/libnativehelper.so",
+                               "/system/lib/libnetd_client.so",
+                               "/system/lib/libpdfium.so",
+                               "/system/lib/libprocessgroup.so",
+                               "/system/lib/libselinux.so",
+                               "/system/lib/libsoundtrigger.so",
+                               "/system/lib/libsqlite.so",
+                               "/system/lib/libssl.so",
+                               "/system/lib/libusbhost.so",
+                               "/system/lib/libandroid_runtime.so",
+                               "/system/lib/libbacktrace_libc++.so",
+                               "/system/lib/libart.so",
+                               "/system/lib/libjavacore.so",
+                               "/system/lib/libexif.so",
+                               "/system/lib/libjhead.so",
+                               "/system/lib/libmtp.so",
+                               "/system/lib/libdrmframework.so",
+                               "/system/lib/libopus.so",
+                               "/system/lib/libpowermanager.so",
+                               "/system/lib/libstagefright_avc_common.so",
+                               "/system/lib/libstagefright_enc_common.so",
+                               "/system/lib/libstagefright_omx.so",
+                               "/system/lib/libstagefright_yuv.so",
+                               "/system/lib/libvorbisidec.so",
+                               "/system/lib/libstagefright.so",
+                               "/system/lib/libstagefright_amrnb_common.so",
+                               "/system/lib/libmedia_jni.so",
+                               "/system/lib/libsoundpool.so",
+                               "/system/lib/libaudioeffect_jni.so",
+                               "/system/lib/librs_jni.so",
+                               "/system/lib/libjavacrypto.so",
+                               "/system/lib/libandroid.so",
+                               "/system/lib/libcompiler_rt.so",
+                               "/system/lib/libjnigraphics.so",
+                               "/system/lib/libwebviewchromium_loader.so",
+
+                               "/system/lib/hw/memtrack.msm8960.so",
+
+                               "/vendor/lib/libgsl.so",
+                               "/vendor/lib/libadreno_utils.so",
+                               "/vendor/lib/egl/libEGL_adreno.so",
+                               "/vendor/lib/egl/libGLESv1_CM_adreno.so",
+                               "/vendor/lib/egl/libGLESv2_adreno.so",
+                       ]),
+               "nexus-10" : Device(
+                       nativeBuildDir = "../native/debug-13-armeabi-v7a",
+                       deviceGdbCmd = "lib/gdbserver",
+                       hostGdbBins = {
+                               "linux" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gdb")),
+                               "windows" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi-gdb"))
+                       },
+                       appProcessName = "app_process",
+                       linkerName = "linker",
+                       libraries = [
+                               "/system/lib/libutils.so",
+                               "/system/lib/libstdc++.so",
+                               "/system/lib/libm.so",
+                               "/system/lib/liblog.so",
+                               "/system/lib/libhardware.so",
+                               "/system/lib/libbinder.so",
+                               "/system/lib/libcutils.so",
+                               "/system/lib/libc++.so",
+                               "/system/lib/libLLVM.so",
+                               "/system/lib/libbcinfo.so",
+                               "/system/lib/libunwind.so",
+                               "/system/lib/libz.so",
+                               "/system/lib/libpng.so",
+                               "/system/lib/libcommon_time_client.so",
+                               "/system/lib/libstlport.so",
+                               "/system/lib/libui.so",
+                               "/system/lib/libsync.so",
+                               "/system/lib/libgui.so",
+                               "/system/lib/libft2.so",
+                               "/system/lib/libbcc.so",
+                               "/system/lib/libGLESv2.so",
+                               "/system/lib/libGLESv1_CM.so",
+                               "/system/lib/libEGL.so",
+                               "/system/lib/libunwind-ptrace.so",
+                               "/system/lib/libgccdemangle.so",
+                               "/system/lib/libcrypto.so",
+                               "/system/lib/libicuuc.so",
+                               "/system/lib/libicui18n.so",
+                               "/system/lib/libjpeg.so",
+                               "/system/lib/libexpat.so",
+                               "/system/lib/libpcre.so",
+                               "/system/lib/libharfbuzz_ng.so",
+                               "/system/lib/libstagefright_foundation.so",
+                               "/system/lib/libsonivox.so",
+                               "/system/lib/libnbaio.so",
+                               "/system/lib/libcamera_client.so",
+                               "/system/lib/libaudioutils.so",
+                               "/system/lib/libinput.so",
+                               "/system/lib/libhardware_legacy.so",
+                               "/system/lib/libcamera_metadata.so",
+                               "/system/lib/libgabi++.so",
+                               "/system/lib/libskia.so",
+                               "/system/lib/libRScpp.so",
+                               "/system/lib/libRS.so",
+                               "/system/lib/libwpa_client.so",
+                               "/system/lib/libnetutils.so",
+                               "/system/lib/libspeexresampler.so",
+                               "/system/lib/libGLES_trace.so",
+                               "/system/lib/libbacktrace.so",
+                               "/system/lib/libusbhost.so",
+                               "/system/lib/libssl.so",
+                               "/system/lib/libsqlite.so",
+                               "/system/lib/libsoundtrigger.so",
+                               "/system/lib/libselinux.so",
+                               "/system/lib/libprocessgroup.so",
+                               "/system/lib/libpdfium.so",
+                               "/system/lib/libnetd_client.so",
+                               "/system/lib/libnativehelper.so",
+                               "/system/lib/libnativebridge.so",
+                               "/system/lib/libminikin.so",
+                               "/system/lib/libmemtrack.so",
+                               "/system/lib/libmedia.so",
+                               "/system/lib/libinputflinger.so",
+                               "/system/lib/libimg_utils.so",
+                               "/system/lib/libhwui.so",
+                               "/system/lib/libandroidfw.so",
+                               "/system/lib/libETC1.so",
+                               "/system/lib/libandroid_runtime.so",
+                               "/system/lib/libsigchain.so",
+                               "/system/lib/libbacktrace_libc++.so",
+                               "/system/lib/libart.so",
+                               "/system/lib/libjavacore.so",
+                               "/system/lib/libvorbisidec.so",
+                               "/system/lib/libstagefright_yuv.so",
+                               "/system/lib/libstagefright_omx.so",
+                               "/system/lib/libstagefright_enc_common.so",
+                               "/system/lib/libstagefright_avc_common.so",
+                               "/system/lib/libpowermanager.so",
+                               "/system/lib/libopus.so",
+                               "/system/lib/libdrmframework.so",
+                               "/system/lib/libstagefright_amrnb_common.so",
+                               "/system/lib/libstagefright.so",
+                               "/system/lib/libmtp.so",
+                               "/system/lib/libjhead.so",
+                               "/system/lib/libexif.so",
+                               "/system/lib/libmedia_jni.so",
+                               "/system/lib/libsoundpool.so",
+                               "/system/lib/libaudioeffect_jni.so",
+                               "/system/lib/librs_jni.so",
+                               "/system/lib/libjavacrypto.so",
+                               "/system/lib/libandroid.so",
+                               "/system/lib/libcompiler_rt.so",
+                               "/system/lib/libjnigraphics.so",
+                               "/system/lib/libwebviewchromium_loader.so",
+                               "/system/lib/libion.so",
+                               "/vendor/lib/hw/gralloc.exynos5.so",
+                               "/vendor/lib/egl/libGLES_mali.so",
+                       ]),
+               "default" : Device(
+                       nativeBuildDir = "../native/debug-13-armeabi-v7a",
+                       deviceGdbCmd = "lib/gdbserver",
+                       hostGdbBins = {
+                               "linux" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gdb")),
+                               "windows" : common.shellquote(os.path.join(common.ANDROID_NDK_PATH, "toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi-gdb"))
+                       },
+                       appProcessName = "app_process",
+                       linkerName = "linker",
+                       libraries = [
+                       ]),
+       }
+
+       parser.add_argument('--adb',                            dest='adbCmd',                  default=common.ADB_BIN, help="Path to adb command. Use absolute paths.")
+       parser.add_argument('--deqp-commandline',       dest='deqpCmdLine',             default="--deqp-log-filename=/sdcard/TestLog.qpa", help="Command line arguments passed to dEQP test binary.")
+       parser.add_argument('--gdb',                            dest='gdbCmd',                  default=None, help="gdb command used by script. Use absolute paths")
+       parser.add_argument('--device-gdb',                     dest='deviceGdbCmd',    default=None, help="gdb command used by script on device.")
        parser.add_argument('--target-gdb-port',        dest='targetGDBPort',   default=60001, type=int, help="Port used by gdbserver on target.")
        parser.add_argument('--host-gdb-port',          dest='hostGDBPort',             default=60002, type=int, help="Host port that is forwarded to device gdbserver port.")
        parser.add_argument('--jdb',                            dest='jdbCmd',                  default="jdb", help="Path to jdb command. Use absolute paths.")
        parser.add_argument('--jdb-port',                       dest='jdbPort',                 default=60003, type=int, help="Host port used to forward jdb commands to device.")
-       parser.add_argument('--build-dir',                      dest='buildDir',                default="../../../deqp-build-android-9-armeabi-v7a-debug", help="Path to dEQP native build directory.")
+       parser.add_argument('--build-dir',                      dest='buildDir',                default=None, help="Path to dEQP native build directory.")
        parser.add_argument('--device-libs',            dest='deviceLibs',              default=[], nargs='+', help="List of libraries that should be pulled from device for debugging.")
        parser.add_argument('--breakpoints',            dest='breakpoints',             default=["tcu::App::App"], nargs='+', help="List of breakpoints that are set by gdb.")
-       parser.add_argument('--device',                         dest='device',                  default=None, choices=defaultDevices, help="Pull default libraries for this device.")
+       parser.add_argument('--app-process-name',       dest='appProcessName',  default=None, help="Name of the app_process binary.")
+       parser.add_argument('--linker-name',            dest='linkerName',              default=None, help="Name of the linker binary.")
+       parser.add_argument('--device',                         dest='device',                  default="default", choices=devices, help="Pull default libraries for this device.")
+       parser.add_argument('--serial','-s',            dest='serial',                  default=None, help="-s Argument for adb.")
 
        args = parser.parse_args()
+       device = devices[args.device]
+
+       if args.deviceGdbCmd == None:
+               args.deviceGdbCmd = device.getDeviceGdbCommand()
+
+       if args.buildDir == None:
+               args.buildDir = device.getBuildDir()
+
+       if args.gdbCmd == None:
+               args.gdbCmd = device.getGdbCommand(common.getPlatform())
+
+       if args.linkerName == None:
+               args.linkerName = device.getLinkerName()
+
+       if args.appProcessName == None:
+               args.appProcessName = device.getAppProcessName()
 
        debug(adbCmd=os.path.normpath(args.adbCmd),
-             gdbCmd=os.path.normpath(args.gdbCmd),
-             targetGDBPort=args.targetGDBPort,
-             hostGDBPort=args.hostGDBPort,
-          jdbCmd=os.path.normpath(args.jdbCmd),
-             jdbPort=args.jdbPort,
-             deqpCmdLine=args.deqpCmdLine,
-             buildDir=args.buildDir,
-             deviceLibs=["/system/lib/libc.so", "/system/lib/libdl.so"] + args.deviceLibs + (defaultDeviceLibs[args.device] if args.device else []),
-             breakpoints=args.breakpoints)
+                 gdbCmd=os.path.normpath(args.gdbCmd),
+                 targetGDBPort=args.targetGDBPort,
+                 hostGDBPort=args.hostGDBPort,
+                 jdbCmd=os.path.normpath(args.jdbCmd),
+                 jdbPort=args.jdbPort,
+                 deqpCmdLine=args.deqpCmdLine,
+                 buildDir=args.buildDir,
+                 deviceLibs=["/system/lib/libc.so", "/system/lib/libdl.so"] + args.deviceLibs + device.getLibs(),
+                 breakpoints=args.breakpoints,
+                 serial=args.serial,
+                 deviceGdbCmd=args.deviceGdbCmd,
+                 appProcessName=args.appProcessName,
+                 linkerName=args.linkerName)