[RFC/PATCH] Extend gdb_core_cmd to allow "Cannot access memory..." messages

Message ID 871tke2b6a.fsf@redhat.com
State New, archived
Headers

Commit Message

Sergio Durigan Junior March 25, 2015, 12:06 a.m. UTC
  Hi,

While hacking the coredump_filter patch, I noticed that, when you load a
corefile on GDB and receive a "Cannot access memory at address..."
message, gdb_core_cmd will fail and return -1, which means that some
fatal error happened.

Unfortunately, this kind of message does not mean that the user cannot
continue debugging with the corefile; it meant that some memory region
(sometimes not important) was inaccessible.  Given that
gcore_create_callback, nowadays, will dump memory regions if they don't
have the 'read' permission set (but have any other permission set), this
kind of error can be expected sometimes.

I would like to propose this patch to be applied, which will allow the
test to continue even if this message is triggered.  I was not sure
wether I should use a "pass" or "xfail" there, so I chose the second
(which makes more sense to me).

WDYT?
  

Comments

Pedro Alves March 27, 2015, 10:06 a.m. UTC | #1
On 03/25/2015 12:06 AM, Sergio Durigan Junior wrote:> Hi,
>
> While hacking the coredump_filter patch, I noticed that, when you load a
> corefile on GDB and receive a "Cannot access memory at address..."
> message, gdb_core_cmd will fail and return -1, which means that some
> fatal error happened.
>
> Unfortunately, this kind of message does not mean that the user cannot
> continue debugging with the corefile; it meant that some memory region
> (sometimes not important) was inaccessible.  Given that
> gcore_create_callback, nowadays, will dump memory regions if they don't
> have the 'read' permission set (but have any other permission set), this
> kind of error can be expected sometimes.

So, gdb itself errors and stops processing the core?

>
> I would like to propose this patch to be applied, which will allow the
> test to continue even if this message is triggered.  I was not sure
> wether I should use a "pass" or "xfail" there, so I chose the second
> (which makes more sense to me).
>

Seems like you chose the first, not second.

> WDYT?

I think I don't understand.  :-)  Can you please show an
example session?  Did GDB continue processing the core when
it printed that error, or was it just a warning and it continued?

From your message and patch, I assume the former, otherwise

 "Core was generated by .*\r\n$gdb_prompt $"

would still match, right?  If it didn't match, why not?

Your arguing that error "does not mean that the user cannot
continue debugging with the corefile".  So why paper over
this in the testsuite?  Saying "pass" in the testsuite when
it was "error" for gdb seems like a conflict.  It seems like what
we really should be discussing is whether that should be a
fatal error for the "core" command.

But as said, we'll need to see a gdb log and understand better
what gdb is doing to discuss this further.

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index f274b64..48b50b5 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3573,7 +3573,7 @@  proc gdb_gcore_cmd {core test} {
 # -1 - core file failed to load
 
 proc gdb_core_cmd { core test } {
-    global gdb_prompt
+    global gdb_prompt hex
 
     gdb_test_multiple "core $core" "$test" {
 	-re "\\\[Thread debugging using \[^ \r\n\]* enabled\\\]\r\n" {
@@ -3591,6 +3591,10 @@  proc gdb_core_cmd { core test } {
 	    fail "$test (incomplete note section)"
 	    return 0
 	}
+	-re "Cannot access memory at address $hex\r\n$gdb_prompt $" {
+	    pass "$test (could not access some memory regions)"
+	    return 0
+	}
 	-re "Core was generated by .*\r\n$gdb_prompt $" {
 	    pass "$test"
 	    return 1