From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 917993858D35 for ; Tue, 16 Apr 2024 13:55:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 917993858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 917993858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713275734; cv=none; b=paPy9vzhYTh53+Zbz0O6m7tHsSBnrDjySURzHCCcIl0GbGuhlccwNXG+N56qJrr99e4mIri39G1fKeASvGNwQfbOzwJ8ZMyuMExsR4ROdyTzqjcHZR9eAbkS230+PcXcsGakzlNYpkkNIWHOxe28LNaTs9TzhAZTVUmPXi+PrqU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713275734; c=relaxed/simple; bh=nmgCVQtfvhxYFIxTWWr5/qeh0/+BrqAfmmW706SDFUU=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=umZRvQluQZW/6nBdNi+MYpLVFrmwJ/+UB4NPM3QUIf8Q6dQCE1eRdv6qpNg3ca3bdpkzO4Bpn4vuPhFV/H9LtmMAElQbrigJOWn6O2ymxz2KXeZ/JMGPThrzNkyTAMZeBg+u0Igq8s/fAzFebngUMnTk53q+DRGgETKVyt5UZQc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 752D15C96F; Tue, 16 Apr 2024 13:55:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1713275731; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r8ht9PvFu2wfWrvPayevGGNAGR9HdxiRLPQKC0OVSA8=; b=FMHAq33Sd9BkVb4LqukDnsN7yW+5olzX/x7DJjS4xJTMcFAkTM4CMHgbDCTYpUWoeZRGHG gPCLFDOSj8TVzKLz+Ed9ZQZoOiQmRMmrHZyyG6tmvjRSKPiZLB8kd9R6dwbV6UOz7bJfyS ee3XVBPd/6CmAA/Nu+qOtcmPuRTY7jM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1713275731; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r8ht9PvFu2wfWrvPayevGGNAGR9HdxiRLPQKC0OVSA8=; b=ER1czPO75rFwA6sfeM9oFsPMm/+4bTDXuI5Wsjy4yUl5vy6alQr5ZPXAshIIuupmAhzbK5 udQzrH4t2AwoG2Aw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1713275731; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r8ht9PvFu2wfWrvPayevGGNAGR9HdxiRLPQKC0OVSA8=; b=FMHAq33Sd9BkVb4LqukDnsN7yW+5olzX/x7DJjS4xJTMcFAkTM4CMHgbDCTYpUWoeZRGHG gPCLFDOSj8TVzKLz+Ed9ZQZoOiQmRMmrHZyyG6tmvjRSKPiZLB8kd9R6dwbV6UOz7bJfyS ee3XVBPd/6CmAA/Nu+qOtcmPuRTY7jM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1713275731; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r8ht9PvFu2wfWrvPayevGGNAGR9HdxiRLPQKC0OVSA8=; b=ER1czPO75rFwA6sfeM9oFsPMm/+4bTDXuI5Wsjy4yUl5vy6alQr5ZPXAshIIuupmAhzbK5 udQzrH4t2AwoG2Aw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 5CEC613931; Tue, 16 Apr 2024 13:55:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id Osw1FVODHmYLZAAAD6G6ig (envelope-from ); Tue, 16 Apr 2024 13:55:31 +0000 Message-ID: <1bf79496-c8df-49d4-919e-3988f1bc9f8f@suse.de> Date: Tue, 16 Apr 2024 15:55:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [gdb/python] Throw MemoryError in inferior.read_memory if malloc fails To: Tom Tromey Cc: gdb-patches@sourceware.org References: <20240411105257.15421-1-tdevries@suse.de> <875xwn51dq.fsf@tromey.com> <87h6g238l8.fsf@tromey.com> Content-Language: en-US From: Tom de Vries In-Reply-To: <87h6g238l8.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Level: X-Spamd-Result: default: False [-2.73 / 50.00]; BAYES_HAM(-1.44)[91.21%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; XM_UA_NO_VERSION(0.01)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns] X-Spam-Score: -2.73 X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 4/15/24 18:16, Tom Tromey wrote: >>>>>> "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. 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