Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix for PR gdb/17017
@ 2014-06-04 19:57 Siva Chandra
  2014-06-04 20:05 ` Pedro Alves
  0 siblings, 1 reply; 2+ messages in thread
From: Siva Chandra @ 2014-06-04 19:57 UTC (permalink / raw)
  To: gdb-patches; +Cc: Pedro Alves

[-- Attachment #1: Type: text/plain, Size: 294 bytes --]

The attached patch should fix PR 17017.

ChangeLog

2014-06-04  Siva Chandra Reddy  <sivachandra@google.com>

       testsuite/

        PR gdb/17017
        * gdb.python/py-xmethods.exp (gdb_test_if_inferiorio): New function.
        Update few gdb_test invocations to gdb_test_if_inferiorio.

[-- Attachment #2: fix_xmethod_failures.txt --]
[-- Type: text/plain, Size: 3215 bytes --]

diff --git a/gdb/testsuite/gdb.python/py-xmethods.exp b/gdb/testsuite/gdb.python/py-xmethods.exp
index 97b6ffa..7f51cb1 100644
--- a/gdb/testsuite/gdb.python/py-xmethods.exp
+++ b/gdb/testsuite/gdb.python/py-xmethods.exp
@@ -36,28 +36,35 @@ if ![runto_main] {
 set xmethods_script [gdb_remote_download host \
 		     ${srcdir}/${subdir}/${testfile}.py]
 
+proc gdb_test_if_inferiorio {gdb_cmd pattern name} {
+  if ![target_info exists gdb,noinferiorio] {
+    gdb_test $gdb_cmd $pattern $name
+  }
+}
+
 gdb_breakpoint [gdb_get_line_number "Break here."]
 gdb_continue_to_breakpoint "Break here" ".*Break here.*"
 
 # Tests before loading the debug methods.
-gdb_test "p a1 + a2" "From CC <A_plus_A>.*15" "Before: a1 + a2"
-gdb_test "p a2 - a1" "From CC <A_minus_A>.*5" "Before: a1 - a2"
-gdb_test "p b1 - a1" "From CC <A_minus_A>.*25" "Before: b1 - a1"
-gdb_test "p a1.geta()" "From CC A::geta.*5" "Before: a1.geta()"
+gdb_test_if_inferiorio "p a1 + a2" "From CC <A_plus_A>.*15" "Before: a1 + a2"
+gdb_test_if_inferiorio "p a2 - a1" "From CC <A_minus_A>.*5" "Before: a1 - a2"
+gdb_test_if_inferiorio "p b1 - a1" "From CC <A_minus_A>.*25" "Before: b1 - a1"
+gdb_test_if_inferiorio "p a1.geta()" "From CC A::geta.*5" "Before: a1.geta()"
 gdb_test "p ++a1" "No symbol.*" "Before: ++a1"
 gdb_test "p a1.getarrayind(5)" "Couldn't find method.*" \
   "Before: a1.getarrayind(5)"
-gdb_test "p a_ptr->geta()" "From CC B::geta.*60" "Before: a_ptr->geta()"
-gdb_test "p e.geta()" "From CC A::geta.*100" "Before: e.geta()"
-gdb_test "p g.size_diff<float>()" "From CC G<>::size_diff.*" \
+gdb_test_if_inferiorio "p a_ptr->geta()" "From CC B::geta.*60" \
+  "Before: a_ptr->geta()"
+gdb_test_if_inferiorio "p e.geta()" "From CC A::geta.*100" "Before: e.geta()"
+gdb_test_if_inferiorio "p g.size_diff<float>()" "From CC G<>::size_diff.*" \
   "Before: g.size_diff<float>()"
 gdb_test "p g.size_diff<unsigned long>()" "Couldn't find method.*" \
   "Before: g.size_diff<unsigned long>()"
-gdb_test "p g.size_mul<2>()" "From CC G<>::size_mul.*" \
+gdb_test_if_inferiorio "p g.size_mul<2>()" "From CC G<>::size_mul.*" \
   "Before: g.size_mul<2>()"
 gdb_test "p g.size_mul<5>()" "Couldn't find method.*" \
   "Before: g.size_mul<5>()"
-gdb_test "p g.mul<double>(2.0)" "From CC G<>::mul.*" \
+gdb_test_if_inferiorio "p g.mul<double>(2.0)" "From CC G<>::mul.*" \
   "Before: g.mul<double>(2.0)"
 gdb_test "p g.mul<char>('a')" "Couldn't find method.*" \
   "Before: g.mul<char>('a')"
@@ -67,9 +74,9 @@ gdb_test_no_output "source ${xmethods_script}" "load the script file"
 
 # Tests after loading debug methods.
 gdb_test "p a1 + a2" "From Python <A_plus_A>.*15" "After: a1 + a2"
-gdb_test "p a2 - a1" "From CC <A_minus_A>.*5" "After: a1 - a2"
+gdb_test_if_inferiorio "p a2 - a1" "From CC <A_minus_A>.*5" "After: a1 - a2"
 gdb_test "p b1 + a1" "From Python <A_plus_A>.*35" "After: b1 + a1"
-gdb_test "p b1 - a1" "From CC <A_minus_A>.*25" "After: b1 - a1"
+gdb_test_if_inferiorio "p b1 - a1" "From CC <A_minus_A>.*25" "After: b1 - a1"
 gdb_test "p a1.geta()" "From Python <A_geta>.*5" "After: a1.geta()"
 gdb_test "p ++a1" "From Python <plus_plus_A>.*6" "After: ++a1"
 gdb_test "p a1.getarrayind(5)" "From Python <A_getarrayind>.*5" \

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix for PR gdb/17017
  2014-06-04 19:57 [PATCH] Fix for PR gdb/17017 Siva Chandra
@ 2014-06-04 20:05 ` Pedro Alves
  0 siblings, 0 replies; 2+ messages in thread
From: Pedro Alves @ 2014-06-04 20:05 UTC (permalink / raw)
  To: Siva Chandra; +Cc: gdb-patches

On 06/04/2014 08:57 PM, Siva Chandra wrote:
> The attached patch should fix PR 17017.
> 
> ChangeLog
> 
> 2014-06-04  Siva Chandra Reddy  <sivachandra@google.com>
> 
>        testsuite/
> 
>         PR gdb/17017
>         * gdb.python/py-xmethods.exp (gdb_test_if_inferiorio): New function.
>         Update few gdb_test invocations to gdb_test_if_inferiorio.


Ah, I hadn't realized the test was relying on IO.  It's unfortunate,
as that way the coverage isn't complete when testing against gdbserver.

Can we make it not rely on IO instead?  You want to be
sure the C++ methods were called, right?

E.g., one idea would be, instead of:

int
B::geta (void)
{
  cout << "From CC B::geta:" << endl;
  return 2 * a;
}

Do:

int B_geta_called;

int
B::geta (void)
{
  B_geta_called++;
  return 2 * a;
}

And then from GDB, read the B_geta_called variable
to tell whether the method was called.  You can e.g.,
use get_integer_valueof for that.

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-04 20:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-04 19:57 [PATCH] Fix for PR gdb/17017 Siva Chandra
2014-06-04 20:05 ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox