[OpenWrt-Devel] scripts: remote-gdb: fix detection with multiple targets
diff mbox

Message ID 1422009427-18667-1-git-send-email-karlp@tweak.net.au
State Superseded
Delegated to: Felix Fietkau
Headers show

Commit Message

Karl Palsson Jan. 23, 2015, 10:37 a.m. UTC
From: Karl Palsson <karlp@remake.is>

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 <karlp@remake.is>
---

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(-)

Patch
diff mbox

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
 	{