Fix fail in gdb.base/annota1.exp and gdb.base/annota3.exp

Hi,

I am seeing the fail below on aarch64-linux with gcc 4.9.2,

break main
Breakpoint 1 at 0x4006e8: file binutils-gdb/gdb/testsuite/gdb.base/annota1.c, line 14.^M
(gdb) FAIL: gdb.base/annota1.exp: breakpoint main

the test expects the breakpoint is set on line 15.  Let us look at
the main function,

12	int
13	main (void)
14	{
15	  int my_array[3] = { 1, 2, 3 };  /* break main */
16
17	  value = 7;
18
19	#ifdef SIGUSR1
20	  signal (SIGUSR1, handle_USR1);
21	#endif

(gdb) disassemble main
Dump of assembler code for function main:
   0x00000000004006e0 <+0>:	stp	x29, x30, [sp,#-48]!
   0x00000000004006e4 <+4>:	mov	x29, sp
   0x00000000004006e8 <+8>:	adrp	x0, 0x411000 <signal@got.plt>
   0x00000000004006ec <+12>:	add	x0, x0, #0x40

the breakpoint is set on the right address after skipping prologue, but
0x00000000004006e8 is mapped to the line 14, as shown below,

(gdb) maintenance info line-table
objfile: /home/yao.qi/source/build-aarch64/gdb/testsuite/outputs/gdb.base/annota1/annota1 ((struct objfile *) 0x2b0e1850)
compunit_symtab: ((struct compunit_symtab *) 0x2b0ded50)
symtab: /home/yao.qi/source/binutils-gdb/gdb/testsuite/gdb.base/annota1.c ((struct symtab *) 0x2b0dedd0)
linetable: ((struct linetable *) 0x2b12c8b0):
INDEX    LINE ADDRESS
0           7 0x00000000004006d0
1           8 0x00000000004006d8
2          14 0x00000000004006e0
3          14 0x00000000004006e8
4          15 0x00000000004006fc

so GDB does nothing wrong.  Program hits breakpoint on either line 14
or line 15 is right to me.  With anther gcc (4.9.3), the line-table looks
correct, and no test fail.  Instead of setting breakpoint on main and
assuming the line is what we get from the source, we can set breakpoint
on that line.  On the other hand, the test prints the values of the
array and check, so we need to set breakpoint on the line setting the
values of array and "next", rather than setting the breakpoint on main.

gdb/testsuite:

2016-04-22  Yao Qi  <yao.qi@linaro.org>

	* gdb.base/annota1.exp: Set breakpoint on line $main_line.
	* gdb.base/annota3.exp: Likewise.
This commit is contained in:
Yao Qi 2016-04-22 15:35:07 +01:00
parent 0f60e29b5a
commit 495346f6f0
3 changed files with 17 additions and 11 deletions

View File

@ -1,3 +1,8 @@
2016-04-22 Yao Qi <yao.qi@linaro.org>
* gdb.base/annota1.exp: Set breakpoint on line $main_line.
* gdb.base/annota3.exp: Likewise.
2016-04-22 Yao Qi <yao.qi@linaro.org>
* gdb.reverse/step-precsave.exp: Do one step and test program

View File

@ -46,12 +46,12 @@ clean_restart ${binfile}
gdb_test_no_output "set height 0"
#
# break at main
# break in main
#
set main_line [gdb_get_line_number "break main"]
gdb_test "break main" \
gdb_test "break ${srcfile}:${main_line}" \
"Breakpoint.*at.* file .*$srcfile, line $main_line\\." \
"breakpoint main"
@ -293,16 +293,17 @@ gdb_test_multiple "delete 3" "delete bp 3" {
}
#
# break at main, after value is initialized. This is in preparation
# break in main, after value is initialized. This is in preparation
# to test the annotate output for the display command.
#
gdb_test_multiple "break main" "break at main" {
set test "break in main"
gdb_test_multiple "break ${srcfile}:${main_line}" $test {
-re "post-prompt.*Breakpoint 4 at $hex: file ${escapedsrcfile}, line $main_line.*\032\032breakpoints-invalid.*$gdb_prompt$" {
pass "break at main"
pass $test
}
-re "post-prompt.*Breakpoint 4 at $hex: file .*${srcfile}, line $main_line.*\032\032breakpoints-invalid.*$gdb_prompt$" {
setup_xfail "*-*-*" 1270
fail "break at main"
fail $test
}
}

View File

@ -45,12 +45,12 @@ clean_restart ${binfile}
gdb_test_no_output "set height 0"
#
# break at main
# break in main
#
set main_line [gdb_get_line_number "break main"]
gdb_test "break main" \
gdb_test "break ${srcfile}:${main_line}" \
"Breakpoint.*at.* file .*$srcfile, line $main_line\\." \
"breakpoint main"
@ -258,11 +258,11 @@ gdb_expect_list "delete bp 3" "$gdb_prompt$" {
}
#
# break at main, after value is initialized. This is in preparation
# break in main, after value is initialized. This is in preparation
# to test the annotate output for the display command.
#
send_gdb "break main\n"
gdb_expect_list "break at main" "$gdb_prompt$" [concat {
send_gdb "break ${srcfile}:${main_line}\n"
gdb_expect_list "break in main" "$gdb_prompt$" [concat {
"\r\n\032\032post-prompt\r\n" } [list \
"Breakpoint 4 at 0x\[0-9a-z\]+: file .*annota3.c, line $main_line.\r\n"]]