public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] [gdb/python] Throw MemoryError in inferior.read_memory if malloc fails
Date: Tue, 16 Apr 2024 15:55:46 +0200	[thread overview]
Message-ID: <1bf79496-c8df-49d4-919e-3988f1bc9f8f@suse.de> (raw)
In-Reply-To: <87h6g238l8.fsf@tromey.com>

On 4/15/24 18:16, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
> 
> Tom> But I couldn't come up with a good rationale as to why I should handle
> Tom> MemoryError differently from BaseException, so I decided to catch it
> Tom> locally and turn it into a DAPException.
> 
> Yeah, makes sense.
> 
> Tom> +    try:
> Tom> +        buf = gdb.selected_inferior().read_memory(addr, count)
> Tom> +    except MemoryError:
> Tom> +        raise DAPException("Out of memory")
> 
> Here I meant something like:
> 
> except MemoryError as e:
>     raise DAPException(...) from e
> 
> There's an example of this in startup.py.

I see, I didn't know that possibility.

Anyway, AFAICT it doesn't seem to make a difference, it just makes the 
chaining explicit, which I prefer.

Pushed with that change.

Thanks,
- Tom




  reply	other threads:[~2024-04-16 13:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11 10:52 Tom de Vries
2024-04-11 16:07 ` Tom Tromey
2024-04-12  7:09   ` Tom de Vries
2024-04-15 16:16     ` Tom Tromey
2024-04-16 13:55       ` Tom de Vries [this message]
2024-04-16 19:10     ` Simon Marchi
2024-04-17  8:29       ` Tom de Vries

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=1bf79496-c8df-49d4-919e-3988f1bc9f8f@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).