From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id 335193858D32 for ; Mon, 15 Apr 2024 16:16:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 335193858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 335193858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713197768; cv=none; b=HQ7NzcqtpuJWKNoLTSjW/jIV+Oh++J4O+qBrPfbZv6FsBC++JhgMXK5DHBATTVsemIH7Nv8iGn6n9L9z5pha8fQqzJ3zVhGv4bkjI+IRkK56M/I0M+ovVVWTj5ODMOgzdyqOZptfuJOZtXbWmh3Sz0n/C0QvWWvvG5B3NKQjkBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713197768; c=relaxed/simple; bh=yaL9AM0466gznyI8Hpf8cefe8MRlLLx6UGDJXqZkHeE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hBtZQExZlsccxyQOtBsQQ54uzXdylDS7mt56kyREWOLzus1IRhGM38VeugjUXnSbnu+q1wugoqRc7wknNjQpSjtLrBC/HRrWSpHXzIqPyYXyBmZ6u4vk5WG2ZXBnFmsVI7gOFowXoePnAqvAfj7r2jaIpEK5mX9wMDeqdO+w4gY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6007a.ext.cloudfilter.net ([10.0.30.247]) by cmsmtp with ESMTPS id wEHGrm5Ubuh6swP01ry6fn; Mon, 15 Apr 2024 16:16:05 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id wP00ryQ4PVdenwP00r5P2G; Mon, 15 Apr 2024 16:16:04 +0000 X-Authority-Analysis: v=2.4 cv=M4FLKTws c=1 sm=1 tr=0 ts=661d52c4 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=raytVjVEu-sA:10 a=Qbun_eYptAEA:10 a=5A3omMn15ZqSvSGokoYA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=4xqakr+LmZrG6vDouSt5wKSQqyhI2Yrobyw2Bh3BFHw=; b=nt3bqrtHBGRJjIIKCo5YGo5wFy hg1ex9zsG/AVR6Ek2oqFwhgmlp9Tu6r51kGxMsmVB1/8rUhGI491H6NFfbrvltuMmZeZABV3ZqMCf /HIF3RZ0jQYN1JLWVMUDo1sIT; Received: from 97-122-82-115.hlrn.qwest.net ([97.122.82.115]:45564 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rwP00-003bAO-0r; Mon, 15 Apr 2024 10:16:04 -0600 From: Tom Tromey To: Tom de Vries Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [PATCH] [gdb/python] Throw MemoryError in inferior.read_memory if malloc fails References: <20240411105257.15421-1-tdevries@suse.de> <875xwn51dq.fsf@tromey.com> X-Attribution: Tom Date: Mon, 15 Apr 2024 10:16:03 -0600 In-Reply-To: (Tom de Vries's message of "Fri, 12 Apr 2024 09:09:07 +0200") Message-ID: <87h6g238l8.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.82.115 X-Source-L: No X-Exim-ID: 1rwP00-003bAO-0r X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-82-115.hlrn.qwest.net (murgatroyd) [97.122.82.115]:45564 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfFO8X+ZK/R+DylfNminHkn/ZcJbCEyn7AxYvvOD3/hTb7bcqRNu3K92x7YUaQ5ccJ1A7Aw1EBe+ZNkkzH9gHrbOELInbNf8sbAxnCZfEeDePV82cEylT aRcgldk3BcG/m6rS0NgsNygU1BJxOzLN1A+Zrkdg9o80NIlujkMYHTxQZtw9NHg4CgWi/F1bjkZNDjU7onGdSjATMPgWg5tnhaY= X-Spam-Status: No, score=-3015.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: >>>>> "Tom" == Tom de Vries 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