Dwarf assembler: handle one instruction function

Message ID 1424877375-14752-1-git-send-email-qiyaoltc@gmail.com
State New, archived
Headers

Commit Message

Yao Qi Feb. 25, 2015, 3:16 p.m. UTC
  From: Yao Qi <yao.qi@linaro.org>

On aarch64, we got the following fail:

(gdb) disassemble func
Dump of assembler code for function func:
   0x0000000000400730 <+0>:     ret
End of assembler dump.^M
(gdb) x/2i func+0^M
   0x400730 <func>:     ret^M
   0x400734 <main>:     stp     x29, x30, [sp,#-16]!^M
(gdb) FAIL: gdb.dwarf2/dw2-ifort-parameter.exp: x/2i func+0

the pattern in proc function_range expects to match <func+0>, however,
GDB doesn't display the offset when it is zero.  This patch is to
adjust the pattern when $func_length.

gdb/testsuite:

2015-02-25  Yao Qi  <yao.qi@linaro.org>

	* lib/dwarf.exp (function_range): Adjust pattern when $func_length
	is zero.
---
 gdb/testsuite/lib/dwarf.exp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
  

Comments

Pedro Alves Feb. 26, 2015, 11:56 a.m. UTC | #1
On 02/25/2015 03:16 PM, Yao Qi wrote:

> GDB doesn't display the offset when it is zero.  This patch is to
> adjust the pattern when $func_length.

"when $func_length is zero.", I think.

> 
> gdb/testsuite:
> 
> 2015-02-25  Yao Qi  <yao.qi@linaro.org>
> 
> 	* lib/dwarf.exp (function_range): Adjust pattern when $func_length
> 	is zero.

Looks fine to me.

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index 8ea7a0f..19963c4 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -146,9 +146,14 @@  proc function_range { func src } {
     }
 
     # Compute the size of the last instruction.
+    if { $func_length == 0 } then {
+	set func_pattern "$func"
+    } else {
+	set func_pattern "$func\\+$func_length"
+    }
     set test "x/2i $func+$func_length"
     gdb_test_multiple $test $test {
-	-re ".*($hex) <$func\\+$func_length>:\[^\r\n\]+\r\n\[ \]+($hex).*\.\r\n$gdb_prompt $" {
+	-re ".*($hex) <$func_pattern>:\[^\r\n\]+\r\n\[ \]+($hex).*\.\r\n$gdb_prompt $" {
 	    set start $expect_out(1,string)
 	    set end $expect_out(2,string)