* [PATCH] Handle memory write errors on gdb.base/break-always.exp
@ 2015-04-13 18:21 Luis Machado
2015-04-14 9:00 ` Yao Qi
2015-04-27 15:41 ` Luis Machado
0 siblings, 2 replies; 5+ messages in thread
From: Luis Machado @ 2015-04-13 18:21 UTC (permalink / raw)
To: gdb-patches
This is another case of the testcase not handling memory write errors that
happen on some targets (QEMU) when GDB attempts to modify an address that
should contain a breakpoint, for example.
The following patch handles this and prevents spurious failures from
happening. It also adds a foreach loop to avoid duplication of code
and hardcoded patterns.
Regression tested on x86-64-linux and aarch64-linux.
Ok?
2015-04-13 Luis Machado <lgustavo@codesourcery.com>
gdb/testsuite/
* gdb.base/break-always.exp: Abort testing if writing to memory
causes an error.
---
gdb/testsuite/gdb.base/break-always.exp | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/gdb/testsuite/gdb.base/break-always.exp b/gdb/testsuite/gdb.base/break-always.exp
index 681be37..9133229 100644
--- a/gdb/testsuite/gdb.base/break-always.exp
+++ b/gdb/testsuite/gdb.base/break-always.exp
@@ -69,19 +69,23 @@ gdb_test "p /x \$shadow = *(char *) $bp_address" \
# and still leave the breakpoint insn planted. Try twice with
# different values, in case we happen to be writting exactly what was
# there already.
-gdb_test "p /x *(char *) $bp_address = 0" \
- " = 0x0" \
- "write 0 to breakpoint's address"
-gdb_test "p /x *(char *) $bp_address" \
- " = 0x0" \
- "read back 0 from the breakpoint's address"
-
-gdb_test "p /x *(char *) $bp_address = 1" \
- " = 0x1" \
- "write 1 to breakpoint's address"
-gdb_test "p /x *(char *) $bp_address" \
- " = 0x1" \
- "read back 1 from the breakpoint's address"
+foreach test_value {0 1} {
+ set write_test "write $test_value to breakpoint's address $bp_address"
+
+ gdb_test_multiple "p /x *(char *) $bp_address = $test_value" $write_test {
+ -re "Cannot access memory at address $hex.*$gdb_prompt $" {
+ unsupported "Cannot write to address $bp_address"
+ return -1
+ }
+ -re " = .*$gdb_prompt $" {
+ pass $write_test
+ }
+ }
+
+ set read_test "read back $test_value from the breakpoint's address $bp_address"
+
+ gdb_test "p /x *(char *) $bp_address" " = 0x$test_value" $read_test
+}
# Restore the original contents.
gdb_test "p /x *(char *) $bp_address = \$shadow" "" \
--
1.9.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Handle memory write errors on gdb.base/break-always.exp
2015-04-13 18:21 [PATCH] Handle memory write errors on gdb.base/break-always.exp Luis Machado
@ 2015-04-14 9:00 ` Yao Qi
2015-04-27 15:41 ` Luis Machado
1 sibling, 0 replies; 5+ messages in thread
From: Yao Qi @ 2015-04-14 9:00 UTC (permalink / raw)
To: Luis Machado; +Cc: gdb-patches
Luis Machado <lgustavo@codesourcery.com> writes:
Hi Luis,
> +foreach test_value {0 1} {
> + set write_test "write $test_value to breakpoint's address $bp_address"
> +
In this way, $bp_address will be shown in the test summary in gdb.sum.
This may cause some differences when we compare gdb.sum of different
runs, like:
-PASS: gdb.base/break-always.exp: write 0 to breakpoint's address 0x1111
+PASS: gdb.base/break-always.exp: write 0 to breakpoint's address 0x2222
Let's remove $bp_address from $write_test.
> + gdb_test_multiple "p /x *(char *) $bp_address = $test_value" $write_test {
> + -re "Cannot access memory at address $hex.*$gdb_prompt $" {
> + unsupported "Cannot write to address $bp_address"
We need comments to explain we may go here. Copying some messages from
your mail should be fine.
> + return -1
> + }
> + -re " = .*$gdb_prompt $" {
> + pass $write_test
> + }
> + }
> +
> + set read_test "read back $test_value from the breakpoint's address $bp_address"
> +
Remove $bp_address from $read_test.
> + gdb_test "p /x *(char *) $bp_address" " = 0x$test_value" $read_test
> +}
Patch is OK to me with these changes.
--
Yao (齐尧)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Handle memory write errors on gdb.base/break-always.exp
2015-04-13 18:21 [PATCH] Handle memory write errors on gdb.base/break-always.exp Luis Machado
2015-04-14 9:00 ` Yao Qi
@ 2015-04-27 15:41 ` Luis Machado
2015-04-28 11:07 ` Yao Qi
1 sibling, 1 reply; 5+ messages in thread
From: Luis Machado @ 2015-04-27 15:41 UTC (permalink / raw)
To: gdb-patches
Ping?
On 04/13/2015 03:21 PM, Luis Machado wrote:
> This is another case of the testcase not handling memory write errors that
> happen on some targets (QEMU) when GDB attempts to modify an address that
> should contain a breakpoint, for example.
>
> The following patch handles this and prevents spurious failures from
> happening. It also adds a foreach loop to avoid duplication of code
> and hardcoded patterns.
>
> Regression tested on x86-64-linux and aarch64-linux.
>
> Ok?
>
> 2015-04-13 Luis Machado <lgustavo@codesourcery.com>
>
> gdb/testsuite/
> * gdb.base/break-always.exp: Abort testing if writing to memory
> causes an error.
> ---
> gdb/testsuite/gdb.base/break-always.exp | 30 +++++++++++++++++-------------
> 1 file changed, 17 insertions(+), 13 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.base/break-always.exp b/gdb/testsuite/gdb.base/break-always.exp
> index 681be37..9133229 100644
> --- a/gdb/testsuite/gdb.base/break-always.exp
> +++ b/gdb/testsuite/gdb.base/break-always.exp
> @@ -69,19 +69,23 @@ gdb_test "p /x \$shadow = *(char *) $bp_address" \
> # and still leave the breakpoint insn planted. Try twice with
> # different values, in case we happen to be writting exactly what was
> # there already.
> -gdb_test "p /x *(char *) $bp_address = 0" \
> - " = 0x0" \
> - "write 0 to breakpoint's address"
> -gdb_test "p /x *(char *) $bp_address" \
> - " = 0x0" \
> - "read back 0 from the breakpoint's address"
> -
> -gdb_test "p /x *(char *) $bp_address = 1" \
> - " = 0x1" \
> - "write 1 to breakpoint's address"
> -gdb_test "p /x *(char *) $bp_address" \
> - " = 0x1" \
> - "read back 1 from the breakpoint's address"
> +foreach test_value {0 1} {
> + set write_test "write $test_value to breakpoint's address $bp_address"
> +
> + gdb_test_multiple "p /x *(char *) $bp_address = $test_value" $write_test {
> + -re "Cannot access memory at address $hex.*$gdb_prompt $" {
> + unsupported "Cannot write to address $bp_address"
> + return -1
> + }
> + -re " = .*$gdb_prompt $" {
> + pass $write_test
> + }
> + }
> +
> + set read_test "read back $test_value from the breakpoint's address $bp_address"
> +
> + gdb_test "p /x *(char *) $bp_address" " = 0x$test_value" $read_test
> +}
>
> # Restore the original contents.
> gdb_test "p /x *(char *) $bp_address = \$shadow" "" \
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Handle memory write errors on gdb.base/break-always.exp
2015-04-27 15:41 ` Luis Machado
@ 2015-04-28 11:07 ` Yao Qi
2015-04-29 15:30 ` Luis Machado
0 siblings, 1 reply; 5+ messages in thread
From: Yao Qi @ 2015-04-28 11:07 UTC (permalink / raw)
To: Luis Machado; +Cc: gdb-patches
Luis Machado <lgustavo@codesourcery.com> writes:
> Ping?
Hi Luis,
I've approved this patch here
https://sourceware.org/ml/gdb-patches/2015-04/msg00512.html If my
comments are addressed in the updated patch, you can push it in.
--
Yao (齐尧)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Handle memory write errors on gdb.base/break-always.exp
2015-04-28 11:07 ` Yao Qi
@ 2015-04-29 15:30 ` Luis Machado
0 siblings, 0 replies; 5+ messages in thread
From: Luis Machado @ 2015-04-29 15:30 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 401 bytes --]
On 04/28/2015 07:46 AM, Yao Qi wrote:
> Luis Machado <lgustavo@codesourcery.com> writes:
>
>> Ping?
>
> Hi Luis,
> I've approved this patch here
> https://sourceware.org/ml/gdb-patches/2015-04/msg00512.html If my
> comments are addressed in the updated patch, you can push it in.
>
Sorry. For some reason i didn't get that reply. I did the changes and
pushed the attached patch in.
Thanks,
Luis
[-- Attachment #2: break-always.diff --]
[-- Type: text/x-patch, Size: 2034 bytes --]
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 639dae7..3e2df8f 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-04-29 Luis Machado <lgustavo@codesourcery.com>
+
+ * gdb.base/break-always.exp: Abort testing if writing to memory
+ causes an error.
+
2015-04-28 Doug Evans <dje@google.com>
* gdb.python/py-pp-maint.py: Move "replace" testing to ...
diff --git a/gdb/testsuite/gdb.base/break-always.exp b/gdb/testsuite/gdb.base/break-always.exp
index 681be37..c45ce54 100644
--- a/gdb/testsuite/gdb.base/break-always.exp
+++ b/gdb/testsuite/gdb.base/break-always.exp
@@ -69,19 +69,25 @@ gdb_test "p /x \$shadow = *(char *) $bp_address" \
# and still leave the breakpoint insn planted. Try twice with
# different values, in case we happen to be writting exactly what was
# there already.
-gdb_test "p /x *(char *) $bp_address = 0" \
- " = 0x0" \
- "write 0 to breakpoint's address"
-gdb_test "p /x *(char *) $bp_address" \
- " = 0x0" \
- "read back 0 from the breakpoint's address"
-
-gdb_test "p /x *(char *) $bp_address = 1" \
- " = 0x1" \
- "write 1 to breakpoint's address"
-gdb_test "p /x *(char *) $bp_address" \
- " = 0x1" \
- "read back 1 from the breakpoint's address"
+foreach test_value {0 1} {
+ set write_test "write $test_value to breakpoint's address"
+
+ gdb_test_multiple "p /x *(char *) $bp_address = $test_value" $write_test {
+ -re "Cannot access memory at address $hex.*$gdb_prompt $" {
+
+ # Some targets do not allow manually writing a breakpoint to a
+ # certain memory address, like QEMU. In that case, just bail out.
+ unsupported "Cannot write to address $bp_address"
+ return -1
+ }
+ -re " = .*$gdb_prompt $" {
+ pass $write_test
+ }
+ }
+
+ set read_test "read back $test_value from the breakpoint's address"
+ gdb_test "p /x *(char *) $bp_address" " = 0x$test_value" $read_test
+}
# Restore the original contents.
gdb_test "p /x *(char *) $bp_address = \$shadow" "" \
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-04-29 15:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-13 18:21 [PATCH] Handle memory write errors on gdb.base/break-always.exp Luis Machado
2015-04-14 9:00 ` Yao Qi
2015-04-27 15:41 ` Luis Machado
2015-04-28 11:07 ` Yao Qi
2015-04-29 15:30 ` Luis Machado
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).