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

Karl Palsson karlp at tweak.net.au
Fri Jan 23 05:37:06 EST 2015


From: Karl Palsson <karlp at 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 at 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(-)

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
 	{
-- 
1.8.3.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list