From patchwork Wed Mar 25 14:38:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 6092341 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C168A9F318 for ; Wed, 25 Mar 2015 14:38:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C9C302035D for ; Wed, 25 Mar 2015 14:38:23 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 690182010C for ; Wed, 25 Mar 2015 14:38:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1E8D76E871; Wed, 25 Mar 2015 07:38:21 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by gabe.freedesktop.org (Postfix) with ESMTP id 1CF446E871 for ; Wed, 25 Mar 2015 07:38:19 -0700 (PDT) Received: by wixw10 with SMTP id w10so76114672wix.0 for ; Wed, 25 Mar 2015 07:38:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-type:content-transfer-encoding; bh=udgu1aYtrT7sblqnLPXPU9OjxAMstUdxdC+8KPvU/Gw=; b=AzTD88Nl3wN6sgc7ykhMlScbVusRAahrw8jz0TtRMKDKpumPf8s5yG/16ggG0frqxb eYQAGFgr4ia/MDxOYbrj2Tb89LAQMuk4eRxQ7iBBoKgyvlHFd46oBsAyTKTJenUUBf+Z GsHGKMTfzw9FH7x0TCLeafo9HmBgDSoaMXUttwixT5B9OTMODKpG3e0DwdU8kH+ylQ8S f9BQ46uefagBAaPLp+CiD3FjAckCmx/WkEq6oxFkQu2X15uJW1nZ1cOBSmcg0bRZi4uG dYnPZQ7JXHJL6qpQAOF7kaOyXNXHJLuCfxJwr+G42XfUNRdXE0eUqQskajTfsg2G5nQO xaUQ== X-Gm-Message-State: ALoCoQl/HkLFsv0/CpjbMfZTzwrly3uNbptv9+/XwTbUAYflxGbAViE02vYNUAHuOorgvAkHZfPJ X-Received: by 10.180.108.13 with SMTP id hg13mr38284375wib.7.1427294298218; Wed, 25 Mar 2015 07:38:18 -0700 (PDT) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id jy7sm20934452wid.22.2015.03.25.07.38.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Mar 2015 07:38:17 -0700 (PDT) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Wed, 25 Mar 2015 14:38:15 +0000 Message-Id: <1427294295-21008-1-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 2.1.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t] Add default debug flags for tests 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Include debugging symbols in tests by default to improve stack traces and also set the compiler optimisation level to improve the debugging experience. Signed-off-by: Thomas Wood --- configure.ac | 14 ++++++++++++ m4/as-compiler-flag.m4 | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/Makefile.am | 2 +- 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 m4/as-compiler-flag.m4 diff --git a/configure.ac b/configure.ac index b9ecef8..51595ad 100644 --- a/configure.ac +++ b/configure.ac @@ -196,6 +196,19 @@ if test "x$with_libunwind" = xyes; then AC_MSG_ERROR([libunwind not found. Use --without-libunwind to disable libunwind support.])) fi +# enable debug symbols +AC_ARG_ENABLE(debug, + AS_HELP_STRING([--disable-debug], + [Build tests without debug symbols]), + [], [enable_debug=yes]) + +if test "x$enable_debug" = xyes; then + AS_COMPILER_FLAG([-g3], [DEBUG_CFLAGS="-g3"], [DEBUG_CFLAGS="-g"]) + AS_COMPILER_FLAG([-Og], [DEBUG_CFLAGS+=" -Og -Wno-maybe-uninitialized"], # disable maybe-uninitialized due to false positives + [DEBUG_CFLAGS+=" -O0"]) + AC_SUBST([DEBUG_CFLAGS]) +fi + # ----------------------------------------------------------------------------- # To build multithread code, gcc uses -pthread, Solaris Studio cc uses -mt @@ -253,6 +266,7 @@ echo " • Tests:" echo " Build tests : ${BUILD_TESTS}" echo " Compile prime tests: ${NOUVEAU}" echo " Print stack traces : ${with_libunwind}" +echo " Debug flags : ${DEBUG_CFLAGS}" echo "" echo " • Tools:" echo " Assembler : ${enable_assembler}" diff --git a/m4/as-compiler-flag.m4 b/m4/as-compiler-flag.m4 new file mode 100644 index 0000000..0f660cf --- /dev/null +++ b/m4/as-compiler-flag.m4 @@ -0,0 +1,62 @@ +dnl as-compiler-flag.m4 0.1.0 + +dnl autostars m4 macro for detection of compiler flags + +dnl David Schleef + +dnl $Id: as-compiler-flag.m4,v 1.1 2005/12/15 23:35:19 ds Exp $ + +dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED]) +dnl Tries to compile with the given CFLAGS. +dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags, +dnl and ACTION-IF-NOT-ACCEPTED otherwise. + +AC_DEFUN([AS_COMPILER_FLAG], +[ + AC_MSG_CHECKING([to see if compiler understands $1]) + + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $1" + + AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no]) + CFLAGS="$save_CFLAGS" + + if test "X$flag_ok" = Xyes ; then + m4_ifvaln([$2],[$2]) + true + else + m4_ifvaln([$3],[$3]) + true + fi + AC_MSG_RESULT([$flag_ok]) +]) + +dnl AS_COMPILER_FLAGS(VAR, FLAGS) +dnl Tries to compile with the given CFLAGS. + +AC_DEFUN([AS_COMPILER_FLAGS], +[ + list=$2 + flags_supported="" + flags_unsupported="" + AC_MSG_CHECKING([for supported compiler flags]) + for each in $list + do + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $each" + AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no]) + CFLAGS="$save_CFLAGS" + + if test "X$flag_ok" = Xyes ; then + flags_supported="$flags_supported $each" + else + flags_unsupported="$flags_unsupported $each" + fi + done + AC_MSG_RESULT([$flags_supported]) + if test "X$flags_unsupported" != X ; then + AC_MSG_WARN([unsupported compiler flags: $flags_unsupported]) + fi + $1="$$1 $flags_supported" +]) + diff --git a/tests/Makefile.am b/tests/Makefile.am index 9c9ac7b..7d3c354 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -32,7 +32,7 @@ EXTRA_DIST = $(TESTS_scripts) $(TESTS_scripts_M) $(scripts) $(IMAGES) $(common_f CLEANFILES = $(EXTRA_PROGRAMS) single-tests.txt multi-tests.txt -AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) \ +AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) $(DEBUG_CFLAGS)\ -I$(srcdir)/.. \ -I$(srcdir)/../lib \ -include "$(srcdir)/../lib/check-ndebug.h" \