From 228dbdd52715c28b54b4a63a06b663597f295836 Mon Sep 17 00:00:00 2001
From: Martin Stein <martin.stein@genode-labs.com>
Date: Wed, 17 May 2017 12:57:14 +0200
Subject: [PATCH] run + noux_gdb: fix source archiving

We do not have debug symbols in the bin/ binaries anymore. Thus, use the
debug/ binaries instead.  We now have kernel specific binary names for
ld.lib.so and some others. Adapt, to this fact as well.  For doing so
without unnecessary output, provide a new parameter "silent" at the
"kernel_specific_binary" procedure.

Ref #2398
---
 repos/ports/run/noux_gdb.inc | 4 +++-
 tool/run/run                 | 6 ++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/repos/ports/run/noux_gdb.inc b/repos/ports/run/noux_gdb.inc
index 8a41268c75..f427450523 100644
--- a/repos/ports/run/noux_gdb.inc
+++ b/repos/ports/run/noux_gdb.inc
@@ -34,7 +34,9 @@ proc create_binary_tar { application_name application_binaries } {
 proc create_source_tar { application_name application_binaries } {
 	exec mkdir -p bin/${application_name}-src
 	foreach application_binary $application_binaries {
-		set source_files [ exec [cross_dev_prefix]objdump -dl bin/${application_binary} | grep "^/.*:.*" | sed -e "s/:.*//" | uniq ]
+		set binary debug/[kernel_specific_binary ${application_binary} silent]
+		puts "archive sources of $binary"
+		set source_files [ exec [cross_dev_prefix]objdump -dl $binary | grep "^/.*:.*" | sed -e "s/:.*//" | uniq ]
 		foreach source_file ${source_files} {
 			# resolve '..' to avoid problems with 'tar' with parts like '/a/b/../'
 			# where '/a' exists, but '/a/b' does not
diff --git a/tool/run/run b/tool/run/run
index 0cde1b8f8f..c0a80a6426 100755
--- a/tool/run/run
+++ b/tool/run/run
@@ -451,14 +451,16 @@ proc kernel_location_from_config_file { config_file default_location } {
 # case for regular binaries that appear in the boot directory under their
 # original name.
 #
-proc kernel_specific_binary { binary } {
+proc kernel_specific_binary { binary {silent ""} } {
 
 	regsub -all {\.} $binary "_" function_suffix
 	set function_name "binary_name_$function_suffix"
 
 	if {[info procs $function_name] == $function_name} {
 		set binary_name [$function_name]
-		puts "using '$binary_name' as '$binary'"
+		if {$silent != "silent"} {
+			puts "using '$binary_name' as '$binary'"
+		}
 		return [$function_name]
 	}