| 1 |
set test bz29676 |
| 2 |
|
| 3 |
# log_user 1 |
| 4 |
# exp_internal 1 |
| 5 |
|
| 6 |
set test_dir [pwd] |
| 7 |
set src $srcdir/$subdir/$test.c |
| 8 |
set exe $test |
| 9 |
set dbg $test.dbg |
| 10 |
|
| 11 |
set result [target_compile $src $exe executable "compiler=gcc additional_flags=-g"] |
| 12 |
if { $result != "" } { |
| 13 |
fail "${test}: unable to compile ${test}.c" |
| 14 |
} |
| 15 |
|
| 16 |
# Seperate the debuginfo from the elf into its own file |
| 17 |
# This contains the debuginfo for the symbols foo1 and foobar |
| 18 |
# (NOT foo2) since this was added directly to the symbol table via inline asm |
| 19 |
catch {exec objcopy --only-keep-debug $exe $dbg} |
| 20 |
|
| 21 |
# Remove foo1 from the executable's symbol table and remove the debuginfo |
| 22 |
# The symbol table contains foo2 and foobar |
| 23 |
catch {exec objcopy --strip-symbol=foo1 $exe} |
| 24 |
catch {exec objcopy --strip-debug $exe} |
| 25 |
|
| 26 |
# The args are the expected completions for function("foo*") |
| 27 |
proc correct_stap_output { args } { |
| 28 |
global test_dir |
| 29 |
global exe |
| 30 |
|
| 31 |
set result "^" |
| 32 |
foreach f $args { |
| 33 |
append $result "process\\\(\"$test_dir/$exe\"\\\).function\\\(\"" $f "\"\\\)\r\n" |
| 34 |
} |
| 35 |
append $result "$" |
| 36 |
return $result |
| 37 |
} |
| 38 |
|
| 39 |
proc test_list { test input output_re } { |
| 40 |
spawn stap -l $input |
| 41 |
expect { |
| 42 |
-timeout 60 |
| 43 |
-re $output_re { pass $test } |
| 44 |
timeout { fail $test } |
| 45 |
eof { fail $test } |
| 46 |
} |
| 47 |
catch { close }; catch { wait } |
| 48 |
} |
| 49 |
|
| 50 |
# Before dbg made is availible only the elf symbol table data can be used (i.e foo2 and foobar) |
| 51 |
test_list $test"_no_dbg" "process(\"$exe\").function(\"foo*\")" [correct_stap_output "foo2" "foobar"] |
| 52 |
|
| 53 |
# add a link to the debugging info into the stripped executable |
| 54 |
catch {exec objcopy --add-gnu-debuglink=$dbg $exe} |
| 55 |
|
| 56 |
# After the link foo1 should be available from dbg and foobar should get a richer output (i.e foobar's debuginfo is taken from dbg and not exe) |
| 57 |
test_list $test"_yes_dbg" "process(\"$exe\").function(\"foo*\")" [correct_stap_output "foo1@$src:5" "foo2" "foobar@$src:1"] |