From patchwork Fri Jan 23 10:37:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karl Palsson X-Patchwork-Id: 432136 X-Patchwork-Delegate: nbd@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A19FB14007F for ; Fri, 23 Jan 2015 21:37:31 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 9854C28BE14; Fri, 23 Jan 2015 11:35:00 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00, T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id E34D1280621 for ; Fri, 23 Jan 2015 11:34:54 +0100 (CET) X-policyd-weight: using cached result; rate: -8.5 Received: from palmtree.beeroclock.net (palmtree.beeroclock.net [178.79.160.154]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Fri, 23 Jan 2015 11:34:54 +0100 (CET) Received: by palmtree.beeroclock.net (Postfix, from userid 1000) id 4AE8E2400B; Fri, 23 Jan 2015 10:37:15 +0000 (UTC) From: Karl Palsson To: openwrt-devel@lists.openwrt.org Date: Fri, 23 Jan 2015 10:37:06 +0000 Message-Id: <1422009427-18667-1-git-send-email-karlp@tweak.net.au> X-Mailer: git-send-email 1.7.9.5 Cc: Karl Palsson Subject: [OpenWrt-Devel] [PATCH] scripts: remote-gdb: fix detection with multiple targets X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" From: Karl Palsson This script always worked when I had a single target, but has been failing now that I have both "atheros" and "ar71xx" targets. This change is clearly not perfect, but I can't work out the regexps any better. Signed-off-by: Karl Palsson --- Before: $ ./scripts/remote-gdb 192.168.255.31:3333 /home/karlp/src/smartgate_firmware/openwrt-bb/build_dir/target-mips_34kc_uClibc-0.9.33.2/libcp210xmanufacturing-1-HEAD/contrib/bin/cp2104-rs485 Using target mips_34kc (uClibc-0.9.33.2/libcp210xmanufacturing-1-HEAD) No gdb found! Make sure that CONFIG_GDB is set! $ After: $ ./scripts/remote-gdb 192.168.255.31:3333 /home/karlp/src/smartgate_firmware/openwrt-bb/build_dir/target-mips_34kc_uClibc-0.9.33.2/libcp210xmanufacturing-1-HEAD/contrib/bin/cp2104-rs485 Using target arch: mips_34kc, libc: uClibc Attempting to set sysroot: /home/karlp/src/smartgate_firmware/openwrt-bb/scripts/../staging_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx/ [ gdb starts here normally (but see next patch) ] scripts/remote-gdb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/remote-gdb b/scripts/remote-gdb index 2c08f14..fdd5008 100755 --- a/scripts/remote-gdb +++ b/scripts/remote-gdb @@ -14,10 +14,14 @@ if( opendir SD, "$Bin/../staging_dir" ) { my ( $tid, $arch, $libc, @arches ); + + # This doesn't work. regexpes are hard. if( $ARGV[1] =~ m!\btarget-(.+?)_(([^_]+libc|musl)[^/]+)\b!i ) { - print("Using target $1 ($2)\n"); - ($arch, $libc) = ($1, $2); + $ARGV[1] =~ m!\btarget-(.+?)-!i; + $1 =~ m!(.+?)_(.+?)_(.*)!i; + ($arch, $libc) = ("$1_$2", $3); + print("Using target arch: $arch, libc: $libc\n"); } else {