From 06e967dbc9b75a4a3c1b15b54360cf1abbf9c2bd Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Tue, 16 Apr 2024 15:53:47 +0200 Subject: [gdb/python] Throw MemoryError in inferior.read_memory if malloc fails PR python/31631 reports a gdb internal error when doing: ... (gdb) python gdb.selected_inferior().read_memory (0, 0xffffffffffffffff) utils.c:709: internal-error: virtual memory exhausted. A problem internal to GDB has been detected, further debugging may prove unreliable. ... Fix this by throwing a python MemoryError, such that we have instead: ... (gdb) python gdb.selected_inferior().read_memory (0, 0xffffffffffffffff) Python Exception : Error occurred in Python. (gdb) ... Likewise for DAP. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31631 --- gdb/testsuite/gdb.dap/memory.exp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gdb/testsuite/gdb.dap') diff --git a/gdb/testsuite/gdb.dap/memory.exp b/gdb/testsuite/gdb.dap/memory.exp index 2e911f4..4e2e361 100644 --- a/gdb/testsuite/gdb.dap/memory.exp +++ b/gdb/testsuite/gdb.dap/memory.exp @@ -55,6 +55,11 @@ set obj [dap_check_request_and_response "evaluate global pointer" \ evaluate {o expression [s thirty_two_p]}] set addr [dict get [lindex $obj 0] body memoryReference] +set obj [dap_request_and_response \ + readMemory [format {o memoryReference [s %s] count [i 18446744073709551615]} $addr]] +set response [lindex $obj 0] +gdb_assert { [dict get $response success] == "false" } "read memory, count to big" + set obj [dap_check_request_and_response "read memory" \ readMemory [format {o memoryReference [s %s] count [i 4]} $addr]] -- cgit v1.1