Commit Message
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.
Comments
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.
@@ -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" \