From patchwork Mon Sep 30 15:04:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arjun Shankar X-Patchwork-Id: 1169461 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-105481-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=lostca.se Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="ibAL9Der"; dkim=pass (1024-bit key; unprotected) header.d=lostca.se header.i=@lostca.se header.b="iio8zJ/7"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46hlzd47pNz9s7T for ; Tue, 1 Oct 2019 01:04:13 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id :mime-version:content-type; q=dns; s=default; b=U0b0LyYHEmK+KGGE 0FYWiY+nim/jlSMjtwyO1QQCaNpw9XtlEtodLfazceWeI6fNKqs+e7xDv1mSf1BE Fjp0d7mOBolvLRNWVNuU3gTfWmjqNwPtAbtcdXbe6516kBH/UrJEeyYp2DKn0b+e aoRE6sD48or7+ArUs+xPRIxUqOg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id :mime-version:content-type; s=default; bh=fiWiZ0ZlnLraHz/pgaHUCA vOOkg=; b=ibAL9DerrPkZ1/Ipcpp8DH19EcsezAMkn1HYv2/Oll6Q7b6DlGwZc0 A10KX6BCIUUlOG9hiodvFiWMe0lSm7WJ2oHrD3LX3EQOjHC5Rxl3Du4GOPje/FE4 bou1nO4esQlotWumhLenKK0pKlVj5xfJuKcxeKrhCK2yYCQGOS7oA= Received: (qmail 21571 invoked by alias); 30 Sep 2019 15:04:07 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 21560 invoked by uid 89); 30 Sep 2019 15:04:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=Notes, H*Ad:D*br, H*r:120, UD:se X-HELO: aloka.lostca.se DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=lostca.se; h=date:from:to :cc:subject:message-id:mime-version:content-type; s=howrah; bh=f iWiZ0ZlnLraHz/pgaHUCAvOOkg=; b=iio8zJ/75uzn2BkrJH2P8ouc6TbUtTOuI nsi5Gt8JPytgq8nnjjShawgOFaITkTf8z5sSSMi2I/svR2YREZZUlKt7XFFNxft9 PZ+Mlj5l5PCHxwo1IxKVt16n/R1oslEs5I4jSdmU9R/i8qGtrrwSbqzFvOwdwm7l FftUB8yFCU= Date: Mon, 30 Sep 2019 15:04:02 +0000 From: Arjun Shankar To: libc-alpha@sourceware.org Cc: "Gabriel F. T. Gomes" Subject: [PATCH] Enable passing arguments to the inferior in debugglibc.sh Message-ID: <20190930150401.GA27942@aloka.lostca.se> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) This patch adds the ability to run debugglibc.sh's inferior program with arguments specified on the command line. This enables convenient debugging of non-testcase programs such as iconv/iconv_prog or other dynamically linked programs. Program arguments may be passed using `--' as a separator. For example: $ ./debugglibc.sh -b iconv -- iconv/iconv_prog -f ASCII -t UTF-8 input.txt 2019-09-30 Arjun Shankar debugglibc.sh: Implement program arguments * Makefile (debugglibc): Change variable definition. Reviewed-by: Gabriel F. T. Gomes --- Discussion Notes: Initial version: https://sourceware.org/ml/libc-alpha/2019-09/msg00502.html As per Gabriel's suggestions: * Changed the patch to only handle program arguments when `--' is used * Documented this in --help (with minor changes: testcase -> program) Also: * It made sense to disable using --direct when program arguments are given --- Makefile | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index a50fb64dc2..a736c3afcc 100644 --- a/Makefile +++ b/Makefile @@ -202,9 +202,12 @@ unset ENVVARS usage() { cat << EOF -Usage: $$0 [OPTIONS] +Usage: $$0 [OPTIONS] - where is the path to the program being tested. + Or: $$0 [OPTIONS] -- []... + + where is the path to the program being tested, + and are the arguments to be passed to it. Options: @@ -224,11 +227,13 @@ Options: The following options do not take arguments: -i, --no-direct - Selects whether to pass the flag --direct to gdb. - Required for glibc test cases and not allowed for non-glibc tests. - Default behaviour is to pass the flag --direct to gdb. + Selects whether to pass the --direct flag to the program. + --direct is useful when debugging glibc test cases. It inhibits the + tests from forking and executing in a subprocess. + Default behaviour is to pass the --direct flag, except when the + program is run with user specified arguments using the "--" separator. -s, --no-symbols-file - Do not tell GDB to load debug symbols from the testcase. + Do not tell GDB to load debug symbols from the program. EOF } @@ -255,8 +260,17 @@ do -s|--no-symbols-file) SYMBOLSFILE=false ;; + --) + shift + TESTCASE=$$1 + COMMANDLINE="$$@" + # Don't add --direct when user specifies program arguments + DIRECT=false + break + ;; *) TESTCASE=$$1 + COMMANDLINE=$$TESTCASE ;; esac shift @@ -302,7 +316,7 @@ __ENVVARS__ __SYMBOLSFILE__ break _dl_start_user run --library-path $(rpath-link):$${BUILD_DIR}/nptl_db \ -__TESTCASE__ __DIRECT__ +__COMMANDLINE__ __DIRECT__ __BREAKPOINTS__ EOF } @@ -311,7 +325,7 @@ EOF template | sed \ -e "s|__ENVVARS__|$$ENVVARSCMD|" \ -e "s|__SYMBOLSFILE__|$$SYMBOLSFILE|" \ - -e "s|__TESTCASE__|$$TESTCASE|" \ + -e "s|__COMMANDLINE__|$$COMMANDLINE|" \ -e "s|__DIRECT__|$$DIRECT|" \ -e "s|__BREAKPOINTS__|$$BREAKPOINTS|" \ > $$CMD_FILE