Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Luis Machado <lgustavo@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH] Make gdb.python/python.exp more robust
Date: Fri, 20 Jan 2017 14:37:00 -0000	[thread overview]
Message-ID: <1484923030-16656-1-git-send-email-lgustavo@codesourcery.com> (raw)

I noticed gdb.python/python.exp failing on aarch64-elf like so:

FAIL: gdb.python/python.exp: Test decode_line func1 line number

This particular test expects the line number for func1 to be 19, hardcoded.

In my aarch64-elf tests gdb thinks func1 is at line 20, making the test fail.

The following patch addresses this by reading the line number information from
GDB and comparing it against the python decoded symtab information.

Regression tested on x86-64/Ubuntu 16.04.

gdb/testsuite/ChangeLog:

2017-01-20  Luis Machado  <lgustavo@codesourcery.com>

	* gdb.python/python.exp: Check line number against what GDB thinks
	the line number is for func1.
---
 gdb/testsuite/gdb.python/python.exp | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index 95ec74e..f099cc0 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -246,7 +246,17 @@ if { [is_remote host] } {
     set python_1_c [string_to_regexp "gdb.python/python-1.c"]
 }
 gdb_test "python print (symtab\[1\]\[0\].symtab)" ".*${python_1_c}" "test decode_line func1 filename"
-gdb_test "python print (symtab\[1\]\[0\].line)" "19" "test decode_line func1 line number"
+
+# Fetch the line GDB thinks func1 starts at.  This may change depending
+# on the architecture and on how GDB handles the prologue of the function.
+gdb_test_multiple "info line func1" "info line func1" {
+    -re "Line ($decimal) of .* starts at address $hex <func1> and ends at $hex <func1\\+$decimal>\.\[\r\n\]+$gdb_prompt $" {
+	# Fetch the line number.
+	set func1_lineno $expect_out(1,string)
+    }
+}
+
+gdb_test "python print (symtab\[1\]\[0\].line)" "$func1_lineno" "test decode_line func1 line number"
 gdb_py_test_silent_cmd {python symtab = gdb.decode_line ("func1,func2")} \
     "test decode_line func1,func2" 1
 gdb_test {python print (symtab[0])} ",func2" "stop at comma in linespec"
-- 
2.7.4


             reply	other threads:[~2017-01-20 14:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-20 14:37 Luis Machado [this message]
2017-01-20 16:59 ` Pedro Alves
2017-01-20 19:17   ` Luis Machado

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1484923030-16656-1-git-send-email-lgustavo@codesourcery.com \
    --to=lgustavo@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox