From patchwork Thu Oct 6 15:16:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lionel Landwerlin X-Patchwork-Id: 9364935 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C0DF06077E for ; Thu, 6 Oct 2016 15:16:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0ECC2909C for ; Thu, 6 Oct 2016 15:16:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A25E6290A3; Thu, 6 Oct 2016 15:16:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AC47D2909C for ; Thu, 6 Oct 2016 15:16:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 439806E9E5; Thu, 6 Oct 2016 15:16:44 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 886966E9E5 for ; Thu, 6 Oct 2016 15:16:43 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id b201so4000799wmb.1 for ; Thu, 06 Oct 2016 08:16:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cXyurYUK/FGks+3fIvL53Lhx8NyOfxjjC/wmroTKnbA=; b=DEW+uXo1qlfHF4Rf9rsgfsanmLliNhn/dqXp4/Y7yuAkbLNVMUThOB/5uAEdLezfNO rJyzbTocc0R/6Xq110FtOH0zHHl9luxUsTDVmGXQwDMYJQey+Y83k1vHxUQcqx2jxscE Z2jn2a4URbkDjm0ycaH6SXZPd+vvP3nKNm2Iqyv8fh6wM+BcDEbx3CgqThn3701Jo5Lb aBjgXHDdI4GfbmWx11mAC9UUkNOhBrLrxSeCR4zBL5TItfw78xkbXuQfjsPEANPGk6cr uDhmpYowfFeysV9jHgKm19CXB+Cnn0R9DzsPU8LaD0LoKuFx/vk/C60rtpSS44YvOJck hiOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cXyurYUK/FGks+3fIvL53Lhx8NyOfxjjC/wmroTKnbA=; b=aFjk1QCtfIL0yO47QK90QwB79MCWGVVTYXLhij6UDveevxleDBztUTk9akV1bf+zTe G+wC2j+yV8xUrvSqi0TLW9I0jmDULa6ftu49qmTcxbbKgXv7RVTEPQelrBnAb4d0kU/Z Djb05K1YfG5q4ofs2TIP7IZGYhMy8iedy7cJbDkyM7A1j3zbp9jsKAZIO0++gigehrtt vBfY5SUyiI06YPdoMaiaFBdz5HaeSm6B/gfwUJ+UfWStdgQZRpLym5Svl2oZlAJJYlCo A6/wYRYu9Nu0cM06CAAepaf6VSTE56/Ffilzn9lp6FQWDxvRW922FBFZT8xqF+PlrXAC +pog== X-Gm-Message-State: AA6/9RnTC34jrCh6701YvLN0PnxBmB9ApzJnrbRoj8adAEGhPLlYx7PiEpEoI70zVGlmcA== X-Received: by 10.28.87.212 with SMTP id l203mr520428wmb.71.1475767002003; Thu, 06 Oct 2016 08:16:42 -0700 (PDT) Received: from localhost.localdomain ([192.198.151.61]) by smtp.googlemail.com with ESMTPSA id u185sm15516997wmu.20.2016.10.06.08.16.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Oct 2016 08:16:41 -0700 (PDT) From: Lionel Landwerlin X-Google-Original-From: Lionel Landwerlin To: intel-gfx@lists.freedesktop.org Date: Thu, 6 Oct 2016 16:16:34 +0100 Message-Id: <20161006151635.28573-2-lionel.g.landwerlin@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161006151635.28573-1-lionel.g.landwerlin@intel.com> References: <20161006151635.28573-1-lionel.g.landwerlin@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 2/3] tools: intel_aubdump: pass configuration through file descriptor X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP This makes parsing options less complicated and easier to extend. Signed-off-by: Lionel Landwerlin --- tools/aubdump.c | 32 ++++++++++++++++++++++---------- tools/intel_aubdump.in | 22 +++++++++++++++------- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/tools/aubdump.c b/tools/aubdump.c index a2ac7f1..e82b514 100644 --- a/tools/aubdump.c +++ b/tools/aubdump.c @@ -430,26 +430,38 @@ static void maybe_init(void) { static bool initialized = false; - const char *args = getenv("INTEL_AUBDUMP_ARGS"); + FILE *config; + char *key, *value; if (initialized) return; initialized = true; - if (sscanf(args, "verbose=%d;file=%m[^;];device=%i", - &verbose, &filename, &device) != 3) - filename = strdup("intel.aub"); - fail_if(filename == NULL, "intel_aubdump: out of memory\n"); + config = fdopen(3, "r"); + while (fscanf(config, "%m[^=]=%m[^\n]\n", &key, &value) != EOF) { + if (!strcmp(key, "verbose")) { + verbose = 1; + } else if (!strcmp(key, "device")) { + device = atoi(value); + device_override = true; + } else if (!strcmp(key, "file")) { + filename = value; + file = fopen(filename, "w+"); + fail_if(file == NULL, + "intel_aubdump: failed to open file '%s'\n", + filename); + } else { + fprintf(stderr, "intel_aubdump: unknown option '%s'\n", key); + } - if (device) - device_override = true; + free(key); + free(value); + } + fclose(config); bos = malloc(MAX_BO_COUNT * sizeof(bos[0])); fail_if(bos == NULL, "intel_aubdump: out of memory\n"); - - file = fopen(filename, "w+"); - fail_if(file == NULL, "intel_aubdump: failed to open file '%s'\n", filename); } int diff --git a/tools/intel_aubdump.in b/tools/intel_aubdump.in index feee23a..445b60f 100644 --- a/tools/intel_aubdump.in +++ b/tools/intel_aubdump.in @@ -21,29 +21,38 @@ EOF exit 0 } -verbose=0 -device=0 +args="" +command="" +file="" + +function add_arg() { + arg=$1 + args="$args$arg\n" +} while true; do case "$1" in -o) file=$2 + add_arg "file=${f:-$(basename ${f}).aub}" shift 2 ;; -v) - verbose=1 + add_arg "verbose=1" shift 1 ;; -o*) file=${1##-o} + add_arg "file=${file:-$(basename ${file}).aub}" shift ;; --output=*) file=${1##--output=} + add_arg "file=${file:-$(basename ${file}).aub}" shift ;; --device=*) - device=${1##--device=} + add_arg "device=${1##--device=}" shift ;; --help) @@ -66,12 +75,11 @@ done [ -z $1 ] && show_help -file=${file:-$(basename $1).aub} +[ -z $file ] && add_arg "file=intel.aub" prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ LD_PRELOAD=${libdir}/intel_aubdump.so${LD_PPRELOAD:+:${LD_PRELOAD}} \ - INTEL_AUBDUMP_ARGS="verbose=$verbose;file=$file;device=$device" \ - exec -- "$@" + exec -- "$@" 3<<< `printf '%b' "$args"`