Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC/ia64] memory error when reading wrong core file
Date: Mon, 01 Feb 2010 06:54:00 -0000	[thread overview]
Message-ID: <20100201065327.GM26827@adacore.com> (raw)
In-Reply-To: <20100201012458.GB6015@host0.dyn.jankratochvil.net>

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

Thanks for taking the time to test my patch!

> this specific problem gets also fixed by:
> 	[patch] Sanity check PIE displacement (like the PIC one)
> 	http://sourceware.org/ml/gdb-patches/2010-02/msg00000.html
[...]
> Still I think you have found a problem of its own which should be fixed
> anyway.

Agreed.

> When some memory access fails it should be IMO printed as it is some sort of
> incorrect operation.  Therefore I would prefer the attached patch producing:

Agreed as well.

> Just if there exists catch_errors shouldn't it be used instead of TRY_CATCH?

TRY_CATCH was introduced after catch_error, and I *think* that it was
intended as a simpler way to call some code while being able to handle
gdb exceptions.  I don't know about others, but I do not really like
the catch_errors/catch_exceptions interface - I think it's awkward to
use: You almost always have to define an "args" struct type that contains
the arguments, and most of the time a developer will also separate
the stub (the function called by catch_exceptions which unmarshalls the
function arguments) from the real implementation.  TRY_CATCH greatly
simplifies the use process, which is why I'm trying to use it in preference
to catch errors as much as I can.

The downside, as you are pointing out, is the lack of error message
when an exception is raised. The attached patch fixes this.

That made me wonder, however, why we have 2 routines to do the exception
printing.  There's probably some cleanup we could do, there...

gdb/ChangeLog:

        * solib-svr4.c (solib_svr4_r_map): catch and print all exception
        errors while reading the inferior memory, and return zero if
        an exception was raised.

This patch should be strictly equivalent to yours, I believe. I've tested
it against the testcase described in this thread as well as the rest of
AdaCore's testsuite.

-- 
Joel

[-- Attachment #2: solib-svr4.diff --]
[-- Type: text/x-diff, Size: 781 bytes --]

diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index e497364..dc9a685 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -835,9 +835,16 @@ solib_svr4_r_map (struct svr4_info *info)
 {
   struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
   struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+  CORE_ADDR addr = 0;
+  volatile struct gdb_exception ex;
 
-  return read_memory_typed_address (info->debug_base + lmo->r_map_offset,
-				    ptr_type);
+  TRY_CATCH (ex, RETURN_MASK_ERROR)
+    {
+      addr = read_memory_typed_address (info->debug_base + lmo->r_map_offset,
+                                        ptr_type);
+    }
+  exception_print (gdb_stderr, ex);
+  return addr;
 }
 
 /* Find r_brk from the inferior's debug base.  */

  reply	other threads:[~2010-02-01  6:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-29 16:02 Joel Brobecker
2010-01-29 17:53 ` Jan Kratochvil
2010-02-01  1:25 ` Jan Kratochvil
2010-02-01  6:54   ` Joel Brobecker [this message]
2010-02-01 19:20     ` Jan Kratochvil
2010-03-08  7:46     ` Joel Brobecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100201065327.GM26827@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox