public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Tom de Vries <tdevries@suse.de>
Cc: Tom Tromey <tom@tromey.com>,  gdb-patches@sourceware.org
Subject: Re: [PATCH] [gdb/python] Throw MemoryError in inferior.read_memory if malloc fails
Date: Mon, 15 Apr 2024 10:16:03 -0600	[thread overview]
Message-ID: <87h6g238l8.fsf@tromey.com> (raw)
In-Reply-To: <b2a4f986-37f7-4838-b535-fb2d3ee90ef7@suse.de> (Tom de Vries's message of "Fri, 12 Apr 2024 09:09:07 +0200")

>>>>> "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.

Tom

  reply	other threads:[~2024-04-15 16:16 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 [this message]
2024-04-16 13:55       ` Tom de Vries
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=87h6g238l8.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    /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).