Patchwork [pushed] Fix gdb.linespec/cpls-ops.exp on 32-bit (Re: [pushed] Re: [PATCH 36/40] Add comprehensive C++ operator linespec/location/completion tests)

login
register
mail settings
Submitter Pedro Alves
Date Nov. 30, 2017, 4:35 p.m.
Message ID <d5fc27e6-5444-b252-e131-8b82de63cdd0@redhat.com>
Download mbox | patch
Permalink /patch/24636/
State New
Headers show

Comments

Pedro Alves - Nov. 30, 2017, 4:35 p.m.
On 11/30/2017 04:05 PM, Pedro Alves wrote:

> Looks like I considered the possibility of different size_t typedefs
> at some point but didn't really address it fully:
> 
>  proc test_operator_new {class_name brackets} {
>      # The type size_t is typedef-ed to.
>      set size_t "unsigned long"
> 
> I'll fix this when I have a chance.

I went ahead and pushed this in.

From e3919f3e898aa5ab9a98dcaf9e242a9ebacc0757 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Thu, 30 Nov 2017 16:32:10 +0000
Subject: [PATCH] Fix gdb.linespec/cpls-ops.exp on 32-bit

gdb.linespec/cpls-ops.exp is currently failing on x86-64 -m32 and other
32-bit ports:

 b test_op_new::operator new(unsigned int) FAIL: gdb.linespec/cpls-ops.exp: operator-new: tab complete "b test_op_new::operator" (timeout)
 ^CQuit
 (gdb) complete b test_op_new::operator
 b test_op_new::operator new(unsigned int)
 (gdb) FAIL: gdb.linespec/cpls-ops.exp: operator-new: cmd complete "b test_op_new::operator"

The problem is simply that the testcase incorrectly assumes that
size_t is "unsigned long".

Fix this by extracting the right type with the "ptype" command.

gdb/testsuite/ChangeLog:
2017-11-30  Pedro Alves  <palves@redhat.com>

	* gdb.linespec/cpls-ops.exp
	(check_explicit_skips_function_argument): Extract the underlying
	type of size_t instead of hardcoding it.
---
 gdb/testsuite/ChangeLog                 |  6 ++++++
 gdb/testsuite/gdb.linespec/cpls-ops.exp | 13 +++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

Patch

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index d19eca2..5b8151d 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@ 
+2017-11-30  Pedro Alves  <palves@redhat.com>
+
+	* gdb.linespec/cpls-ops.exp
+	(check_explicit_skips_function_argument): Extract the underlying
+	type of size_t instead of hardcoding it.
+
 2017-11-29  Pedro Alves  <palves@redhat.com>
 
 	PR c++/19436
diff --git a/gdb/testsuite/gdb.linespec/cpls-ops.exp b/gdb/testsuite/gdb.linespec/cpls-ops.exp
index c1b6c33..d58a6de 100644
--- a/gdb/testsuite/gdb.linespec/cpls-ops.exp
+++ b/gdb/testsuite/gdb.linespec/cpls-ops.exp
@@ -43,8 +43,17 @@  proc check_explicit_skips_function_argument {function} {
 # testing operator new.
 
 proc test_operator_new {class_name brackets} {
-    # The type size_t is typedef-ed to.
-    set size_t "unsigned long"
+    global gdb_prompt
+
+    # Extract the type size_t is typedef-ed to.
+    set size_t ""
+    set test "get size_t underlying type"
+    gdb_test_multiple "ptype size_t" $test {
+	-re " = (\[ a-z\]*)\r\n$gdb_prompt $" {
+	    set size_t $expect_out(1,string)
+	    pass "$test"
+	}
+    }
 
     # Complete all prefixes between "operato" and the full prototype.
     foreach cmd_prefix {"b" "b -function"} {