Fix problem that alias can be defined or not depending on the order.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / entry-values.exp
index 0fb35a06406f3d235184f82f042fb18ed0885371..8822950826a887efa7a276a3441fbbd849b4f20d 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2013-2014 Free Software Foundation, Inc.
+# Copyright 2013-2020 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -26,111 +26,79 @@ if  {[gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile}1.o \
     return -1
 }
 
-# Start GDB and load object file, compute the function length and
-# the offset of branch instruction in function.  They are needed
-# in the Dwarf Assembler below.
+if  {[gdb_compile [list ${binfile}1.o] \
+         "${binfile}1" executable {}] != ""} {
+    return -1
+}
+
+# Start GDB and load executable file, compute the offset of the
+# instruction in bar returned from foo.  It is needed in the Dwarf
+# Assembler.
 
 gdb_exit
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}1.o
-
-set foo_length ""
-
-# Calculate the offset of the last instruction from the beginning.
-set test "disassemble foo"
-gdb_test_multiple $test $test {
-    -re ".*$hex <\\+($decimal)>:\[^\r\n\]+\r\nEnd of assembler dump\.\r\n$gdb_prompt $" {
-       set foo_length $expect_out(1,string)
-       pass $test
-    }
-    -re ".*$gdb_prompt $" {
-       fail $test
-       # Bail out here, because we can't do the following tests if
-       # $foo_length is unknown.
-       return -1
-    }
-}
+gdb_load ${binfile}1
 
-# Calculate the size of the last instruction.  Single instruction
-# shouldn't be longer than 10 bytes.
-
-set test "disassemble foo+$foo_length,+10"
-gdb_test_multiple $test $test {
-    -re ".*($hex) <foo\\+$foo_length>:\[^\r\n\]+\r\n\[ \]+($hex) .*\.\r\n$gdb_prompt $" {
-       set start $expect_out(1,string)
-       set end $expect_out(2,string)
-
-       set foo_length [expr $foo_length + $end - $start]
-       pass $test
-    }
-    -re ".*$gdb_prompt $" {
-       fail $test
-       # Bail out here, because we can't do the following tests if
-       # $foo_length is unknown.
-       return -1
-    }
-}
-
-set bar_length ""
-set bar_call_foo ""
+set returned_from_foo ""
 
 if { [istarget "arm*-*-*"] || [istarget "aarch64*-*-*"] } {
     set call_insn "bl"
+} elseif { [istarget "s390*-*-*"] } {
+    set call_insn "brasl"
+} elseif { [istarget "powerpc*-*-*"] } {
+    set call_insn "bl"
+} elseif { [istarget "mips*-*-*"] } {
+    # Skip the delay slot after the instruction used to make a call
+    # (which can be a jump or a branch) if it has one.
+    #
+    #  JUMP (or BRANCH) foo
+    #  insn1
+    #  insn2
+    #
+    # Most MIPS instructions used to make calls have a delay slot.
+    # These include JAL, JALS, JALX, JALR, JALRS, BAL and BALS.
+    # In this case the program continues from `insn2' when `foo'
+    # returns.  The only exception is JALRC, in which case execution
+    # resumes from `insn1' instead.
+    set call_insn {jalrc|[jb]al[sxr]*[ \t][^\r\n]+\r\n}
+} elseif [is_amd64_regs_target] {
+    set call_insn "callq"
 } else {
     set call_insn "call"
 }
 
-# Calculate the offset of the last instruction from the beginning.
+# Calculate the offset of the instruction in bar returned from foo.
 set test "disassemble bar"
 gdb_test_multiple $test $test {
-    -re ".*$hex <\\+$decimal>:\[ \t\]+$call_insn\[^\r\n\]+\r\n\[ \]+$hex <\\+($decimal)>:" {
-       set bar_call_foo $expect_out(1,string)
-       exp_continue
-    }
-    -re ".*$hex <\\+($decimal)>:\[^\r\n\]+\r\nEnd of assembler dump\.\r\n$gdb_prompt $" {
-       set bar_length $expect_out(1,string)
-       pass $test
+    -re ".*$hex <\\+$decimal>:\[ \t\]+\\y$call_insn\\y\[^\r\n\]+\r\n\[ \]+$hex <\\+($decimal)>:.*$gdb_prompt $" {
+       set returned_from_foo $expect_out(1,string)
     }
     -re ".*$gdb_prompt $" {
        fail $test
     }
 }
 
-if { [string equal $bar_call_foo ""] || [string equal $bar_length ""] } {
-    fail "Find the call or branch instruction offset in bar"
+if { [string equal $returned_from_foo ""] } {
+    fail "find the call or branch instruction offset in bar"
     # The following test makes no sense if the offset is unknown.  We need
     # to update the pattern above to match call or branch instruction for
     # the target architecture.
     return -1
 }
 
-# Calculate the size of the last instruction.
-
-set test "disassemble bar+$bar_length,+10"
-gdb_test_multiple $test $test {
-    -re ".*($hex) <bar\\+$bar_length>:\[^\r\n\]+\r\n\[ \]+($hex) .*\.\r\n$gdb_prompt $" {
-       set start $expect_out(1,string)
-       set end $expect_out(2,string)
-
-       set bar_length [expr $bar_length + $end - $start]
-       pass $test
-    }
-    -re ".*$gdb_prompt $" {
-       fail $test
-       # Bail out here, because we can't do the following tests if
-       # $bar_length is unknown.
-       return -1
-    }
-}
-
 gdb_exit
 
 # Make some DWARF for the test.
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
     declare_labels int_label foo_label
-    global foo_length bar_length bar_call_foo
+    global returned_from_foo
+    global srcdir subdir srcfile
+
+    set bar_result [function_range bar ${srcdir}/${subdir}/${srcfile}]
+    set bar_start [lindex $bar_result 0]
+    set bar_length [lindex $bar_result 1]
 
     cu {} {
        compile_unit {{language @DW_LANG_C}} {
@@ -141,10 +109,8 @@ Dwarf::assemble $asm_file {
            }
 
            foo_label: subprogram {
-               {name foo}
-               {decl_file 1}
-               {low_pc foo addr}
-               {high_pc "foo + $foo_length" addr}
+               {decl_file 0 udata}
+               {MACRO_AT_func { foo ${srcdir}/${subdir}/${srcfile} }}
            } {
                formal_parameter {
                    {type :$int_label}
@@ -160,10 +126,10 @@ Dwarf::assemble $asm_file {
 
            subprogram {
                {name bar}
-               {decl_file 1}
-               {low_pc bar addr}
-               {high_pc "bar + $bar_length" addr}
-               {GNU_all_call_sites 1}
+               {decl_file 0 udata}
+               {low_pc $bar_start addr}
+               {high_pc "$bar_start + $bar_length" addr}
+               {GNU_all_call_sites 1 sdata}
            } {
                formal_parameter {
                    {type :$int_label}
@@ -171,7 +137,7 @@ Dwarf::assemble $asm_file {
                }
 
                GNU_call_site {
-                   {low_pc "bar + $bar_call_foo" addr}
+                   {low_pc "$bar_start + $returned_from_foo" addr}
                    {abstract_origin :$foo_label}
                } {
                    # Faked entry values are reference to variables 'global1'
@@ -209,7 +175,7 @@ if  {[gdb_compile [list ${binfile}1.o ${binfile}2.o] \
 clean_restart ${testfile}
 
 if ![runto_main] {
-    fail "Can't run to main"
+    fail "can't run to main"
     return -1
 }
 
@@ -222,19 +188,19 @@ gdb_test_no_output "set print entry-values both"
 gdb_test_sequence "bt" "bt (1)" {
     "\[\r\n\]#0 .* foo \\(i=[-]?[0-9]+, i@entry=2, j=[-]?[0-9]+, j@entry=3\\)"
     "\[\r\n\]#1 .* bar \\(i=<optimized out>, i@entry=<optimized out>\\)"
-    "\[\r\n\]#2 .* main \\(\\)"
+    "\[\r\n\]#2 .* \.?main \\(\\)"
 }
 
 # Update global variables 'global1' and 'global2' and test that the
 # entry values are updated too.
 
-gdb_test_no_output "set var global1=10"
-gdb_test_no_output "set var global2=11"
+gdb_test_no_output "set var *(int *) &global1=10"
+gdb_test_no_output "set var *(int *) &global2=11"
 
 gdb_test_sequence "bt" "bt (2)" {
     "\[\r\n\]#0 .* foo \\(i=[-]?[0-9]+, i@entry=10, j=[-]?[0-9]+, j@entry=11\\)"
     "\[\r\n\]#1 .* bar \\(i=<optimized out>, i@entry=<optimized out>\\)"
-    "\[\r\n\]#2 .* main \\(\\)"
+    "\[\r\n\]#2 .* \.?main \\(\\)"
 }
 
 # Restart GDB and trace.
@@ -244,7 +210,7 @@ clean_restart $binfile
 load_lib "trace-support.exp"
 
 if ![runto_main] {
-    fail "Can't run to main to check for trace support"
+    fail "can't run to main to check for trace support"
     return -1
 }
 
@@ -255,20 +221,12 @@ if ![gdb_target_supports_trace] {
 
 gdb_test "trace foo" "Tracepoint $decimal at .*"
 
-if [is_amd64_regs_target] {
-    set spreg "\$rsp"
-} elseif [is_x86_like_target] {
-    set spreg "\$esp"
-} else {
-    set spreg "\$sp"
-}
-
 # Collect arguments i and j.  Collect 'global1' which is entry value
 # of argument i.  Don't collect 'global2' to test the entry value of
 # argument j.
 
 gdb_trace_setactions "set action for tracepoint 1" "" \
-    "collect i, j, global1, \(\*\(void \*\*\) \($spreg\)\) @ 64" "^$"
+    "collect i, j, (int) global1, \(\*\(void \*\*\) \(\$$spreg\)\) @ 128" "^$"
 
 gdb_test_no_output "tstart"
 
This page took 0.041201 seconds and 4 git commands to generate.