[2/3] gdb/testsuite/gdb.cp: Fix tests for ARM C++ ABI.

Message ID 51AF143F.8000205@linaro.org
State Accepted
Headers show

Commit Message

Will Newton June 5, 2013, 10:34 a.m.
The ARM C++ ABI defines constructors and destructors to return
pointers to this. The C++ tests that check the types of constructors
and destructors expect a return type of void. Conditionalize these
tests so they pass on ARM.

gdb/testsuite/ChangeLog:

2013-06-05  Will Newton  <will.newton@linaro.org>

	* gdb.cp/anon-struct.exp: Conditionalize constructor and
	destructor prototypes for ARM ABI.
	* gdb.cp/m-static.exp: Likewise.
---
 gdb/testsuite/gdb.cp/anon-struct.exp | 25 ++++++++----
 gdb/testsuite/gdb.cp/m-static.exp    | 75 ++++++++++++++++++++++++------------
 2 files changed, 69 insertions(+), 31 deletions(-)

Comments

Tom Tromey June 5, 2013, 3:52 p.m. | #1
>>>>> "Will" == Will Newton <will.newton@linaro.org> writes:

Will> The ARM C++ ABI defines constructors and destructors to return
Will> pointers to this. The C++ tests that check the types of constructors
Will> and destructors expect a return type of void. Conditionalize these
Will> tests so they pass on ARM.

I think conditionalizing is fine, but I was curious about the results:

Will> +    gdb_test "ptype t3::~t3" "type = void \\*\\(t3 \\* const\\)" \

Why does the destructor return 'void *' here but not elsewhere?

Tom
Will Newton June 5, 2013, 5:52 p.m. | #2
On 5 June 2013 16:52, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Will" == Will Newton <will.newton@linaro.org> writes:
>
> Will> The ARM C++ ABI defines constructors and destructors to return
> Will> pointers to this. The C++ tests that check the types of constructors
> Will> and destructors expect a return type of void. Conditionalize these
> Will> tests so they pass on ARM.
>
> I think conditionalizing is fine, but I was curious about the results:
>
> Will> +    gdb_test "ptype t3::~t3" "type = void \\*\\(t3 \\* const\\)" \
>
> Why does the destructor return 'void *' here but not elsewhere?

I'm not sure where elsewhere is? ;-)

For reference it's documented here:

http://infocenter.arm.com/help/topic/com.arm.doc.ihi0041d/IHI0041D_cppabi.pdf

Bottom of page 9 / top of 10.

--
Will Newton
Toolchain Working Group, Linaro
Tom Tromey June 5, 2013, 7:24 p.m. | #3
Tom> Why does the destructor return 'void *' here but not elsewhere?

Will> I'm not sure where elsewhere is? ;-)

Sorry about that.  I misread the patch.
The patch is ok.

Tom

Patch

diff --git a/gdb/testsuite/gdb.cp/anon-struct.exp b/gdb/testsuite/gdb.cp/anon-struct.exp
index edab092..3446eb7 100644
--- a/gdb/testsuite/gdb.cp/anon-struct.exp
+++ b/gdb/testsuite/gdb.cp/anon-struct.exp
@@ -20,14 +20,25 @@  if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] }
      return -1
 }

-gdb_test "ptype t::t" "type = void \\(t \\* const\\)" \
-    "print type of t::t"
+if { [istarget arm*-*-*] } {
+    gdb_test "ptype t::t" "type = struct t {\r\n    C m;\r\n} \\*\\(t \\* const\\)" \
+	"print type of t::t"
+} else {
+    gdb_test "ptype t::t" "type = void \\(t \\* const\\)" \
+	"print type of t::t"
+}

 gdb_test "ptype X::t2" "type = struct X::t2 {\[\r\n \]*X::C2 m;\[\r\n \]*}" \
     "print type of X::t2"

-gdb_test "ptype X::t2::t2" "type = void \\(X::t2 \\* const\\)" \
-    "print type of X::t2::t2"
-
-gdb_test "ptype t3::~t3" "type = void \\(t3 \\* const\\)" \
-    "print type of t3::~t3"
+if { [istarget arm*-*-*] } {
+    gdb_test "ptype X::t2::t2" "type = struct X::t2 {\r\n    X::C2 m;\r\n} \\*\\(X::t2 \\* const\\)" \
+	"print type of X::t2::t2"
+    gdb_test "ptype t3::~t3" "type = void \\*\\(t3 \\* const\\)" \
+	"print type of t3::~t3"
+} else {
+    gdb_test "ptype X::t2::t2" "type = void \\(X::t2 \\* const\\)" \
+	"print type of X::t2::t2"
+    gdb_test "ptype t3::~t3" "type = void \\(t3 \\* const\\)" \
+	"print type of t3::~t3"
+}
diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp
index 65ec6a0..9b0e642 100644
--- a/gdb/testsuite/gdb.cp/m-static.exp
+++ b/gdb/testsuite/gdb.cp/m-static.exp
@@ -69,30 +69,57 @@  gdb_test "print test1.key2" "\\$\[0-9\]* = 77" "simple object, static long"
 # simple object, static enum
 gdb_test "print test1.value" "\\$\[0-9\]* = oriental" "simple object, static enum"

-gdb_test "print test5.single_constructor" \
-    { = {void \(single_constructor \* const\)} 0x[0-9a-f]+ <single_constructor::single_constructor\(\)>} \
-    "simple object instance, print constructor"
-gdb_test "ptype test5.single_constructor" \
-    {type = void \(single_constructor \* const\)} \
-    "simple object instance, ptype constructor"
-gdb_test "ptype single_constructor::single_constructor" \
-    {type = void \(single_constructor \* const\)} \
-    "simple object class, ptype constructor"
-
-gdb_test "print test1.~gnu_obj_1" \
-    { = {void \(gnu_obj_1 \* const, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
-    "simple object instance, print destructor"
-gdb_test "ptype test1.~gnu_obj_1" \
-    {type = void \(gnu_obj_1 \* const, int\)} \
-    "simple object instance, ptype destructor"
-
-gdb_test "print test1.'~gnu_obj_1'" \
-    { = {void \(gnu_obj_1 \*( const)?, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
-    "simple object instance, print quoted destructor"
-
-gdb_test "ptype gnu_obj_1::'~gnu_obj_1'" \
-    {type = void \(gnu_obj_1 \* const\)} \
-    "simple object class, ptype quoted destructor"
+if { [istarget arm*-*-*] } {
+    gdb_test "print test5.single_constructor" \
+	{ = {single_constructor \*\(single_constructor \* const\)} 0x[0-9a-f]+ <single_constructor::single_constructor\(\)>} \
+	"simple object instance, print constructor"
+    gdb_test "ptype test5.single_constructor" \
+	{type = class single_constructor {\r\n  public:\r\n    single_constructor\(void\);\r\n    ~single_constructor\(int\);\r\n} \*\(single_constructor \* const\)} \
+	"simple object instance, ptype constructor"
+    gdb_test "ptype single_constructor::single_constructor" \
+	{type = class single_constructor {\r\n  public:\r\n    single_constructor\(void\);\r\n    ~single_constructor\(int\);\r\n} \*\(single_constructor \* const\)} \
+	"simple object class, ptype constructor"
+
+    gdb_test "print test1.~gnu_obj_1" \
+	{ = {void \*\(gnu_obj_1 \* const, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
+	"simple object instance, print destructor"
+    gdb_test "ptype test1.~gnu_obj_1" \
+	{type = void \*\(gnu_obj_1 \* const, int\)} \
+	"simple object instance, ptype destructor"
+
+    gdb_test "print test1.'~gnu_obj_1'" \
+	{ = {void \*\(gnu_obj_1 \*( const)?, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
+	"simple object instance, print quoted destructor"
+
+    gdb_test "ptype gnu_obj_1::'~gnu_obj_1'" \
+	{type = void \*\(gnu_obj_1 \* const\)} \
+	"simple object class, ptype quoted destructor"
+} else {
+    gdb_test "print test5.single_constructor" \
+	{ = {void \(single_constructor \* const\)} 0x[0-9a-f]+ <single_constructor::single_constructor\(\)>} \
+	"simple object instance, print constructor"
+    gdb_test "ptype test5.single_constructor" \
+	{type = void \(single_constructor \* const\)} \
+	"simple object instance, ptype constructor"
+    gdb_test "ptype single_constructor::single_constructor" \
+	{type = void \(single_constructor \* const\)} \
+	"simple object class, ptype constructor"
+
+    gdb_test "print test1.~gnu_obj_1" \
+	{ = {void \(gnu_obj_1 \* const, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
+	"simple object instance, print destructor"
+    gdb_test "ptype test1.~gnu_obj_1" \
+	{type = void \(gnu_obj_1 \* const, int\)} \
+	"simple object instance, ptype destructor"
+
+    gdb_test "print test1.'~gnu_obj_1'" \
+	{ = {void \(gnu_obj_1 \*( const)?, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
+	"simple object instance, print quoted destructor"
+
+    gdb_test "ptype gnu_obj_1::'~gnu_obj_1'" \
+	{type = void \(gnu_obj_1 \* const\)} \
+	"simple object class, ptype quoted destructor"
+}

 # Two.